menu
Is this helpful?

# Multi-Instance

# 1. Introduction of Multi-instance

We support the feature of multiple Appid to create SDK instances, which we call Multi-instances for short. With the multi-instance function, you can report data to different projects.

# 2. How to Create Multiple SDK Instances

Multiple SDK instances can be created by uploading different APP IDs to complete SDK initialization

// initialize SDK
TDAnalytics.init(this, TA_APP_ID, TA_SERVER_URL);
TDAnalytics.init(this, ANOTHER_TA_APP_ID, TA_SERVER_URL);

TDAnalyticsAPI.track("some_event",properties, TA_APP_ID);
TDAnalyticsAPI.track("some_event",properties, ANOTHER_TA_APP_ID)

It should be noted that the Appid of multiple SDK instances must be different. Most data between multiple instances is not the same. For detailed information, please refer to section "Data and Setting Sharing between Multiple Instances".

# 3. Create a Light-instance

You can create multiple instances under the same Appid by creating light-instance

//create an SDK instance first
TDAnalytics.init(this, TA_APP_ID, TA_SERVER_URL);

//call createLightInstance through previously-created instances to generate lightweight instances
String uuid = TDAnalytics.lightInstance();
TDAnalyticsAPI.login("anotherAccount",uuid);
TDAnalyticsAPI.track("some_event",properties,uuid);

The Appid, receiver URL, and some settings of sub-light instances are the same as that of the parent instances, without sharing the other information. For detailed information, please refer to section 4 "Data and Settings Sharing among Multiple Instances".

# 4. Data Sharing among Multi-instances

Since most API are called by instance objects, a majority of data and settings are not shared between Multi-appid instances, Parent-instances, and Light-instances. However, some data and settings will become valid for all instances. The detailed description of whether all data and settings are shared among multiple instances is as follows

  1. Account information
  • The distinct ID #distinct_id generated by the system by default: shared
  • The distinct ID #distinct_id set by calling identify: not shared
  • The distinct ID #account_id set by calling login: not shared
  1. Event tracking track and user property track user_setuser_setOnceuser_adduser_delete : not shared
  2. Super property setSuperProperties and dynamic super property set setDynamicSuperPropertiesTracker: not shared
  3. Whether SDK configuration information is shared among multiple instances:
  • Tracking policy related (i.e. the time interval of data tracking and the volume of each batch of data): shared, decided by the project data corresponding to the first instantiated Appid
  • Upload network condition setNetworkType: shared
  • Print uploaded data Log EnableTrackLogging: shared
  1. Auto-tracking event
  • It is suggested that Auto-Tracking be enabled on only one instance
  • Support reporting auto-tracking events to multiple APP IDs
  • Whether the relevant configuration of the auto-tracking event is shared by multiple instances:
    • Set view ID setViewID: not shared
    • Self-defined view properties setViewProperties,etc.: not shared
    • Ignore auto-tracking event of a certain screen ignoreAutoTrackActivity, etc.: not shared
    • Ignore the click event of a certain view type ignoreViewType: not shared
    • Ignore a certain view ignoreView: not shared
    • All annotations: the valid instances could be specified by setting Appid parameters. If such parameters are not set, all instances should share the configuration, for example:
@ThinkingDataIgnoreTrackAppViewScreen(Appid = "debug-Appid")
  1. Record event duration timeEvent: not shared