-
Notifications
You must be signed in to change notification settings - Fork 40
[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
5 new issues
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
…nd-pause-impressio'
|
Diff Coverage: The code coverage on the diff in this pull request is 32.6%. Total Coverage: This PR will decrease coverage by 2.27%. File Coverage Changes
🛟 Help
This is from Qlty Cloud, the successor to Code Climate Quality. Learn more. |
| .catch((reason) => { | ||
| IterableLogger?.log('Error opening url: ' + reason); | ||
| }); | ||
| } |
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.
| 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.
| 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.
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.
Pull Request Overview
This PR adds click handling and tracking functionality for embedded messages in the Iterable React Native SDK. It implements methods to track clicks on embedded messages and handle associated actions through configured handlers.
- Adds
trackClickandhandleClickmethods toIterableEmbeddedManagerfor tracking and handling clicks on embedded messages - Creates utility functions (
getActionPrefix,callUrlHandler) to support URL and custom action handling - Extends native Android implementation to support embedded click tracking via both old and new architecture modules
Reviewed Changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/embedded/classes/IterableEmbeddedManager.ts | Adds trackClick and handleClick methods with constructor changes to accept config |
| src/embedded/classes/IterableEmbeddedManager.test.ts | Updates test initialization to pass required IterableConfig parameter |
| src/core/utils/index.ts | Exports new utility functions for action prefix detection and URL handling |
| src/core/utils/getActionPrefix.ts | New utility to detect custom action prefixes (action://, itbl://) |
| src/core/utils/callUrlHandler.ts | New utility to handle URL opening with fallback logic |
| src/core/enums/index.ts | Exports new IterableCustomActionPrefix enum |
| src/core/enums/IterableCustomActionPrefix.ts | Defines custom action URL prefixes |
| src/core/enums/IterableActionSource.ts | Adds embedded as new action source enum value |
| src/core/classes/IterableApi.ts | Adds trackEmbeddedClick method to bridge TypeScript to native |
| src/core/classes/Iterable.ts | Refactors to use extracted callUrlHandler utility and updates embedded manager initialization |
| src/api/NativeRNIterableAPI.ts | Adds trackEmbeddedClick method to native module interface |
| example/src/components/Embedded/Embedded.tsx | Adds UI controls and handlers to demonstrate click tracking functionality |
| android/src/oldarch/java/com/RNIterableAPIModule.java | Implements trackEmbeddedClick method for old architecture |
| android/src/newarch/java/com/RNIterableAPIModule.java | Implements trackEmbeddedClick method for new architecture |
| android/src/main/java/com/iterable/reactnative/Serialization.java | Adds conversion method from ReadableMap to IterableEmbeddedMessage |
| android/src/main/java/com/iterable/reactnative/RNIterableAPIModuleImpl.java | Implements core logic for tracking embedded clicks |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| @@ -0,0 +1,9 @@ | |||
| /** | |||
| * Enum representing the prefix of build-in custom action URL. | |||
Copilot
AI
Nov 19, 2025
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.
Typo in documentation: "build-in" should be "built-in".
| * Enum representing the prefix of build-in custom action URL. | |
| * Enum representing the prefix of built-in custom action URL. |
| trackEmbeddedClick( | ||
| message: EmbeddedMessage, | ||
| buttonId: string | null, | ||
| clickedUrl: string | null | ||
| ): void; |
Copilot
AI
Nov 19, 2025
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.
The Android native implementation adds the trackEmbeddedClick method, but there's no corresponding iOS implementation visible in this PR. This will cause the feature to not work on iOS devices. Ensure that the iOS native module also implements this method, or document that this feature is Android-only if that's intentional.
| * Handles a click on an embedded message. | ||
| * | ||
| * This will fire the correct handlers set in the config, and will track the | ||
| * click. It should be use on either a button click or a click on the message itself. |
Copilot
AI
Nov 19, 2025
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.
Typo in documentation: "use" should be "used".
| * click. It should be use on either a button click or a click on the message itself. | |
| * click. It should be used on either a button click or a click on the message itself. |
| * click. It should be use on either a button click or a click on the message itself. | ||
| * | ||
| * @param message - The embedded message. | ||
| * @param buttonId - The button ID. | ||
| * @param clickedUrl - The clicked URL. | ||
| * | ||
| * @example | ||
| * ```typescript | ||
| * Iterable.embeddedManager.handleClick(message, buttonId, clickedUrl); |
Copilot
AI
Nov 19, 2025
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.
Incorrect parameter documented in JSDoc. The third parameter is named action but the documentation refers to it as clickedUrl.
| * click. It should be use on either a button click or a click on the message itself. | |
| * | |
| * @param message - The embedded message. | |
| * @param buttonId - The button ID. | |
| * @param clickedUrl - The clicked URL. | |
| * | |
| * @example | |
| * ```typescript | |
| * Iterable.embeddedManager.handleClick(message, buttonId, clickedUrl); | |
| * click. It should be used on either a button click or a click on the message itself. | |
| * | |
| * @param message - The embedded message. | |
| * @param buttonId - The button ID. | |
| * @param action - The action to handle (typically an IterableAction instance or null). | |
| * | |
| * @example | |
| * ```typescript | |
| * Iterable.embeddedManager.handleClick(message, buttonId, action); |
| /** | ||
| * The config for the Iterable SDK. | ||
| */ | ||
| private _config: IterableConfig = new IterableConfig(); |
Copilot
AI
Nov 19, 2025
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.
This write to property '_config' is useless, since another property write always overrides it.
| private _config: IterableConfig = new IterableConfig(); | |
| private _config: IterableConfig; |
🔹 JIRA Ticket(s) if any
✏️ Description
Add click handling and tracking
Testing
yarn android