integrationlatestIntegration / Multiple instances
Multiple instances
1. Feature overview
You can create SDK instances with multiple APP IDs, which we call multiple instances for short. With multiple instances, you can report data to different projects.
2. Create multiple instances
To create multiple SDK instances, initialize the SDK with different APP IDs:
//Initialize configuration 1
TDAnalytics.init(context, "app-id-1", "https://youserverurl.1.com");
//Initialize configuration 2
TDAnalytics.init(context, "app-id-2", "https://youserverurl.2.com");
//Report an event to configuration 1 (if no app-id is passed, the event is reported to configuration 1 by default)
TDAnalytics.track({
eventName: 'event_from_appid_1'
});
//Report an event to configuration 1 (app-id-1 specified)
TDAnalytics.track({
eventName: 'event_from_appid_1'
}, 'app-id-1');
//Report an event to configuration 2 (app-id-2 specified)
TDAnalytics.track({
eventName: 'event_from_appid_2'
}, 'app-id-2');
Note that each SDK instance must have a different APP ID, and most data is not shared between instances. For details, see Section 3, "Data sharing between instances".
3. Data sharing between instances
Most APIs are called on instance objects, so most data and settings are not shared among instances with different APPIDs, or between a parent instance and its light instances. However, some data and settings take effect for all instances. The following describes whether each type of data and setting is shared among instances:
- Account information
- Distinct ID
#distinct_idgenerated by the system by default: shared - Distinct ID
#distinct_idset by callingidentify: not shared - Account ID
#account_idset by callinglogin: not shared
- Event tracking
trackand user property operationsuser_set,user_setOnce,user_add, anduser_delete: not shared - Super properties
setSuperPropertiesand dynamic super propertiessetDynamicSuperPropertiesTracker: not shared - Record event duration
timeEvent: not shared
Was this page helpful?

