react-native-analytics-segment-io icon indicating copy to clipboard operation
react-native-analytics-segment-io copied to clipboard

Sending Segment Anonymous ID to the Branch SDK

Open 0xpatrickdev opened this issue 7 years ago • 0 comments

Hey folks,

Has anyone had success sending the Segment Anonymous ID to the Branch SDK using this library?

The documentation on the Branch website is a little sparse/unclear for React Native, but essentially the branch sdk needs the user's anonymous id before the branch sdk is set up, and I am not sure if that is possible using this library. The branch side of things is set up on the native end, while it seems Segment is set up on the JS side of things. As such, I am not sure if it's possible to get the value for [[SEGAnalytics sharedAnalytics] getAnonymousId] while using this implementation.

Here are the relevant excerpts:

iOS: Inside didFinishLaunchingWithOptions

Branch *branch = [Branch getInstance];
[[Branch getInstance] setRequestMetadataKey:@"$segment_anonymous_id" value:[[SEGAnalytics sharedAnalytics] getAnonymousId]];

Android: Before you initialize in your Application#onCreate or Deep Link Activity's #onCreate.

Branch.getInstance().setRequestMetadata("$segment_anonymous_id", com.segment.analytics.Analytics.with(this).getAnalyticsContext().traits().anonymousId());
...
Branch.initSession(...);

In the above snippet, this is the Activity context.

I opened an issue in the react-native-branch-deep-linking repo where I go into a little more detail, but wanted to post here since it's obviously related to this library.

0xpatrickdev avatar Sep 28 '18 20:09 0xpatrickdev