BranchMetrics / android-branch-deep-linking-attribution

The Branch Android SDK for deep linking and attribution. Branch helps mobile apps grow with deep links / deeplinks that power paid acquisition and re-engagement campaigns, referral programs, content sharing, deep linked emails, smart banners, custom user onboarding, and more.
https://docs.branch.io/pages/apps/android/
MIT License
399 stars 156 forks source link

[SDK-2325] Added callback to disableTracking() #1180

Closed nsingh-branch closed 6 months ago

nsingh-branch commented 6 months ago

Reference

SDK-2325 -- Add callback to disableTracking()

Description

This change adds a new callback to the disabledTracking() method that returns the new tracking state, the referring params, and an error. If tracking is disabled, only the tracking state will be returned. If tracking is enabled, it will also return the referringParams and any potential errors from the Branch session initialization.

This change is useful for delayed initialization situations where tracking is initially disabled and the re-enabling of tracking is the first Branch initialization call.

Testing Instructions

Call the disableTracking() method without and with the callback and observe that all of the returned variables are correct.

//Example code with callback
Branch.getInstance().disableTracking(true, new Branch.TrackingStateCallback() {
    @Override
    public void onTrackingStateChanged(boolean trackingDisabled, JSONObject referringParams, BranchError error) {
        if (trackingDisabled) {
            Log.d("BranchSDK", "Tracking is now disabled.");
        } else {
            Log.d("BranchSDK", "Tracking is now enabled. Referring params: " + referringParams);
        }
    }
});

Risk Assessment [LOW]

Reviewer Checklist (To be checked off by the reviewer only)

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

codecov[bot] commented 6 months ago

Codecov Report

Attention: Patch coverage is 45.00000% with 11 lines in your changes are missing coverage. Please review.

Project coverage is 38.03%. Comparing base (1b6bb47) to head (ac98a07). Report is 2 commits behind head on master.

Files Patch % Lines
...in/java/io/branch/referral/TrackingController.java 33.33% 7 Missing and 3 partials :warning:
...h-SDK/src/main/java/io/branch/referral/Branch.java 80.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #1180 +/- ## ============================================ - Coverage 38.11% 38.03% -0.08% + Complexity 689 687 -2 ============================================ Files 59 59 Lines 6279 6289 +10 Branches 939 941 +2 ============================================ - Hits 2393 2392 -1 - Misses 3443 3449 +6 - Partials 443 448 +5 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.