integrationlatestIntegration / Multiple instances
Multiple instances
This SDK supports multiple instances. The instance that is initialized using the method described above is called the main instance, and instances created using the method described in this section are called sub-instances.
Multiple instances share device-related preset properties (including the device ID). No other properties are shared, including:
#distinct_iddistinct ID#account_idaccount ID- Super properties and dynamic super properties
- Events timed by
timeEvent
By creating a sub-instance, you can report data to another project, or report data with a different set of user IDs.
- uni-app
- uni-app x
//Initialize configuration 1
var config_1 = {
appId: "app-id-1",
serverUrl: "https://youserverurl.1.com"
};
TDAnalytics.init(config_1);
//Initialize configuration 2
var config_2 = {
appId: "app-id-2",
serverUrl: "https://youserverurl.2.com"
};
TDAnalytics.init(config_2);
//Report an event to configuration 1 (if app-id is not passed, data is reported to configuration 1 by default)
TDAnalytics.track('event_from_appid_1');
//Report an event to configuration 1 (app-id-1 specified)
TDAnalytics.track('event_from_appid_1',{},'app-id-1');
//Report an event to configuration 2 (app-id-2 specified)
TDAnalytics.track('event_from_appid_2',{},'app-id-2');
//Initialize configuration 1
let tdConfig1 = new TDConfig("app-id-1", "https://youserverurl.1.com");
TDAnalytics.initWithConfig(tdConfig1);
//Initialize configuration 2
let tdConfig2 = new TDConfig("app-id-2", "https://youserverurl.2.com");
TDAnalytics.initWithConfig(tdConfig2);
//Report an event to configuration 1 (if app-id is not passed, data is reported to configuration 1 by default)
TDAnalytics.track('event_from_appid_1');
//Report an event to configuration 1 (app-id-1 specified)
TDAnalytics.track('event_from_appid_1',{},'app-id-1');
//Report an event to configuration 2 (app-id-2 specified)
TDAnalytics.track('event_from_appid_2',{},'app-id-2');
Was this page helpful?

