@thinkingai/ae-cli 6.0.58 → 6.0.60

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 (253) hide show
  1. package/README.md +10 -5
  2. package/README.zh.md +10 -5
  3. package/bin/ai-monitor.js +2 -0
  4. package/dist/ai-monitor-FCXSLHAP.js +32 -0
  5. package/dist/ai-monitor.js +135 -0
  6. package/dist/{auth-A5OO4VS4.js → auth-ATK2SLEV.js} +10 -9
  7. package/dist/{automation-FD2QZUP6.js → automation-FLCPFMN4.js} +4 -4
  8. package/dist/{capability-SKI4GHF4.js → capability-6KTSOI7L.js} +31 -35
  9. package/dist/{chunk-UYJMEHAF.js → chunk-2ETRY2CU.js} +15 -15
  10. package/dist/{chunk-QWSA3EOD.js → chunk-5E7MTTFN.js} +2 -2
  11. package/dist/{chunk-JSBLCLFE.js → chunk-5M5LBRR3.js} +1 -1
  12. package/dist/chunk-6M7ZEDT2.js +182 -0
  13. package/dist/{chunk-KPQY44JQ.js → chunk-AWW2T2WL.js} +3 -0
  14. package/dist/chunk-AXTO4FTM.js +1285 -0
  15. package/dist/{chunk-HQCY3QCA.js → chunk-BEYLCUZX.js} +17 -12
  16. package/dist/chunk-CF6JTT2U.js +64 -0
  17. package/dist/{chunk-VDICGXCY.js → chunk-F2VFZUGG.js} +2 -2
  18. package/dist/{chunk-K2Z7QHDR.js → chunk-HSZAIPUX.js} +47 -12
  19. package/dist/{chunk-SOSFRU3O.js → chunk-HTZ2MLYA.js} +47 -21
  20. package/dist/{chunk-AWVZTN2B.js → chunk-HVMCPKOZ.js} +1 -1
  21. package/dist/{chunk-E25OSZLJ.js → chunk-KTJXD27G.js} +2 -2
  22. package/dist/{chunk-GBSACKFB.js → chunk-LOR4IA26.js} +564 -314
  23. package/dist/{chunk-YVG6QD3V.js → chunk-P7QDCWJ6.js} +98 -7
  24. package/dist/{chunk-EEARZNHE.js → chunk-SDKW6LYE.js} +88 -36
  25. package/dist/{chunk-WMDO53YK.js → chunk-VJUXKVRE.js} +1 -1
  26. package/dist/chunk-VRMGHQKE.js +556 -0
  27. package/dist/{compat-check-WFEKVLTH.js → compat-check-XD2U7PZ2.js} +2 -2
  28. package/dist/{config-U4I7X25P.js → config-U3GDWU6E.js} +25 -12
  29. package/dist/{context-CDB5H5PD.js → context-YAQG6YQC.js} +2 -2
  30. package/dist/{evaluation-LR4YDYWL.js → evaluation-2JSF4V47.js} +13 -158
  31. package/dist/index.js +84 -579
  32. package/dist/{memory-SNFR5M23.js → memory-WEB27VI6.js} +7 -7
  33. package/dist/{metadata-6QM6EED5.js → metadata-7FYE4234.js} +7 -7
  34. package/dist/{model-KEVCEXWD.js → model-T7H7Q6BG.js} +2 -2
  35. package/dist/{personal-semantic-preference-7VXQPP2N.js → personal-semantic-preference-O6VXM74A.js} +6 -6
  36. package/dist/{project-semantic-PSEPYH2L.js → project-semantic-2GGFJWW6.js} +15 -13
  37. package/dist/{sync-22ACDK5Z.js → sync-ULBB7WO5.js} +4 -4
  38. package/dist/{te-agent-BJ36B4QI.js → te-agent-6RMF7LUV.js} +5 -5
  39. package/dist/{te-analysis-WQ6D6YG4.js → te-analysis-HSYC7GNV.js} +382 -193
  40. package/dist/{te-community-VRWMFGI6.js → te-community-FLKZGQKB.js} +9 -9
  41. package/dist/{te-dataops-YTLFTTW7.js → te-dataops-OQQGTCUA.js} +3 -3
  42. package/dist/{te-engage-V2QW7TIC.js → te-engage-RIEBHL5T.js} +9 -9
  43. package/dist/{te-kb-4AQLISDR.js → te-kb-4HG2FMHJ.js} +18 -9
  44. package/dist/{te-system-CYWSK3UN.js → te-system-AL4B4XZL.js} +2 -2
  45. package/dist/{te-team-6ELNGBWT.js → te-team-5O4UVUWE.js} +5 -5
  46. package/dist/{things-HFWLGCUH.js → things-TSJ64GBT.js} +5 -5
  47. package/dist/{update-3CRVVHV5.js → update-Q5LURAWV.js} +3 -3
  48. package/dist/{workspace-2CKQX2XL.js → workspace-FF2HXJGR.js} +4 -4
  49. package/package.json +8 -6
  50. package/skills/ae-ai-monitor/SKILL.md +179 -0
  51. package/skills/ae-ai-monitor/references/read-commands.md +866 -0
  52. package/skills/ae-analysis/SKILL.md +10 -4
  53. package/skills/ae-analysis/references/adhoc_export.md +3 -1
  54. package/skills/ae-analysis/references/ai_models.md +1 -0
  55. package/skills/ae-analysis/references/analysis_gateway_assets.md +2 -0
  56. package/skills/ae-analysis/references/asset_search.md +1 -1
  57. package/skills/ae-analysis/references/bad_case_begin.md +12 -0
  58. package/skills/ae-analysis/references/bad_case_get.md +12 -0
  59. package/skills/ae-analysis/references/bad_case_history.md +12 -0
  60. package/skills/ae-analysis/references/bad_case_list.md +12 -0
  61. package/skills/ae-analysis/references/bad_case_review.md +51 -0
  62. package/skills/ae-analysis/references/bad_case_run.md +12 -0
  63. package/skills/ae-analysis/references/bad_case_submit.md +12 -0
  64. package/skills/ae-analysis/references/bad_case_submit_to_page.md +12 -0
  65. package/skills/ae-analysis/references/bad_case_sync_evaluation.md +11 -0
  66. package/skills/ae-analysis/references/bi_panel_list.md +1 -1
  67. package/skills/ae-analysis/references/bi_panel_share.md +3 -1
  68. package/skills/ae-analysis/references/catalog_list.md +2 -0
  69. package/skills/ae-analysis/references/command_index.md +38 -29
  70. package/skills/ae-analysis/references/dashboard_daily_report_update.md +2 -0
  71. package/skills/ae-analysis/references/dashboard_handover.md +3 -1
  72. package/skills/ae-analysis/references/dashboard_list.md +3 -3
  73. package/skills/ae-analysis/references/dashboard_report_data_export.md +1 -1
  74. package/skills/ae-analysis/references/dashboard_share.md +3 -1
  75. package/skills/ae-analysis/references/dashboard_update.md +3 -2
  76. package/skills/ae-analysis/references/filter_value_list.md +2 -0
  77. package/skills/ae-analysis/references/folder_share.md +8 -2
  78. package/skills/ae-analysis/references/governance_recommendation_run_update.md +3 -1
  79. package/skills/ae-analysis/references/project_data_power_upsert.md +3 -1
  80. package/skills/ae-analysis/references/project_mark_time_create.md +2 -0
  81. package/skills/ae-analysis/references/project_mark_time_update.md +2 -0
  82. package/skills/ae-analysis/references/project_member_add.md +3 -1
  83. package/skills/ae-analysis/references/project_member_batch_update.md +3 -1
  84. package/skills/ae-analysis/references/project_member_handover_run.md +3 -1
  85. package/skills/ae-analysis/references/project_member_update.md +3 -1
  86. package/skills/ae-analysis/references/project_owner_update.md +3 -1
  87. package/skills/ae-analysis/references/project_role_upsert.md +5 -3
  88. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +16 -1
  89. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +14 -1
  90. package/skills/ae-analysis/references/project_space_share.md +8 -2
  91. package/skills/ae-analysis/references/property_get.md +2 -0
  92. package/skills/ae-analysis/references/public_link_list.md +3 -1
  93. package/skills/ae-analysis/references/query_cancel.md +4 -1
  94. package/skills/ae-analysis/references/report_data_run.md +1 -1
  95. package/skills/ae-analysis/references/report_list.md +3 -3
  96. package/skills/ae-analysis/references/scenario_append.md +2 -2
  97. package/skills/ae-analysis/references/scenario_collect.md +15 -4
  98. package/skills/ae-analysis/references/scenario_list.md +2 -1
  99. package/skills/ae-analysis/references/system_oauth2_update.md +3 -1
  100. package/skills/ae-analysis/references/system_third_party_login_upsert.md +4 -2
  101. package/skills/ae-analysis/references/user_tag_create.md +4 -1
  102. package/skills/ae-analysis/references/user_tag_get.md +2 -0
  103. package/skills/ae-analysis/references/user_tag_models.md +8 -2
  104. package/skills/ae-analysis/references/user_tag_update.md +5 -2
  105. package/skills/ae-analysis/references/virtual_property_create.md +12 -1
  106. package/skills/ae-analysis/references/virtual_property_sql_rule_update.md +10 -0
  107. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +55 -13
  108. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +2 -2
  109. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +2 -2
  110. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +7 -1
  111. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/wait-compile-run.mjs +79 -0
  112. package/skills/ae-automation/SKILL.md +4 -2
  113. package/skills/ae-capability/SKILL.md +9 -5
  114. package/skills/ae-community/SKILL.md +1 -0
  115. package/skills/ae-dataops/SKILL.md +1 -0
  116. package/skills/ae-engage/SKILL.md +1 -0
  117. package/skills/ae-evaluation/SKILL.md +17 -2
  118. package/skills/ae-generate-tracking-plan/SKILL.md +5 -0
  119. package/skills/ae-kb/SKILL.md +5 -3
  120. package/skills/ae-kb/references/analysis-workflow.md +11 -2
  121. package/skills/ae-kb/references/query-workflow.md +3 -1
  122. package/skills/ae-kb/references/versions.md +1 -1
  123. package/skills/ae-metadata/SKILL.md +1 -0
  124. package/skills/ae-migrate-tracking-code/SKILL.md +2 -1
  125. package/skills/ae-team/SKILL.md +1 -1
  126. package/skills/ae-tracking-matrix/SKILL.md +170 -0
  127. package/skills/ae-tracking-matrix/assets//345/237/213/347/202/271/346/250/241/347/211/210.xlsx +0 -0
  128. package/skills/ae-tracking-matrix/i18n.yaml +12 -0
  129. package/skills/ae-tracking-matrix/references/ae-capabilities.md +93 -0
  130. package/skills/ae-tracking-matrix/references/business-semantic-checks.md +30 -0
  131. package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +256 -0
  132. package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +213 -0
  133. package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +407 -0
  134. package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +218 -0
  135. package/skills/ae-tracking-matrix/references/categories/casual_music.md +112 -0
  136. package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +301 -0
  137. package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +356 -0
  138. package/skills/ae-tracking-matrix/references/categories/fishing.md +775 -0
  139. package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +89 -0
  140. package/skills/ae-tracking-matrix/references/categories/idle_card.md +27 -0
  141. package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +415 -0
  142. package/skills/ae-tracking-matrix/references/categories/interactive_video.md +133 -0
  143. package/skills/ae-tracking-matrix/references/categories/merge.md +639 -0
  144. package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +406 -0
  145. package/skills/ae-tracking-matrix/references/categories/mmo_web.md +230 -0
  146. package/skills/ae-tracking-matrix/references/categories/music.md +137 -0
  147. package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +414 -0
  148. package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +199 -0
  149. package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +158 -0
  150. package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +546 -0
  151. package/skills/ae-tracking-matrix/references/categories/rpg.md +195 -0
  152. package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +115 -0
  153. package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +151 -0
  154. package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +260 -0
  155. package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +232 -0
  156. package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +359 -0
  157. package/skills/ae-tracking-matrix/references/categories/tower_defense.md +365 -0
  158. package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +211 -0
  159. package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +132 -0
  160. package/skills/ae-tracking-matrix/references/category-registry.md +77 -0
  161. package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +230 -0
  162. package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +406 -0
  163. package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +128 -0
  164. package/skills/ae-tracking-matrix/references/eval-cases.md +74 -0
  165. package/skills/ae-tracking-matrix/references/naming-dict.md +238 -0
  166. package/skills/ae-tracking-matrix/references/optimization-checklist.md +85 -0
  167. package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +142 -0
  168. package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +47 -0
  169. package/skills/ae-tracking-matrix/references/plan-generation/reference.md +794 -0
  170. package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +94 -0
  171. package/skills/ae-tracking-matrix/references/scene-routing.md +80 -0
  172. package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +3787 -0
  173. package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +827 -0
  174. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +655 -0
  175. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +953 -0
  176. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +1128 -0
  177. package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +714 -0
  178. package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +1268 -0
  179. package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +776 -0
  180. package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +182 -0
  181. package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +2755 -0
  182. package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +1182 -0
  183. package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +1300 -0
  184. package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +1369 -0
  185. package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +1692 -0
  186. package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +902 -0
  187. package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +763 -0
  188. package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +1107 -0
  189. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +1532 -0
  190. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +845 -0
  191. package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +228 -0
  192. package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +149 -0
  193. package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +407 -0
  194. package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +163 -0
  195. package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +149 -0
  196. package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +153 -0
  197. package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +232 -0
  198. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +314 -0
  199. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +117 -0
  200. package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +148 -0
  201. package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +645 -0
  202. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +307 -0
  203. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +347 -0
  204. package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +72 -0
  205. package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +264 -0
  206. package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +566 -0
  207. package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +409 -0
  208. package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +446 -0
  209. package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +557 -0
  210. package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +457 -0
  211. package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +490 -0
  212. package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +523 -0
  213. package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +484 -0
  214. package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +442 -0
  215. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +391 -0
  216. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +91 -0
  217. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +635 -0
  218. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +113 -0
  219. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +466 -0
  220. package/skills/ae-tracking-matrix/references/standard-base/README.md +22 -0
  221. package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +174 -0
  222. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +20 -0
  223. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +7 -0
  224. package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +14 -0
  225. package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +370 -0
  226. package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +47 -0
  227. package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +37 -0
  228. package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +27 -0
  229. package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +23 -0
  230. package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +14 -0
  231. package/skills/ae-tracking-matrix/references/standard-base/user_data.md +46 -0
  232. package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +13 -0
  233. package/skills/ae-tracking-matrix/references/system-fields.md +297 -0
  234. package/skills/ae-tracking-matrix/references/te-field-translations.md +1791 -0
  235. package/skills/ae-tracking-matrix/references/workflows/data-verification.md +232 -0
  236. package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +829 -0
  237. package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +355 -0
  238. package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +283 -0
  239. package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +168 -0
  240. package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +205 -0
  241. package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +75 -0
  242. package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +36 -0
  243. package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +107 -0
  244. package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +114 -0
  245. package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +53 -0
  246. package/skills/ae-tracking-matrix/scripts/finalize_plan.py +166 -0
  247. package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +674 -0
  248. package/skills/ae-tracking-matrix/scripts/plan_contract.py +200 -0
  249. package/skills/ae-tracking-matrix/scripts/plan_types.py +60 -0
  250. package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +169 -0
  251. package/skills/ae-tracking-matrix/scripts/sync_plan.py +296 -0
  252. package/skills/ae-tracking-matrix/scripts/upload_plan.py +340 -0
  253. package/dist/chunk-AMBFK2K3.js +0 -28
