@thinkingai/ae-cli 6.1.38 → 6.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (188) hide show
  1. package/README.md +2 -0
  2. package/README.zh.md +2 -0
  3. package/dist/{ai-monitor-UL2O7J4X.js → ai-monitor-DST4NDOK.js} +5 -5
  4. package/dist/ai-monitor.js +7 -7
  5. package/dist/{auth-ERWVKQDG.js → auth-BD3NIY3T.js} +3 -3
  6. package/dist/{automation-OQ647CSW.js → automation-IMDCJUML.js} +85 -9
  7. package/dist/{capability-HPP6E3ZX.js → capability-3NJOQHZQ.js} +3 -3
  8. package/dist/{chunk-DKOGWIYQ.js → chunk-24DCOJBJ.js} +2 -2
  9. package/dist/{chunk-SHB7A2JE.js → chunk-2RORKIF6.js} +2 -2
  10. package/dist/{chunk-HBI7IQH3.js → chunk-6NJZSWUT.js} +3 -28
  11. package/dist/{chunk-QPUPWGZ3.js → chunk-DTODOQ6T.js} +1 -1
  12. package/dist/{chunk-PCQTBRPT.js → chunk-FRJUB66C.js} +1 -1
  13. package/dist/{chunk-ZLJZPPPV.js → chunk-IY5G42YY.js} +2 -2
  14. package/dist/{chunk-JRXSLFCA.js → chunk-KBJHBVO7.js} +1 -1
  15. package/dist/{chunk-CYZV5AXW.js → chunk-KE5WGBXS.js} +2 -1
  16. package/dist/chunk-N2MAYIRU.js +32 -0
  17. package/dist/{chunk-DULCIC67.js → chunk-SQEK6S4X.js} +2 -3
  18. package/dist/{chunk-VPLRZSMY.js → chunk-STHIGWWC.js} +10 -1
  19. package/dist/{chunk-BWEQIKA3.js → chunk-TVSGS5QB.js} +5 -5
  20. package/dist/{chunk-LXRALNNA.js → chunk-UK7HQ4IL.js} +1 -1
  21. package/dist/{chunk-NDX4VJO7.js → chunk-VXKKTUU2.js} +2 -2
  22. package/dist/{chunk-E5CJI7L3.js → chunk-WRYXVIJP.js} +1 -1
  23. package/dist/{compat-check-WRPEFB5N.js → compat-check-7VBBE7KO.js} +1 -1
  24. package/dist/{config-IS33K45R.js → config-LFRZBPH5.js} +3 -3
  25. package/dist/{context-Y2A6QIS3.js → context-WJQGJD6F.js} +1 -1
  26. package/dist/{data-integration-EIF5QHYF.js → data-integration-KMJWYAKK.js} +2 -1
  27. package/dist/index.js +34 -32
  28. package/dist/{memory-6QMZS4HF.js → memory-VPOPSU52.js} +3 -3
  29. package/dist/{metadata-TMAXVLOL.js → metadata-AR64J76Z.js} +5 -5
  30. package/dist/{model-LEYRQKOS.js → model-2F2354QP.js} +1 -1
  31. package/dist/{personal-semantic-preference-RMZEDRCJ.js → personal-semantic-preference-BCOSI4DO.js} +4 -4
  32. package/dist/{project-semantic-UD3OAZ6K.js → project-semantic-DJLXAXLD.js} +4 -4
  33. package/dist/{sync-GVF3OI2U.js → sync-4TUIQ2PZ.js} +3 -3
  34. package/dist/{te-agent-S7UH657Z.js → te-agent-EMDWA3M6.js} +4 -4
  35. package/dist/{te-analysis-SJIE5OZY.js → te-analysis-XHAMRMTQ.js} +5 -5
  36. package/dist/{te-community-VNHJDEID.js → te-community-JSUSZEYH.js} +4 -4
  37. package/dist/{te-dataops-AO4OQBQV.js → te-dataops-I264BUTI.js} +2 -2
  38. package/dist/{te-engage-EZJRFG3Q.js → te-engage-XNMQYO5N.js} +68 -16
  39. package/dist/{te-experiment-R2MNSAKV.js → te-experiment-5SCHMYVO.js} +4 -4
  40. package/dist/{te-kb-C44A4BHM.js → te-kb-QQ53TNRZ.js} +44 -13
  41. package/dist/{te-system-DB5Z3LLF.js → te-system-Z4VEB6PL.js} +1 -1
  42. package/dist/{te-team-J52STTEZ.js → te-team-V6BBI52R.js} +87 -6
  43. package/dist/{things-G2QFXDK7.js → things-THHGDSEC.js} +4 -4
  44. package/dist/{update-GEKOZMHU.js → update-53ZUXWV5.js} +2 -2
  45. package/dist/{web-runtime-5M7PRY7R.js → web-runtime-ZJHOIPKX.js} +4 -4
  46. package/dist/{workspace-RZESYB6T.js → workspace-W5ZPVWJS.js} +3 -3
  47. package/package.json +3 -3
  48. package/skills/ae-automation/SKILL.md +6 -2
  49. package/skills/ae-automation/references/cli.md +9 -3
  50. package/skills/ae-engage/SKILL.md +6 -1
  51. package/skills/ae-engage/references/common-metric.md +47 -1
  52. package/skills/ae-engage/references/flow-metric-update.md +1 -1
  53. package/skills/ae-engage/references/task-metric-update.md +1 -1
  54. package/skills/ae-experiment/SKILL.md +1 -1
  55. package/skills/ae-experiment/references/save_experiment.md +1 -1
  56. package/skills/ae-kb/SKILL.md +8 -6
  57. package/skills/ae-kb/references/query-workflow.md +5 -1
  58. package/skills/ae-team/SKILL.md +7 -3
  59. package/skills/ae-team/references/copy-to-personal.md +7 -0
  60. package/skills/ae-team/references/promote.md +7 -0
  61. package/skills/ae-team/references/update.md +3 -3
  62. package/skills/ae-tracking-matrix/SKILL.md +0 -170
  63. package/skills/ae-tracking-matrix/assets//345/237/213/347/202/271/346/250/241/347/211/210.xlsx +0 -0
  64. package/skills/ae-tracking-matrix/i18n.yaml +0 -12
  65. package/skills/ae-tracking-matrix/references/ae-capabilities.md +0 -93
  66. package/skills/ae-tracking-matrix/references/business-semantic-checks.md +0 -30
  67. package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +0 -256
  68. package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +0 -213
  69. package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +0 -407
  70. package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +0 -218
  71. package/skills/ae-tracking-matrix/references/categories/casual_music.md +0 -112
  72. package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +0 -301
  73. package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +0 -356
  74. package/skills/ae-tracking-matrix/references/categories/fishing.md +0 -775
  75. package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +0 -89
  76. package/skills/ae-tracking-matrix/references/categories/idle_card.md +0 -27
  77. package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +0 -415
  78. package/skills/ae-tracking-matrix/references/categories/interactive_video.md +0 -133
  79. package/skills/ae-tracking-matrix/references/categories/merge.md +0 -639
  80. package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +0 -406
  81. package/skills/ae-tracking-matrix/references/categories/mmo_web.md +0 -230
  82. package/skills/ae-tracking-matrix/references/categories/music.md +0 -137
  83. package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +0 -414
  84. package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +0 -199
  85. package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +0 -158
  86. package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +0 -546
  87. package/skills/ae-tracking-matrix/references/categories/rpg.md +0 -195
  88. package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +0 -115
  89. package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +0 -151
  90. package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +0 -260
  91. package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +0 -232
  92. package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +0 -359
  93. package/skills/ae-tracking-matrix/references/categories/tower_defense.md +0 -365
  94. package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +0 -211
  95. package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +0 -132
  96. package/skills/ae-tracking-matrix/references/category-registry.md +0 -77
  97. package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +0 -230
  98. package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +0 -406
  99. package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +0 -128
  100. package/skills/ae-tracking-matrix/references/eval-cases.md +0 -74
  101. package/skills/ae-tracking-matrix/references/naming-dict.md +0 -238
  102. package/skills/ae-tracking-matrix/references/optimization-checklist.md +0 -85
  103. package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +0 -142
  104. package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +0 -47
  105. package/skills/ae-tracking-matrix/references/plan-generation/reference.md +0 -794
  106. package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +0 -94
  107. package/skills/ae-tracking-matrix/references/scene-routing.md +0 -80
  108. package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +0 -3787
  109. package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +0 -827
  110. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +0 -655
  111. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +0 -953
  112. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +0 -1128
  113. package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +0 -714
  114. package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +0 -1268
  115. package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +0 -776
  116. package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +0 -182
  117. package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +0 -2755
  118. package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +0 -1182
  119. package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +0 -1300
  120. package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +0 -1369
  121. package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +0 -1692
  122. package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +0 -902
  123. package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +0 -763
  124. package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +0 -1107
  125. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +0 -1532
  126. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +0 -845
  127. package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +0 -228
  128. package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +0 -149
  129. package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +0 -407
  130. package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +0 -163
  131. package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +0 -149
  132. package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +0 -153
  133. package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +0 -232
  134. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +0 -314
  135. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +0 -117
  136. package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +0 -148
  137. package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +0 -645
  138. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +0 -307
  139. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +0 -347
  140. package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +0 -72
  141. package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +0 -264
  142. package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +0 -566
  143. package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +0 -409
  144. package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +0 -446
  145. package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +0 -557
  146. package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +0 -457
  147. package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +0 -490
  148. package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +0 -523
  149. package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +0 -484
  150. package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +0 -442
  151. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +0 -391
  152. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +0 -91
  153. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +0 -635
  154. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +0 -113
  155. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +0 -466
  156. package/skills/ae-tracking-matrix/references/standard-base/README.md +0 -22
  157. package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +0 -174
  158. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +0 -20
  159. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +0 -7
  160. package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +0 -14
  161. package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +0 -370
  162. package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +0 -47
  163. package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +0 -37
  164. package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +0 -27
  165. package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +0 -23
  166. package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +0 -14
  167. package/skills/ae-tracking-matrix/references/standard-base/user_data.md +0 -46
  168. package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +0 -13
  169. package/skills/ae-tracking-matrix/references/system-fields.md +0 -297
  170. package/skills/ae-tracking-matrix/references/te-field-translations.md +0 -1791
  171. package/skills/ae-tracking-matrix/references/workflows/data-verification.md +0 -232
  172. package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +0 -829
  173. package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +0 -355
  174. package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +0 -283
  175. package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +0 -168
  176. package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +0 -205
  177. package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +0 -75
  178. package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +0 -36
  179. package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +0 -107
  180. package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +0 -114
  181. package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +0 -53
  182. package/skills/ae-tracking-matrix/scripts/finalize_plan.py +0 -166
  183. package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +0 -674
  184. package/skills/ae-tracking-matrix/scripts/plan_contract.py +0 -200
  185. package/skills/ae-tracking-matrix/scripts/plan_types.py +0 -60
  186. package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +0 -169
  187. package/skills/ae-tracking-matrix/scripts/sync_plan.py +0 -296
  188. package/skills/ae-tracking-matrix/scripts/upload_plan.py +0 -340
