目录
此内容是否有帮助?

# Multi-instance

# 1. Create Multiple SDK Instances

If you want to send data to multiple projects, you can use the multi-instance feature.

Multi-instance can be created by initializing the SDK with multiple settings of project information.

//multi-instance initialization
ThinkingAnalyticsAPI.Token token_1 = new ThinkingAnalyticsAPI.Token(appId_1, serverUrl_2);
ThinkingAnalyticsAPI.Token token_2 = new ThinkingAnalyticsAPI.Token(appId_2, serverUrl_2);
ThinkingAnalyticsAPI.Token[] tokens = new ThinkingAnalyticsAPI.Token[2];
tokens[0] = token_1;
tokens[1] = token_2;
ThinkingAnalyticsAPI.StartThinkingAnalytics(tokens);
//multi-instance tracking
Dictionary<string, object> properties = new Dictionary<string, object>(){
    {"product_name", "product name"}
};
//track event with 1st instance
ThinkingAnalyticsAPI.Track("product_buy", properties, appId_1);
//track event with 2ed instance
ThinkingAnalyticsAPI.Track("product_buy", properties, appId_2);
//if Track without APP ID, it will be reported with 1st instance
ThinkingAnalyticsAPI.Track("product_buy", properties);

Distinct ID, account ID, super properties, etc. are not shared across multi-instance and need to be set for each instance.

# 2. Create Light Instance

// initializing instance
ThinkingAnalyticsAPI.StartThinkingAnalytics("APPID", "SERVER");
// call CreateLightInstance to creat Lightweight Instance
string lightKey = ThinkingAnalyticsAPI.CreateLightInstance();
// Login/Track with lightKey
ThinkingAnalyticsAPI.Login("TE2", lightKey);
ThinkingAnalyticsAPI.Track("some_event", lightKey);

The Light Instance has the same APP ID, server URL, and some settings as the parent instance, but other information is not shared.