@@ -0,0 +1,484 @@
1
+ ---
2
+ code: python_sdk_installation
3
+ name: "Python"
4
+ wikiToken: HsQ2wYZDripMsZkFc2wcz2Zhn06
5
+ parentWikiToken: O3YxwgHGiiEnvYkHCcIcX51inkf
6
+ updateTime: 1745310930000
7
+ sourceUrl: https://docs-v2.thinkingdata.cn/?version=6.0&lan=zh-CN&code=python_sdk_installation
8
+ ---
9
+
10
+ # Python
11
+
12
+ This guide will introduce how to use Python SDK to integrate into your project.
13
+
14
+ **Latest Version**: v3.0.0
15
+
16
+ **Update Date**: 2023-10-07
17
+
18
+ **Download**: Source Code
19
+
20
+ ::: warning Note
21
+
22
+ This document applies to v3.0.0 and later versions. For historical versions, please refer to Python SDK Integration Guide (V2).
23
+
24
+ :::
25
+
26
+ ### 1. SDK Integration
27
+
28
+ 1. Get Python SDK via `pip`
29
+
30
+ ```
31
+ pip install ThinkingDataSdk
32
+ ```
33
+
34
+ Upgrade command:
35
+
36
+ ```
37
+ pip install --upgrade ThinkingDataSdk
38
+ ```
39
+
40
+ 2. Install LogBus
41
+ We recommend using SDK + LogBus for server-side data collection and reporting. You can refer to the following documentation for LogBus installation: LogBus User Guide.
42
+
43
+ ### 2. Initialization
44
+
45
+ Here is sample code for SDK initialization:
46
+
47
+ ```
48
+ from tgasdk.sdk import *
49
+
50
+ consumer = TDLogConsumer("LOG_DIRECTORY", rotate_mode=TD_ROTATE_MODE.HOURLY, file_prefix="LOG_FILE_PREFIX")
51
+ te = TDAnalytics(consumer)
52
+ ```
53
+
54
+ `LOG_DIRECTORY` is the local folder address for writing. You just need to set LogBus's monitoring folder address to this address to use LogBus for data monitoring and uploading.
55
+
56
+ `LOG_FILE_PREFIX` is the prefix for log file names.
57
+
58
+ ### 3. Common Features
59
+
60
+ To ensure successful binding of visitor ID and account ID, if your game uses both visitor ID and account ID, we strongly recommend uploading both IDs. Otherwise, account matching issues may occur, leading to duplicate user counts. For specific ID binding rules, please refer to the User Identification Rules chapter.
61
+
62
+ #### 3.1 Track Events
63
+
64
+ You can call `track` to upload events. We recommend setting event properties and sending conditions based on your previously documented requirements. Here is sample code for tracking events:
65
+
66
+ ```
67
+ distinct_id = "ABCDEF123456"
68
+ account_id = "TE10001"
69
+ properties = {
70
+ "#time": datetime.datetime.now(),
71
+ # Set event occurrence time, if not set, defaults to current time
72
+ "#ip": "192.168.1.1",
73
+ # Set user IP, TDA will automatically parse province and city based on IP
74
+ # "#uuid":uuid.uuid1(),# Optional, if enable_uuid switch is on above, no need to fill
75
+ "Product_Name": "Product Name",
76
+ "Price": 30,
77
+ "OrderId": "Order ID abc_123"
78
+ }
79
+ # Upload event, including account ID and visitor ID
80
+ try:
81
+ te.track(distinct_id, account_id, "Payment", properties)
82
+ # You can also upload only visitor ID
83
+ # te.track(distinct_id = distinct_id, event_name = "Payment", properties = properties)
84
+ # Or upload only account ID
85
+ # te.track(account_id = account_id, event_name = "Payment", properties = properties)
86
+ except Exception as e:
87
+ # Exception handling
88
+ print(e)
89
+ ```
90
+
91
+ - Event name must be a string type, starting with a letter, containing numbers, letters, and underscores "\_", with maximum length of 50 characters.
92
+ - Key is the property name, must be a string type, starting with a letter, containing numbers, letters, and underscores "\_", with maximum length of 50 characters. Case-insensitive, TE will convert to lowercase.
93
+ - Value is the property value, supporting strings, numbers, booleans, dates, objects, object arrays, and arrays.
94
+
95
+ **User property requirements are consistent with event property requirements**
96
+
97
+ #### 3.2 Set User Properties
98
+
99
+ For general user properties, you can call `user_set` to set them. Properties uploaded via this interface will overwrite existing property values. If the user property does not exist previously, a new user property will be created with the same type as the uploaded property. Here is an example of setting a username:
100
+
101
+ ```
102
+ properties = {"user_name": "ABC"}
103
+ # Upload user property, "user_name" value is "ABC"
104
+ try:
105
+ te.user_set(account_id="account_id", distinct_id="distinct_id", properties=properties)
106
+ except Exception as e:
107
+ # Exception handling
108
+ print(e)
109
+ ```
110
+
111
+ #### 3.3 Data Reporting
112
+
113
+ When using TDLogConsumer, collected events are first converted to JSON strings and added to a cache array. Data is written to disk only when the array element count exceeds the set capacity. Default capacity limit is 5 data items. You can set buffer_size in TDLogConsumer constructor.
114
+
115
+ In certain business scenarios, if you want data to be reported to the TE server immediately, you can call the `flush()` interface. Note that frequent calls to `flush()` will cause service performance degradation.
116
+
117
+ ```
118
+ te.flush();
119
+ ```
120
+
121
+ #### 3.4 Close SDK
122
+
123
+ ```
124
+ te.close()
125
+ ```
126
+
127
+ Close and exit the SDK. Please call this interface before shutting down the server to avoid data loss in the cache.
128
+
129
+ ### 4. Best Practices
130
+
131
+ The following sample code includes all the above operations. We recommend using it as follows:
132
+
133
+ ```
134
+ from tgasdk.sdk import *
135
+
136
+ # Initialize SDK
137
+ te = TDAnalytics(TDLogConsumer("LOG_DIRECTORY"))
138
+
139
+ # Upload event, account ID and visitor ID cannot both be empty
140
+ properties = {
141
+ "#time": datetime.datetime.now(), # Set event occurrence time, if not set, defaults to current time
142
+ "#ip": "192.168.1.1", # Set user IP, TDA will automatically parse province and city based on IP
143
+ "Product_Name": "Product Name"
144
+ }
145
+ try:
146
+ te.track("distinct_id", "account_id", "Payment", properties)
147
+ except Exception as e:
148
+ # Exception handling
149
+ print(e)
150
+
151
+ # Upload user property, "user_name" value is "ABC"
152
+ user_properties = {"user_name": "ABC"}
153
+ try:
154
+ te.user_set(account_id="account_id", distinct_id="distinct_id", properties=user_properties)
155
+ except Exception as e:
156
+ # Exception handling
157
+ print(e)
158
+
159
+ # Calling flush interface will immediately write data to file. In production environment, avoid frequent flush calls to prevent IO or network overhead issues
160
+ te.flush()
161
+ ```
162
+
163
+ ---
164
+
165
+ # Advanced Guide
166
+
167
+ ### 1. Track Events
168
+
169
+ After SDK initialization, you can perform data tracking to collect user behavior information. Generally, regular events can meet business scenario requirements. You can also use first-time events, updateable events, etc. based on your actual business scenarios.
170
+
171
+ #### 1.1 Regular Events
172
+
173
+ You can call `track` to upload events. We recommend setting event properties and sending conditions based on your previously documented requirements. Here is an example of a user purchasing a product:
174
+
175
+ ```
176
+ distinct_id = "ABCDEF123456"
177
+ account_id = "TE10001"
178
+ properties = {
179
+ "#time": datetime.datetime.now(),
180
+ # Set event occurrence time, if not set, defaults to current time
181
+ "#ip": "192.168.1.1",
182
+ # Set user IP, TDA will automatically parse province and city based on IP
183
+ # "#uuid":uuid.uuid1(),# Optional, if enable_uuid switch is on above, no need to fill
184
+ "Product_Name": "Product Name",
185
+ "Price": 30,
186
+ "OrderId": "Order ID abc_123"
187
+ }
188
+
189
+ # Upload event, including account ID and visitor ID
190
+ try:
191
+ te.track(distinct_id, account_id, "Payment", properties)
192
+ # You can also upload only visitor ID
193
+ # te.track(distinct_id = distinct_id, event_name = "Payment", properties = properties)
194
+ # Or upload only account ID
195
+ # te.track(account_id = account_id, event_name = "Payment", properties = properties)
196
+ except Exception as e:
197
+ # Exception handling
198
+ print(e)
199
+ ```
200
+
201
+ #### 1.2 First-Time Events
202
+
203
+ First-time events are events that are recorded only once for a specific device or other dimensional ID. For example, in some scenarios, you may want to record an activation event on a specific device, which can be reported using a first-time event.
204
+
205
+ ```
206
+ # Call first-time event
207
+ try:
208
+ properties = {'name': 'hello'}
209
+ te.track_first(account_id="account_id", distinct_id="distinct_id", event_name='first_event', first_check_id='first_flag_id', properties=properties)
210
+ except Exception as e:
211
+ # Exception handling
212
+ raise TDIllegalDataException(e)
213
+ ```
214
+
215
+ Note: Since first-time verification is completed on the server side, first-time events will be delayed by 1 hour before entering the database.
216
+
217
+ #### 1.3 Updateable Events
218
+
219
+ You can implement the need to modify event data in specific scenarios through updateable events. Updateable events need to specify an ID that identifies the event and pass it when creating the updateable event object. TE backend will determine the data to be updated based on the event name and event ID.
220
+
221
+ ```
222
+ # Example: Report updateable event, assuming event name is UPDATABLE_EVENT
223
+ distinct_id = "65478cc0-275a-4aeb-9e6b-861155b5aca7"
224
+ account_id = "123"
225
+ event_name = "UPDATABLE_EVENT"
226
+ event_id = "123"
227
+ properties = {
228
+ "price": 100,
229
+ "status": 3
230
+ }
231
+ # After reporting, event property status is 3, price is 100
232
+ te.track_update(distinct_id=distinct_id, account_id=account_id, event_name=event_name, event_id=event_id,
233
+ properties=properties)
234
+
235
+ # After reporting, same event_name + event_id property status is updated to 5, price unchanged
236
+ new_properties = {
237
+ "status": 5
238
+ }
239
+ te.track_update(distinct_id=distinct_id, account_id=account_id, event_name=event_name, event_id=event_id,
240
+ properties=new_properties)
241
+ ```
242
+
243
+ #### 1.4 Overwriteable Events
244
+
245
+ Overwriteable events are similar to updateable events, except that overwriteable events will completely overwrite historical data with the latest data. Effectively, this is equivalent to deleting the previous data and inserting the latest data. TE backend will determine the data to be updated based on the event name and event ID.
246
+
247
+ ```
248
+ # Example: Report overwriteable event, assuming event name is OVERWRITE_EVENT
249
+ distinct_id = "65478cc0-275a-4aeb-9e6b-861155b5aca7"
250
+ account_id = "123"
251
+ event_name = "OVERWRITE_EVENT"
252
+ event_id = "123"
253
+ properties = {
254
+ "price": 100,
255
+ "status": 3
256
+ }
257
+ # After reporting, event property status is 3, price is 100
258
+ te.track_overwrite(distinct_id=distinct_id, account_id=account_id, event_name=event_name, event_id=event_id,
259
+ properties=properties)
260
+
261
+ # After reporting, event property status is updated to 5, price property is deleted
262
+ new_properties = {
263
+ "status": 5
264
+ }
265
+ te.track_overwrite(distinct_id=distinct_id, account_id=account_id, event_name=event_name, event_id=event_id,
266
+ properties=new_properties)
267
+ ```
268
+
269
+ ### 2. User Properties
270
+
271
+ TE platform supports the following user property setting APIs: `user_set`, `user_setOnce`, `user_add`, `user_unset`, `user_del`, `user_append`, `user_uniq_append`.
272
+
273
+ #### 2.1 user_set
274
+
275
+ For general user properties, you can call `user_set` to set them. Properties uploaded via this interface will overwrite existing property values. If the user property does not exist previously, a new user property will be created with the same type as the uploaded property. Here is an example of setting a username:
276
+
277
+ ```
278
+ properties = {"user_name": "ABC"}
279
+ # Upload user property, "user_name" value is "ABC"
280
+ try:
281
+ te.user_set(account_id="account_id", distinct_id="distinct_id", properties=properties)
282
+ properties = {"user_name": "XYZ"}
283
+ # Upload user property again, at this point "user_name" value is overwritten to "XYZ"
284
+ te.user_set(account_id="account_id", distinct_id="distinct_id", properties=properties)
285
+ except Exception as e:
286
+ # Exception handling
287
+ print(e)
288
+ ```
289
+
290
+ #### 2.2 user_setOnce
291
+
292
+ If you want to set a user property only once, you can call `user_setOnce`. When the property already has a value, this information will be ignored. Here is another example of setting a username:
293
+
294
+ ```
295
+ properties = {"user_name": "ABC"}
296
+ # Upload user property, "user_name" value is "ABC"
297
+ try:
298
+ te.user_setOnce(account_id="account_id", distinct_id="distinct_id", properties=properties)
299
+ except Exception as e:
300
+ # Exception handling
301
+ print(e)
302
+ properties = {
303
+ "user_name": "XYZ",
304
+ "user_age": 18
305
+ }
306
+ # Upload user property again, at this point "user_name" already has value, so no modification, still "ABC"; "user_age" value is 18
307
+ try:
308
+ te.user_setOnce(account_id="account_id", distinct_id="distinct_id", properties=properties)
309
+ except Exception as e:
310
+ # Exception handling
311
+ print(e)
312
+ ```
313
+
314
+ #### 2.3 user_add
315
+
316
+ When you want to upload numeric properties, you can call `user_add` to accumulate the property. If the property has not been set, it will be assigned 0 before calculation. Negative values can be passed, equivalent to subtraction. Here is an example of accumulating total payment amount:
317
+
318
+ ```
319
+ properties = {
320
+ "total_revenue": 30,
321
+ "vip_level": 1
322
+ }
323
+ # Upload user property, at this point "total_revenue" value is 30, "vip_level" value is 1
324
+ te.user_add(account_id="account_id", distinct_id="distinct_id", properties=properties)
325
+
326
+ properties = {"total_revenue": 90}
327
+ # Upload user property, at this point "total_revenue" value is 90, "vip_level" value is 1
328
+ try:
329
+ te.user_add(account_id="account_id", distinct_id="distinct_id", properties=properties)
330
+ except Exception as e:
331
+ # Exception handling
332
+ print(e)
333
+ ```
334
+
335
+ The property key must be a string, and Value only allows numeric values.
336
+
337
+ #### 2.4 user_append
338
+
339
+ You can call `user_append` to append array-type user properties.
340
+
341
+ ```
342
+ list1 = ['Google']
343
+ # Append array-type properties for arrKey1, arrKey2
344
+ properties = {'arrKey1': list1, 'arrKey2': ['11', '22']}
345
+ try:
346
+ te.user_append(account_id="account_id", distinct_id="distinct_id", properties=properties)
347
+ except Exception as e:
348
+ # Exception handling
349
+ print(e)
350
+ ```
351
+
352
+ #### 2.5 user_uniq_append
353
+
354
+ You can call `user_uniq_append` to append array-type user properties. The `user_uniq_append` interface will deduplicate appended user properties, while `user_append` interface does not deduplicate, allowing duplicate user properties.
355
+
356
+ ```
357
+ arrayValue = ['Google', 'True', '2.222']
358
+ properties = {'arrKey4': arrayValue, 'arrKey3': ['appendList', '222'], 'dict1': {'name': 'Tom', 'Age': 28}}
359
+ try:
360
+ # After execution, user property arrKey4 is ['Google', True, 2.222], arrKey3 is ['appendList', '222']
361
+ te.user_append(account_id="account_id", distinct_id="distinct_id", properties=properties)
362
+ except Exception as e:
363
+ # Exception handling
364
+ raise TDIllegalDataException(e)
365
+
366
+ properties = {'arrKey4': ['addValue', 'True'], 'arrKey3': ['appendList', '222']}
367
+ try:
368
+ # After execution, user property arrKey4 is ['Google', True, 2.222, 'addValue'], arrKey3 is ['appendList', '222']
369
+ te.user_uniq_append(account_id="account_id", distinct_id="distinct_id", properties=properties)
370
+ except Exception as e:
371
+ # Exception handling
372
+ raise TDIllegalDataException(e)
373
+ ```
374
+
375
+ #### 2.6 user_unset
376
+
377
+ When you want to clear user property values, you can call `user_unset` to clear specified properties. If the property has not been created in the cluster, `user_unset` will not create the property.
378
+
379
+ ```
380
+ try:
381
+ te.user_unset("distinct_id", "account_id", ["string1", "lastTime"])
382
+ except Exception as e:
383
+ # Exception handling
384
+ print(e)
385
+ ```
386
+
387
+ user_unset: The parameter is the Key value of the property to be cleared.
388
+
389
+ #### 2.7 user_del
390
+
391
+ If you want to delete a user, you can call `user_del` to delete the user. You will no longer be able to query the user's properties, but events generated by the user can still be queried. This operation may have irreversible consequences, please use with caution.
392
+
393
+ ```
394
+ try:
395
+ te.user_del(account_id="account_id", distinct_id="distinct_id")
396
+ except Exception as e:
397
+ # Exception handling
398
+ print(e)
399
+ ```
400
+
401
+ ### 3. Other Features
402
+
403
+ #### 3.1 TDBatchConsumer
404
+
405
+ ::: warning Note
406
+
407
+ When data volume is large or network is abnormal, there is a risk of data loss. Not recommended for production environments.
408
+
409
+ :::
410
+
411
+ Batch real-time data transmission to TE server without requiring transmission tools.
412
+
413
+ ```
414
+ te = TDAnalytics(TDBatchConsumer("SERVER_URL", "APP_ID"))
415
+ ```
416
+
417
+ Parameter Description:
418
+
419
+ - `APP_ID`: Your project's APP ID, can be obtained from TE backend project management page
420
+ - `SERVER_URL`: Data upload URL
421
+ - If you are connecting to cloud service, enter: https://global-receiver-ta.thinkingdata.cn
422
+ - If you use private deployment version, please bind domain for data collection address and configure HTTPS certificate: https://YOUR_DATA_COLLECTION_DOMAIN
423
+
424
+ ---
425
+
426
+ # Real-time Debugging
427
+
428
+ ::: warning Note
429
+
430
+ SDK Debug mode is only for integration debugging. Do not use in production environment.
431
+
432
+ :::
433
+
434
+ During SDK integration, you can view SDK logs in IDE console or use TE's Debug feature for real-time debugging.
435
+
436
+ ### 1. Print SDK Logs
437
+
438
+ ```
439
+ TDAnalytics.enableLog(isPrint=True)
440
+ ```
441
+
442
+ ### 2. Real-time Debugging
443
+
444
+ During SDK integration, you can use TE's Debug feature for real-time debugging. Enabling Debug feature requires two steps:
445
+
446
+ 1. Use TDDebugConsumer
447
+ Here is sample code using TDDebugConsumer:
448
+
449
+ ```
450
+ te = TDAnalytics(TDDebugConsumer("https://receiver-ta-demo.thinkingdata.cn", "appId", device_id="123456789"))
451
+ distinct_id = "ABD"
452
+ account_id = "11111"
453
+ try:
454
+ te.track(account_id=account_id, event_name='event_name', properties={'level': 0})
455
+ except Exception as e:
456
+ print(e)
457
+ ```
458
+
459
+ 2. Add Debug Device in TE Backend
460
+ To prevent Debug mode from going live in production environment, only specified devices can enable Debug mode. Debug mode can only be enabled when Debug mode is turned on in the client and the device ID is configured in TE backend's "Tracking Management" page under "Debug Data" section.
461
+
462
+ Debug mode may affect data collection quality and App stability. Only use for integration stage data verification, not for online environment.
463
+
464
+ ---
465
+
466
+ # Preset Properties
467
+
468
+ The following preset properties are included in all events for Python SDK.
469
+
470
+ **Property Name** | **Chinese Name** | **Property Type** | **Description**
471
+
472
+ #ip | IP Address | Text | User's IP address, needs to be set manually. TE will use this to obtain user's geographic location information.
473
+
474
+ #country | Country | Text | User's country, generated based on IP address.
475
+
476
+ #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.
477
+
478
+ #province | Province | Text | User's province, generated based on IP address.
479
+
480
+ #city | City | Text | User's city, generated based on IP address.
481
+
482
+ #lib | SDK Type | Text | Type of SDK you integrated, such as Java, etc.
483
+
484
+ #lib_version | SDK Version | Text | Version of SDK you integrated.