-
Couldn't load subscription status.
- Fork 39
[MOB-12268] Add click handling and tracking #747
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: loren/embedded/MOB-12267-android-add-start-impression-and-pause-impressio
Are you sure you want to change the base?
Conversation
4 new issues
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
| export const getActionPrefix = ( | ||
| str?: string | null | ||
| ): IterableCustomActionPrefix | null => { | ||
| if (!str) return null; | ||
| if (str.startsWith(IterableCustomActionPrefix.Action)) { | ||
| return IterableCustomActionPrefix.Action; | ||
| } | ||
| if (str.startsWith(IterableCustomActionPrefix.Itbl)) { | ||
| return IterableCustomActionPrefix.Itbl; | ||
| } | ||
| return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| handleClick( | ||
| message: IterableEmbeddedMessage, | ||
| buttonId: string | null, | ||
| action?: IterableAction | null | ||
| ) { | ||
| const { data, type: actionType } = action ?? {}; | ||
| const clickedUrl = data && data?.length > 0 ? data : actionType; | ||
|
|
||
| IterableLogger.log( | ||
| 'IterableEmbeddedManager.handleClick', | ||
| message, | ||
| buttonId, | ||
| clickedUrl | ||
| ); | ||
|
|
||
| if (!clickedUrl) { | ||
| IterableLogger.log( | ||
| 'IterableEmbeddedManager.handleClick:', | ||
| 'A url or action is required to handle an embedded click', | ||
| clickedUrl | ||
| ); | ||
| return; | ||
| } | ||
|
|
||
| const actionPrefix = getActionPrefix(clickedUrl); | ||
| const source = IterableActionSource.embedded; | ||
|
|
||
| this.trackClick(message, buttonId, clickedUrl); | ||
|
|
||
| if (actionPrefix) { | ||
| const actionName = clickedUrl?.replace(actionPrefix, ''); | ||
| const actionDetails = new IterableAction(actionName, '', ''); | ||
| const context = new IterableActionContext(actionDetails, source); | ||
| if (this.config.customActionHandler) { | ||
| this.config.customActionHandler(actionDetails, context); | ||
| } | ||
| } else { | ||
| const actionDetails = new IterableAction('openUrl', clickedUrl, ''); | ||
| const context = new IterableActionContext(actionDetails, source); | ||
| callUrlHandler(this.config, clickedUrl, context); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…ages## 🔹 JIRA Ticket(s) if any
✏️ Description