Skip to content

Conversation

NidhiDixit09
Copy link
Collaborator

Reference

SDK-XXXX -- <TITLE>.

Summary

Motivation

Type Of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Testing Instructions

cc @BranchMetrics/saas-sdk-devs for visibility.

Copy link
Contributor

matter-code-review bot commented Jun 13, 2025

Code Quality new feature maintainability testability

Summary By MatterAI MatterAI logo

🔄 What Changed

This Pull Request introduces a new BranchConfigurationController class, designed as a singleton, to centralize the collection of critical SDK configuration details. These details include:

  • The source of the Branch key (e.g., getInstance API, setBranchKey API, Info.plist, config.json).
  • The state of feature flags such as deferInitForPluginRuntime and checkPasteboardOnInstall.
  • Information about dynamically linked frameworks like AdSupport, ATTrackingManager, FirebaseCrashlytics, SafariServices, and AppAdsOnDeviceConversion.

This collected configuration data, termed operational_metrics, is now included as part of the v1/install API request payload.

Key modifications include:

  • New Class: BranchConfigurationController.h and BranchConfigurationController.m were added to manage and provide SDK configuration.
  • Branch.m Updates: Modified to populate the BranchConfigurationController's properties (branchKeySource, deferInitForPluginRuntime, checkPasteboardOnInstall) during SDK initialization and Branch key retrieval.
  • BNCRequestFactory.m Updates: Modified to fetch the operational_metrics from BranchConfigurationController and include them in the dataForInstallWithURLString: method, which prepares the v1/install request.
  • Constants: New string constants for operational metrics keys and framework names were added to BranchConstants.h and BranchConstants.m.

🔍 Impact of the Change

This change significantly enhances the telemetry collected by the Branch SDK during installation. By providing detailed insights into how the SDK is configured and which optional frameworks are integrated, it will greatly assist in:

  • Debugging: Faster identification of integration issues related to SDK setup or missing dependencies.
  • Performance Analysis: Understanding the impact of various configurations on SDK performance.
  • Feature Adoption: Gaining visibility into the usage of specific SDK features and integrations.
  • SDK Improvement: Informing future SDK development and optimization efforts based on real-world usage patterns.

📁 Total Files Changed

7 files were changed in this pull request.

🧪 Test Added

A new test file, Branch-TestBed/Branch-SDK-Tests/BranchConfigurationControllerTests.m, was added to ensure the correctness and reliability of the BranchConfigurationController. The following tests are included:

  • testSingletonInstance: Verifies that BranchConfigurationController correctly implements the singleton pattern, ensuring only one instance exists throughout the application lifecycle.
  • testPropertySettersAndGetters: Confirms that the branchKeySource, deferInitForPluginRuntime, and checkPasteboardOnInstall properties of the controller can be set and retrieved accurately.
  • testGetConfiguration: Asserts that the getConfiguration method correctly aggregates all relevant configuration data (Branch key source, feature flags, and linked frameworks) into a well-formed dictionary.
  • testInstallRequestParams: Validates that the operational_metrics dictionary, containing the collected configuration, is properly included within the v1/install request payload generated by BNCRequestFactory, and that its contents match the expected values.

🔒Security Vulnerabilities

No new security vulnerabilities were detected in the provided code changes. The changes primarily focus on telemetry and data collection, which do not introduce direct security risks. The data collected is configuration-related and does not appear to include sensitive user information.

Tip

Quality Recommendations

  1. In BranchConfigurationController.m, the branchKeyInfo method uses @"Unknown" as a literal string for the default branchKeySource. It would be more consistent and maintainable to use the BRANCH_KEY_SOURCE_UNKNOWN constant defined in BranchConstants.h.

  2. Consider adding a comment to the isClassAvailable: helper method in BranchConfigurationController.m to explain its purpose (dynamic framework detection) and the implications of using NSClassFromString.

Sequence Diagram

sequenceDiagram
    participant App as Application
    participant BranchSDK as Branch SDK
    participant BCC as BranchConfigurationController
    participant BRF as BNCRequestFactory
    participant BranchAPI as Branch API (v1/install)

    App->>BranchSDK: Initialize SDK (e.g., [Branch getInstance] or [Branch getInstance:branchKey])
    BranchSDK->>BCC: Set branchKeySource (e.g., BRANCH_KEY_SOURCE_GET_INSTANCE_API, BRANCH_KEY_SOURCE_INFO_PLIST, etc.)
    BranchSDK->>BCC: Set deferInitForPluginRuntime (BOOL)
    BranchSDK->>BCC: Set checkPasteboardOnInstall (BOOL)

    BranchSDK->>BRF: Request install data (dataForInstallWithURLString:)
    BRF->>BCC: Get Configuration (getConfiguration)
    BCC-->>BRF: Returns operational_metrics Dictionary
        Note right of BCC: Collects:
        - branch_key_source
        - deferInitForPluginRuntime
        - checkPasteboardOnInstall
        - linked_frameworks (AdSupport, ATTrackingManager, FirebaseCrashlytics, SafariServices, AppAdsOnDeviceConversion)
    BRF->>BranchAPI: Send v1/install request with operational_metrics in payload
Loading

Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

Copy link
Contributor

Important

PR Review Skipped

PR review skipped as per the configuration setting. Run a manually review by commenting /matter review

💡Tips to use Matter AI

Command List

  • /matter summary: Generate AI Summary for the PR
  • /matter review: Generate AI Reviews for the latest commit in the PR
  • /matter review-full: Generate AI Reviews for the complete PR
  • /matter release-notes: Generate AI release-notes for the PR
  • /matter : Chat with your PR with Matter AI Agent
  • /matter remember : Generate AI memories for the PR
  • /matter explain: Get an explanation of the PR
  • /matter help: Show the list of available commands and documentation
  • Need help? Join our Discord server: https://discord.gg/fJU5DvanU3

@gdeluna-branch gdeluna-branch changed the title [Draft] Added class BranchConfigurationController to send operational_metrics with v1/install request. Added class BranchConfigurationController to send operational_metrics with v1/install request. Jul 7, 2025
@NidhiDixit09 NidhiDixit09 merged commit b54e2eb into master Jul 14, 2025
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants