menu
Is this helpful?

# C#

최신 버전:v2.0.0

업데이트 시간:2023-10-08

다운로드:source code (opens new window)

# 1. SDK 구현

  1. SDK 파일 다운로드 (opens new window) 및 압축 해제 후 dll 참조
  2. Logbus 설치

TE 시스템을 통해 신속하고 정확한 데이터 전송을 위해, SDK와 LogBus를 함께 사용하여 서버 데이터의 데이터 리포트를 추천합니다.

# 2. 초기 설정

다음은 SDK의 초기 설정을 위한 포맷 코드입니다:

using ThinkingData.Analytics
TDAnalytics te = new TDAnalytics(new LoggerConsumer(LOG_DIRECTORY));

LOG_DIRECTORY는 로컬 액세스 파일의 주소입니다. LogBus의 모니터 주소를 이 주소로 설정하면 자동으로 업로드됩니다.

# 3. 주요 기능

게스트 ID와 계정 ID를 효과적으로 연결하기 위해, 게임 내에서 게스트 ID와 계정 ID를 동시에 사용하는 경우, 이들 ID를 동시에 업로드하는 것을 추천합니다. 동시에 업로드하지 않을 경우, 유저가 중복으로 계산될 수 있습니다.

# 3.1 이벤트 전송

track을 호출하여 이벤트를 전송합니다. 데이터 플랜을 준비한 후 전송하세요. 아래는 모델 코드입니다. 예: 아이템 구매

Dictionary<string, object> properties= new Dictionary<string, object>();

properties.Add("#ip", "123.123.123.123");
properties.Add("channel", "TE");// string
properties.Add("age", 1);// number
properties.Add("is_success", true);// bool
List<string> list = new List<string>();
list.Add("value");
properties.Add("array",list);// array

Dictionary<string, Object> object = new Dictionary<string, object>();
object.Add("key", "vale");
properties.Add("object", object); // object
// object group
List<Object> object_arr = new List<Object>();
object_arr.Add(object);
properties.Add("object_arr", objet_arr);

te.Track("accountId", "distinctId", "Payment", properties);
  • 이벤트 이름은 string 타입이며, 영문자와 숫자, "_"를 포함, 최대 50자
  • Key는 해당 속성의 이름으로 string 타입이며, 영문자와 숫자, "_"를 포함, 최대 50자. TE 시스템은 일괄적으로 소문자로 통일됩니다
  • Value는 해당 속성의 값으로, String, Number, Boolean, Time, object, array, list object를 지원합니다.

# 3.2 유저 속성 설정

일반적인 유저 속성에 대해서는, UserSet을 사용하여 설정할 수 있으며, UserSet은 원래의 값을 덮어씁니다. 본래 해당 속성에 값이 없는 경우, 속성이 새로 생성됩니다. 아래는 코드 예제입니다.

// username is TA
Dictionary<string, object> properties= new Dictionary<string, object>();
properties.Add("user_name","TA");
te.UserSet("accountId","distinctId", properties);
// userName is TE
Dictionary<string, object> newProperties= new Dictionary<string, object>();
newProperties.Add("user_name","TE");

te.UserSet("accountId","distinctId", newProperties);

# 4. 코드 예시 (Example Code)

아래의 코드 예시에 모든 작업이 포함되어 있으며, 아래 순서대로 사용하는 것을 권장합니다:

using ThinkingData.Analytics
// inti SDK
TDAnalytics te = new TDAnalytics(new LoggerConsumer(LOG_DIRECTORY));

Dictionary<string, object> properties= new Dictionary<string, object>();
properties.Add("#ip", "123.123.123.123");
properties.Add("channel", "TE");
properties.Add("age", 1);
properties.Add("is_success", true);

List<string> list = new List<string>();
list.Add("value");
properties.Add("array",list);

Dictionary<string, Object> object = new Dictionary<string, object>();
object.Add("key", "vale");
properties.Add("object", object);

List<Object> object_arr = new List<Object>();
object_arr.Add(object);
properties.Add("object_arr", objet_arr);

te.Track("accountId", "distinctId", "Payment", properties);

Dictionary<string, object> properties= new Dictionary<string, object>();
properties.Add("user_name","TE");

te.UserSet("accountId","distinctId", properties);
te.Flush();