@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,1692 +0,0 @@
1
- ---
2
- code: mp_sdk_installation
3
- name: "Mini Program & Mini Game"
4
- wikiToken: HBNXwSFSFiWQGWkt0ynccCeIn9g
5
- parentWikiToken: FTcTwinIOi3OiRkK4MPc2Ex7neg
6
- updateTime: 1770106195000
7
- sourceUrl: https://docs-v2.thinkingdata.cn/?version=6.0&lan=zh-CN&code=mp_sdk_installation
8
- ---
9
-
10
- # Mini Program & Mini Game
11
-
12
- ::: tip Tip
13
-
14
- Before integration, please read the pre-installation preparation.
15
-
16
- If you use game engine to develop mini games, please read integration solutions for common game engines: Egret White Egret Engine, LayaAir, CocosCreator.
17
-
18
- :::
19
-
20
- **Latest Version:** v3.4.4 Download (Mini Program) Download (Mini Game)
21
-
22
- **Update Time:** 2026-02-03
23
-
24
- **Resource Download:** Source code
25
-
26
- ::: warning Note
27
-
28
- This document applies to v3.0.0 and later versions. For historical versions, please refer to Mini Program & Mini Game Integration Guide (V2), Mini Program SDK Download (v2.2.4), Mini Game SDK Download (v2.2.4)
29
-
30
- :::
31
-
32
- Mini Program & Mini Game SDK provides a set of standard API interfaces for common mini program platforms, quick apps, and mini game platforms to implement data reporting functionality. Currently, supported platforms and corresponding files are as follows:
33
-
34
- **Mini Programs:**
35
-
36
- - WeChat Mini Program: tdanalytics.wx.min.js
37
- - Baidu Mini Program: tdanalytics.swan.min.js
38
- - Douyin Mini Program: tdanalytics.tt.min.js
39
- - Alipay Mini Program: tdanalytics.my.min.js
40
- - DingTalk Mini Program: tdanalytics.dd.min.js
41
- - Kuaishou Mini Program: tdanalytics.ks.min.js
42
- - Quick App: tdanalytics.quick.min.js
43
- - QQ Mini Program: tdanalytics.qq.min.js
44
- - JD Mini Program: tdanalytics.jd.min.js
45
- - 360 Mini Program: tdanalytics.qh.min.js
46
- **Mini Games:**
47
-
48
- - WeChat Mini Game: tdanalytics.mg.wx.min.js
49
- - QQ Mini Game: tdanalytics.mg.qq.min.js
50
- - Douyin Mini Game: tdanalytics.mg.tt.min.js
51
- - Baidu Mini Game: tdanalytics.mg.swan.min.js
52
- - Bilibili Mini Game: tdanalytics.mg.bl.min.js
53
- - Huawei Quick Game: tdanalytics.mg.huawei.min.js
54
- - OPPO Quick Game: tdanalytics.mg.oppo.min.js
55
- - VIVO Quick Game: tdanalytics.mg.vivo.min.js
56
- - Meizu Quick Game: tdanalytics.mg.mz.min.js
57
- - Xiaomi Quick Game: tdanalytics.mg.xiaomi.min.js
58
- - Taobao Mini Game: tdanalytics.mg.tb.min.js
59
- - Kuaishou Mini Game: tdanalytics.mg.ks.min.js
60
- - Alipay Mini Game: tdanalytics.mg.my.min.js
61
- - Meituan Mini Game: tdanalytics.mg.mt.min.js
62
- - H5 Mini Game
63
- - UC Mini Game
64
- - Facebook Mini Game
65
-
66
- ### 1. Integrate SDK
67
-
68
- :::: el-tabs
69
-
70
- ::: el-tab-pane label=Mini Program
71
-
72
- Download Mini Program SDK, import corresponding SDK file in app.js (example with WeChat Mini Program):
73
-
74
- ```
75
- var TDAnalytics = require("./tdanalytics.wx.min.js");
76
- ```
77
-
78
- After importing SDK, you can create SDK instance and start reporting data:
79
-
80
- ```
81
- // TE SDK configuration object
82
- var config = {
83
- appId: "YOU-APP-ID", // Project APP ID
84
- serverUrl: "https://youserverurl.com", // Data reporting address
85
- autoTrack: {
86
- appLaunch: true, // Auto track ta_mp_launch
87
- appShow: true, // Auto track ta_mp_show
88
- appHide: true, // Auto track ta_mp_hide
89
- pageShow: true, // Auto track ta_mp_view
90
- pageShare: true // Auto track ta_mp_share
91
- }
92
- };
93
-
94
- // Initialize
95
- TDAnalytics.init(config);
96
- ```
97
-
98
- TE configuration object parameter description:
99
-
100
- - `appId`: Your project's APP ID, required, can be viewed in TE backend project management page
101
- - `serverUrl`: Data reporting URL, required
102
- - If you are using cloud service, enter: https://global-receiver-ta.thinkingdata.cn
103
- - If you are using privately deployed version, please confirm reporting address with operations team
104
- - `enableBatch`: Data cached locally first, then batch sent, default is false
105
- - `autoTrack`: Optional, indicates whether to enable auto tracking function. Each element represents the following auto tracking events, default all disabled:
106
- - `appLaunch`: Auto track mini program initialization, triggers once per session
107
- - `appShow`: Auto track mini program startup, or from background to foreground
108
- - `appHide`: Auto track mini program from foreground to background, and record this visit duration (from startup to background)
109
- - `pageShow`: Auto track mini program page show or switch to foreground, record page path and referrer path
110
- - `pageShare`: Auto track mini program forward/share, record the page when forwarding
111
- **For details about auto tracking events, please refer to Auto Tracking Events section**
112
-
113
- :::
114
-
115
- ::: el-tab-pane label=Quick App
116
-
117
- Download Mini Program SDK, import corresponding SDK in app.ux file `tdanalytics.quick.min.js`:
118
-
119
- ```
120
- var TDAnalytics = require("./tdanalytics.quick.min.js");
121
- ```
122
-
123
- After that, you can create SDK instance and start reporting data:
124
-
125
- ```
126
- // TE SDK configuration object
127
- var config = {
128
- appId: "YOU-APP-ID", // Project APP ID
129
- serverUrl: "https://youserverurl.com", // Data reporting address
130
- persistenceComplete(ta) {
131
- // Callback when async storage initialization completes, can do some cache related delete operations
132
- //TDAnalytics.clearSuperProperties();
133
- }
134
- };
135
-
136
- // Initialize
137
- TDAnalytics.init(config);
138
- ```
139
-
140
- TE configuration object parameter description:
141
-
142
- - `appId`: Your project's APP ID, required, can be viewed in TE backend project management page
143
- - `serverUrl`: Data reporting URL, required
144
- - If you are using cloud service, enter: https://global-receiver-ta.thinkingdata.cn
145
- - If you are using privately deployed version, please confirm reporting address with operations team
146
- - `persistenceComplete`: Optional. Quick app cache is read asynchronously, so before cache reading completes, query and delete operations on cache related fields will have unexpected results. To ensure cache query and delete during initialization phase can execute correctly, relevant operations need to be completed in persistenceComplete callback. Cache related data includes: user ID (#account_id and #distinct_id), device ID, common event properties etc.
147
-
148
- **Further explanation of persistenceComplete:**
149
-
150
- For SDK state issues caused by async calls, we set Ready state for each instance. When the following conditions are **all met**, we consider the instance is Ready:
151
-
152
- - System info obtained: We get system info by calling platform provided `getSystemInfo()`
153
- - Cache info read complete: Quick app reads cache asynchronously
154
- - User actively called `TDAnalytics.init()`
155
- When instance has not entered Ready state, we will cache all reported data. After instance initialization completes, cache will be cleared to ensure correct state.
156
-
157
- During different stages of async cache reading, please pay attention to the following notes:
158
-
159
- 1. When cache info has not been read, you can set common properties and login account.
160
- 1. When cache reading completes, we will use new value to override previous value in cache.
161
- 1. **Before cache reading completes, if you call functions that involve deleting or reading previous cache info, you cannot read or delete actual cache data.**
162
- For the above point 3, you can ensure call order by passing callback function (i.e. persistenceComplete) during initialization.
163
-
164
- <!-- unsupported block: 34 -->
165
-
166
- Note: Quick app does not support auto tracking events
167
-
168
- :::
169
-
170
- ::: el-tab-pane label=Mini Game
171
-
172
- Download Mini Game SDK, import corresponding SDK file in game.js (example with WeChat Mini Game):
173
-
174
- ```
175
- var TDAnalytics = require("./tdanalytics.mg.wx.min.js");
176
- ```
177
-
178
- ```
179
- // TE SDK configuration object
180
- var config = {
181
- appId: "YOUR_APPID", // Project APP ID
182
- serverUrl: "YOUR_SERVER_URL", // Reporting address
183
- autoTrack: {
184
- appShow: true, // Auto track ta_mg_show
185
- appHide: true // Auto track ta_mg_hide
186
- }
187
- };
188
- // Initialize
189
- TDAnalytics.init(config);
190
- ```
191
-
192
- TE configuration object parameter description:
193
-
194
- - `appId`: Your project's APP ID, required, can be viewed in TE backend project management page
195
- - `serverUrl`: Data reporting URL, required
196
- - If you are using cloud service, enter: https://global-receiver-ta.thinkingdata.cn
197
- - If you are using privately deployed version, please confirm reporting address with operations team
198
- - `autoTrack`: Optional, indicates whether to enable auto tracking function. Each element represents the following auto tracking events, default all disabled:
199
- - `appShow`: Auto track mini game startup, or from background to foreground
200
- - `appHide`: Auto track mini game from foreground to background, and record this visit duration (from startup to background)
201
- :::
202
-
203
- ::::
204
-
205
- ::: warning Note
206
-
207
- Before reporting data, please first add the data transfer URL to the server domain request list in the development settings of WeChat Public Platform or other platforms.
208
-
209
- :::
210
-
211
- ### 2. Common Features
212
-
213
- Before using common features, we recommend you first understand the user identification rules. SDK generates random number as visitor ID by default and persists visitor ID locally. Before user logs in, visitor ID is used as identification ID. Note: Visitor ID will change when user clears cache or changes device.
214
-
215
- #### 2.1 Set Account ID
216
-
217
- When user logs in, you can call `login` to set user's account ID. TE platform will use account ID as identification ID. The set account ID will be kept until `logout` is called. Multiple calls to `login` will override previous account ID.
218
-
219
- ```
220
- // User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
221
- TDAnalytics.login("TA");
222
- ```
223
-
224
- <!-- unsupported block: 34 -->
225
-
226
- **This method will not upload login event**
227
-
228
- #### 2.2 Set Common Event Properties
229
-
230
- Common event properties refer to properties that every event will have. You can call `setSuperProperties` to set common event properties. We recommend you set common 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 common event properties.
231
-
232
- ```
233
- var superProperties = {
234
- channel : "ta",
235
- age : 1,
236
- isSuccess : true,
237
- birthday : new Date(),
238
- object : { key : "value" },
239
- object_arr : [ { key : "value" } ],
240
- arr : [ "value" ]
241
- };
242
- TDAnalytics.setSuperProperties(superProperties);
243
- ```
244
-
245
- Common event properties will be saved to cache, no need to call every time on startup. If you call `setSuperProperties` to upload a previously set common event property, it will override the previous property.
246
-
247
- - Key is the property name, string type, must start with letter, contains numbers, letters and underscore "\_", maximum length is 50 characters, case insensitive, TE will convert to lowercase letters
248
- - Value is the property value, supports string, number, boolean, date, object, object array, array
249
- <!-- unsupported block: 34 -->
250
-
251
- **Event properties and user properties requirements are the same as common event properties**
252
-
253
- #### 2.3 Send Event
254
-
255
- You can call `track` to upload event. We recommend you set event properties and send event conditions based on previously documented tracking plan. Here is an example of user purchasing a product:
256
-
257
- ```
258
- TDAnalytics.track({
259
- eventName: "product_buy", // Event name
260
- properties: {
261
- product_name: "product name"
262
- } // Event properties
263
- });
264
- ```
265
-
266
- Event name is string type, must start with letter, can contain numbers, letters and underscore "\_", maximum length is 50 characters.
267
-
268
- #### 2.4 Set User Properties
269
-
270
- For general user properties, you can call `userSet` to set. Properties uploaded using this interface will override original property values. If the user property did not exist before, it will create a new user property with the same type as the uploaded property. Here is an example of setting username:
271
-
272
- ```
273
- // At this time username is TA
274
- TDAnalytics.userSet({
275
- properties: {
276
- username: "TA"
277
- }
278
- });
279
- // At this time username is TE
280
- TDAnalytics.userSet({
281
- properties: {
282
- username: "TE"
283
- }
284
- });
285
- ```
286
-
287
- ### 3. Best Practices
288
-
289
- The following example code includes all operations above. We recommend using it as follows
290
-
291
- :::: el-tabs
292
-
293
- ::: el-tab-pane label=Mini Program
294
-
295
- Download Mini Program SDK, after importing SDK, you can create SDK instance and start reporting data:
296
-
297
- ```
298
- var TDAnalytics = require("./tdanalytics.wx.min.js");
299
- var config = {
300
- appId: "YOU-APP-ID", // Project APP ID
301
- serverUrl: "https://youserverurl.com", // Data reporting address
302
- autoTrack: {
303
- appLaunch: true, // Auto track ta_mp_launch
304
- appShow: true, // Auto track ta_mp_show
305
- appHide: true, // Auto track ta_mp_hide
306
- pageShow: true, // Auto track ta_mp_view
307
- pageShare: true // Auto track ta_mp_share
308
- }
309
- };
310
- // Initialize
311
- TDAnalytics.init(config);
312
- // User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
313
- TDAnalytics.login("TA");
314
- // Set common event properties
315
- var superProperties = {
316
- channel : "ta", // String
317
- age : 1,// Number
318
- isSuccess : true,// Boolean
319
- birthday : new Date(),// Object
320
- object : { key : "value" },// Object
321
- object_arr : [ { key : "value" } ],// Object array
322
- arr : [ "value" ]// Array
323
- };
324
- TDAnalytics.setSuperProperties(superProperties);
325
- // Send event
326
- TDAnalytics.track({
327
- eventName: "product_buy", // Event name
328
- properties: {
329
- product_name: "product name"
330
- } // Event properties
331
- });
332
- // Set user properties
333
- TDAnalytics.userSet({
334
- properties: {
335
- username: "TE"
336
- }
337
- });
338
- ```
339
-
340
- :::
341
-
342
- ::: el-tab-pane label=Quick App
343
-
344
- Download Mini Program SDK, import corresponding SDK in app.ux (`tdanalytics.quick.min.js`)
345
-
346
- You can create SDK instance and start reporting data:
347
-
348
- ```
349
- var TDAnalytics = require("./tdanalytics.quick.min.js");
350
- // TE SDK configuration object
351
- var config = {
352
- appId: "YOU-APP-ID", // Project APP ID
353
- serverUrl: "https://youserverurl.com", // Data reporting address
354
- persistenceComplete(ta) {
355
- // Callback when async storage initialization completes, can do some cache related delete operations
356
- //TDAnalytics.clearSuperProperties();
357
- }
358
- };
359
- // Initialize
360
- TDAnalytics.init(config);
361
- // User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
362
- TDAnalytics.login("TA");
363
- // Set common event properties
364
- var superProperties = {
365
- channel : "ta", // String
366
- age : 1,// Number
367
- isSuccess : true,// Boolean
368
- birthday : new Date(),// Object
369
- object : { key : "value" },// Object
370
- object_arr : [ { key : "value" } ],// Object array
371
- arr : [ "value" ]// Array
372
- };
373
- TDAnalytics.setSuperProperties(superProperties);
374
- // Send event
375
- TDAnalytics.track({
376
- eventName: "product_buy", // Event name
377
- properties: {
378
- product_name: "product name"
379
- } // Event properties
380
- });
381
- // Set user properties
382
- TDAnalytics.userSet({
383
- properties: {
384
- username: "TE"
385
- }
386
- });
387
-
388
- ```
389
-
390
- :::
391
-
392
- ::: el-tab-pane label=Mini Game
393
-
394
- Download Mini Game SDK, import corresponding SDK file in game.js (example with WeChat Mini Game). After importing SDK, you can create SDK instance and start reporting data:
395
-
396
- ```
397
- var TDAnalytics = require("./tdanalytics.mg.wx.min.js");
398
- var config = {
399
- appId: "YOUR_APPID", // Project APP ID
400
- serverUrl: "YOUR_SERVER_URL", // Reporting address
401
- autoTrack: {
402
- appShow: true, // Auto track ta_mg_show
403
- appHide: true // Auto track ta_mg_hide
404
- }
405
- };
406
- // Initialize
407
- TDAnalytics.init(config);
408
- // User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
409
- TDAnalytics.login("TA");
410
- // Set common event properties
411
- var superProperties = {
412
- channel : "ta", // String
413
- age : 1,// Number
414
- isSuccess : true,// Boolean
415
- birthday : new Date(),// Object
416
- object : { key : "value" },// Object
417
- object_arr : [ { key : "value" } ],// Object array
418
- arr : [ "value" ]// Array
419
- };
420
- TDAnalytics.setSuperProperties(superProperties);
421
- // Send event
422
- TDAnalytics.track(
423
- eventName: "product_buy", // Event name
424
- properties: {
425
- product_name: "product name"
426
- } // Event properties
427
- );
428
- // Set user properties
429
- TDAnalytics.userSet({
430
- properties: {
431
- username: "TE"
432
- }
433
- });
434
-
435
- ```
436
-
437
- :::
438
-
439
- ::::
440
-
441
- ---
442
-
443
- # Advanced Guide
444
-
445
- ### 1. Set User ID
446
-
447
- SDK instance uses random number as default visitor ID for each user by default. This ID will be used as identification ID when user is not logged in. Note that visitor ID will change when user clears cache or changes device.
448
-
449
- #### 1.1 Set Visitor ID
450
-
451
- ::: tip Tip
452
-
453
- Generally, you don't need to customize visitor ID. Please ensure you understand user identification rules before setting visitor ID.
454
-
455
- :::
456
-
457
- If your App has its own visitor ID management system for each user, you can call `setDistinctId` to set visitor ID:
458
-
459
- ```
460
- // Set visitor ID to Thinker
461
- TDAnalytics.setDistinctId("Thinker");
462
- ```
463
-
464
- If you need to get current visitor ID, you can call `getDistinctId`:
465
-
466
- ```
467
- // Return visitor ID
468
- let distinctId = TDAnalytics.getDistinctId();
469
- ```
470
-
471
- #### 1.2 Set Account ID
472
-
473
- When user logs in, you can call `login` to set user's account ID. TE platform will use account ID as identification ID. The set account ID will be kept until `logout` is called. Multiple calls to `login` will override previous account ID.
474
-
475
- ```
476
- // User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
477
- TDAnalytics.login("TA");
478
- ```
479
-
480
- <!-- unsupported block: 34 -->
481
-
482
- **This method will not upload login event**
483
-
484
- #### 1.3 Clear Account ID
485
-
486
- After user performs logout behavior, you can call `logout` to clear account ID. Before next call to `login`, visitor ID will be used as identification ID.
487
-
488
- ```
489
- // Remove #account_id from reported data, subsequent data will not have "#account_id"
490
- TDAnalytics.logout();
491
- ```
492
-
493
- We recommend you call `logout` during explicit logout event, such as when user performs account deregistration, rather than when closing App.
494
-
495
- <!-- unsupported block: 34 -->
496
-
497
- **This method will not upload logout event**
498
-
499
- ### 2. Send Event
500
-
501
- After SDK initialization is complete, you can perform data tracking to collect user behavior information. Generally, normal events can meet business scenario requirements. You can also use first-time, updatable events according to your actual business scenarios.
502
-
503
- #### 2.1 Normal Event
504
-
505
- You can call `track` to upload event. We recommend you set event properties and send event conditions based on previously documented tracking plan. Here is an example of user purchasing a product
506
-
507
- ```
508
- TDAnalytics.track({
509
- eventName: "product_buy", // Event name
510
- properties: {
511
- product_name: "product name"
512
- } // Event properties
513
- });
514
- ```
515
-
516
- #### 2.2 First-time Event
517
-
518
- First-time event refers to event that will only be recorded once for a certain device or other dimension ID. For example, in some scenarios, you may want to record activation event on a certain device, then you can use first-time event to report data.
519
-
520
- ```
521
- TDAnalytics.trackFirst({
522
- eventName: "device_activation",
523
- properties: { key: "value" }
524
- });
525
- ```
526
-
527
- If you want to judge whether it's first time based on other dimensions besides device, you can customize first_check_id for first-time event:
528
-
529
- ```
530
- // Set user ID as first_check_id for first-time event, to implement user first activation event collection
531
- TDAnalytics.trackFirst({
532
- eventName: "account_activation",
533
- firstCheckId: "TA",
534
- properties: { key: "value" }
535
- });
536
- ```
537
-
538
- <!-- unsupported block: 34 -->
539
-
540
- Note: Since validation of whether it's first time is done on server side, first-time events are delayed by 1 hour before being stored in database by default.
541
-
542
- #### 2.3 Updatable Event
543
-
544
- You can use updatable event to implement requirements for modifying event data in specific scenarios. Updatable event needs to specify the ID that identifies the event and pass it when creating updatable event object. TE backend will determine the data to be updated based on event name and event ID.
545
-
546
- ```
547
- // Example: Report updatable event, assuming event name is UPDATABLE_EVENT
548
- // After reporting, event property status is 3, price is 100
549
- TDAnalytics.trackUpdate({
550
- eventName: "UPDATABLE_EVENT",
551
- properties: { status: 3, price: 100 },
552
- eventId: "test_event_id"
553
- });
554
-
555
- // After reporting, event property status is updated to 5, price unchanged
556
- TDAnalytics.trackUpdate({
557
- eventName: "UPDATABLE_EVENT",
558
- properties: { status: 5 },
559
- eventId: "test_event_id"
560
- });
561
- ```
562
-
563
- #### 2.4 Overwritable Event
564
-
565
- Overwritable event is similar to updatable event, the difference is that overwritable event will completely overwrite historical data with latest data. From the effect, it's equivalent to deleting previous data and storing latest data. TE backend will determine the data to be updated based on event name and event ID.
566
-
567
- ```
568
- // Example: Report overwritable event, assuming event name is OVERWRITE_EVENT
569
- // After reporting, event property status is 3, price is 100
570
- TDAnalytics.trackOverwrite({
571
- eventName: "OVERWRITE_EVENT",
572
- properties: { status: 3, price: 100 },
573
- eventId: "test_event_id"
574
- });
575
-
576
- // After reporting, event property status is updated to 5, price property is deleted
577
- TDAnalytics.trackOverwrite({
578
- eventName: "OVERWRITE_EVENT",
579
- properties: { status: 5 },
580
- eventId: "test_event_id"
581
- });
582
- ```
583
-
584
- #### 2.5 Common Event Properties
585
-
586
- 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 common properties, i.e. properties that every event will have. We recommend you set common properties before sending events.
587
-
588
- Common properties include two types: event common properties and dynamic common properties. When event is reported, common properties will be inserted into data's properties. If common properties have the same key as custom properties set in event, the property value will be determined according to the following priority: `Custom Properties > Dynamic Common Properties > Static Common Properties > Preset Properties`
589
-
590
- ##### 2.5.1 Static Common Event Properties
591
-
592
- 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 common event properties. Static common event properties will be effective globally. When cache is enabled (default on), static common properties will be cached and still effective on next startup.
593
-
594
- The parameter for static common properties is a JSON object, and its format requirements are the same as event properties.
595
-
596
- ```
597
- // Set common event properties, all data events will have these properties
598
- TDAnalytics.setSuperProperties({
599
- channel: "channel name",
600
- user_name: "username"
601
- });
602
- ```
603
-
604
- Besides property setting, we also provide other APIs to manipulate static common event properties to meet daily business needs.
605
-
606
- ```
607
- // Get static common event properties
608
- var superProperties = TDAnalytics.getSuperProperties();
609
- // Clear a static common event property, for example clear previously set 'channel' property, subsequent data will not have this property
610
- TDAnalytics.unsetSuperProperty("channel");
611
- // Clear all static common event properties
612
- TDAnalytics.clearSuperProperties();
613
- ```
614
-
615
- ##### 2.5.2 Dynamic Common Event Properties
616
-
617
- Through `setDynamicSuperProperties` to set callback function for dynamic common properties. SDK will trigger callback function when event is reported and add returned JSON object to event properties. `setDynamicSuperProperties` parameter is a function that needs to return a JSON object.
618
-
619
- ```
620
- // Set dynamic common properties, trigger callback function when event is reported, and add returned JSON object to event properties
621
- TDAnalytics.setDynamicSuperProperties(function() {
622
- var d = new Date();
623
- d.setHours(10);
624
- return { date: d };
625
- });
626
- ```
627
-
628
- #### 2.6 Record Event Duration
629
-
630
- 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 the event, `#duration` property will be automatically added to your event properties to represent the recorded duration, in seconds. Note that the same event name can only have one timing task.
631
-
632
- ```
633
- // The following example completes statistics of user's stay time on a product page
634
- TDAnalytics.timeEvent({
635
- eventName: "stay_shop"
636
- });
637
- /**do someting
638
- .......
639
- **/
640
- // User leaves product page, timing ends, "stay_shop" event will have #duration property representing event duration
641
- TDAnalytics.track({
642
- eventName: "stay_shop",
643
- properties: {
644
- product_name: "product name"
645
- }
646
- });
647
- ```
648
-
649
- ### 3. User Properties
650
-
651
- TE platform supported user property setting APIs are: `userSet`, `userSetOnce`, `userAdd`, `userUnset`, `userDelete`, `userAppend`, `userUniqAppend`.
652
-
653
- #### 3.1 userSet
654
-
655
- For general user properties, you can call `userSet` to set. Properties uploaded using this interface will override original property values. If the user property did not exist before, it will create a new user property with the same type as the uploaded property. Here is an example of setting username:
656
-
657
- ```
658
- // username is TA
659
- TDAnalytics.userSet({
660
- properties: {
661
- username: "TA"
662
- }
663
- });
664
- // username is TE
665
- TDAnalytics.userSet({
666
- properties: {
667
- username: "TE"
668
- }
669
- });
670
- ```
671
-
672
- #### 3.2 userSetOnce
673
-
674
- If the user property you want to upload only needs to be set once, you can call `userSetOnce` to set. When the property already has a value, this information will be ignored. Here is an example of setting first payment time:
675
-
676
- ```
677
- // first_payment_time is 2018-01-01 01:23:45.678
678
- TDAnalytics.userSetOnce({
679
- properties: {
680
- first_payment_time: "2018-01-01 01:23:45.678"
681
- }
682
- });
683
- // first_payment_time is still 2018-01-01 01:23:45.678
684
- TDAnalytics.userSetOnce({
685
- properties: {
686
- first_payment_time: "2018-12-31 01:23:45.678"
687
- }
688
- });
689
- ```
690
-
691
- #### 3.3 userAdd
692
-
693
- When you want to upload numeric properties, you can call `userAdd` to perform accumulation operation on that property. If the property has not been set, it will assign 0 then perform calculation. If negative value is passed, it's equivalent to subtraction operation.
694
-
695
- ```
696
- // At this time total_revenue is 30
697
- TDAnalytics.userAdd({
698
- properties: {
699
- total_revenue: 30
700
- }
701
- });
702
- // At this time total_revenue is 678
703
- TDAnalytics.userAdd({
704
- properties: {
705
- total_revenue: 648
706
- }
707
- });
708
- ```
709
-
710
- #### 3.4 userUnset
711
-
712
- When you want to clear user's user property value, you can call `userUnset` to clear specified property. If the property has not been created in the cluster, `userUnset` **will not** create that property
713
-
714
- ```
715
- // Clear the user property value named userPropertykey, set to NULL
716
- TDAnalytics.userUnset({
717
- property: "userPropertykey"
718
- });
719
- ```
720
-
721
- #### 3.5 userDelete
722
-
723
- If you want to delete a user, you can call `userDelete` to delete that user. You will no longer be able to query that user's user properties, but events generated by that user can still be queried.
724
-
725
- ```
726
- TDAnalytics.userDelete();
727
- ```
728
-
729
- #### 3.6 userAppend
730
-
731
- You can call `userAppend` to append elements to array type user data.
732
-
733
- ```
734
- TDAnalytics.userAppend({
735
- properties: {
736
- user_list: ["apple", "ball"]
737
- }
738
- });
739
- ```
740
-
741
- #### 3.7 userUniqAppend
742
-
743
- Since v1.6.0, you can call `userUniqAppend` to append unique elements to Array (List) type user data. Calling `userUniqAppend` interface will deduplicate appended user properties. `userAppend` interface does not deduplicate, user properties may have duplicates.
744
-
745
- ```
746
- // At this time user_list property value is ["apple", "ball"]
747
- TDAnalytics.userAppend({
748
- properties: {
749
- user_list: ["apple", "ball"]
750
- }
751
- });
752
- // At this time user_list property value is ["apple", "apple", "ball", "cube"]
753
- TDAnalytics.userAppend({
754
- properties: {
755
- user_list: ["apple", "cube"]
756
- }
757
- });
758
- // At this time user_list property value is ["apple", "ball", "cube"]
759
- TDAnalytics.userUniqAppend({
760
- properties: {
761
- user_list: ["apple", "cube"]
762
- }
763
- });
764
- ```
765
-
766
- ### 4. Encryption Feature
767
-
768
- Since v2.1.0, SDK supports AES+RSA encrypted data. Data encryption feature requires cooperation between client and server. For specific usage, please consult customer success personnel.
769
-
770
- Set `enableEncrypt` property to true, and set default version number and public key.
771
-
772
- ```
773
- var config = {
774
- appId: "YOUR_APP_ID", // Project APP ID
775
- serverUrl: "YOUR_SERVER_URL", // Reporting address
776
- enableEncrypt: true, // Enable data transfer encryption
777
- secretKey: {
778
- publicKey:'YOUR_PUBLIC_KEY', // Encryption public key
779
- version:0 // Key version number
780
- }
781
- };
782
- // Initialize
783
- TDAnalytics.init(config);
784
- ```
785
-
786
- To support data encryption, you need to additionally import crypto-js and jsencrypt (example with WeChat Mini Program)
787
-
788
- - npm import crypto-js
789
- - Download jsencrypt.min.js and import into project
790
- - Execute the following code before SDK initialization:
791
-
792
- ```
793
- const cryptojs = require('crypto-js');
794
- const jsencrypt = require('./jsencrypt.min')
795
- Object.defineProperty(Object.prototype, "CryptoJS", { value: cryptojs });
796
- Object.defineProperty(Object.prototype, "JSEncrypt", { value: jsencrypt });
797
- ```
798
-
799
- ### 5. Other Features
800
-
801
- #### 5.1 Get Device ID
802
-
803
- You can call `getDeviceId()` to get device ID.
804
-
805
- ```
806
- var deviceId = TDAnalytics.getDeviceId();
807
- ```
808
-
809
- <!-- unsupported block: 34 -->
810
-
811
- **Device ID will be saved in cache. If user clears cache, device ID will be reset.**
812
-
813
- #### 5.2 onComplete Callback Function
814
-
815
- For interfaces like `track, userSet, userSetOnce, userAdd, userDel`, onComplete callback is supported. You can pass onComplete directly after original parameter list, or use parameter object method. If using parameter object, the parameter object must include onComplete, otherwise parameter error will occur. Example with uploading event:
816
-
817
- ```
818
- TDAnalytics.track({
819
- eventName: "test", // Required
820
- properties: { testkey: 123 }, // Optional
821
- time: new Date(),
822
- onComplete: res => {
823
- console.log(res);
824
- }
825
- });
826
- ```
827
-
828
- onComplete parameter res is object type, has two properties code and msg.
829
-
830
- res.code is int type, defined as follows:
831
-
832
- - 0: Success
833
- - -1: Data format incorrect
834
- - -2: APP ID invalid
835
- - -3: Network or server exception
836
- Debug mode defined as follows:
837
-
838
- - 0: Success
839
- - -1: Parameter or permission validation issue
840
- - 1: Indicates basic field error, will give detailed error field and reason
841
- - 2: Indicates entire record error
842
- - -3: Network or server exception
843
- res.msg is text explanation of res.code.
844
-
845
- #### 5.3 Set Event Cache Reporting
846
-
847
- Since v2.2.0, you can configure to enable event cache reporting during initialization.
848
-
849
- ```
850
- // TE SDK configuration object
851
- var config = {
852
- appId: "YOU-APP-ID", // Project APP ID
853
- serverUrl: "https://youserverurl.com", // Data reporting address
854
- enableBatch: true, // Whether to enable event cache batch reporting, true=enable, false=disable
855
-   batchConfig: {
856
- size: 5, // Event cache reporting count
857
- interval: 5000 // Event cache reporting interval (milliseconds)
858
- }
859
- };
860
- // Initialize
861
- TDAnalytics.init(config);
862
- ```
863
-
864
- #### 5.4 Set Default Timezone
865
-
866
- By default, SDK uses local time at interface call time as event occurrence time for reporting. Since v3.0.3, you can also set default timezone during initialization, so all events will align event time according to the timezone you set:
867
-
868
- ```
869
- var config = {
870
- appId: "YOU-APP-ID", // Project APP ID
871
- serverUrl: "https://youserverurl.com", // Data reporting address
872
- zoneOffset:8
873
- };
874
- ```
875
-
876
- <!-- unsupported block: 34 -->
877
-
878
- Note: Aligning event time with specified timezone will lose device local timezone information. If you need to preserve device local timezone information, you currently need to add related properties to events yourself.
879
-
880
- ### 6. Channel SDK Compatibility
881
-
882
- #### 6.1 Tencent Advertising
883
-
884
- ##### 6.1.1 Solution Overview
885
-
886
- After integrating TDAnalytics SDK, you don't need to additionally integrate Tencent Advertising SDK. Once you complete TDAnalytics initialization method, the system will automatically trigger Tencent Advertising SDK initialization. When you report key events like registration, payment, etc., the system will automatically report these event information to Tencent Advertising according to your configuration.
887
-
888
- ##### 6.1.2 Integration Process
889
-
890
- 1. Download Tencent Advertising SDK, currently using version 1.5.4, other versions can also be used.
891
- Place dn-sdk-minigame.cjs.js file in the same directory as TDAnalytics SDK.
892
-
893
- 1. Initialize
894
- <!-- unsupported block: 19 -->
895
-
896
- TDAnalytics SDK version needs >= 3.0.4
897
-
898
- ```
899
- TDAnalytics.init({
900
- appId: 'AppId',
901
- serverUrl: 'ServerUrl',
902
- tgaInitParams: {
903
- user_action_set_id: 100001,// Data source ID, number, required
904
- secret_key: '5e853xxxxxxd57a690xxxxxxxxxx',// Encryption key, required
905
- appid: 'wx123xyz123xyz123x',// WeChat Mini Game APPID, starts with wx, required
906
- },
907
- reportingToTencentSdk: 2,//1 Only report to Tencent 2 Report to Tencent and TE 3 Only report to TE
908
- debugMode: 'debug'// If debug mode, will print Tencent Advertising SDK local debug logs
909
- })
910
- ```
911
-
912
- 1. Set User ID
913
-
914
- - setOpenId
915
- openid is usually obtained asynchronously by calling backend interface (get openid method). Please call _ sdk.setOpenId() _ method to set after obtaining openid. Only one of openid and unionid can be set, openid is preferred.
916
-
917
- ```
918
- TDAnalytics.init({
919
- appId: 'AppId',
920
- serverUrl: 'ServerUrl',
921
- tgaInitParams: {
922
- user_action_set_id: 100001,// Data source ID, number, required
923
- secret_key: '5e853xxxxxxd57a690xxxxxxxxxx',// Encryption key, required
924
- appid: 'wx123xyz123xyz123x',// WeChat Mini Game APPID, starts with wx, required
925
- openId:'wx_openid'// WeChat platform OpenId
926
- },
927
- reportingToTencentSdk: 2,//1 Only report to Tencent 2 Report to Tencent and TE 3 Only report to TE
928
- debugMode: 'debug'// If debug mode, will print Tencent Advertising SDK local debug logs
929
- })
930
- ```
931
-
932
- - setUnionId
933
- unionid is usually obtained asynchronously by calling backend interface (get unionid method). Please call _ sdk.setUnionId() _ method to set after obtaining unionid. Use this method to set unionid only when openid is not available.
934
-
935
- ```
936
- TDAnalytics.init({
937
- appId: 'AppId',
938
- serverUrl: 'ServerUrl',
939
- tgaInitParams: {
940
- user_action_set_id: 100001,// Data source ID, number, required
941
- secret_key: '5e853xxxxxxd57a690xxxxxxxxxx',// Encryption key, required
942
- appid: 'wx123xyz123xyz123x',// WeChat Mini Game APPID, starts with wx, required
943
- unionId:'wx_unionId'// WeChat platform unionId
944
- },
945
- reportingToTencentSdk: 2,//1 Only report to Tencent 2 Report to Tencent and TE 3 Only report to TE
946
- debugMode: 'debug'// If debug mode, will print Tencent Advertising SDK local debug logs
947
- })
948
- ```
949
-
950
- 1. Report Behavior
951
-
952
- ```
953
- TDAnalytics.track({
954
- eventName: "product_buy", // Event name
955
- properties: {
956
- product_name: "product name"
957
- } // Event properties
958
- });
959
- ```
960
-
961
- For the following specific events, need to report with specified event name
962
-
963
- Event
964
-
965
- Event Name
966
-
967
- Event Properties (must include the key)
968
-
969
- ##### Mini Game Startup
970
-
971
- ##### START_APP
972
-
973
- None
974
-
975
- ##### Payment
976
-
977
- ##### PURCHASE
978
-
979
- {
980
-
981
- value: 600
982
-
983
- }
984
-
985
- ##### Registration
986
-
987
- ##### REGISTER
988
-
989
- ##### Silent Wake
990
-
991
- ##### RE_ACTIVE
992
-
993
- {
994
-
995
- backFlowDay: 30
996
-
997
- }
998
-
999
- ##### Favorite Mini Game
1000
-
1001
- ##### ADD_TO_WISHLIST
1002
-
1003
- {
1004
-
1005
- type: 'default',
1006
-
1007
- }
1008
-
1009
- ##### Share Mini Game
1010
-
1011
- ##### SHARE
1012
-
1013
- {
1014
-
1015
- target: 'APP_MESSAGE'
1016
-
1017
- }
1018
-
1019
- ##### Create Character
1020
-
1021
- ##### CREATE_ROL
1022
-
1023
- {
1024
-
1025
- name: 'SuperMan'
1026
-
1027
- }
1028
-
1029
- ##### Complete Tutorial
1030
-
1031
- ##### TUTORIAL_FINISH
1032
-
1033
- None
1034
-
1035
- ##### Game Level Up
1036
-
1037
- ##### UPDATE_LEVEL
1038
-
1039
- {
1040
-
1041
- level: 2,
1042
-
1043
- power: 85,
1044
-
1045
- }
1046
-
1047
- ##### View Mall Page
1048
-
1049
- ##### VIEW_CONTENT
1050
-
1051
- {
1052
-
1053
- // Key scene visit: Mall
1054
-
1055
- item: 'Mall',
1056
-
1057
- }
1058
-
1059
- ##### View Game Activity
1060
-
1061
- ##### VIEW_CONTENT
1062
-
1063
- {
1064
-
1065
- // Key scene visit: Activity
1066
-
1067
- item: 'Activity',
1068
-
1069
- }
1070
-
1071
- For example, report game level up event
1072
-
1073
- ```
1074
- TDAnalytics.track({
1075
- eventName: "UPDATE_LEVEL",
1076
- properties: {
1077
- level: 2,
1078
- power: 85,
1079
- }
1080
- });
1081
- ```
1082
-
1083
- ---
1084
-
1085
- # Multi Instance
1086
-
1087
- Since v1.3.0, this SDK supports multi instances. We call the instance ta that is initialized through the method described above as main instance, and instances created through the method described in this section as sub instances.
1088
-
1089
- Multiple instances share device related preset properties (including device ID), other properties are not shared, including:
1090
-
1091
- - `#distinct_id` visitor ID
1092
- - `#account_id` account ID
1093
- - Common event properties, dynamic common properties
1094
- - `timeEvent` monitored events
1095
- You can create sub instance to report data to another project, or report data with another set of user IDs.
1096
-
1097
- ```
1098
- // Initialize configuration 1
1099
- var config_1 = {
1100
- appId: "app-id-1",
1101
- serverUrl: "https://youserverurl.1.com"
1102
- };
1103
- TDAnalytics.init(config_1);
1104
-
1105
- // Initialize configuration 2
1106
- var config_2 = {
1107
- appId: "app-id-2",
1108
- serverUrl: "https://youserverurl.2.com"
1109
- };
1110
- TDAnalytics.init(config_2);
1111
-
1112
- // Report event to configuration 1 (no app-id passed, default report to configuration 1)
1113
- TDAnalytics.track({
1114
- eventName: 'event_from_appid_1'
1115
- });
1116
- // Report event to configuration 1 (specify app-id-1)
1117
- TDAnalytics.track({
1118
- eventName: 'event_from_appid_1'
1119
- }, 'app-id-1');
1120
- // Report event to configuration 2 (specify app-id-2)
1121
- TDAnalytics.track({
1122
- eventName: 'event_from_appid_2'
1123
- }, 'app-id-2');
1124
- ```
1125
-
1126
- If you need each instance's persistence data to be stored separately, you can set `persistenceName` in config to customize storage path
1127
-
1128
- ```
1129
- var config = {
1130
- appId: "app-id-1",
1131
- serverUrl: "https://youserverurl.1.com",
1132
- persistenceName:"persistence_name" // Can be customized, needs to be different for each instance
1133
- };
1134
- TDAnalytics.init(config);
1135
- ```
1136
-
1137
- If you need to create sub instance for the same AppId, you can use `initInstance` to set instance alias. These two instances report data to the same appId, but use different initialization configuration info. For example, configuration 1 uses normal mode to report data, configuration 2 uses Batch mode to report data.
1138
-
1139
- Example code:
1140
-
1141
- ```
1142
- // Initialize configuration 1
1143
- TDAnalytics.init({
1144
- appId: "app-id-1",
1145
- serverUrl: "https://youserverurl.1.com"
1146
- });
1147
-
1148
- // Initialize configuration 2
1149
- TDAnalytics.initInstance("td",{
1150
- appId: "app-id-1",
1151
- serverUrl: "https://youserverurl.1.com",
1152
- enableBatch: true
1153
- });
1154
- ```
1155
-
1156
- ---
1157
-
1158
- # Real-time Debugging
1159
-
1160
- During SDK integration, you can perform real-time debugging by viewing SDK logs in IDE console or using TE's Debug function.
1161
-
1162
- ### 1. Print SDK Logs
1163
-
1164
- You can set enableLog to true during SDK initialization to enable SDK log switch. After enabling, reported data will be printed in browser console.
1165
-
1166
- ```
1167
- var config = {
1168
- appId: "xxx",
1169
- serverUrl: "xxx",
1170
- enableLog:true
1171
- };
1172
- TDAnalytics.init(config);
1173
- ```
1174
-
1175
- ### 2. Enable Debug Mode
1176
-
1177
- Enabling Debug mode requires the following two steps:
1178
-
1179
- 1. Client enables Debug mode
1180
- The following is example code for client enabling Debug mode:
1181
-
1182
- ```
1183
- /*
1184
- Set running mode to Debug mode
1185
- none: Data will be cached and reported according to certain cache strategy, default is NORMAL mode; recommended for production environment
1186
- debug: Data is reported one by one. When problems occur, logs and exceptions will be displayed to users; not recommended for production environment
1187
- debugOnly: Only validates data, will not be stored in database; not recommended for production environment
1188
- */
1189
- var config = {
1190
- appid: "YOUR_APPID",
1191
- server_url: "YOUR_SERVER_URL",
1192
- debugMode: "debug"
1193
- };
1194
- TDAnalytics.init(config);
1195
- ```
1196
-
1197
- 1. TE backend adds Debug device
1198
- To avoid Debug mode going live in production environment, only specified devices can enable Debug mode. Only when Debug mode is enabled on client and the device ID is configured in TE backend's "Tracking Management" page's "Debug Data" section can Debug mode be enabled.
1199
-
1200
- Device ID can be obtained through the following three ways:
1201
-
1202
- - #device_id property in event data in TE platform
1203
- - Client log: Device DeviceId will be printed after SDK initialization completes
1204
- - Through instance interface call: Get device ID
1205
- <!-- unsupported block: 34 -->
1206
-
1207
- Debug mode may affect data collection quality and App stability, only use for integration phase data validation, do not use in production environment.
1208
-
1209
- ---
1210
-
1211
- # Auto Tracking
1212
-
1213
- After version 1.2.0, we provide auto tracking function. You just need to enable the auto tracking events you need in the config when creating instance. SDK will automatically collect some behaviors of mini program. Currently, the following events support auto tracking:
1214
-
1215
- Current supported automatic data collection:
1216
-
1217
- 1. Mini program initialization, triggers once per user session
1218
- 1. Mini program startup, including startup and background to foreground
1219
- 1. Mini program to background, and record this visit duration (from startup to background)
1220
- 1. Mini program page show or switch to foreground, automatically record page path and referrer path
1221
- 1. Mini program forward/share, automatically record the page when forwarding
1222
- 1. Mini program page unload, automatically record when page unloads (supported in version 3.2.0 and above)
1223
- 1. Mini program page favorite, automatically record when page is favorited (supported in version 3.2.0 and above)
1224
- 1. Mini program page element click, automatically record when page element is clicked (supported in version 3.2.0 and above)
1225
- Next, we will introduce each data collection method in detail
1226
-
1227
- ### 1. Enable Auto Tracking Events
1228
-
1229
- In config, elements in parameter `autoTrack` represent switch for each auto tracking event. Set to `true` to enable auto tracking:
1230
-
1231
- ```
1232
- var config = {
1233
- appid: "YOU-APP-ID",
1234
- server_url: "https://youserverurl.com",
1235
- autoTrack: {
1236
- appLaunch: true, // Auto track ta_mp_launch
1237
- appShow: true, // Auto track ta_mp_show
1238
- appHide: true, // Auto track ta_mp_hide
1239
- pageShow: true, // Auto track ta_mp_view
1240
- pageShare: true, // Auto track ta_mp_share
1241
- pageLeave: true,// Auto track ta_page_leave
1242
- mpFavorite: true,// Auto track ta_add_favorite
1243
- mpClick: true,// Auto track ta_mp_click
1244
- properties: { // Auto tracking custom properties
1245
- staticKey: 'staticValue'
1246
- },
1247
- callback: (eventType:any) => { // Auto tracking callback
1248
- if (eventType === 'appShow') {
1249
- return { appShowKey: 'appShowValue' };
1250
- } else if (eventType === 'appHide') {
1251
- return { appHideKey: 'appHideValue' };
1252
- } else {
1253
- return {};
1254
- }
1255
- }
1256
- }
1257
- };
1258
- ```
1259
-
1260
- - `appLaunch`: Auto track mini program initialization
1261
- - `appShow`: Auto track mini program startup, or from background to foreground
1262
- - `appHide`: Auto track mini program from foreground to background
1263
- - `pageShow`: Auto track mini program page show or switch to foreground
1264
- - `pageShare`: Auto track mini program forward/share
1265
- - `pageLeave`: Auto track mini program page unload
1266
- - `mpFavorite`: Auto track page favorite
1267
- - `mpClick`: Auto track page element click
1268
- - `properties`: Auto tracking custom properties (supports appShow/appHide)
1269
- - `callback`: Auto tracking callback (supports appShow/appHide)
1270
- Due to different running environments and structures, different platforms support different auto tracking events. Support list as follows:
1271
-
1272
- **Platform**
1273
-
1274
- **appLaunch**
1275
-
1276
- **appShow**
1277
-
1278
- **appHide**
1279
-
1280
- **pageShow**
1281
-
1282
- **pageShare**
1283
-
1284
- **pageLeave**
1285
-
1286
- **mpFavorite**
1287
-
1288
- **mpClick**
1289
-
1290
- Mini Program
1291
-
1292
- √
1293
-
1294
- √
1295
-
1296
- √
1297
-
1298
- √
1299
-
1300
- √
1301
-
1302
- √
1303
-
1304
- √
1305
-
1306
- √
1307
-
1308
- Mini Game
1309
-
1310
- √
1311
-
1312
- √
1313
-
1314
- √
1315
-
1316
- ### 2. Auto Tracking Events Details
1317
-
1318
- #### 2.1 Mini Program Initialization
1319
-
1320
- Mini program initialization will trigger when mini program is first opened, or user kills process and reopens. It will only trigger once in process lifecycle. Detailed event introduction:
1321
-
1322
- - Event name: ta_mp_launch
1323
- - Auto tracking properties:
1324
- - `#scene`: Scene value, from scene value provided by WeChat
1325
- - `#start_reason`: App startup source, content is JSON string, parameters obtained from `getLaunchOptionsSync` interface
1326
- Through mini program initialization event, you can calculate daily user usage count, per capita usage count, including grouping by scene value to view user usage for different scene values.
1327
-
1328
- #### 2.2 Mini Program Startup
1329
-
1330
- Mini program startup will trigger when mini program is started, or mini program is called from background to foreground. Detailed event introduction:
1331
-
1332
- - Event name: ta_mp_show
1333
- - Auto tracking properties:
1334
- - `#scene`, scene value, from scene value provided by WeChat
1335
- - `#url_path`, page path, path of page shown when mini program starts
1336
- - `#start_reason`: App startup source, content is JSON string, parameters obtained from `getLaunchOptionsSync` interface
1337
- Mini program startup is affected by foreground/background switching (more records), so it's not suitable for direct analysis. But it can mark a user session in behavior path, can be used as initial behavior of user behavior path.
1338
-
1339
- #### 2.3 Mini Program Hide
1340
-
1341
- Mini program hide will trigger when mini program is put to background, and record this usage duration. Detailed event introduction:
1342
-
1343
- - Event name: ta_mp_hide
1344
- - Auto tracking properties:
1345
- - `#scene`, scene value, from scene value provided by WeChat
1346
- - `#duration`, numeric type, represents duration from this startup (ta_mp_show) to hide
1347
- Mini program hide event records usage duration (unit is seconds), so you can directly calculate total user usage duration and per capita duration, can also divide by initialization count to calculate single usage duration.
1348
-
1349
- #### 2.4 Mini Program Page View
1350
-
1351
- Mini program page view will trigger when mini program page is opened, or mini program page is shown when called from background to foreground. It records page path and referrer path. Detailed event introduction:
1352
-
1353
- - Event name: ta_mp_view
1354
- - Auto tracking properties:
1355
- - `#scene`, scene value, from scene value provided by WeChat
1356
- - `#url_path`, page path, path of shown page
1357
- - `#referrer`, referrer path, path of previous page before shown page, i.e. path before redirect. If it's the homepage shown when starting mini program, value is "direct open"
1358
- Through mini program page view event, you can calculate each page's pv, uv, and user's usage path in mini program.
1359
-
1360
- #### 2.5 Mini Program Page Forward/Share
1361
-
1362
- Mini program page forward/share will trigger when forward button is clicked (including forward button in upper right navigation bar, and forward button in page). Detailed event introduction:
1363
-
1364
- - Event name: ta_mp_share
1365
- - Auto tracking properties:
1366
- - `#scene`, scene value, from scene value provided by WeChat
1367
- - `#url_path`, page path, path of page when forwarding
1368
- Mini program page forward/share event is suitable for analyzing page share rate, can help you optimize page forwarding.
1369
-
1370
- #### 2.6 Mini Program Page Unload
1371
-
1372
- Triggers when mini program page is unloaded (e.g. going to other pages). Detailed event introduction:
1373
-
1374
- - Event name: ta_page_leave
1375
- - Auto tracking properties:
1376
- - `#duration`, page stay duration
1377
- - `#url_path`, page path, path when page is unloaded
1378
-
1379
- #### 2.7 Mini Program Page Favorite
1380
-
1381
- Triggers when mini program page is favorited. Detailed event introduction:
1382
-
1383
- - Event name: ta_add_favorite
1384
- - Auto tracking properties:
1385
- - `#url_path`, page path, path when page is unloaded
1386
-
1387
- #### 2.7 Mini Program Page Element Click
1388
-
1389
- Triggers when mini program page element is clicked. Detailed event introduction:
1390
-
1391
- - Event name: ta_mp_click
1392
- - Auto tracking properties:
1393
- - `#element_id`, element ID
1394
- - `#element_type`, element type
1395
- - `#element_content`, element content
1396
- - `#element_name`, element name
1397
-
1398
- ---
1399
-
1400
- # Preset Properties
1401
-
1402
- ### 1. Preset Properties for All Events
1403
-
1404
- The following preset properties are preset properties that all events (including auto tracking events) will have in Mini Program/Mini Game SDK
1405
-
1406
- **Property Name**
1407
-
1408
- **English Name**
1409
-
1410
- **Property Type**
1411
-
1412
- **Description**
1413
-
1414
- #ip
1415
-
1416
- IP Address
1417
-
1418
- Text
1419
-
1420
- User's IP address, TE will use this to obtain user's geographic location information
1421
-
1422
- #country
1423
-
1424
- Country
1425
-
1426
- Text
1427
-
1428
- User's country, generated based on IP address
1429
-
1430
- #country_code
1431
-
1432
- Country Code
1433
-
1434
- Text
1435
-
1436
- User's country code (ISO 3166-1 alpha-2, i.e. two uppercase English letters), generated based on IP address
1437
-
1438
- #province
1439
-
1440
- Province
1441
-
1442
- Text
1443
-
1444
- User's province, generated based on IP address
1445
-
1446
- #city
1447
-
1448
- City
1449
-
1450
- Text
1451
-
1452
- User's city, generated based on IP address
1453
-
1454
- #device_model
1455
-
1456
- Device Model
1457
-
1458
- Text
1459
-
1460
- User device's model, such as iPhone 8 etc.
1461
-
1462
- #device_id
1463
-
1464
- Device ID
1465
-
1466
- Text
1467
-
1468
- User's device ID, UUID generated during initialization
1469
-
1470
- #screen_height
1471
-
1472
- Screen Height
1473
-
1474
- Numeric
1475
-
1476
- User device's screen height, such as 1920 etc.
1477
-
1478
- #screen_width
1479
-
1480
- Screen Width
1481
-
1482
- Numeric
1483
-
1484
- User device's screen width, such as 1080 etc.
1485
-
1486
- #manufacturer
1487
-
1488
- Device Manufacturer
1489
-
1490
- Text
1491
-
1492
- User device's manufacturer, such as Apple, vivo etc.
1493
-
1494
- #os_version
1495
-
1496
- Operating System Version
1497
-
1498
- Text
1499
-
1500
- iOS 11.2.2, Android 8.0.0 etc.
1501
-
1502
- #os
1503
-
1504
- Operating System
1505
-
1506
- Text
1507
-
1508
- Such as Android, iOS etc.
1509
-
1510
- #network_type
1511
-
1512
- Network Type
1513
-
1514
- Text
1515
-
1516
- Network status when uploading event, such as WIFI, 3G, 4G etc.
1517
-
1518
- #lib
1519
-
1520
- SDK Type
1521
-
1522
- Text
1523
-
1524
- The type of SDK you integrated, such as MP (Mini Program), MG (Mini Game) etc.
1525
-
1526
- #lib_version
1527
-
1528
- SDK Version
1529
-
1530
- Text
1531
-
1532
- The version of SDK you integrated
1533
-
1534
- #scene
1535
-
1536
- Scene Value
1537
-
1538
- Numeric
1539
-
1540
- Scene value passed when mini program/mini game starts
1541
-
1542
- #mp_platform
1543
-
1544
- Mini Program Platform
1545
-
1546
- Text
1547
-
1548
- Identifies the platform where the app is located
1549
-
1550
- #zone_offset
1551
-
1552
- Timezone Offset
1553
-
1554
- Numeric
1555
-
1556
- Data time offset hours relative to UTC time
1557
-
1558
- #system_language
1559
-
1560
- System Language
1561
-
1562
- Text
1563
-
1564
- User device's system language (ISO 639-1, i.e. two lowercase English letters), such as zh, en etc.
1565
-
1566
- ### 2. Preset Properties for Auto Tracking Events
1567
-
1568
- The following preset properties are unique preset properties for each auto tracking event
1569
-
1570
- - Mini Program Startup (ta_mp_show) preset properties
1571
- **Property Name**
1572
-
1573
- **English Name**
1574
-
1575
- **Property Type**
1576
-
1577
- **Description**
1578
-
1579
- #url_path
1580
-
1581
- Page Path
1582
-
1583
- Text
1584
-
1585
- Path of page shown when mini program starts
1586
-
1587
- #start_reason
1588
-
1589
- App Startup Source
1590
-
1591
- Text
1592
-
1593
- Content is JSON string, parameters obtained from `getLaunchOptionsSync` interface
1594
-
1595
- - Mini Program Hide (ta_mp_hide) preset properties
1596
- **Property Name**
1597
-
1598
- **English Name**
1599
-
1600
- **Property Type**
1601
-
1602
- **Description**
1603
-
1604
- #duration
1605
-
1606
- Event Duration
1607
-
1608
- Numeric
1609
-
1610
- Represents duration from this startup `ta_mp_show` to hide `ta_mp_hide`, unit is seconds
1611
-
1612
- - Mini Program Page View (ta_mp_view) preset properties
1613
- **Property Name**
1614
-
1615
- **English Name**
1616
-
1617
- **Property Type**
1618
-
1619
- **Description**
1620
-
1621
- #url_path
1622
-
1623
- Page Path
1624
-
1625
- Text
1626
-
1627
- Page path, path of shown page
1628
-
1629
- #referrer
1630
-
1631
- Referrer Path
1632
-
1633
- Text
1634
-
1635
- Path of previous page before shown page, i.e. path before redirect. If it's the homepage shown when starting mini program, value is "direct open"
1636
-
1637
- - Mini Program Page Forward/Share (ta_mp_share) preset properties
1638
- **Property Name**
1639
-
1640
- **English Name**
1641
-
1642
- **Property Type**
1643
-
1644
- **Description**
1645
-
1646
- #url_path
1647
-
1648
- Page Path
1649
-
1650
- Text
1651
-
1652
- Path of mini program page when forwarded
1653
-
1654
- ### 3. Get Preset Properties
1655
-
1656
- When server-side tracking needs some preset properties from App client side, you can get client-side preset properties through this method, then pass to server side.
1657
-
1658
- ```
1659
- // Get property object
1660
- var presetProperties = TDAnalytics.getPresetProperties();
1661
- // Generate event preset properties
1662
- var properties = presetProperties.toEventPresetProperties();
1663
- /*
1664
- {
1665
- "#device_model":"iPhone 5",
1666
- "#device_id":"3204487163-1624513721217",
1667
- "#screen_width":320,
1668
- "#screen_height":568,
1669
- "#os":"iOS",
1670
- "#os_version":"10.0.1",
1671
- "#network_type":"wifi",
1672
- "#zone_offset":8,
1673
- "#manufacturer":"Apple"
1674
- }
1675
- */
1676
- // Get a specific preset property
1677
- var os=presetProperties.os;// OS type, such as Android
1678
- var osVersion=presetProperties.osVersion;// System version number
1679
- var networkType=presetProperties.networkType;// Network type
1680
- var manufacture=presetProperties.manufacturer;// Device manufacturer
1681
- var deviceModel=presetProperties.deviceModel;// Device model
1682
- var screenWidth=presetProperties.screenWidth;// Screen width
1683
- var screenHeight=presetProperties.screenHeight;// Screen height
1684
- var deviceId=presetProperties.deviceId;// Device ID
1685
- var zoneOffset=presetProperties.zoneOffset;// Timezone offset value
1686
- ```
1687
-
1688
- <!-- unsupported block: 34 -->
1689
-
1690
- IP, country and city information are parsed and generated by server side, client side does not provide interface to get these properties
1691
-
1692
- ###