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: 57%
57.94% (361/623) 30.76% (76/247) 58.84% (133/226)

@qltysh
Copy link

qltysh bot commented Oct 13, 2025

5 new issues

Tool Category Rule Count
qlty Structure Function with high complexity (count = 5): callUrlHandler 3
qlty Structure High total complexity (count = 67) 1
qlty Structure Function with many returns (count = 4): getActionPrefix 1

This is from Qlty Cloud, the successor to Code Climate Quality. Learn more.

@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

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
Path File Coverage Δ Indirect
src/core/classes/Iterable.ts 0.7
src/core/classes/IterableApi.ts -2.2
src/core/enums/IterableCustomActionPrefix.ts 100.0
src/core/utils/callUrlHandler.ts 83.3
src/core/utils/getActionPrefix.ts 14.3
src/core/utils/index.ts 100.0
src/embedded/classes/IterableEmbeddedManager.ts -59.4
🛟 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.

This is from Qlty Cloud, the successor to Code Climate Quality. Learn more.

.catch((reason) => {
IterableLogger?.log('Error opening url: ' + reason);
});
}
Copy link

Choose a reason for hiding this comment

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

Function with high complexity (count = 5): callUrlHandler [qlty:function-complexity]

if (str.startsWith(IterableCustomActionPrefix.Itbl)) {
return IterableCustomActionPrefix.Itbl;
}
return null;
Copy link

Choose a reason for hiding this comment

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

Found 2 issues:

1. Function with many returns (count = 4): getActionPrefix [qlty:return-statements]


2. Function with high complexity (count = 6): getActionPrefix [qlty:function-complexity]

const actionDetails = new IterableAction('openUrl', clickedUrl, '');
const context = new IterableActionContext(actionDetails, source);
callUrlHandler(this._config, clickedUrl, context);
}
Copy link

Choose a reason for hiding this comment

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

Function with high complexity (count = 7): handleClick [qlty:function-complexity]

@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
Copilot finished reviewing on behalf of lposen November 19, 2025 09:13
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.
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.

2 participants