@thinkingai/ae-cli 6.0.61 → 6.0.63

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 (184) hide show
  1. package/README.md +2 -0
  2. package/README.zh.md +2 -0
  3. package/dist/{ai-monitor-NUKSJPLE.js → ai-monitor-X5GL44JT.js} +5 -5
  4. package/dist/ai-monitor.js +7 -7
  5. package/dist/{auth-MVAEBGBP.js → auth-SPQ46XQ3.js} +3 -3
  6. package/dist/{automation-6L6IAYRK.js → automation-7XC3VBZI.js} +85 -9
  7. package/dist/{capability-74N7AN5X.js → capability-JZP4KXZC.js} +3 -3
  8. package/dist/{chunk-SVNED423.js → chunk-2VKMHNUU.js} +4 -4
  9. package/dist/{chunk-JZY6WWAP.js → chunk-6HOM2FOJ.js} +10 -1
  10. package/dist/{chunk-COOMXFUG.js → chunk-AAN6KBUK.js} +2 -2
  11. package/dist/{chunk-H35VDOAE.js → chunk-E457FREE.js} +2 -2
  12. package/dist/{chunk-VLOGOM7N.js → chunk-ETQXIZFP.js} +2 -1
  13. package/dist/{chunk-XZDKAR4N.js → chunk-F36ORPI6.js} +3 -28
  14. package/dist/{chunk-7WBCSJL6.js → chunk-F7TCQPQX.js} +1 -1
  15. package/dist/{chunk-HRFYYEXR.js → chunk-FGGEF7MI.js} +2 -2
  16. package/dist/chunk-N2MAYIRU.js +32 -0
  17. package/dist/{chunk-RB26WNLM.js → chunk-PRCHMOWT.js} +1 -1
  18. package/dist/{chunk-LPKIMGIU.js → chunk-RYY5NJK3.js} +2 -2
  19. package/dist/{chunk-OTZ4JQDU.js → chunk-VR2D54AA.js} +1 -1
  20. package/dist/{chunk-THTROEGD.js → chunk-YIG3L4RC.js} +1 -1
  21. package/dist/{chunk-XPARQSYS.js → chunk-YJYC5PLL.js} +2 -3
  22. package/dist/{chunk-HIMOBNEY.js → chunk-ZVUXAHEV.js} +1 -1
  23. package/dist/{compat-check-W4XC27RG.js → compat-check-JD5D77ET.js} +1 -1
  24. package/dist/{config-264GB6C7.js → config-IIMRATTP.js} +3 -3
  25. package/dist/{context-SOQDFZIB.js → context-BXHIPIIX.js} +1 -1
  26. package/dist/{data-integration-UNJ7EPW2.js → data-integration-VRJQ3HVK.js} +2 -1
  27. package/dist/index.js +33 -31
  28. package/dist/{memory-ZLTTULZK.js → memory-B44LY27L.js} +3 -3
  29. package/dist/{metadata-EN2IWCDI.js → metadata-ZVPG2MIA.js} +5 -5
  30. package/dist/{model-NAKQWK4W.js → model-ANZBYVST.js} +1 -1
  31. package/dist/{personal-semantic-preference-UGN67KTN.js → personal-semantic-preference-YNCV4QG3.js} +4 -4
  32. package/dist/{project-semantic-5OP3YPZD.js → project-semantic-E7ZAQL5S.js} +4 -4
  33. package/dist/{sync-LDJQZRQH.js → sync-Y4OZRQAY.js} +3 -3
  34. package/dist/{te-agent-WNNAD4AJ.js → te-agent-RKAUTYJZ.js} +4 -4
  35. package/dist/{te-analysis-KIMH6AGU.js → te-analysis-7N5VC4JB.js} +5 -5
  36. package/dist/{te-community-P7NNBVCS.js → te-community-SIA2UHTS.js} +4 -4
  37. package/dist/{te-dataops-ZRKSG4R7.js → te-dataops-5MJQCODU.js} +2 -2
  38. package/dist/{te-engage-PVBVNRSU.js → te-engage-ZTLOMKO3.js} +68 -16
  39. package/dist/{te-kb-W7PRC7QN.js → te-kb-LDL3MF2Y.js} +44 -13
  40. package/dist/{te-system-F4ZU2HRQ.js → te-system-473I5O53.js} +1 -1
  41. package/dist/{te-team-5ONMRGKF.js → te-team-JOWHCMZA.js} +87 -6
  42. package/dist/{things-PFENSIF4.js → things-DOQ2L3O2.js} +4 -4
  43. package/dist/{update-EUZ4GNND.js → update-KUS6TCPB.js} +2 -2
  44. package/dist/{workspace-Z7L33OBQ.js → workspace-MJFPIV7C.js} +3 -3
  45. package/package.json +3 -3
  46. package/skills/ae-automation/SKILL.md +6 -2
  47. package/skills/ae-automation/references/cli.md +9 -3
  48. package/skills/ae-engage/SKILL.md +6 -1
  49. package/skills/ae-engage/references/common-metric.md +47 -1
  50. package/skills/ae-engage/references/flow-metric-update.md +1 -1
  51. package/skills/ae-engage/references/task-metric-update.md +1 -1
  52. package/skills/ae-kb/SKILL.md +8 -6
  53. package/skills/ae-kb/references/query-workflow.md +5 -1
  54. package/skills/ae-team/SKILL.md +7 -3
  55. package/skills/ae-team/references/copy-to-personal.md +7 -0
  56. package/skills/ae-team/references/promote.md +7 -0
  57. package/skills/ae-team/references/update.md +3 -3
  58. package/skills/ae-tracking-matrix/SKILL.md +0 -170
  59. package/skills/ae-tracking-matrix/assets//345/237/213/347/202/271/346/250/241/347/211/210.xlsx +0 -0
  60. package/skills/ae-tracking-matrix/i18n.yaml +0 -12
  61. package/skills/ae-tracking-matrix/references/ae-capabilities.md +0 -93
  62. package/skills/ae-tracking-matrix/references/business-semantic-checks.md +0 -30
  63. package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +0 -256
  64. package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +0 -213
  65. package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +0 -407
  66. package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +0 -218
  67. package/skills/ae-tracking-matrix/references/categories/casual_music.md +0 -112
  68. package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +0 -301
  69. package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +0 -356
  70. package/skills/ae-tracking-matrix/references/categories/fishing.md +0 -775
  71. package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +0 -89
  72. package/skills/ae-tracking-matrix/references/categories/idle_card.md +0 -27
  73. package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +0 -415
  74. package/skills/ae-tracking-matrix/references/categories/interactive_video.md +0 -133
  75. package/skills/ae-tracking-matrix/references/categories/merge.md +0 -639
  76. package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +0 -406
  77. package/skills/ae-tracking-matrix/references/categories/mmo_web.md +0 -230
  78. package/skills/ae-tracking-matrix/references/categories/music.md +0 -137
  79. package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +0 -414
  80. package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +0 -199
  81. package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +0 -158
  82. package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +0 -546
  83. package/skills/ae-tracking-matrix/references/categories/rpg.md +0 -195
  84. package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +0 -115
  85. package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +0 -151
  86. package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +0 -260
  87. package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +0 -232
  88. package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +0 -359
  89. package/skills/ae-tracking-matrix/references/categories/tower_defense.md +0 -365
  90. package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +0 -211
  91. package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +0 -132
  92. package/skills/ae-tracking-matrix/references/category-registry.md +0 -77
  93. package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +0 -230
  94. package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +0 -406
  95. package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +0 -128
  96. package/skills/ae-tracking-matrix/references/eval-cases.md +0 -74
  97. package/skills/ae-tracking-matrix/references/naming-dict.md +0 -238
  98. package/skills/ae-tracking-matrix/references/optimization-checklist.md +0 -85
  99. package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +0 -142
  100. package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +0 -47
  101. package/skills/ae-tracking-matrix/references/plan-generation/reference.md +0 -794
  102. package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +0 -94
  103. package/skills/ae-tracking-matrix/references/scene-routing.md +0 -80
  104. package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +0 -3787
  105. package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +0 -827
  106. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +0 -655
  107. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +0 -953
  108. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +0 -1128
  109. package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +0 -714
  110. package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +0 -1268
  111. package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +0 -776
  112. package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +0 -182
  113. package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +0 -2755
  114. package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +0 -1182
  115. package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +0 -1300
  116. package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +0 -1369
  117. package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +0 -1692
  118. package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +0 -902
  119. package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +0 -763
  120. package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +0 -1107
  121. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +0 -1532
  122. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +0 -845
  123. package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +0 -228
  124. package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +0 -149
  125. package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +0 -407
  126. package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +0 -163
  127. package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +0 -149
  128. package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +0 -153
  129. package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +0 -232
  130. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +0 -314
  131. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +0 -117
  132. package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +0 -148
  133. package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +0 -645
  134. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +0 -307
  135. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +0 -347
  136. package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +0 -72
  137. package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +0 -264
  138. package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +0 -566
  139. package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +0 -409
  140. package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +0 -446
  141. package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +0 -557
  142. package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +0 -457
  143. package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +0 -490
  144. package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +0 -523
  145. package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +0 -484
  146. package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +0 -442
  147. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +0 -391
  148. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +0 -91
  149. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +0 -635
  150. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +0 -113
  151. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +0 -466
  152. package/skills/ae-tracking-matrix/references/standard-base/README.md +0 -22
  153. package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +0 -174
  154. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +0 -20
  155. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +0 -7
  156. package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +0 -14
  157. package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +0 -370
  158. package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +0 -47
  159. package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +0 -37
  160. package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +0 -27
  161. package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +0 -23
  162. package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +0 -14
  163. package/skills/ae-tracking-matrix/references/standard-base/user_data.md +0 -46
  164. package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +0 -13
  165. package/skills/ae-tracking-matrix/references/system-fields.md +0 -297
  166. package/skills/ae-tracking-matrix/references/te-field-translations.md +0 -1791
  167. package/skills/ae-tracking-matrix/references/workflows/data-verification.md +0 -232
  168. package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +0 -829
  169. package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +0 -355
  170. package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +0 -283
  171. package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +0 -168
  172. package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +0 -205
  173. package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +0 -75
  174. package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +0 -36
  175. package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +0 -107
  176. package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +0 -114
  177. package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +0 -53
  178. package/skills/ae-tracking-matrix/scripts/finalize_plan.py +0 -166
  179. package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +0 -674
  180. package/skills/ae-tracking-matrix/scripts/plan_contract.py +0 -200
  181. package/skills/ae-tracking-matrix/scripts/plan_types.py +0 -60
  182. package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +0 -169
  183. package/skills/ae-tracking-matrix/scripts/sync_plan.py +0 -296
  184. package/skills/ae-tracking-matrix/scripts/upload_plan.py +0 -340
