Skip to content

Conversation

@lposen
Copy link
Contributor

@lposen lposen commented Oct 13, 2025

🔹 JIRA Ticket(s) if any

✏️ Description

Add click handling and tracking

Testing

  1. cd into the example dir and run:
    yarn install
    watchman watch-del-all
    yarn start --reset-cache
  2. In a separate terminal, cd into example then either run yarn android
  3. Click on the "Embedded" tab.
  4. Click "Get messages"
  5. In the messages, click "Handle click"
  6. If the link is an action, it should alert. If the link is a link, it should navigate to that link.

@github-actions
Copy link

github-actions bot commented Oct 13, 2025

Lines Statements Branches Functions
Coverage: 62%
62.72% (392/625) 38.64% (97/251) 61.5% (139/226)

@qltysh
Copy link

qltysh bot commented Oct 13, 2025

All good ✅

@lposen lposen changed the title feat: add trackEmbeddedClick method to handle clicks on embedded mess… [MOB-12268] Add click handling and tracking Oct 13, 2025
@lposen lposen added the embedded Issues/PRs related to Embedded Messages label Oct 14, 2025
@qltysh
Copy link

qltysh bot commented Nov 19, 2025

Qlty

Coverage Impact

⬆️ Merging this pull request will increase total coverage on loren/embedded/master by 2.12%.

Modified Files with Diff Coverage (5)

RatingFile% DiffUncovered Line #s
Coverage rating: A Coverage rating: A
src/core/classes/IterableApi.ts100.0%
Coverage rating: A Coverage rating: A
src/embedded/classes/IterableEmbeddedManager.ts100.0%
Coverage rating: A Coverage rating: A
src/core/classes/Iterable.ts83.3%988
New file Coverage rating: B
src/core/utils/callUrlHandler.ts83.3%28
New file Coverage rating: A
src/core/utils/getActionPrefix.ts100.0%
Total95.3%
🤖 Increase coverage with AI coding...

In the `loren/embedded/MOB-12268-android-add-click-handling-and-track` branch, add test coverage for this new code:

- `src/core/classes/Iterable.ts` -- Line 988
- `src/core/utils/callUrlHandler.ts` -- Line 28

🚦 See full report on Qlty Cloud »

🛟 Help
  • Diff Coverage: Coverage for added or modified lines of code (excludes deleted files). Learn more.

  • Total Coverage: Coverage for the whole repository, calculated as the sum of all File Coverage. Learn more.

  • File Coverage: Covered Lines divided by Covered Lines plus Missed Lines. (Excludes non-executable lines including blank lines and comments.)

    • Indirect Changes: Changes to File Coverage for files that were not modified in this PR. Learn more.

@lposen lposen requested a review from Copilot November 19, 2025 09:09
@lposen lposen marked this pull request as ready for review November 19, 2025 09:09
Copy link
Contributor

Copilot AI left a 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 trackClick and handleClick methods to IterableEmbeddedManager for 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.
Copy link

Copilot AI Nov 19, 2025

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".

Suggested change
* Enum representing the prefix of build-in custom action URL.
* Enum representing the prefix of built-in custom action URL.

Copilot uses AI. Check for mistakes.
Comment on lines +158 to +162
trackEmbeddedClick(
message: EmbeddedMessage,
buttonId: string | null,
clickedUrl: string | null
): void;
Copy link

Copilot AI Nov 19, 2025

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.

Copilot uses AI. Check for mistakes.
* 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.
Copy link

Copilot AI Nov 19, 2025

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".

Suggested change
* 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.

Copilot uses AI. Check for mistakes.
Comment on lines +223 to +231
* 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);
Copy link

Copilot AI Nov 19, 2025

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.

Suggested change
* 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);

Copilot uses AI. Check for mistakes.
/**
* The config for the Iterable SDK.
*/
private _config: IterableConfig = new IterableConfig();
Copy link

Copilot AI Nov 19, 2025

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.

Suggested change
private _config: IterableConfig = new IterableConfig();
private _config: IterableConfig;

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably is a good suggestion. It can be null

…nd-pause-impressio' into loren/embedded/MOB-12268-android-add-click-handling-and-track
Copy link
Member

@Ayyanchira Ayyanchira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looking great! Bug bash will give us the confidence we need

* This is needed as in new arch you can only pass in basic types, which
* then need to be converted in the native layer.
*/
static IterableEmbeddedMessage embeddedMessageFromReadableMap(ReadableMap messageMap) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

annotation like @nullable here will future proof for kotlin conversion if it ever happens and also for test frameworks

export * from './IterableLogLevel';
export * from './IterablePushPlatform';
export * from './IterableRetryBackoff';
export * from './IterableCustomActionPrefix';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about the custom prefix idea. Can DM you regarding this for clarification

context: IterableActionContext
) {
if (!config.urlHandler?.(url, context)) {
Linking.canOpenURL(url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to be tested thoroughly to see its behavior.

/**
* The config for the Iterable SDK.
*/
private _config: IterableConfig = new IterableConfig();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably is a good suggestion. It can be null

Base automatically changed from loren/embedded/MOB-12267-android-add-start-impression-and-pause-impressio to loren/embedded/master December 24, 2025 19:38
@lposen lposen merged commit 64ebe17 into loren/embedded/master Dec 24, 2025
4 of 5 checks passed
@lposen lposen deleted the loren/embedded/MOB-12268-android-add-click-handling-and-track branch December 24, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

embedded Issues/PRs related to Embedded Messages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants