Skip to content

Conversation

@lposen
Copy link
Contributor

@lposen lposen commented Oct 10, 2025

🔹 JIRA Ticket(s) if any

✏️ Description

Adds the embedded manager class

Testing

  1. cd into the example dir and run:
    yarn install
    watchman watch-del-all
    yarn start --reset-cache
    ```bash
  2. In a separate terminal, cd into example then either run ios (yarn ios) or android (yarn android)
  3. Click on the "Embedded" tab. You should see the following:
    Does embedded class exist? Yes
    Is embedded manager enabled? Yes
  4. Open example/src/hooks/useIterableApp.tsx
  5. Change config.enableEmbeddedMessaging = true; to config.enableEmbeddedMessaging = false;
  6. Focus on the tab running the server (where you ran yarn start), and hit the key r
  7. The "Embedded" tab should now say:
    Does embedded class exist? Yes
    Is embedded manager enabled? No

@github-actions
Copy link

github-actions bot commented Oct 10, 2025

Lines Statements Branches Functions
Coverage: 58%
58.8% (334/568) 33.18% (76/229) 57% (118/207)

@qltysh
Copy link

qltysh bot commented Oct 10, 2025

Diff Coverage: The code coverage on the diff in this pull request is 100.0%.

Total Coverage: This PR will increase coverage by 0.45%.

File Coverage Changes
Path File Coverage Δ Indirect
src/core/classes/Iterable.ts 0.1
src/embedded/classes/IterableEmbeddedManager.ts 100.0
src/embedded/classes/index.ts 100.0
src/embedded/index.ts 100.0
🛟 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.

@lposen lposen changed the title feat: add IterableEmbeddedManager class and update exports for embedded messages [MOB-12261] add IterableEmbeddedManager class and update exports for embedded messages Oct 11, 2025
@lposen lposen changed the title [MOB-12261] add IterableEmbeddedManager class and update exports for embedded messages [MOB-12261] Add IterableEmbeddedManager class and update exports for embedded messages Oct 11, 2025
@lposen lposen changed the title [MOB-12261] Add IterableEmbeddedManager class and update exports for embedded messages [MOB-12261] Add IterableEmbeddedManager class Oct 11, 2025
@lposen lposen added the embedded Issues/PRs related to Embedded Messages label Oct 14, 2025
@lposen lposen marked this pull request as ready for review November 19, 2025 04:58
@lposen lposen requested a review from Copilot November 19, 2025 04:58
Copilot finished reviewing on behalf of lposen November 19, 2025 05:03
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 introduces the IterableEmbeddedManager class as the foundation for embedded messaging functionality in the Iterable React Native SDK. The implementation adds the manager class with basic enabled/disabled state management and integrates it with the SDK's configuration system.

Key changes:

  • Adds IterableEmbeddedManager class with isEnabled property and setEnabled() method
  • Introduces embeddedMessagingEnabled configuration option in IterableConfig
  • Integrates the embedded manager as a static property on the Iterable class, initialized during SDK setup

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
src/embedded/classes/IterableEmbeddedManager.ts New manager class with basic enabled state management
src/embedded/classes/index.ts Export file for embedded classes
src/embedded/index.ts Main export file for embedded module
src/core/classes/IterableConfig.ts Adds embeddedMessagingEnabled configuration property and includes it in serialization
src/core/classes/Iterable.ts Adds embeddedManager static property and initializes it based on config during SDK setup
src/index.tsx Exports IterableEmbeddedManager from the main SDK entry point
example/src/components/Embedded/Embedded.tsx Example component demonstrating how to check manager existence and enabled state

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 16 to 24
isEnabled = false;

/**
* Sets whether the embedded manager is enabled.
*
* @param enabled - Whether the embedded manager is enabled.
*/
setEnabled(enabled: boolean) {
this.isEnabled = enabled;
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 isEnabled property should be readonly or private to prevent direct mutation from outside the class. Currently, consumers can bypass setEnabled() and directly modify the property (e.g., Iterable.embeddedManager.isEnabled = true), which could lead to inconsistent state management.

Consider making this property readonly and providing a getter method, or making it private with a public getter:

private _isEnabled = false;

get isEnabled(): boolean {
  return this._isEnabled;
}

Then update setEnabled() to use this._isEnabled = enabled;

Suggested change
isEnabled = false;
/**
* Sets whether the embedded manager is enabled.
*
* @param enabled - Whether the embedded manager is enabled.
*/
setEnabled(enabled: boolean) {
this.isEnabled = enabled;
private _isEnabled = false;
/**
* Gets whether the embedded manager is enabled.
*/
get isEnabled(): boolean {
return this._isEnabled;
}
/**
* Sets whether the embedded manager is enabled.
*
* @param enabled - Whether the embedded manager is enabled.
*/
setEnabled(enabled: boolean) {
this._isEnabled = enabled;

Copilot uses AI. Check for mistakes.
Comment on lines +113 to +115
* Iterable.embeddedManager.getMessages().then(messages => {
* console.log('Messages:', messages);
* });
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 documentation example shows calling getMessages() method, but the IterableEmbeddedManager class does not implement this method. The current implementation only has isEnabled property and setEnabled() method.

Either update the example to reflect the current API:

// Check if embedded manager is enabled
if (Iterable.embeddedManager.isEnabled) {
  console.log('Embedded messaging is enabled');
}

Or remove the example until getMessages() is implemented.

Suggested change
* Iterable.embeddedManager.getMessages().then(messages => {
* console.log('Messages:', messages);
* });
* // Check if embedded manager is enabled
* if (Iterable.embeddedManager.isEnabled) {
* console.log('Embedded messaging is enabled');
* }

Copilot uses AI. Check for mistakes.
Comment on lines 198 to 200
Iterable.embeddedManager.setEnabled(
config.embeddedMessagingEnabled === true
);
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 new embeddedMessagingEnabled configuration option and embeddedManager integration lack test coverage. Similar configuration options like logReactNativeSdkCalls have comprehensive test coverage in Iterable.test.ts.

Consider adding tests for:

  1. Default value of embeddedMessagingEnabled (should be false)
  2. embeddedMessagingEnabled being included in the toDict() output
  3. embeddedManager.isEnabled being set correctly during Iterable.initialize() based on the config value
  4. embeddedManager being accessible as a static property

Example test structure:

describe('embeddedManager', () => {
  it('should be disabled by default', () => {
    const config = new IterableConfig();
    expect(config.embeddedMessagingEnabled).toBe(false);
    expect(Iterable.embeddedManager.isEnabled).toBe(false);
  });

  it('should enable embeddedManager when config is set', async () => {
    const config = new IterableConfig();
    config.embeddedMessagingEnabled = true;
    await Iterable.initialize('test-key', config);
    expect(Iterable.embeddedManager.isEnabled).toBe(true);
  });
});

Copilot uses AI. Check for mistakes.
* - [Android Embedded Messaging](https://support.iterable.com/hc/en-us/articles/23061877893652-Embedded-Messages-with-Iterable-s-Android-SDK)
* - [iOS Embedded Messaging](https://support.iterable.com/hc/en-us/articles/23061840746900-Embedded-Messages-with-Iterable-s-iOS-SDK)
*/
embeddedMessagingEnabled = false;
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 test that validates default configuration values in Iterable.test.ts does not include verification for the new embeddedMessagingEnabled property. The test should be updated to include:

expect(config.embeddedMessagingEnabled).toBe(false);
expect(configDict.embeddedMessagingEnabled).toBe(false);

This ensures the new configuration option has proper test coverage for its default value and serialization.

Copilot uses AI. Check for mistakes.
IterableLogger.setLogLevel(config.logLevel);

Iterable.embeddedManager.setEnabled(
config.embeddedMessagingEnabled === true
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.

[nitpick] The explicit === true comparison is redundant since config.embeddedMessagingEnabled is already typed as a boolean and defaults to false. This is inconsistent with the pattern used on line 195 for config.logReactNativeSdkCalls.

Consider simplifying to match the existing pattern:

Iterable.embeddedManager.setEnabled(
  config.embeddedMessagingEnabled ?? false
);

Or if you prefer simpler syntax since the default is already false:

Iterable.embeddedManager.setEnabled(config.embeddedMessagingEnabled);
Suggested change
config.embeddedMessagingEnabled === true
config.embeddedMessagingEnabled ?? false

Copilot uses AI. Check for mistakes.
@qltysh
Copy link

qltysh bot commented Nov 19, 2025

1 new issue

Tool Category Rule Count
qlty Structure Function with many returns (count = 10): IterableAppProvider 1

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

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