@@ -1,1128 +0,0 @@
1
- ---
2
- code: cocoscreator_sdk_installation
3
- name: "CocosCreator"
4
- wikiToken: MLL7wtab3ivQNYk3TDJcbjJRnRd
5
- parentWikiToken: BAU2w0eipiqGnckeUsIc0mYQnZc
6
- updateTime: 1773027497000
7
- sourceUrl: https://docs-v2.thinkingdata.cn/?version=6.0&lan=zh-CN&code=cocoscreator_sdk_installation
8
- ---
9
-
10
- # CocosCreator
11
-
12
- ::: tip Tip
13
-
14
- Before integration, please read the Pre-Integration Guide first.
15
-
16
- CocosCreator SDK supports platforms: Android, iOS, OpenHarmony, Web, WeChat Mini Game, Alipay Mini Game, Taobao Mini Game, ByteDance Mini Game, OPPO Mini Game, Huawei Quick Game, vivo Mini Game, Xiaomi Quick Game, Baidu Mini Game, Qutoutiao Mini Game, Facebook Mini Game, Google Play Mini Game.
17
-
18
- :::
19
-
20
- **Latest Version:** v3.5.0
21
-
22
- **Update Time:** 2026-03-09
23
-
24
- **Resource Download**: Source code, SDK download
25
-
26
- ::: warning Note
27
-
28
- This document applies to v3.0.0 and later versions. For historical versions, please refer to CocosCreator Integration Guide (V2), SDK Download (v2.2.4)
29
-
30
- :::
31
-
32
- ### 1. SDK Integration
33
-
34
- Download and unzip CocosCreator SDK
35
-
36
- :::: el-tabs
37
-
38
- ::: el-tab-pane label=TypeScript Integration
39
-
40
- If your project is a TypeScript project, integration steps are as follows:
41
-
42
- 1. Put the declaration file tdanalytics.cc.d.ts in the libs directory under assets in the project root directory, if libs does not exist, create libs directory
43
- 1. Put the SDK file (tdanalytics.mg.cocoscreator.min.js) in assets/Script directory
44
-
45
- :::
46
-
47
- ::: el-tab-pane label=JavaScript Integration
48
-
49
- If your project is a JavaScript project, you can directly put the SDK file (tdanalytics.mg.cocoscreator.min.js) in assets/Script directory
50
-
51
- :::
52
-
53
- ::::
54
-
55
- ### 2. Initialization
56
-
57
- After importing TE SDK, you can use TDAnalytics in code:
58
-
59
- Note: For Taobao mini game platform, TDAnalytics is mounted on window object, you need to use var TDAnalytics = window['TDAnalytics']
60
-
61
- ```
62
- // TE SDK configuration object
63
- var config = {
64
- appId: "YOUR_APPID", // Project APP ID
65
- serverUrl: "YOUR_SERVER_URL", // Reporting URL
66
- autoTrack: {
67
- appLaunch: true, // Auto-track ta_mg_launch
68
- appShow: true, // Auto-track ta_mg_show
69
- appHide: true // Auto-track ta_mg_hide
70
- }
71
- };
72
- // Initialize
73
- TDAnalytics.init(config);
74
- ```
75
-
76
- TE configuration object parameter description:
77
-
78
- - `appId`: Your project's APP ID, required, can be viewed in TE backend project management page
79
- - `serverUrl`: Data reporting URL, required
80
- - If you use cloud service, enter: https://global-receiver-ta.thinkingdata.cn
81
- - If you use privately deployed version, please confirm reporting address with operations team
82
- - `autoTrack`: Optional, indicates whether to enable auto-tracking feature, each element represents the following auto-tracking events, default all disabled:
83
- - `appLaunch`: Auto-track mini game initialization
84
- - `appShow`: Auto-track mini game start, or from background to foreground
85
- - `appHide`: Auto-track mini game from foreground to background, and record the duration of this visit (from start to entering background)
86
-
87
- ::: warning Note
88
-
89
- Before reporting data, please add data transmission URL to server domain's request list in WeChat public platform or other platform's development settings.
90
-
91
- :::
92
-
93
- ### 3. Common Features
94
-
95
- Before using common features, we recommend you understand user identification rules first. SDK will generate a random number as visitor ID by default, and persist visitor ID locally, before user logs in, visitor ID will be used as identity identification ID. Note: Visitor ID will change when user clears cache or changes device.
96
-
97
- #### 3.1 Set Account ID
98
-
99
- When user logs in, you can call `login` to set user's account ID, TE platform will use account ID as identity identification ID, and the set account ID will be retained until `logout` is called. Calling `login` multiple times will overwrite the previous account ID.
100
-
101
- ```
102
- // User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
103
- TDAnalytics.login("TA");
104
- ```
105
-
106
- **This method will not upload login event**
107
-
108
- #### 3.2 Set Public Event Properties
109
-
110
- Public event properties are properties that every event will have, you can call `setSuperProperties` to set public event properties, we recommend you set public event properties before sending events. For some important properties, such as user's membership level, source channel, etc., these properties need to be set in every event, you can set these properties as public event properties.
111
-
112
- ```
113
- var superProperties = {
114
- channel : "ta", //String
115
- age : 1,//Number
116
- isSuccess : true,//Boolean
117
- birthday : new Date(),//Object
118
- object : { key : "value" },//Object
119
- object_arr : [ { key : "value" } ],//Object array
120
- arr : [ "value" ]//Array
121
- };
122
- //Set public event properties
123
- TDAnalytics.setSuperProperties(superProperties);
124
- ```
125
-
126
- Public event properties will be saved to cache, no need to call every time when starting. If `setSuperProperties` is called to upload previously set public event properties, it will overwrite previous properties.
127
-
128
- - Key is the property name, string type, must start with letter, contain numbers, letters and underscore "\_", maximum length 50 characters, case insensitive, TE will convert to lowercase uniformly
129
- - Value is the property value, supports string, number, boolean, time, object, object array, array
130
-
131
- **Event properties and user property requirements are consistent with public event properties**
132
-
133
- #### 3.3 Send Event
134
-
135
- You can call `track` to upload events, we recommend you set event properties and conditions for sending information according to the previously prepared tracking document, here we use user purchasing a product as an example:
136
-
137
- ```
138
- TDAnalytics.track({
139
- eventName: "product_buy", // Event name
140
- properties: {
141
- product_name: "Product Name"
142
- } //Event properties
143
- });
144
- ```
145
-
146
- Event name is string type, must start with letter, can contain numbers, letters and underscore "\_", maximum length 50 characters.
147
-
148
- #### 3.4 Set User Properties
149
-
150
- For general user properties, you can call `userSet` to set them, properties uploaded using this interface will overwrite existing property values, if the user property did not exist before, it will create a new user property with the same type as the passed property type, here we use setting username as an example:
151
-
152
- ```
153
- //At this time username is TA
154
- TDAnalytics.userSet({
155
- properties: { username: "TA" }
156
- });
157
- //At this time userName is TE
158
- TDAnalytics.userSet({
159
- properties: { username: "TE" }
160
- });
161
- ```
162
-
163
- ### 4. Best Practices
164
-
165
- The following example code includes all the above operations, we recommend using the following steps:
166
-
167
- ```
168
- var config = {
169
- appId: "YOUR_APPID", // Project APP ID
170
- serverUrl: "YOUR_SERVER_URL", // Reporting URL
171
- autoTrack: {
172
- appLaunch: true, // Auto-track ta_mp_launch
173
- appShow: true, // Auto-track ta_mg_show
174
- appHide: true // Auto-track ta_mg_hide
175
- }
176
- };
177
- //Initialize
178
- TDAnalytics.init(config);
179
- // User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
180
- TDAnalytics.login("TA");
181
- //Set public event properties
182
- var superProperties = {
183
- channel : "ta", //String
184
- age : 1,//Number
185
- isSuccess : true,//Boolean
186
- birthday : new Date(),//Object
187
- object : { key : "value" },//Object
188
- object_arr : [ { key : "value" } ],//Object array
189
- arr : [ "value" ]//Array
190
- };
191
- TDAnalytics.setSuperProperties(superProperties);
192
- //Send event
193
- TDAnalytics.track({
194
- eventName: "product_buy", // Event name
195
- properties: {
196
- product_name: "Product Name"
197
- } //Event properties
198
- });
199
- //Set user properties
200
- TDAnalytics.userSet({
201
- properties: {
202
- username: "TE"
203
- }
204
- });
205
- ```
206
-
207
- ---
208
-
209
- # Advanced Guide
210
-
211
- ### 1. Set User ID
212
-
213
- SDK instance will use random number as default visitor ID for each user by default, this ID will be used as identity identification ID for user in unlogged state. Note that visitor ID will change when user clears cache or changes device.
214
-
215
- #### 1.1 Set Visitor ID
216
-
217
- ::: tip Tip
218
-
219
- Generally, you don't need to customize visitor ID. Please make sure you understand user identification rules before setting visitor ID.
220
-
221
- :::
222
-
223
- If your App has its own visitor ID management system for each user, you can call `setDistinctId` to set visitor ID:
224
-
225
- ```
226
- // Set visitor ID to Thinker
227
- TDAnalytics.setDistinctId("Thinker");
228
- ```
229
-
230
- If you need to get current visitor ID, you can call `getDistinctId` to get:
231
-
232
- ```
233
- //Return visitor ID
234
- let distinctId = TDAnalytics.getDistinctId();
235
- ```
236
-
237
- If you need to set it, must call this interface before initialization.
238
-
239
- #### 1.2 Set Account ID
240
-
241
- When user logs in, you can call `login` to set user's account ID, TE platform will use account ID as identity identification ID, and the set account ID will be retained until `logout` is called. Calling `login` multiple times will overwrite the previous account ID.
242
-
243
- ```
244
- //User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
245
- TDAnalytics.login("TA");
246
- ```
247
-
248
- **This method will not upload login event**
249
-
250
- #### 1.3 Clear Account ID
251
-
252
- After user logs out, you can call `logout` to clear account ID, before calling `login` next time, visitor ID will be used as identity identification ID.
253
-
254
- ```
255
- // Remove #account_id from reported data, subsequent data will not have #account_id
256
- TDAnalytics.logout();
257
- ```
258
-
259
- We recommend you call `logout` when there is an explicit logout event, such as when user performs account cancellation action, rather than calling it when closing App.
260
-
261
- **This method will not upload logout event**
262
-
263
- ### 2. Send Event
264
-
265
- After SDK initialization is complete, you can perform data tracking and collect user behavior information. Generally, normal events can meet business scenario requirements, you can also use first, updatable and other events according to your actual business scenarios.
266
-
267
- #### 2.1 Normal Event
268
-
269
- You can call `track` to upload events, we recommend you set event properties and conditions for sending events according to the previously prepared document, here we use user purchasing a product as an example
270
-
271
- ```
272
- TDAnalytics.track({
273
- eventName: "product_buy", // Tracking event name
274
- properties: { product_name: "Product Name" } // Event properties to upload
275
- });
276
- ```
277
-
278
- #### 2.2 First Event
279
-
280
- First event refers to events that will only be recorded once for a certain device or other dimension ID. For example, in some scenarios, you may want to record the activation event on a certain device, then you can use first event to report data.
281
-
282
- ```
283
- TDAnalytics.trackFirst({
284
- eventName: "device_activation",
285
- properties: { key: "value" }
286
- });
287
- ```
288
-
289
- If you want to determine whether it's the first time based on dimensions other than device, you can customize first_check_id for first event:
290
-
291
- ```
292
- // Set user ID as first_check_id for first event, to collect user's first activation event
293
- TDAnalytics.trackFirst({
294
- eventName: "account_activation",
295
- firstCheckId: "TA",
296
- properties: { key: "value" }
297
- });
298
- ```
299
-
300
- Note: Since the verification of whether it's the first time is completed on the server side, first event will be delayed by 1 hour before entering the database by default.
301
-
302
- #### 2.3 Updatable Event
303
-
304
- You can use updatable event to achieve the requirement of modifying event data in specific scenarios. Updatable event needs to specify the ID that identifies the event and pass it when creating the updatable event object. TE backend will determine the data that needs to be updated based on event name and event ID.
305
-
306
- ```
307
- // Example: Report an updatable event, assume event name is UPDATABLE_EVENT
308
- // After reporting, event property status is 3, price is 100
309
- TDAnalytics.trackUpdate({
310
- eventName: "UPDATABLE_EVENT",
311
- properties: { status: 3, price: 100 },
312
- eventId: "test_event_id"
313
- });
314
-
315
- // After reporting, event property status is updated to 5, price unchanged
316
- TDAnalytics.trackUpdate({
317
- eventName: "UPDATABLE_EVENT",
318
- properties: { status: 5 },
319
- eventId: "test_event_id"
320
- });
321
- ```
322
-
323
- #### 2.4 Overwritable Event
324
-
325
- Overwritable event is similar to updatable event, the difference is that overwritable event will completely overwrite historical data with the latest data, from the effect it's equivalent to deleting the previous data and storing the latest data in the database. TE backend will determine the data that needs to be updated based on event name and event ID.
326
-
327
- ```
328
- // Example: Report an overwritable event, assume event name is OVERWRITE_EVENT
329
- // After reporting, event property status is 3, price is 100
330
- TDAnalytics.trackOverwrite({
331
- eventName: "OVERWRITE_EVENT",
332
- properties: { status: 3, price: 100 },
333
- eventId: "test_event_id"
334
- });
335
-
336
- // After reporting, event property status is updated to 5, price property is deleted
337
- TDAnalytics.trackOverwrite({
338
- eventName: "OVERWRITE_EVENT",
339
- properties: { status: 5 },
340
- eventId: "test_event_id"
341
- });
342
- ```
343
-
344
- #### 2.5 Public Event Properties
345
-
346
- For some important properties, such as user's device ID, source channel, user status, etc., these properties need to be set in every event, you can set these properties as public properties, i.e. properties that every event will have. We recommend you set public properties before sending events.
347
-
348
- Public properties include two types, event public properties and dynamic public properties. When reporting events, public properties will be inserted into data's properties. If public property and custom property set in event have the same key value, the property value will be determined according to the following priority: `Custom Property > Dynamic Public Event Property > Static Public Event Property > Preset Property`
349
-
350
- ##### 2.5.1 Static Public Event Properties
351
-
352
- For some important properties, such as user's channel, nickname, ID, etc., these properties need to be set in every event, you can call `setSuperProperties` to set static public event properties, static public event properties will be globally effective. When caching is enabled (default on), static public properties will be cached in `localStorage` or `cookie`.
353
-
354
- Static public property parameter is a JSON object, its format requirements are consistent with event properties.
355
-
356
- ```
357
- // Set public event properties, all data events will have these properties
358
- TDAnalytics.setSuperProperties({ channel: "Channel Name", user_name: "Username" });
359
- ```
360
-
361
- Besides property setting, we also provide other APIs to operate static public event properties to meet daily business needs.
362
-
363
- ```
364
- // Get static public event properties
365
- var superProperties = TDAnalytics.getSuperProperties();
366
- // Clear a static public event property, for example clear previously set 'channel' property, subsequent data will not have this property
367
- TDAnalytics.unsetSuperProperty("channel");
368
- // Clear all static public event properties
369
- TDAnalytics.clearSuperProperties();
370
- ```
371
-
372
- ##### 2.5.2 Dynamic Public Event Properties
373
-
374
- Set dynamic public property callback function through `setDynamicSuperProperties`, SDK will trigger callback function when reporting events and add the returned JSON object to event properties. `setDynamicSuperProperties` parameter is a function, the function needs to return a JSON object.
375
-
376
- ```
377
- // Set dynamic public properties, trigger callback function when reporting events and add returned JSON object to event properties
378
- TDAnalytics.setDynamicSuperProperties(function() {
379
- var d = new Date();
380
- d.setHours(10);
381
- return { date: d };
382
- });
383
- ```
384
-
385
- #### 2.6 Record Event Duration
386
-
387
- If you need to record the duration of an event, you can call `timeEvent` to start timing. Configure the event name you want to time, when you upload that event, it will automatically add `#duration` property in your event properties to represent the recorded duration, unit is seconds. Note that the same event name can only have one timing task.
388
-
389
- ```
390
- //The following example completes the statistics of user's stay duration on a product page
391
- TDAnalytics.timeEvent({
392
- eventName: "stay_shop"
393
- });
394
- /**do something
395
- .......
396
- **/
397
- //User leaves product page, timing ends, "stay_shop" event will have #duration property representing event duration
398
- TDAnalytics.track({
399
- eventName: "stay_shop",
400
- properties: {
401
- product_name: "Product Name"
402
- }
403
- });
404
- ```
405
-
406
- ### 3. User Properties
407
-
408
- TE platform supported user property setting APIs are: `userSet`, `userSetOnce`, `userAdd`, `userUnset`, `userDelete`, `userAppend`, `userUniqAppend`.
409
-
410
- #### 3.1 userSet
411
-
412
- For general user properties, you can call `userSet` to set them. Properties uploaded using this interface will overwrite existing property values, if the user property did not exist before, it will create a new user property with the same type as the passed property type, here we use setting username as an example:
413
-
414
- ```
415
- // username is TA
416
- TDAnalytics.userSet({
417
- properties: {
418
- username: "TA"
419
- }
420
- });
421
- //username is TE
422
- TDAnalytics.userSet({
423
- properties: {
424
- username: "TE"
425
- }
426
- });
427
- ```
428
-
429
- #### 3.2 userSetOnce
430
-
431
- If the user property you want to upload only needs to be set once, you can call `userSetOnce` to set it, when the property already has a value before, this message will be ignored, here we use setting first payment time as an example:
432
-
433
- ```
434
- //first_payment_time is 2018-01-01 01:23:45.678
435
- TDAnalytics.userSetOnce({
436
- properties: {
437
- first_payment_time: "2018-01-01 01:23:45.678"
438
- }
439
- });
440
- //first_payment_time is still 2018-01-01 01:23:45.678
441
- TDAnalytics.userSetOnce({
442
- properties: {
443
- first_payment_time: "2018-12-31 01:23:45.678"
444
- }
445
- });
446
- ```
447
-
448
- #### 3.3 userAdd
449
-
450
- When you want to upload numeric properties, you can call `userAdd` to accumulate the property, if the property hasn't been set yet, it will assign 0 before calculation. If negative value is passed, it's equivalent to subtraction operation.
451
-
452
- ```
453
- //At this time total_revenue is 30
454
- TDAnalytics.userAdd({
455
- properties: {
456
- total_revenue: 30
457
- }
458
- });
459
- //At this time total_revenue is 678
460
- TDAnalytics.userAdd({
461
- properties: {
462
- total_revenue: 648
463
- }
464
- });
465
- ```
466
-
467
- #### 3.4 userUnset
468
-
469
- When you want to clear user's user property value, you can call `userUnset` to clear the specified property, if the property has not been created in the cluster yet, `userUnset` will **not** create the property
470
-
471
- ```
472
- // Clear user property value with property name userPropertykey, i.e. set to NULL
473
- TDAnalytics.userUnset({
474
- property: "userPropertykey"
475
- });
476
- ```
477
-
478
- #### 3.5 userDelete
479
-
480
- If you want to delete a user, you can call `userDelete` to delete this user, you will no longer be able to query this user's user properties, but the events generated by this user can still be queried.
481
-
482
- ```
483
- TDAnalytics.userDelete();
484
- ```
485
-
486
- #### 3.6 userAppend
487
-
488
- You can call `userAppend` to append elements to array type user data.
489
-
490
- ```
491
- TDAnalytics.userAppend({
492
- properties: {
493
- user_list: ["apple", "ball"]
494
- }
495
- });
496
- ```
497
-
498
- #### 3.7 userUniqAppend
499
-
500
- You can call `userUniqAppend` to append unique elements to Array (List) type user data. Calling `userUniqAppend` interface will deduplicate the appended user properties, `userAppend` interface does not deduplicate, user properties can have duplicates.
501
-
502
- ```
503
- //At this time user_list property value is ["apple", "ball"]
504
- TDAnalytics.userAppend({
505
- properties: {
506
- user_list: ["apple", "ball"]
507
- }
508
- });
509
- //At this time user_list property value is ["apple", "apple", "ball", "cube"]
510
- TDAnalytics.userAppend({
511
- properties: {
512
- user_list: ["apple", "cube"]
513
- }
514
- });
515
- //At this time user_list property value is ["apple", "ball", "cube"]
516
- TDAnalytics.userUniqAppend({
517
- properties: {
518
- user_list: ["apple", "cube"]
519
- }
520
- });
521
- ```
522
-
523
- ### 4. Encryption Feature
524
-
525
- From v2.1.0, SDK supports encryption feature, client supports AES + RSA to encrypt data, then server decrypts the data, encryption/decryption capability needs client and server to cooperate, please consult customer success personnel for details.
526
-
527
- Set `enableEncrypt` property to true, and set default version number and public key.
528
-
529
- ```
530
- var config = {
531
- appId: "YOUR_APP_ID", // Project APP ID
532
- serverUrl: "YOUR_SERVER_URL", // Reporting URL
533
- enableEncrypt: true, // Enable data transmission encryption
534
- secretKey: {
535
- publicKey:'YOUR_PUBLIC_KEY', // Encryption public key
536
- version:0 // Key version number
537
- }
538
- };
539
- // Initialize
540
- TDAnalytics.init(config);
541
- ```
542
-
543
- ### 5. Other Features
544
-
545
- #### 5.1 Get Device ID
546
-
547
- You can call `getDeviceId()` to get device ID.
548
-
549
- ```
550
- var deviceId = TDAnalytics.getDeviceId();
551
- ```
552
-
553
- **Device ID will be saved in cache, if user clears cache, device ID will be reset.**
554
-
555
- #### 5.2 onComplete Callback Function
556
-
557
- For `track`, `userSet`, `userSetOnce`, `userAdd`, `userDelete` and other interfaces, onComplete callback can be passed. You can directly pass onComplete after original parameter list, or use parameter object way. If using parameter object, the parameter object must include onComplete, otherwise parameter error will occur. Using upload event as example:
558
-
559
- ```
560
- TDAnalytics.track({
561
- eventName: "test", // Required
562
- properties: { testkey: 123 }, // Optional
563
- time: new Date(),
564
- onComplete: res => {
565
- console.log(res);
566
- }
567
- });
568
- ```
569
-
570
- onComplete parameter res is object type, has two properties code and msg.
571
-
572
- res.code is int type, defined as:
573
-
574
- - 0: Success
575
- - -1: Data format incorrect
576
- - -2: APP ID invalid
577
- - -3: Network or server exception
578
-
579
- Debug mode definition:
580
-
581
- - 0: Success
582
- - -1: Parameter or permission validation issue
583
- - 1: Indicates field basic error, will give detailed error field and reason
584
- - 2: Indicates whole record error
585
- - -3: Network or server exception
586
-
587
- res.msg is textual description of res.code.
588
-
589
- #### 5.3 Set Event Cache Reporting
590
-
591
- From v2.2.0, you can configure to enable event cache reporting during initialization.
592
-
593
- ```
594
- // TE SDK configuration object
595
- var config = {
596
- appId: "YOU-APP-ID", // Project APP ID
597
- serverUrl: "https://youserverurl.com", // Data reporting URL
598
- enableBatch: true, // Whether to enable event cache batch reporting, true=enable, false=disable
599
- batchConfig: {
600
- size: 5, // Event cache reporting count
601
- interval: 5000 // Event cache reporting interval (milliseconds)
602
- }
603
- };
604
- // Initialize
605
- TDAnalytics.init(config);
606
- ```
607
-
608
- #### 5.4 Calibrate Time
609
-
610
- - SDK will use local time as event occurrence time by default, if user manually modifies device time it will affect your business analysis, you can ensure the accuracy of event occurrence time through time calibration operation. Currently only supports Android, iOS, OpenHarmony platforms.
611
-
612
- ```
613
- // 1585633785954 is current unix timestamp, unit is milliseconds, corresponding to Beijing time 2020-03-31 13:49:45
614
- TDAnalytics.calibrateTime(1585633785954);
615
- ```
616
-
617
- - You can also set automatic time calibration, after that SDK will try to get current time from config interface and calibrate SDK time. If correct return result is not obtained, subsequent data will be reported using local time.
618
-
619
- ```
620
-
621
- var config = {
622
- appId: "YOUR_APPID",
623
- serverUrl: "YOUR_SERVER_URL",
624
- enableAutoCalibrated:true
625
- };
626
- TDAnalytics.init(config);
627
- ```
628
-
629
- #### 5.5 Set Default Timezone
630
-
631
- By default, SDK (>=3.5.0) will use local time as event occurrence time. You can also set default timezone interface to specify timezone, so all events will align event time according to your set timezone. Currently does not support OpenHarmony platform temporarily.
632
-
633
- ```
634
- var config = {
635
- appId: "YOUR_APPID",
636
- serverUrl: "YOUR_SERVER_URL",
637
- zoneOffset:9
638
- };
639
- TDAnalytics.init(config);
640
- ```
641
-
642
- Aligning event time with specified timezone will lose device local timezone information. If you need to preserve device local timezone information, currently you need to add related properties to events yourself.
643
-
644
- ### 6. Channel SDK Compatibility
645
-
646
- #### 6.1 Tencent Ads
647
-
648
- ##### 6.1.1 Solution Introduction
649
-
650
- After integrating TDAnalytics SDK, you don't need to additionally integrate Tencent Ads SDK. Once you complete TDAnalytics initialization method, the system will automatically trigger Tencent Ads SDK initialization. When you report key events like registration, payment, etc., the system will automatically report these event information to Tencent Ads according to your configuration.
651
-
652
- ##### 6.1.2 Integration Process
653
-
654
- 1. Download Tencent Ads SDK, currently using version 1.5.4, other versions can also be used.
655
- Put dn-sdk-minigame.cjs.js file in the same directory as TDAnalytics SDK.
656
-
657
- 1. Initialize
658
- Note: TDAnalytics SDK version needs >= 3.0.4
659
-
660
- ```
661
- TDAnalytics.init({
662
- appId: 'AppId',
663
- serverUrl: 'ServerUrl',
664
- tgaInitParams: {
665
- user_action_set_id: 100001,// Data source ID, number, required
666
- secret_key: '5e853xxxxxxd57a690xxxxxxxxxx',// Encryption key, required
667
- appid: 'wx123xyz123xyz123x',//WeChat mini game APPID, starts with wx, required
668
- },
669
- reportingToTencentSdk: 2,//1 Only report to Tencent 2 Report to both Tencent and TA 3 Only report to TA
670
- debugMode: 'debug'// If debug mode, will print Tencent Ads SDK local debug log
671
- })
672
- ```
673
-
674
- 1. Set User ID
675
-
676
- - setOpenId
677
- openid is generally obtained asynchronously by calling backend interface (get openid method), please call _ sdk.setOpenId() _ method to set after getting openid. Only one of openid and unionid can be set, prioritize setting openid.
678
-
679
- ```
680
- wx.request({
681
- url: 'Backend get openid and determine if registered user interface url',
682
- success: function(res){
683
- if(res.openid){
684
- // Set openid, must set openid before reporting registration behavior. setOpenId is synchronous method, can immediately report registration behavior after setting.
685
- TDAnalytics.login(res.openid);
686
-
687
- //Report registration behavior, backend interface determines if registered user
688
- if(res.isRegisterUser){
689
- TDAnalytics.track({
690
- eventName: "REGISTER"
691
- });
692
- }
693
- }
694
- }
695
- });
696
- ```
697
-
698
- - setUnionId
699
- unionid is generally obtained asynchronously by calling backend interface (get unionid method), please call _ sdk.setUnionId() _ method to set after getting unionid. Use this method to set unionid only when openid is not available.
700
-
701
- ```
702
- wx.request({
703
- url: 'Backend get openid and determine if registered user interface url',
704
- success: function(res){
705
- if(res.unionid){
706
- // Set unionid, please prioritize openid, only set unionid when openid is not available or backend uniformly uses unionid.
707
- TDAnalytics.setDistinctId(res.unionid);
708
-
709
- //Report registration behavior, backend interface determines if registered user
710
- if(res.isRegisterUser){
711
- TDAnalytics.track({
712
- eventName: "REGISTER"
713
- });
714
- }
715
- }
716
- }
717
- });
718
- ```
719
-
720
- 1. Report Behavior
721
-
722
- ```
723
- TDAnalytics.track({
724
- eventName: "product_buy", // Event name
725
- properties: {
726
- product_name: "Product Name"
727
- } //Event properties
728
- });
729
- ```
730
-
731
- If it's the following specific events, need to report specified event name
732
-
733
- Event | Event Name | Event Properties (need to include key)
734
- Mini Game Startup | START_APP | None
735
- Payment | PURCHASE | { value: 600 }
736
- Registration | REGISTER | None
737
- Silent Wake-up | RE_ACTIVE | { backFlowDay: 30 }
738
- Add Mini Game to Wishlist | ADD_TO_WISHLIST | { type: 'default' }
739
- Share Mini Game | SHARE | { target: 'APP_MESSAGE' }
740
- Create Character | CREATE_ROL | { name: 'SuperMan' }
741
- Complete Tutorial | TUTORIAL_FINISH | None
742
- Game Level Up | UPDATE_LEVEL | { level: 2, power: 85 }
743
- View Mall Page | VIEW_CONTENT | { item: 'Mall' }
744
- View Game Activity | VIEW_CONTENT | { item: 'Activity' }
745
-
746
- For example, report game level up event
747
-
748
- ```
749
- TDAnalytics.track({
750
- eventName: "UPDATE_LEVEL",
751
- properties: {
752
- level: 2,
753
- power: 85,
754
- }
755
- });
756
- ```
757
-
758
- ---
759
-
760
- # Native Support
761
-
762
- ### 1. iOS Native Support
763
-
764
- First iOS project build will generate project code in `./build/ios/` and `./native/engine/ios/` two directories, then start configuring iOS project.
765
-
766
- #### **1.1 Manual Configuration**
767
-
768
- - Add iOS project dependency files
769
- - `CocosCreatorProxyApi.h`
770
- - `CocosCreatorProxyApi.mm`
771
- - `ThinkingSDK.framework`
772
- - `ThinkingDataCore.framework`
773
- - Build Phases settings
774
- - Add `ThinkingSDK.framework` in `Link Binary With Libraries`
775
- - Build Settings settings
776
- - Add `ThinkingSDK.framework` reference path in Framework Search Paths, such as `"$(SRCROOT)/../Classes"`
777
- - Add `-ObjC` in `Other Linker Flags`
778
-
779
- #### **1.2 CMakeList Configuration**
780
-
781
- ::: tip Tip:
782
-
783
- `CMakeList` file path is `./native/engine/ios/CMakeLists.txt`;
784
-
785
- CMakeList file will be generated after first iOS project build, configuration will take effect when building again after configuration;
786
-
787
- Need to copy iOS resource files to corresponding folder first, such as `./native/engine/common/Classes/ThinkingAnalytics/ios/`, fill corresponding path when configuring CMakeList.
788
-
789
- :::
790
-
791
- - Add iOS project dependency files
792
-
793
- ```
794
- # Find this line of code
795
- set(PROJ_COMMON_SOURCES
796
- ${CMAKE_CURRENT_LIST_DIR}/../common/Classes/Game.h
797
- ${CMAKE_CURRENT_LIST_DIR}/../common/Classes/Game.cpp
798
- # Add the following code
799
- ${CMAKE_CURRENT_LIST_DIR}/../common/Classes/ThinkingAnalytics/ios/CocosCreatorProxyApi.h
800
- ${CMAKE_CURRENT_LIST_DIR}/../common/Classes/ThinkingAnalytics/ios/CocosCreatorProxyApi.mm
801
- ${CMAKE_CURRENT_LIST_DIR}/../common/Classes/ThinkingAnalytics/ios/ThinkingSDK.framework
802
- ${CMAKE_CURRENT_LIST_DIR}/../common/Classes/ThinkingAnalytics/ios/ThinkingDataCore.framework
803
- )
804
- ```
805
-
806
- - Build Phases settings
807
-
808
- ```
809
- # Find this line of code
810
- target_link_libraries(${LIB_NAME} cocos2d)
811
- # Add the following code
812
- target_link_libraries(${LIB_NAME} ${CMAKE_CURRENT_LIST_DIR}/../common/Classes/ThinkingAnalytics/ios/ThinkingSDK.framework)
813
- target_link_libraries(${LIB_NAME} ${CMAKE_CURRENT_LIST_DIR}/../common/Classes/ThinkingAnalytics/ios/ThinkingDataCore.framework)
814
- ```
815
-
816
- - Build Settings settings
817
-
818
- ```
819
- # Find this line of code
820
- set(PRODUCT_NAME ${APP_NAME})
821
- # Add the following code
822
- set(CMAKE_EXE_LINKER_FLAGS -ObjC)
823
- ```
824
-
825
- ::: warning Note
826
-
827
- Cocos Creator v2.x editor does not support `CMake` configuration method temporarily, need to configure manually.
828
-
829
- :::
830
-
831
- ### 2. Android Native Support
832
-
833
- Build Android project, configure Android project.
834
-
835
- - In Android display mode app project, add dependency file `CocosCreatorProxyApi.java` to `com.cocos.game`, as shown below
836
- - In project's app folder proguard-rules.pro file, add obfuscation
837
-
838
- ```
839
- -keep public class com.cocos.game.CocosCreatorProxyApi {*;}
840
- ```
841
-
842
- - Create libs directory in project's app folder, copy `TDAnalytics.aar`, `TDCore.aar` to it
843
- - Add dependency in `Module`'s `build.gradle` file
844
-
845
- ```
846
- dependencies {
847
- ...
848
- implementation fileTree(dir: 'libs', include: ['*.aar'])
849
- }
850
- ```
851
-
852
- ### 3. OpenHarmony Native Support
853
-
854
- First build OpenHarmony project
855
-
856
- - Put TDAnalytics.har and CocosCreatorProxyApi.ts in the following directory
857
- - Import SDK in oh-packages.json5 file
858
-
859
- ```
860
- "@thinkingdata/analytics": "file:./libs/TDAnalytics.har"
861
- ```
862
-
863
- - Import bridge file in build-profile.json5
864
-
865
- ```
866
- arkOptions: {
867
- runtimeOnly: {
868
- sources: [
869
- './src/main/ets/CocosCreatorProxyApi.ts',
870
- ],
871
- },
872
- }
873
- ```
874
-
875
- - Import context
876
- Currently CocosCreator's first version supporting OpenHarmony, interaction is in work thread, temporarily no official API to get context, will wait for official update later, currently can add manually
877
-
878
- The above operation is to pass context to work thread, then need to use it when SDK initialization
879
-
880
- If there are other ways to get context, you can also modify initWithConfig method in CocosCreatorProxyApi.ts file yourself
881
-
882
- ### 4. Enable Native Support
883
-
884
- When initializing SDK, add `enableNative: true` in `config` to enable Native support.
885
-
886
- ```
887
- // TA SDK configuration object
888
- var config = {
889
- appId: "YOUR_APPID", // Project APP ID
890
- serverUrl: "YOUR_SERVER_URL", // Reporting URL
891
- enableNative: true,// Allow calling Native code
892
- autoTrack: {
893
- appShow: true, // Auto-track start event
894
- appHide: true, // Auto-track end event
895
- appCrash: true, // Auto-track crash event (only native effective)
896
- appInstall: true // Auto-track install event (only native effective)
897
- }
898
- };
899
- // Initialize
900
- TDAnalytics.init(config);
901
- ```
902
-
903
- ---
904
-
905
- # Real-time Debugging
906
-
907
- During SDK integration, you can perform real-time debugging by viewing SDK logs in IDE console or using TE's Debug feature.
908
-
909
- #### 1. Print SDK Logs
910
-
911
- ```
912
- var config = {
913
- appId: "xxx",
914
- serverUrl: "xxx",
915
- enableLog:true
916
- };
917
- TDAnalytics.init(config);
918
- ```
919
-
920
- After enabling logs, you can filter ThinkingAnalytics related logs in IDE to observe SDK data reporting.
921
-
922
- #### 2. Enable Debug Mode
923
-
924
- Enabling Debug mode requires the following two steps:
925
-
926
- 1. Client enables Debug mode
927
- Here is the client Debug mode enable example code:
928
-
929
- ```
930
- /*
931
- Set running mode to Debug mode
932
- none: Data will be stored in cache and reported according to certain cache strategy, default is NORMAL mode; recommended for production environment
933
- debug: Data is reported one by one. When problems occur, it will prompt users with logs and exceptions; not recommended for production environment
934
- debugOnly: Only validates data, will not store in database; not recommended for production environment
935
- */
936
- var config = {
937
- appId: "YOUR_APPID",
938
- serverUrl: "YOUR_SERVER_URL",
939
- debugMode: "debug"
940
- };
941
- TDAnalytics.init(config);
942
- ```
943
-
944
- 1. TE backend adds Debug device
945
- To avoid Debug mode going live in production environment, it is specified that only designated devices can enable Debug mode. Only when client has enabled Debug mode and device ID is configured in TE backend's "Tracking Management" page's "Debug Data" section can Debug mode be enabled.
946
-
947
- Device ID can be obtained through the following three ways:
948
-
949
- - #device_id property in event data on TE platform
950
- - Client log: SDK will print device DeviceId after initialization is complete
951
- - Call through instance interface: Get Device ID
952
-
953
- Debug mode may affect data collection quality and App stability, only use for integration phase data validation, do not use in production environment.
954
-
955
- ---
956
-
957
- # Auto-tracking
958
-
959
- In config when creating instance, enable auto-tracking events you need, SDK will automatically collect mini game behaviors, currently the following events support auto-tracking:
960
-
961
- Currently supported automated data collection includes:
962
-
963
- 1. Mini game returns to foreground event
964
- 1. Mini game enters background, and records the duration of this visit (from start to entering background)
965
-
966
- Next we will introduce each data collection method in detail
967
-
968
- ### 1. Enable Auto-tracking Events
969
-
970
- In config, elements in `autoTrack` parameter represent the switch for each auto-tracking event, set to `true` to enable auto-tracking:
971
-
972
- ```
973
- var config = {
974
- appId: "YOUR_APPID",
975
- serverUrl: "YOUR_SERVER_URL",
976
- autoTrack: {
977
- appLaunch: true, // Auto-track ta_mg_launch
978
- appShow: true, // Auto-track ta_mg_show
979
- appHide: true, // Auto-track ta_mg_hide
980
- properties: { // Auto-track custom properties staticKey: 'staticValue'},
981
- callback: (eventType:any) =>{ // Auto-track callback
982
- if (eventType === 'appShow')
983
- {
984
- return { appShowKey: 'appShowValue' };
985
- }
986
- else if (eventType === 'appHide')
987
- {
988
- return { appHideKey: 'appHideValue' };
989
- }
990
- else {
991
- return {};
992
- }
993
- }
994
- }
995
- };
996
- TDAnalytics.init(config);
997
- ```
998
-
999
- - appLaunch: Auto-track mini game initialization
1000
- - appShow: Auto-track mini game start, or from background to foreground
1001
- - appHide: Auto-track mini game from foreground to background
1002
- - properties: Auto-track custom properties (supports appShow/appHide)
1003
- - callback: Auto-track callback (supports appShow/appHide)
1004
-
1005
- If you need the first auto-tracking event to carry account, visitor and static public properties, you can pass the following configuration during initialization:
1006
-
1007
- ```
1008
- TDAnalytics.init(config, () => {
1009
- TDAnalytics.login("TA")
1010
- TDAnalytics.setDistinctId("DIS_TA")
1011
- TDAnalytics.setSuperProperties({
1012
- key: "value"
1013
- });
1014
- });
1015
- ```
1016
-
1017
- ### 2. Auto-tracking Event Details
1018
-
1019
- #### 2.1 Mini Game Initialization
1020
-
1021
- Mini game initialization will be triggered when mini game is first opened, or when user kills process and reopens, will only trigger once in process lifecycle, detailed event introduction:
1022
-
1023
- - Event name: ta_mg_launch
1024
- - Auto-tracking properties:
1025
- - `#scene`, scene value, taken from WeChat provided scene value
1026
- - `#start_reason`, app start source, is parameter obtained from `getLaunchOptionsSync` interface
1027
-
1028
- Through mini game initialization event, you can calculate daily user usage times, average usage times per user, including grouping by scene value to view different scene value user usage situations.
1029
-
1030
- #### 2.2 Mini Game Start
1031
-
1032
- Mini game start will be triggered when mini game is started, or when mini game is called back from background to foreground, detailed event introduction:
1033
-
1034
- - Event name: ta_mg_show
1035
- - Auto-tracking properties:
1036
- - `#scene`, scene value, taken from WeChat provided scene value
1037
-
1038
- Mini game start is affected by foreground/background switching (many records), so not suitable for direct analysis, but can mark user's usage in behavior path, can serve as initial behavior of user behavior path
1039
-
1040
- #### 2.3 Mini Game Hide
1041
-
1042
- Mini game hide will be triggered when mini game enters background, and records this usage duration, detailed event introduction:
1043
-
1044
- - Event name: ta_mg_hide
1045
- - Auto-tracking properties:
1046
- - `#scene`, scene value, taken from WeChat provided scene value
1047
- - `#duration`, numeric type, represents the duration from this start (ta_mg_show) to hide
1048
-
1049
- Mini game hide event will record usage duration (unit is seconds), so can directly calculate user total usage duration and average duration per user, can also divide by initialization times to calculate single usage duration.
1050
-
1051
- ---
1052
-
1053
- # Preset Properties
1054
-
1055
- #### 1. Preset Properties for All Events
1056
-
1057
- Preset properties collected by each platform will have certain differences, you can refer to the following documents: Android Platform, iOS Platform
1058
-
1059
- **Mini game platform preset properties for all events:**
1060
-
1061
- **Property Name** | **Chinese Name** | **Property Type** | **Description**
1062
- #ip | IP Address | Text | User's IP address, TE will use this to get user's geographic location information
1063
- #country | Country | Text | User's country, generated based on IP address
1064
- #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
1065
- #province | Province | Text | User's province, generated based on IP address
1066
- #city | City | Text | User's city, generated based on IP address
1067
- #device_model | Device Model | Text | User device's model, such as iPhone 8
1068
- #device_id | Device ID | Text | User's device ID, UUID generated during initialization
1069
- #screen_height | Screen Height | Number | User device's screen height, such as 1920
1070
- #screen_width | Screen Width | Number | User device's screen height, such as 1080
1071
- #manufacturer | Device Manufacturer | Text | User device's manufacturer, such as Apple, vivo
1072
- #os_version | Operating System Version | Text | iOS 11.2.2, Android 8.0.0, etc.
1073
- #os | Operating System | Text | Such as Android, iOS
1074
- #network_type | Network Status | Text | Network status when uploading event, such as WIFI, 3G, 4G
1075
- #lib | SDK Type | Text | SDK type you integrated, such as MG (mini game)
1076
- #lib_version | SDK Version | Text | SDK version you integrated
1077
- #scene | Scene Value | Number | Scene value passed when WeChat mini game starts
1078
- #mp_platform | Mini Game Platform | Text | Identifies the platform where app is located
1079
- #zone_offset | Timezone Offset | Number | Data time offset hours relative to UTC time
1080
-
1081
- #### 2. Auto-tracking Event Preset Properties
1082
-
1083
- The following preset properties are unique preset properties in each auto-tracking event
1084
-
1085
- - Mini program start (ta_mp_show) preset properties
1086
- **Property Name** | **Chinese Name** | **Property Type** | **Description**
1087
- #url_path | Page Path | Text | Mini program start displayed page path
1088
- #start_reason | App Start Source | Text | Content is JSON string, is parameter obtained from `getLaunchOptionsSync` interface
1089
-
1090
- - Mini game hide (ta_mg_hide) preset properties
1091
- **Property Name** | **Chinese Name** | **Property Type** | **Description**
1092
- #duration | Event Duration | Number | Represents the duration from this start `ta_mg_show` to hide `ta_mg_hide`, unit is seconds
1093
-
1094
- #### 3. Get Preset Properties
1095
-
1096
- When server tracking needs some preset properties from App side, you can get client preset properties through this method, then pass to server.
1097
-
1098
- ```
1099
- //Get property object
1100
- var presetProperties = TDAnalytics.getPresetProperties();
1101
- //Generate event preset properties
1102
- var properties = presetProperties.toEventPresetProperties();
1103
- /*
1104
- {
1105
- "#device_model":"iPhone 5",
1106
- "#device_id":"3204487163-1624513721217",
1107
- "#screen_width":320,
1108
- "#screen_height":568,
1109
- "#os":"iOS",
1110
- "#os_version":"10.0.1",
1111
- "#network_type":"wifi",
1112
- "#zone_offset":8,
1113
- "#manufacturer":"Apple"
1114
- }
1115
- */
1116
- //Get a preset property
1117
- var os=presetProperties.os;//OS type, such as Android
1118
- var osVersion=presetProperties.osVersion;//System version number
1119
- var networkType=presetProperties.networkType;//Network type
1120
- var manufacture=presetProperties.manufacturer;//Device manufacturer
1121
- var deviceModel=presetProperties.deviceModel;//Device model
1122
- var screenWidth=presetProperties.screenWidth;//Screen width
1123
- var screenHeight=presetProperties.screenHeight;//Screen height
1124
- var deviceId=presetProperties.deviceId;//Device ID
1125
- var zoneOffset=presetProperties.zoneOffset;//Timezone offset value
1126
- ```
1127
-
1128
- IP, country city information is generated by server parsing, client does not provide interface to get these properties