@@ -1,566 +0,0 @@
1
- ---
2
- code: c_sdk_installation
3
- name: "C"
4
- wikiToken: SLlQwuOYRifeDVkRAxTc08pVnMg
5
- parentWikiToken: O3YxwgHGiiEnvYkHCcIcX51inkf
6
- updateTime: 1745310920000
7
- sourceUrl: https://docs-v2.thinkingdata.cn/?version=6.0&lan=zh-CN&code=c_sdk_installation
8
- ---
9
-
10
- # C
11
-
12
- ::: tip Note
13
-
14
- Before integration, please read the Pre-Integration Guide first.
15
-
16
- :::
17
-
18
- **Latest Version**: v2.0.0
19
-
20
- **Update Date**: 2023-11-30
21
-
22
- **Download**: Source Code
23
-
24
- ::: warning Note
25
-
26
- This document applies to v2.0.0 and later versions. For historical versions, please refer to C SDK Integration Guide (V1).
27
-
28
- :::
29
-
30
- ### 1. SDK Integration
31
-
32
- 1. Download C SDK source code, modify `CMakeLists.txt` file, use `logconsumer` method to compile .a file
33
-
34
- ```
35
- cmake_minimum_required(VERSION 3.12)
36
- project(thinking_data_c)
37
- message(STATUS "[ThinkingData] CMAKE_HOST_SYSTEM: ${CMAKE_HOST_SYSTEM} ")
38
-
39
- include_directories(include)
40
-
41
- #################################################################
42
-
43
- # Product Library: logging consumer
44
- if(WIN32)
45
- add_compile_definitions(USE_WIN)
46
- set(CMAKE_C_FLAGS "-std=c89 -pedantic-errors -m64")
47
- else()
48
- add_compile_definitions(USE_POSIX)
49
- set(CMAKE_C_FLAGS "-std=c89")
50
- endif()
51
- SET(TE_LIB_NAME thinkingdata)
52
- add_library(${TE_LIB_NAME} src/thinkingdata.c src/td_json.c src/td_list.c src/td_util.c src/td_logger_consumer.c)
53
- if(WIN32)
54
- include_directories(thirdparty/pcre/include)
55
- link_directories(thirdparty/pcre/lib)
56
- target_link_libraries(${TE_LIB_NAME} pcre_x64)
57
- endif()
58
- ```
59
-
60
- Compile the project to get the `libthinkingdata.a` file.
61
-
62
- 2. Install LogBus
63
- We recommend using SDK + LogBus for server-side data collection and reporting. You can refer to the following documentation for LogBus installation: LogBus User Guide.
64
-
65
- ### 2. Initialization
66
-
67
- Here is sample code for SDK initialization:
68
-
69
- ```
70
- struct TDAnalytics* ta = NULL;
71
- struct TDConsumer* consumer = NULL;
72
-
73
- TDConfig* config = td_init_config();
74
- char* logPath = "LOG_DIRECTORY";
75
- TD_ASSERT(TD_OK == td_add_string("file_path", logPath, strlen(logPath), config));
76
-
77
- if (TD_OK != td_init_consumer(&consumer, config)) {
78
- fprintf(stderr, "Failed to initialize the consumer.");
79
- }
80
- td_free_properties(config);
81
-
82
- if (TD_OK != td_init(consumer, &ta)) {
83
- fprintf(stderr, "Failed to initialize the SDK.");
84
- return 1;
85
- }
86
- ```
87
-
88
- `LOG_DIRECTORY` is the local folder address for writing. You just need to set LogBus's monitoring folder path to this address to use LogBus for data monitoring and uploading.
89
-
90
- ### 3. Common Features
91
-
92
- To ensure successful binding of visitor ID and account ID, if your game uses both visitor ID and account ID, we strongly recommend uploading both IDs. Otherwise, account matching issues may occur, leading to duplicate user counts. For specific ID binding rules, please refer to the User Identification Rules chapter.
93
-
94
- #### 3.1 Track Events
95
-
96
- You can call `td_track` to upload events. We recommend setting event properties and sending conditions based on your previously documented requirements. Here is sample code for tracking events:
97
-
98
- ```
99
- // Generate custom properties
100
- TDProperties *properties = td_init_properties();
101
- // Set user IP address, TE system will parse user geographic location based on IP
102
- TD_ASSERT(TD_OK == td_add_string("#ip", "192.168.1.1", strlen("192.168.1.1"), properties));
103
- // Add custom properties
104
- TD_ASSERT(TD_OK == td_add_string("channel", "ta", strlen("ta"), properties));// String
105
- TD_ASSERT(TD_OK == td_add_int("age", 1, properties)); // Number
106
- TD_ASSERT(TD_OK == td_add_bool("is_success", TD_TRUE, properties));// Boolean
107
- TD_ASSERT(TD_OK == td_add_date("birthday", time(NULL), 0, properties));// Date
108
- // Array
109
- TD_ASSERT(TD_OK == td_append_array("arr", "value", strlen("value"), properties));
110
- TD_ASSERT(TD_OK == td_append_array("arr", "value1", strlen("value1"), properties));
111
- // Object
112
- TDProperties *object = td_init_custom_properties("object");
113
- TD_ASSERT(TD_OK == td_add_string("key", "value", strlen("value"), object));
114
- TD_ASSERT(TD_OK == td_add_property(object, properties));
115
- // Object Array
116
- TDProperties *object1 = td_init_custom_properties("object1");
117
- TD_ASSERT(TD_OK == td_add_string("key", "value", strlen("value"), object1));
118
- TD_ASSERT(TD_OK == td_append_properties("object_arr", object1, properties));
119
- // Report event with custom properties, account_id and distinct_id must have at least one set
120
- TD_ASSERT(TD_OK == td_track("account_id", "distinct_id", "payment", properties, ta));
121
- td_free_properties(properties);
122
- ```
123
-
124
- - Event name must be a string type, starting with a letter, containing numbers, letters, and underscores "\_", with maximum length of 50 characters.
125
- - Key is the property name, must be a string type, starting with a letter, containing numbers, letters, and underscores "\_", with maximum length of 50 characters. Case-insensitive, TE will convert to lowercase.
126
- - Value is the property value, supporting strings, numbers, booleans, dates, objects, object arrays, and arrays.
127
-
128
- **User property requirements are consistent with event property requirements**
129
-
130
- #### 3.2 Set User Properties
131
-
132
- For general user properties, you can call `td_user_set` to set them. Properties uploaded via this interface will overwrite existing property values. If the user property does not exist previously, a new user property will be created with the same type as the uploaded property. Here is an example of setting a username:
133
-
134
- ```
135
- // At this point, username is "TA"
136
- // account_id and distinct_id must have at least one set
137
- TDProperties *user_properties = td_init_properties();
138
- TD_ASSERT(TD_OK == td_add_string("user_name", "TA", strlen("TA"), user_properties));
139
- TD_ASSERT(TD_OK == td_user_set(account_id, distinct_id, user_properties,ta));
140
- td_free_properties(user_properties);
141
-
142
- // At this point, userName is "TE"
143
- TDProperties *user_properties2 = td_init_properties();
144
- TD_ASSERT(TD_OK == td_add_string("user_name", "TE", strlen("TE"), user_properties2));
145
- TD_ASSERT(TD_OK == td_user_set(account_id, distinct_id, user_properties2,ta));
146
- td_free_properties(user_properties2);
147
- ```
148
-
149
- #### 3.3 Data Reporting
150
-
151
- When initializing SDK using `td_init_consumer()` method, SDK will write collected data to disk in real-time.
152
-
153
- The `td_flush()` function internally synchronizes the default memory cache in the file system to disk in real-time. Generally, no need to call manually.
154
-
155
- ```
156
- td_flush(ta);
157
- ```
158
-
159
- #### 3.4 Close SDK
160
-
161
- ```
162
- td_free(ta);
163
- td_consumer_free(consumer);
164
- ```
165
-
166
- Close and exit the SDK. Please call this interface before shutting down the server to avoid data loss in the cache.
167
-
168
- ### 4. Best Practices
169
-
170
- ```
171
- struct TDAnalytics* ta = NULL;
172
- struct TDConsumer* consumer = NULL;
173
-
174
- TDConfig* config = td_init_config();
175
- char* logPath = "LOG_DIRECTORY";
176
- TD_ASSERT(TD_OK == td_add_string("file_path", logPath, strlen(logPath), config));
177
-
178
- if (TD_OK != td_init_consumer(&consumer, config)) {
179
- fprintf(stderr, "Failed to initialize the consumer.");
180
- }
181
- td_free_properties(config);
182
-
183
- if (TD_OK != td_init(consumer, &ta)) {
184
- fprintf(stderr, "Failed to initialize the SDK.");
185
- return 1;
186
- }
187
-
188
- // Generate custom properties
189
- TDProperties *properties = td_init_properties();
190
- // Set user IP address, TE system will parse user geographic location based on IP
191
- TD_ASSERT(TD_OK == td_add_string("#ip", "192.168.1.1", strlen("192.168.1.1"), properties));
192
- // Add custom properties
193
- TD_ASSERT(TD_OK == td_add_string("channel", "ta", strlen("ta"), properties));// String
194
- TD_ASSERT(TD_OK == td_add_int("age", 1, properties)); // Number
195
- TD_ASSERT(TD_OK == td_add_bool("is_success", TD_TRUE, properties));// Boolean
196
- TD_ASSERT(TD_OK == td_add_date("birthday", time(NULL), 0, properties));// Date
197
- // Array
198
- TD_ASSERT(TD_OK == td_append_array("arr", "value", strlen("value"), properties));
199
- TD_ASSERT(TD_OK == td_append_array("arr", "value1", strlen("value1"), properties));
200
- // Object
201
- TDProperties *object = td_init_custom_properties("object");
202
- TD_ASSERT(TD_OK == td_add_string("key", "value", strlen("value"), object));
203
- TD_ASSERT(TD_OK == td_add_property(object, properties));
204
- // Object Array
205
- TDProperties *object1 = td_init_custom_properties("object1");
206
- TD_ASSERT(TD_OK == td_add_string("key", "value", strlen("value"), object1));
207
- TD_ASSERT(TD_OK == td_append_properties("object_arr", object1, properties));
208
- // Report event with custom properties, account_id and distinct_id must have at least one set
209
- TD_ASSERT(TD_OK == td_track("account_id", "distinct_id", "payment", properties, ta));
210
- td_free_properties(properties);
211
-
212
- // At this point, username is "TA"
213
- // account_id and distinct_id must have at least one set
214
- TDProperties *user_properties = td_init_properties();
215
- TD_ASSERT(TD_OK == td_add_string("user_name", "TA", strlen("TA"), user_properties));
216
- TD_ASSERT(TD_OK == td_user_set("account_id", "distinct_id", user_properties,ta));
217
- td_free_properties(user_properties);
218
-
219
- // At this point, userName is "TE"
220
- TDProperties *user_properties2 = td_init_properties();
221
- TD_ASSERT(TD_OK == td_add_string("user_name", "TE", strlen("TE"), user_properties2));
222
- TD_ASSERT(TD_OK == td_user_set("account_id", "distinct_id", user_properties2,ta));
223
- td_free_properties(user_properties2);
224
- ```
225
-
226
- ---
227
-
228
- # Advanced Guide
229
-
230
- ### 1. Track Events
231
-
232
- After SDK initialization, you can perform data tracking to collect user behavior information. Generally, regular events can meet business scenario requirements. You can also use first-time events, updateable events, etc. based on your actual business scenarios.
233
-
234
- #### 1.1 Regular Events
235
-
236
- You can call `td_track` to upload events. We recommend setting event properties and sending conditions based on your previously documented requirements. Here is an example of a user purchasing a product:
237
-
238
- ```
239
- // Set event properties
240
- TDProperties *properties = td_init_properties();
241
- TD_ASSERT(TD_OK == td_add_string("product_name", "goods_name", strlen("goods_name"), properties));
242
- // Report event with custom properties, account_id and distinct_id must have at least one set
243
- TD_ASSERT(TD_OK == td_track("account_id", "distinct_id", "product_buy", properties, ta));
244
- td_free_properties(properties);
245
- ```
246
-
247
- #### 1.2 First-Time Events
248
-
249
- First-time events are events that are recorded only once for a specific device or other dimensional ID. For example, in some scenarios, you may want to record an activation event on a specific device, which can be reported using a first-time event.
250
-
251
- ```
252
- TD_ASSERT(TD_OK == td_track_first_event("account_id", "distinct_id", "device_activation", "first_id", properties, ta));
253
- ```
254
-
255
- Note: Since first-time verification is completed on the server side, first-time events will be delayed by 1 hour before entering the database.
256
-
257
- #### 1.3 Updateable Events
258
-
259
- You can implement the need to modify event data in specific scenarios through updateable events. Updateable events need to specify an ID that identifies the event and pass it when creating the updateable event object. TE backend will determine the data to be updated based on the event name and event ID.
260
-
261
- ```
262
- // Report updateable event, event name is UPDATABLE_EVENT, event ID is event_id
263
- // After reporting, event property status is 3, price is 100
264
- TDProperties *properties = td_init_properties();
265
- TD_ASSERT(TD_OK == td_add_int("price",100,properties));
266
- TD_ASSERT(TD_OK == td_add_int("status",3,properties));
267
- TD_ASSERT(TD_OK == td_track_update("account_id", "distinct_id", "UPDATABLE_EVENT", "event_id",properties, ta));
268
- td_free_properties(properties);
269
- // After reporting, same event property status is updated to 5, price unchanged
270
- TDProperties *new_properties = td_init_properties();
271
- TD_ASSERT(TD_OK == td_add_int("status",5,new_properties));
272
- TD_ASSERT(TD_OK == td_track_update("account_id", "distinct_id", "UPDATABLE_EVENT", "event_id",new_properties, ta));
273
- td_free_properties(new_properties);
274
- ```
275
-
276
- #### 1.4 Overwriteable Events
277
-
278
- Overwriteable events are similar to updateable events, except that overwriteable events will completely overwrite historical data with the latest data. Effectively, this is equivalent to deleting the previous data and inserting the latest data. TE backend will determine the data to be updated based on the event name and event ID.
279
-
280
- ```
281
- // Report overwriteable event, event name is OVERWRITE_EVENT, event ID is event_id
282
- // After reporting, event property status is 3, price is 100
283
- TDProperties *properties = td_init_properties();
284
- TD_ASSERT(TD_OK == td_add_int("price",100,properties));
285
- TD_ASSERT(TD_OK == td_add_int("status",3,properties));
286
- TD_ASSERT(TD_OK == td_track_overwrite("account_id", "distinct_id", "OVERWRITE_EVENT", "event_id",properties, ta));
287
- td_free_properties(properties);
288
- // After reporting, same event property status is updated to 5, price property is deleted
289
- TDProperties *new_properties = td_init_properties();
290
- TD_ASSERT(TD_OK == td_add_int("status",5,new_properties));
291
- TD_ASSERT(TD_OK == td_track_overwrite("account_id", "distinct_id", "OVERWRITE_EVENT", "event_id",new_properties, ta));
292
- td_free_properties(new_properties);
293
- ```
294
-
295
- ### 2. User Properties
296
-
297
- TE platform supports the following user property setting APIs: `td_user_set`, `td_user_setOnce`, `td_user_add`, `td_user_unset`, `td_user_delete`, `td_user_append`, `td_user_uniq_append`.
298
-
299
- #### 2.1 td_user_set
300
-
301
- For general user properties, you can call `td_user_set` to set them. Properties uploaded via this interface will overwrite existing property values. If the user property does not exist previously, a new user property will be created with the same type as the uploaded property. Here is an example of setting a username:
302
-
303
- ```
304
- // At this point, username is "TA"
305
- TDProperties *user_properties = td_init_properties();
306
- TD_ASSERT(TD_OK == td_add_string("user_name", "TA", strlen("TA"), user_properties));
307
- TD_ASSERT(TD_OK == td_user_set("account_id", "distinct_id", user_properties,ta));
308
- td_free_properties(user_properties);
309
-
310
- // At this point, userName is "TE"
311
- TDProperties *user_properties2 = td_init_properties();
312
- TD_ASSERT(TD_OK == td_add_string("user_name", "TE", strlen("TE"), user_properties2));
313
- TD_ASSERT(TD_OK == td_user_set("account_id", "distinct_id", user_properties2,ta));
314
- td_free_properties(user_properties2);
315
- ```
316
-
317
- #### 2.2 td_user_setOnce
318
-
319
- If you want to set a user property only once, you can call `td_user_setOnce`. When the property already has a value, this information will be ignored. Here is another example of setting a username:
320
-
321
- ```
322
- // first_payment_time is 2018-01-01 01:23:45.678
323
- TDProperties *user_properties = td_init_properties();
324
- TD_ASSERT(TD_OK == td_add_string("first_payment_time", "2018-01-01 01:23:45.678", strlen("2018-01-01 01:23:45.678"), user_properties));
325
- TD_ASSERT(TD_OK == td_user_setOnce("account_id", "distinct_id", user_properties,ta));
326
- td_free_properties(user_properties);
327
-
328
- // first_payment_time is still 2018-01-01 01:23:45.678
329
- TDProperties *user_properties2 = td_init_properties();
330
- TD_ASSERT(TD_OK == td_add_string("first_payment_time", "2018-12-31 01:23:45.678", strlen("2018-12-31 01:23:45.678"), user_properties2));
331
- TD_ASSERT(TD_OK == td_user_setOnce("account_id", "distinct_id", user_properties2,ta));
332
- td_free_properties(user_properties2);
333
- ```
334
-
335
- #### 2.3 td_user_add
336
-
337
- When you want to upload numeric properties, you can call `td_user_add` to accumulate the property. If the property has not been set, it will be assigned 0 before calculation. Negative values can be passed, equivalent to subtraction. Here is an example of accumulating total payment amount:
338
-
339
- ```
340
- // Upload user property, at this point "total_revenue" value is 30
341
- TDProperties *user_properties = td_init_properties();
342
- TD_ASSERT(TD_OK == td_add_int("total_revenue", 30, user_properties));
343
- TD_ASSERT(TD_OK == td_user_add("account_id", "distinct_id", user_properties, ta));
344
- td_free_properties(user_properties);
345
-
346
- // Upload user property, at this point "total_revenue" value is 678
347
- TDProperties *new_user_properties = td_init_properties();
348
- TD_ASSERT(TD_OK == td_add_int("total_revenue",648 , new_user_properties));
349
- TD_ASSERT(TD_OK == td_user_add("account_id", "distinct_id", new_user_properties, ta));
350
- td_free_properties(new_user_properties);
351
- ```
352
-
353
- The property key must be a string, and Value only allows numeric values.
354
-
355
- #### 2.4 td_user_append
356
-
357
- You can call `td_user_append` to append array-type user properties.
358
-
359
- ```
360
- // At this point, user_list property value is ["apple", "ball"]
361
- TDProperties *array_properties = td_init_properties();
362
- TD_ASSERT(TD_OK == td_append_array("user_list", "apple", strlen("apple"), array_properties));
363
- TD_ASSERT(TD_OK == td_append_array("user_list", "ball", strlen("ball"), array_properties));
364
- TD_ASSERT(TD_OK == td_user_append("account_id", "distinct_id", array_properties, ta));
365
- td_free_properties(array_properties);
366
-
367
- // At this point, user_list property value is ["apple","apple","ball","cube"]
368
- TDProperties *new_array_properties = td_init_properties();
369
- TD_ASSERT(TD_OK == td_append_array("user_list", "apple", strlen("apple"), new_array_properties));
370
- TD_ASSERT(TD_OK == td_append_array("user_list", "cube", strlen("cube"), new_array_properties));
371
- TD_ASSERT(TD_OK == td_user_append("account_id", "distinct_id", new_array_properties, ta));
372
- ```
373
-
374
- #### 2.5 td_user_uniq_append
375
-
376
- You can call `td_user_uniq_append` to append array-type user properties. The `td_user_uniq_append` interface will deduplicate appended user properties, while `td_user_append` interface does not deduplicate, allowing duplicate user properties.
377
-
378
- ```
379
- // At this point, user_list property value is ["apple", "ball"]
380
- TDProperties *array_properties = td_init_properties();
381
- TD_ASSERT(TD_OK == td_append_array("user_list", "apple", strlen("apple"), array_properties));
382
- TD_ASSERT(TD_OK == td_append_array("user_list", "ball", strlen("ball"), array_properties));
383
- TD_ASSERT(TD_OK == td_user_append("account_id", "distinct_id", array_properties, ta));
384
- td_free_properties(array_properties);
385
-
386
- // At this point, user_list property value is ["apple", "ball","cube"]
387
- TDProperties *new_array_properties = td_init_properties();
388
- TD_ASSERT(TD_OK == td_append_array("user_list", "apple", strlen("apple"), new_array_properties));
389
- TD_ASSERT(TD_OK == td_append_array("user_list", "cube", strlen("cube"), new_array_properties));
390
- TD_ASSERT(TD_OK == td_user_uniq_append("account_id","distinct_id", new_array_properties, ta));
391
- td_free_properties(new_array_properties);
392
- ```
393
-
394
- #### 2.6 td_user_unset
395
-
396
- When you want to clear user property values, you can call `td_user_unset` to clear specified properties. If the property has not been created in the cluster, `td_user_unset` will not create the property.
397
-
398
- ```
399
- TD_ASSERT(TD_OK == td_user_unset("account_id", "distinct_id", "test", ta));
400
- ```
401
-
402
- td_user_unset: The parameter is the Key value of the property to be cleared.
403
-
404
- #### 2.7 td_user_delete
405
-
406
- If you want to delete a user, you can call `td_user_delete` to delete the user. You will no longer be able to query the user's properties, but events generated by the user can still be queried. This operation may have irreversible consequences, please use with caution.
407
-
408
- ```
409
- TD_ASSERT(TD_OK == td_user_delete("account_id", "distinct_id", ta));
410
- ```
411
-
412
- ### 3. Other Features
413
-
414
- #### 3.1 BatchConsumer
415
-
416
- ::: warning Note
417
-
418
- When data volume is large or network is abnormal, there is a risk of data loss. Not recommended for production environments.
419
-
420
- :::
421
-
422
- Batch real-time data transmission to TE server without requiring transmission tools. Cache buffer size can be set, default 20, meaning maximum cached data count is 20 (20 is batch value for each upload, configurable).
423
-
424
- ```
425
- // First: Modify CMakeList.txt file, package TDBatchConsumer type library file
426
-
427
- struct TDAnalytics* ta = NULL;
428
- struct TDConsumer* consumer = NULL;
429
-
430
- // Generate config
431
- TDConfig *config = td_init_config();
432
- // Configure appid and url
433
- char* appid = "APPID";
434
- char* serverURL = "SERVER_URL";
435
- TD_ASSERT(TD_OK == td_add_string("push_url", serverURL, strlen(serverURL), config));
436
- TD_ASSERT(TD_OK == td_add_string("appid", appid, strlen(appid), config));
437
-
438
- // Generate SDK instance
439
- if (TD_OK != td_init_consumer(&consumer, config)) {
440
- fprintf(stderr, "Failed to initialize the consumer.");
441
- return 1;
442
- }
443
- td_free_properties(config);
444
- if (TD_OK != td_init(consumer, &ta)) {
445
- fprintf(stderr, "Failed to initialize the SDK.");
446
- return 1;
447
- }
448
- ```
449
-
450
- Parameter Description:
451
-
452
- - `APPID`: Your project's APPID, can be obtained from TE backend project management page
453
- - `SERVER_URL`: Data upload URL
454
- - If you are connecting to cloud service, enter: https://global-receiver-ta.thinkingdata.cn
455
- - If you use private deployment version, please bind domain for data collection address and configure HTTPS certificate: https://YOUR_DATA_COLLECTION_DOMAIN
456
-
457
- ---
458
-
459
- # Real-time Debugging
460
-
461
- ::: warning Note
462
-
463
- SDK Debug mode is only for integration debugging. Do not use in production environment.
464
-
465
- :::
466
-
467
- ### Enable Log Printing
468
-
469
- ```
470
- td_enableLog(1);
471
- ```
472
-
473
- ### Use DebugConsumer
474
-
475
- During SDK integration, you can use TE's Debug feature for real-time debugging. Enabling Debug feature requires two steps:
476
-
477
- 1. Use DebugConsumer
478
-
479
- - Package .a file including debugConsumer functionality, `CMakeLists.txt` modification example:
480
-
481
- ```
482
- # Debug Library: debug consumer
483
- if(WIN32)
484
- add_compile_definitions(USE_WIN)
485
- set(CMAKE_C_FLAGS "-std=c99 -pedantic-errors -m64")
486
- else()
487
- add_compile_definitions(USE_POSIX)
488
- set(CMAKE_C_FLAGS "-std=c99")
489
- endif()
490
- SET(TE_LIB_NAME thinkingDataDebug)
491
- add_library(${TE_LIB_NAME} src/thinkingdata.c src/td_json.c src/td_list.c src/td_util.c src/td_debug_consumer.c src/td_http_client.c)
492
- if(WIN32)
493
- add_compile_definitions(BUILDING_LIBCURL)
494
- include_directories(thirdparty/pcre/include thirdparty/curl/include)
495
- link_directories(thirdparty/pcre/lib thirdparty/curl/lib)
496
- target_link_libraries(${TE_LIB_NAME} pcre_x64 libcurl)
497
- else()
498
- target_link_libraries(${TE_LIB_NAME} curl)
499
- endif()
500
- ```
501
-
502
- - Here is sample code using DebugConsumer:
503
-
504
- ```
505
- struct TDAnalytics* ta = NULL;
506
- struct TDConsumer* consumer = NULL;
507
- /*
508
- * DebugConsumer: Data is reported one by one. When problems occur, users are notified via logs and exceptions. Not recommended for production environment.
509
- */
510
- TDConfig *config = td_init_config();
511
- // debug_mode, 0 means write to database, otherwise no write
512
- TD_ASSERT(TD_OK == td_add_int("debug_mode", 0, config));
513
- // TE backend test device ID: 123456789
514
- TD_ASSERT(TD_OK == td_add_string("device_id", "123456789", strlen("123456789"), config));
515
- // Configure appid and url
516
- char* appid = "APPID";
517
- char* serverURL = "SERVER_URL";
518
- TD_ASSERT(TD_OK == td_add_string("push_url", serverURL, strlen(serverURL), config));
519
- TD_ASSERT(TD_OK == td_add_string("appid", appid, strlen(appid), config));
520
-
521
- // Generate SDK instance
522
- if (TD_OK != td_init_consumer(&consumer, config)) {
523
- fprintf(stderr, "Failed to initialize the consumer.");
524
- return 1;
525
- }
526
- td_free_properties(config);
527
- if (TD_OK != td_init(consumer, &ta)) {
528
- fprintf(stderr, "Failed to initialize the SDK.");
529
- return 1;
530
- }
531
-
532
- // Generate custom properties
533
- TDProperties *properties = td_init_properties();
534
- // Add device ID property, device ID value is td_device_id
535
- TD_ASSERT(TD_OK == td_add_string("#device_id", "td_device_id", strlen("td_device_id"), properties));
536
- // Report event with custom properties, account_id and distinct_id must have at least one set
537
- TD_ASSERT(TD_OK == td_track("account_id", "distinct_id", "test", properties, ta));
538
- td_free_properties(properties);
539
- ```
540
-
541
- 2. Add Debug Device in TE Backend
542
- To prevent Debug mode from going live in production environment, only specified devices can enable Debug mode. Debug mode can only be enabled when Debug mode is turned on in the client and the device ID is configured in TE backend's "Tracking Management" page under "Debug Data" section.
543
-
544
- Debug mode may affect data collection quality and App stability. Only use for integration stage data verification, not for online environment.
545
-
546
- ---
547
-
548
- # Preset Properties
549
-
550
- The following preset properties are included in all events for C SDK.
551
-
552
- **Property Name** | **Chinese Name** | **Property Type** | **Description**
553
-
554
- #ip | IP Address | Text | User's IP address, needs to be set manually. TE will use this to obtain user's geographic location information.
555
-
556
- #country | Country | Text | User's country, generated based on IP address.
557
-
558
- #country_code | Country Code | Text | User's country code (ISO 3166-1 alpha-2, i.e., two uppercase English letters), generated based on IP address.
559
-
560
- #province | Province | Text | User's province, generated based on IP address.
561
-
562
- #city | City | Text | User's city, generated based on IP address.
563
-
564
- #lib | SDK Type | Text | Type of SDK you integrated, such as Java, etc.
565
-
566
- #lib_version | SDK Version | Text | Version of SDK you integrated.