@thinkingai/ae-cli 6.1.29 → 6.1.32

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 (265) hide show
  1. package/README.md +11 -5
  2. package/README.zh.md +11 -5
  3. package/bin/ai-monitor.js +2 -0
  4. package/dist/ai-monitor-MKMHSSNI.js +32 -0
  5. package/dist/ai-monitor.js +135 -0
  6. package/dist/{auth-OBQ5KVQM.js → auth-CZHHPZOQ.js} +12 -11
  7. package/dist/{automation-NAR5DDGL.js → automation-FLCPFMN4.js} +5 -5
  8. package/dist/{capability-LFSVNI5B.js → capability-64KVJFIA.js} +28 -32
  9. package/dist/{chunk-IN7KKL6K.js → chunk-2F64AZYH.js} +1 -1
  10. package/dist/{chunk-QZLRHGVH.js → chunk-3ULDJJTZ.js} +1 -1
  11. package/dist/{chunk-JNVVJ273.js → chunk-4PSTYEG5.js} +5 -10
  12. package/dist/{chunk-3SDHJOCR.js → chunk-4XKTRCRK.js} +16 -16
  13. package/dist/{chunk-RJHGDWSC.js → chunk-5M5LBRR3.js} +2 -2
  14. package/dist/chunk-6M7ZEDT2.js +182 -0
  15. package/dist/{chunk-KPQY44JQ.js → chunk-AWW2T2WL.js} +3 -0
  16. package/dist/chunk-BNBCMCYN.js +563 -0
  17. package/dist/chunk-CF6JTT2U.js +64 -0
  18. package/dist/{chunk-2UW3Y463.js → chunk-DWBYNGSR.js} +565 -315
  19. package/dist/{chunk-N6XBLRB7.js → chunk-F2VFZUGG.js} +2 -2
  20. package/dist/{chunk-CVCTFLSO.js → chunk-FCAA7I2D.js} +3 -3
  21. package/dist/{chunk-H3K5UGYC.js → chunk-HTZ2MLYA.js} +48 -22
  22. package/dist/{chunk-QZUVLFNR.js → chunk-HVMCPKOZ.js} +1 -1
  23. package/dist/chunk-IDDWEZ7F.js +1285 -0
  24. package/dist/{chunk-7JAVT5TK.js → chunk-KTJXD27G.js} +2 -2
  25. package/dist/{chunk-6HAUVWOQ.js → chunk-NLEXY2TM.js} +48 -13
  26. package/dist/{chunk-YVG6QD3V.js → chunk-P7QDCWJ6.js} +98 -7
  27. package/dist/{chunk-PWXDWMCW.js → chunk-T7WF4HYW.js} +84 -32
  28. package/dist/{chunk-VCZE3IWO.js → chunk-TMQGS4TO.js} +15 -10
  29. package/dist/{compat-check-CII6B74E.js → compat-check-ZJNCMNQV.js} +3 -3
  30. package/dist/{config-YZ6O2UQ2.js → config-FSH2NMNZ.js} +26 -13
  31. package/dist/{context-F6FCGTF3.js → context-YAQG6YQC.js} +3 -3
  32. package/dist/{data-integration-6UAZO4GG.js → data-integration-QE37EQ3A.js} +1 -1
  33. package/dist/{evaluation-4LO2O4AF.js → evaluation-2JSF4V47.js} +13 -158
  34. package/dist/index.js +84 -586
  35. package/dist/{memory-HHPX3NF2.js → memory-VEZZVAAP.js} +5 -5
  36. package/dist/{metadata-TIFY24LW.js → metadata-3IWHX3V4.js} +8 -8
  37. package/dist/{model-7UHGWYVR.js → model-T7H7Q6BG.js} +3 -3
  38. package/dist/{personal-semantic-preference-WKJEGPTM.js → personal-semantic-preference-YITU23SA.js} +7 -7
  39. package/dist/{project-semantic-EIQVZNHW.js → project-semantic-MHEXJF3C.js} +16 -14
  40. package/dist/{sync-RV3OPCTI.js → sync-AQHVCSPI.js} +5 -5
  41. package/dist/{te-agent-5ENVZJUH.js → te-agent-RXI7WOH4.js} +6 -6
  42. package/dist/{te-analysis-USIK6ZZG.js → te-analysis-CZY74HVF.js} +381 -192
  43. package/dist/{te-community-WE2UU4XV.js → te-community-DKCYUBCM.js} +7 -7
  44. package/dist/{te-dataops-XNMO7MBF.js → te-dataops-QEH6VE56.js} +5 -5
  45. package/dist/{te-engage-6C3HCFQR.js → te-engage-WK7WKDKF.js} +7 -7
  46. package/dist/{te-experiment-LVTRI3QK.js → te-experiment-LH3RPIOE.js} +275 -30
  47. package/dist/{te-kb-TUPGMVBY.js → te-kb-UPORIOVN.js} +17 -8
  48. package/dist/{te-system-YM657FKO.js → te-system-AL4B4XZL.js} +3 -3
  49. package/dist/{te-team-G4VEJJNL.js → te-team-LLVTO2G4.js} +6 -6
  50. package/dist/{things-22KQWC23.js → things-XLMLBYQR.js} +6 -6
  51. package/dist/{update-XX4ILU7X.js → update-7J5UQHSK.js} +4 -4
  52. package/dist/{workspace-LYDAP647.js → workspace-FF2HXJGR.js} +5 -5
  53. package/package.json +9 -7
  54. package/skills/ae-ai-monitor/SKILL.md +179 -0
  55. package/skills/ae-ai-monitor/references/read-commands.md +866 -0
  56. package/skills/ae-analysis/SKILL.md +10 -4
  57. package/skills/ae-analysis/references/adhoc_export.md +3 -1
  58. package/skills/ae-analysis/references/ai_models/path.md +5 -6
  59. package/skills/ae-analysis/references/ai_models.md +1 -0
  60. package/skills/ae-analysis/references/analysis_gateway_assets.md +2 -0
  61. package/skills/ae-analysis/references/asset_search.md +1 -1
  62. package/skills/ae-analysis/references/bad_case_begin.md +12 -0
  63. package/skills/ae-analysis/references/bad_case_get.md +12 -0
  64. package/skills/ae-analysis/references/bad_case_history.md +12 -0
  65. package/skills/ae-analysis/references/bad_case_list.md +12 -0
  66. package/skills/ae-analysis/references/bad_case_review.md +51 -0
  67. package/skills/ae-analysis/references/bad_case_run.md +12 -0
  68. package/skills/ae-analysis/references/bad_case_submit.md +12 -0
  69. package/skills/ae-analysis/references/bad_case_submit_to_page.md +12 -0
  70. package/skills/ae-analysis/references/bad_case_sync_evaluation.md +11 -0
  71. package/skills/ae-analysis/references/bi_panel_list.md +1 -1
  72. package/skills/ae-analysis/references/bi_panel_share.md +3 -1
  73. package/skills/ae-analysis/references/catalog_list.md +2 -0
  74. package/skills/ae-analysis/references/command_index.md +38 -29
  75. package/skills/ae-analysis/references/dashboard_daily_report_update.md +2 -0
  76. package/skills/ae-analysis/references/dashboard_handover.md +3 -1
  77. package/skills/ae-analysis/references/dashboard_list.md +3 -3
  78. package/skills/ae-analysis/references/dashboard_report_data_export.md +1 -1
  79. package/skills/ae-analysis/references/dashboard_share.md +3 -1
  80. package/skills/ae-analysis/references/dashboard_update.md +3 -2
  81. package/skills/ae-analysis/references/filter_value_list.md +2 -0
  82. package/skills/ae-analysis/references/folder_share.md +8 -2
  83. package/skills/ae-analysis/references/governance_recommendation_run_update.md +3 -1
  84. package/skills/ae-analysis/references/project_data_power_upsert.md +3 -1
  85. package/skills/ae-analysis/references/project_mark_time_create.md +2 -0
  86. package/skills/ae-analysis/references/project_mark_time_update.md +2 -0
  87. package/skills/ae-analysis/references/project_member_add.md +3 -1
  88. package/skills/ae-analysis/references/project_member_batch_update.md +3 -1
  89. package/skills/ae-analysis/references/project_member_handover_run.md +3 -1
  90. package/skills/ae-analysis/references/project_member_update.md +3 -1
  91. package/skills/ae-analysis/references/project_owner_update.md +3 -1
  92. package/skills/ae-analysis/references/project_role_upsert.md +5 -3
  93. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +16 -1
  94. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +14 -1
  95. package/skills/ae-analysis/references/project_space_share.md +8 -2
  96. package/skills/ae-analysis/references/property_get.md +2 -0
  97. package/skills/ae-analysis/references/public_link_list.md +3 -1
  98. package/skills/ae-analysis/references/query_cancel.md +4 -1
  99. package/skills/ae-analysis/references/report_data_run.md +1 -1
  100. package/skills/ae-analysis/references/report_list.md +3 -3
  101. package/skills/ae-analysis/references/scenario_append.md +2 -2
  102. package/skills/ae-analysis/references/scenario_collect.md +15 -4
  103. package/skills/ae-analysis/references/scenario_list.md +2 -1
  104. package/skills/ae-analysis/references/system_oauth2_update.md +3 -1
  105. package/skills/ae-analysis/references/system_third_party_login_upsert.md +4 -2
  106. package/skills/ae-analysis/references/user_tag_create.md +4 -1
  107. package/skills/ae-analysis/references/user_tag_get.md +2 -0
  108. package/skills/ae-analysis/references/user_tag_models.md +8 -2
  109. package/skills/ae-analysis/references/user_tag_update.md +5 -2
  110. package/skills/ae-analysis/references/virtual_property_create.md +12 -1
  111. package/skills/ae-analysis/references/virtual_property_sql_rule_update.md +10 -0
  112. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +55 -13
  113. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +2 -2
  114. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +2 -2
  115. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +7 -1
  116. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/wait-compile-run.mjs +79 -0
  117. package/skills/ae-automation/SKILL.md +4 -2
  118. package/skills/ae-capability/SKILL.md +9 -5
  119. package/skills/ae-community/SKILL.md +1 -0
  120. package/skills/ae-dataops/SKILL.md +1 -0
  121. package/skills/ae-engage/SKILL.md +1 -0
  122. package/skills/ae-evaluation/SKILL.md +17 -2
  123. package/skills/ae-experiment/SKILL.md +38 -11
  124. package/skills/ae-experiment/references/experiment_approval.md +171 -0
  125. package/skills/ae-experiment/references/manage_experiment.md +11 -2
  126. package/skills/ae-experiment/references/save_experiment.md +28 -8
  127. package/skills/ae-experiment/references/save_submit_experiment.md +18 -3
  128. package/skills/ae-experiment/references/save_submit_external_experiment.md +57 -3
  129. package/skills/ae-generate-tracking-plan/SKILL.md +5 -0
  130. package/skills/ae-kb/SKILL.md +9 -5
  131. package/skills/ae-kb/references/analysis-workflow.md +11 -2
  132. package/skills/ae-kb/references/query-workflow.md +9 -6
  133. package/skills/ae-kb/references/versions.md +1 -1
  134. package/skills/ae-kb-discovery/SKILL.md +15 -6
  135. package/skills/ae-metadata/SKILL.md +1 -0
  136. package/skills/ae-migrate-tracking-code/SKILL.md +2 -1
  137. package/skills/ae-team/SKILL.md +1 -1
  138. package/skills/ae-tracking-matrix/SKILL.md +170 -0
  139. package/skills/ae-tracking-matrix/assets//345/237/213/347/202/271/346/250/241/347/211/210.xlsx +0 -0
  140. package/skills/ae-tracking-matrix/i18n.yaml +12 -0
  141. package/skills/ae-tracking-matrix/references/ae-capabilities.md +93 -0
  142. package/skills/ae-tracking-matrix/references/business-semantic-checks.md +30 -0
  143. package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +256 -0
  144. package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +213 -0
  145. package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +407 -0
  146. package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +218 -0
  147. package/skills/ae-tracking-matrix/references/categories/casual_music.md +112 -0
  148. package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +301 -0
  149. package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +356 -0
  150. package/skills/ae-tracking-matrix/references/categories/fishing.md +775 -0
  151. package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +89 -0
  152. package/skills/ae-tracking-matrix/references/categories/idle_card.md +27 -0
  153. package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +415 -0
  154. package/skills/ae-tracking-matrix/references/categories/interactive_video.md +133 -0
  155. package/skills/ae-tracking-matrix/references/categories/merge.md +639 -0
  156. package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +406 -0
  157. package/skills/ae-tracking-matrix/references/categories/mmo_web.md +230 -0
  158. package/skills/ae-tracking-matrix/references/categories/music.md +137 -0
  159. package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +414 -0
  160. package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +199 -0
  161. package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +158 -0
  162. package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +546 -0
  163. package/skills/ae-tracking-matrix/references/categories/rpg.md +195 -0
  164. package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +115 -0
  165. package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +151 -0
  166. package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +260 -0
  167. package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +232 -0
  168. package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +359 -0
  169. package/skills/ae-tracking-matrix/references/categories/tower_defense.md +365 -0
  170. package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +211 -0
  171. package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +132 -0
  172. package/skills/ae-tracking-matrix/references/category-registry.md +77 -0
  173. package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +230 -0
  174. package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +406 -0
  175. package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +128 -0
  176. package/skills/ae-tracking-matrix/references/eval-cases.md +74 -0
  177. package/skills/ae-tracking-matrix/references/naming-dict.md +238 -0
  178. package/skills/ae-tracking-matrix/references/optimization-checklist.md +85 -0
  179. package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +142 -0
  180. package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +47 -0
  181. package/skills/ae-tracking-matrix/references/plan-generation/reference.md +794 -0
  182. package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +94 -0
  183. package/skills/ae-tracking-matrix/references/scene-routing.md +80 -0
  184. package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +3787 -0
  185. package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +827 -0
  186. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +655 -0
  187. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +953 -0
  188. package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +1128 -0
  189. package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +714 -0
  190. package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +1268 -0
  191. package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +776 -0
  192. package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +182 -0
  193. package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +2755 -0
  194. package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +1182 -0
  195. package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +1300 -0
  196. package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +1369 -0
  197. package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +1692 -0
  198. package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +902 -0
  199. package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +763 -0
  200. package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +1107 -0
  201. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +1532 -0
  202. package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +845 -0
  203. package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +228 -0
  204. package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +149 -0
  205. package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +407 -0
  206. package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +163 -0
  207. package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +149 -0
  208. package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +153 -0
  209. package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +232 -0
  210. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +314 -0
  211. package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +117 -0
  212. package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +148 -0
  213. package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +645 -0
  214. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +307 -0
  215. package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +347 -0
  216. package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +72 -0
  217. package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +264 -0
  218. package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +566 -0
  219. package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +409 -0
  220. package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +446 -0
  221. package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +557 -0
  222. package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +457 -0
  223. package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +490 -0
  224. package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +523 -0
  225. package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +484 -0
  226. package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +442 -0
  227. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +391 -0
  228. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +91 -0
  229. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +635 -0
  230. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +113 -0
  231. package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +466 -0
  232. package/skills/ae-tracking-matrix/references/standard-base/README.md +22 -0
  233. package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +174 -0
  234. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +20 -0
  235. package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +7 -0
  236. package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +14 -0
  237. package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +370 -0
  238. package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +47 -0
  239. package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +37 -0
  240. package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +27 -0
  241. package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +23 -0
  242. package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +14 -0
  243. package/skills/ae-tracking-matrix/references/standard-base/user_data.md +46 -0
  244. package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +13 -0
  245. package/skills/ae-tracking-matrix/references/system-fields.md +297 -0
  246. package/skills/ae-tracking-matrix/references/te-field-translations.md +1791 -0
  247. package/skills/ae-tracking-matrix/references/workflows/data-verification.md +232 -0
  248. package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +829 -0
  249. package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +355 -0
  250. package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +283 -0
  251. package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +168 -0
  252. package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +205 -0
  253. package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +75 -0
  254. package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +36 -0
  255. package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +107 -0
  256. package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +114 -0
  257. package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +53 -0
  258. package/skills/ae-tracking-matrix/scripts/finalize_plan.py +166 -0
  259. package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +674 -0
  260. package/skills/ae-tracking-matrix/scripts/plan_contract.py +200 -0
  261. package/skills/ae-tracking-matrix/scripts/plan_types.py +60 -0
  262. package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +169 -0
  263. package/skills/ae-tracking-matrix/scripts/sync_plan.py +296 -0
  264. package/skills/ae-tracking-matrix/scripts/upload_plan.py +340 -0
  265. package/dist/chunk-AMBFK2K3.js +0 -28
@@ -0,0 +1,3787 @@
1
+ ---
2
+ code: android_sdk_installation
3
+ name: "Android"
4
+ wikiToken: EnSPwbQvsi8Vm4km9JqcbhQ6nv2
5
+ parentWikiToken: FTcTwinIOi3OiRkK4MPc2Ex7neg
6
+ updateTime: 1773209364000
7
+ sourceUrl: https://docs-v2.thinkingdata.cn/?version=6.0&lan=zh-CN&code=android_sdk_installation
8
+ ---
9
+
10
+ # Android
11
+
12
+ ::: tip Tip
13
+
14
+ Before integration, please read the Pre-installation Preparation.
15
+
16
+ Android SDK requires minimum system version Android 4.0 (API 14)
17
+
18
+ Android SDK (aar format) size is approximately 200 KB
19
+
20
+ SDK Name: ThinkingData SDK
21
+
22
+ Developer: ThinkingData Information Technology (Shanghai) Co., Ltd.
23
+
24
+ Version:3.3.6
25
+
26
+ Function: SDK collects client logs through events and user properties, capable of daily active users, usage duration, retention behavior analysis, etc.
27
+
28
+ Privacy Statement: ThinkingData SDK Privacy Statement
29
+
30
+ :::
31
+
32
+ **Latest Version:** 3.3.6
33
+
34
+ **Update Time:** 2026-03-05
35
+
36
+ **Resource Download:** Source Code Download
37
+
38
+ ::: warning Note
39
+
40
+ This document applies to v3.0.0 and later versions, For historical versions, please refer to Android Integration Guide (V2), SDK Download (V2)
41
+
42
+ :::
43
+
44
+ ### 1. Integrate SDK
45
+
46
+ #### 1.1 Automatic Integration
47
+
48
+ - Add the following configuration dependencies in the `Project` level `build.gradle` file
49
+
50
+ ```
51
+ buildscript {
52
+ repositories {
53
+ jcenter()
54
+ mavenCentral()
55
+ }
56
+ }
57
+ ```
58
+
59
+ - Add dependencies in the `build.gradle` file under the `Module` directory:
60
+
61
+ ```
62
+ dependencies {
63
+ implementation 'cn.thinkingdata.android:ThinkingAnalyticsSDK:3.3.6'
64
+ }
65
+ ```
66
+
67
+ #### 1.2 Manual Integration
68
+
69
+ 1. Download and extract Android SDK
70
+ 1. Add TDAnalytics.aar and TDCore.aar in the libs folder
71
+ <!-- unsupported block: 24 -->
72
+
73
+ <!-- unsupported block: 25 -->
74
+
75
+ <!-- unsupported block: 25 -->
76
+
77
+ 1. Add the following configuration in build.gradle
78
+
79
+ ```
80
+ dependencies {
81
+ implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])
82
+ }
83
+ ```
84
+
85
+ ### 2. Initialization
86
+
87
+ :::: el-tabs
88
+
89
+ ::: el-tab-pane label=Java
90
+
91
+ ```
92
+ // Initialize SDK on the main thread
93
+ // Method 1
94
+ TDAnalytics.*init*(this, APPID, SERVER_URL);
95
+ // Method 2
96
+ TDConfig config = TDConfig.getInstance(this, APPID, TE_SERVER_URL);
97
+ TDAnalytics.*init*(config);
98
+ ```
99
+
100
+ :::
101
+
102
+ ::: el-tab-pane label=Kotlin
103
+
104
+ ```
105
+ // Initialize SDK on the main thread
106
+ // Method 1
107
+ TDAnalytics.*init*(this, APPID, SERVER_URL)
108
+ // Method 2
109
+ val config = TDConfig.getInstance(this,APPID,TE_SERVER_URL)
110
+ TDAnalytics.*init*(config);
111
+ ```
112
+
113
+ :::
114
+
115
+ ::::
116
+
117
+ Parameter Description:
118
+
119
+ - `APPID`: Your project APPID, available in TE project management page
120
+ - `SERVER_URL`: Data upload URL
121
+ - For cloud service, check the reporting URL in Project Management > Integration Configuration.
122
+ - For private deployment, you can customize the data collection address.
123
+ <!-- unsupported block: 34 -->
124
+
125
+ Since Android 9.0+ restricts HTTP requests by default, please use HTTPS protocol
126
+
127
+ ### 3. Common Features
128
+
129
+ Before using common features, we recommend you understand user identification rules; SDK will generate a random number as visitor ID by default, and persist the visitor ID locally; Before user login, visitor ID is used as the identity ID.Note: Visitor ID will change when user reinstalls the App or changes device.
130
+
131
+ #### 3.1 Set Account ID
132
+
133
+ When user logs in, call `login` to set account ID, TE platform will use account ID as the identity ID, and the account ID will remain until `logout` is called.Multiple calls to `login` will override the previous account ID.
134
+
135
+ :::: el-tabs
136
+
137
+ ::: el-tab-pane label=Java
138
+
139
+ ```
140
+ // User login unique identifier, corresponds to #account_id in reported data, now #account_id is TA
141
+ TDAnalytics.*login*("TA");
142
+ ```
143
+
144
+ :::
145
+
146
+ ::: el-tab-pane label=Kotlin
147
+
148
+ ```
149
+ // User login unique identifier, corresponds to #account_id in reported data, now #account_id is TA
150
+ TDAnalytics.*login*("TA")
151
+ ```
152
+
153
+ :::
154
+
155
+ ::::
156
+
157
+ <!-- unsupported block: 34 -->
158
+
159
+ **This method does not upload login event**
160
+
161
+ #### 3.2 Set Super Properties
162
+
163
+ Super properties are properties that every event will have, You can call `setSuperProperties` to set super properties, we recommend setting super properties before sending events.For important properties like membership level, source channel, these properties need to be set in every event, you can set them as super properties.
164
+
165
+ :::: el-tabs
166
+
167
+ ::: el-tab-pane label=Java
168
+
169
+ ```
170
+ try {
171
+ JSONObject superProperties = new JSONObject();
172
+ superProperties.put("channel","ta");// string
173
+ superProperties.put("age",1);// number
174
+ superProperties.put("isSuccess",true);// boolean
175
+ superProperties.put("birthday",new Date());// time
176
+
177
+ JSONObject object = new JSONObject();
178
+ object.put("key", "value");
179
+ superProperties.put("object",object);// object
180
+
181
+ JSONObject object1 = new JSONObject();
182
+ object1.put("key", "value");
183
+ JSONArray arr = new JSONArray();
184
+ arr.put(object1);
185
+ superProperties.put("object_arr",arr);// object group
186
+
187
+ JSONArray arr1 = new JSONArray();
188
+ arr1.put("value");
189
+ superProperties.put("arr",arr1);// array
190
+ // set super properties
191
+ TDAnalytics.*setSuperProperties*(superProperties);
192
+ } catch (JSONException e) {
193
+ e.printStackTrace();
194
+ }
195
+ ```
196
+
197
+ :::
198
+
199
+ ::: el-tab-pane label=Kotlin
200
+
201
+ ```
202
+ val superProperties = JSONObject().*apply ***{**
203
+ ** **put("channel", "ta") // string
204
+ put("age", 1) // number
205
+ put("isSuccess", true) // boolean
206
+ put("birthday", Date()) // time
207
+ put("object",JSONObject().*apply ***{ **// object
208
+ put("key", "value")
209
+ **}**)
210
+ put("object_arr",JSONArray().*apply ***{ **// object group
211
+ put(JSONObject().*apply ***{**
212
+ ** **put("key", "value")
213
+ **}**)
214
+ **}**)
215
+ put("arr",JSONArray().*apply ***{ **// array
216
+ put("value")
217
+ **}**)
218
+ **}**
219
+ TDAnalytics.setSuperProperties(superProperties)
220
+ ```
221
+
222
+ :::
223
+
224
+ ::::
225
+
226
+ Super properties will be saved to cache, No need to call every time App starts.If you call `setSuperProperties` with previously set property, it will override the previous value.
227
+
228
+ - Key is the property name, string type, must start with a letter, contain numbers, letters and underscores "\_", maximum length 50 characters, case-insensitive, TE will convert to lowercase
229
+ - Value supports string, number, boolean, time, object, object array, array
230
+ <!-- unsupported block: 34 -->
231
+
232
+ **Event properties and user properties follow the same requirements as super properties**
233
+
234
+ #### 3.3 Enable Auto Tracking
235
+
236
+ The following code enables install, start, and end events, For details on auto tracking capabilities, see Auto Tracking Introduction
237
+
238
+ :::: el-tabs
239
+
240
+ ::: el-tab-pane label=Java
241
+
242
+ ```
243
+ //TDAnalytics.TDAutoTrackEventType.*APP_INSTALL* APP install event
244
+ //TDAnalytics.TDAutoTrackEventType.*APP_START* APP start event
245
+ //TDAnalytics.TDAutoTrackEventType.*APP_END* APP end event
246
+
247
+ // enable auto tracking events
248
+ TDAnalytics.*enableAutoTrack*(TDAnalytics.TDAutoTrackEventType.*APP_START *| TDAnalytics.TDAutoTrackEventType.*APP_END*
249
+ * *| TDAnalytics.TDAutoTrackEventType.*APP_INSTALL*);
250
+ ```
251
+
252
+ :::
253
+
254
+ ::: el-tab-pane label=Kotlin
255
+
256
+ ```
257
+ //TDAnalytics.TDAutoTrackEventType.*APP_INSTALL* APP install event
258
+ //TDAnalytics.TDAutoTrackEventType.*APP_START* APP start event
259
+ //TDAnalytics.TDAutoTrackEventType.*APP_END* APP end event
260
+
261
+ // enable auto tracking events
262
+ TDAnalytics.enableAutoTrack(
263
+ TDAnalytics.TDAutoTrackEventType.*APP_START *or TDAnalytics.TDAutoTrackEventType.*APP_END*
264
+ * *or TDAnalytics.TDAutoTrackEventType.*APP_INSTALL*
265
+ )
266
+ ```
267
+
268
+ :::
269
+
270
+ ::::
271
+
272
+ #### 3.4 Track Event
273
+
274
+ You can call `track` to upload events, We recommend setting event properties based on your tracking plan, Here is an example of user purchasing a product:
275
+
276
+ :::: el-tabs
277
+
278
+ ::: el-tab-pane label=Java
279
+
280
+ ```
281
+ try {
282
+ JSONObject properties = new JSONObject();
283
+ properties.put("product_name","product name");
284
+ TDAnalytics.*track*("product_buy", properties);
285
+ } catch (JSONException e) {
286
+ e.printStackTrace();
287
+ }
288
+ ```
289
+
290
+ :::
291
+
292
+ ::: el-tab-pane label=Kotlin
293
+
294
+ ```
295
+ val properties = JSONObject()
296
+ properties.put("product_name", "product name")
297
+ TDAnalytics.track("product_buy", properties)
298
+ ```
299
+
300
+ :::
301
+
302
+ ::::
303
+
304
+ Event name is string type, must start with a letter, can contain numbers, letters, underscores "\_", maximum length 50 characters.
305
+
306
+ #### 3.5 Set User Properties
307
+
308
+ For general user properties, call `userSet`, Properties uploaded via this interface will override existing values; If property doesn't exist, it will be created, Type matches the uploaded property type, Here is an example of setting username:
309
+
310
+ :::: el-tabs
311
+
312
+ ::: el-tab-pane label=Java
313
+
314
+ ```
315
+ try {
316
+ // now username is TA
317
+ JSONObject properties = new JSONObject();
318
+ properties.put("username","TA");
319
+ TDAnalytics.*userSet*(properties);
320
+ // now username is TE
321
+ JSONObject newProperties = new JSONObject();
322
+ newProperties.put("username","TE");
323
+ TDAnalytics.*userSet*(newProperties);
324
+ } catch (JSONException e) {
325
+ e.printStackTrace();
326
+ }
327
+ ```
328
+
329
+ :::
330
+
331
+ ::: el-tab-pane label=Kotlin
332
+
333
+ ```
334
+ // now username is TA
335
+ val properties = JSONObject()
336
+ properties.put("username", "TA")
337
+ TDAnalytics.userSet(properties)
338
+ // now username is TE
339
+ val newProperties = JSONObject()
340
+ newProperties.put("username", "TE")
341
+ TDAnalytics.userSet(newProperties)
342
+ ```
343
+
344
+ :::
345
+
346
+ ::::
347
+
348
+ ### 4. Best Practices
349
+
350
+ The following example contains all operations above, We recommend following these steps:
351
+
352
+ :::: el-tabs
353
+
354
+ ::: el-tab-pane label=Java
355
+
356
+ ```
357
+ if (privacy policy granted) {
358
+ TDAnalytics.*init*(this, APPID, SERVER_URL);
359
+
360
+ // enable auto tracking events
361
+ TDAnalytics.*enableAutoTrack*(TDAnalytics.TDAutoTrackEventType.*APP_START *| TDAnalytics.TDAutoTrackEventType.*APP_END*
362
+ * *| TDAnalytics.TDAutoTrackEventType.*APP_INSTALL*);
363
+
364
+ // If user is logged in, set account ID as unique identifier
365
+ TDAnalytics.*login*("TA");
366
+ // After setting super properties, every event will have common event properties
367
+ try {
368
+ JSONObject superProperties = new JSONObject();
369
+ superProperties.put("channel","ta");// string
370
+ superProperties.put("age",1);// number
371
+ superProperties.put("isSuccess",true);// boolean
372
+ superProperties.put("birthday",new Date());// time
373
+
374
+ JSONObject object = new JSONObject();
375
+ object.put("key", "value");
376
+ superProperties.put("object",object);// object
377
+
378
+ JSONObject object1 = new JSONObject();
379
+ object1.put("key", "value");
380
+ JSONArray arr = new JSONArray();
381
+ arr.put(object1);
382
+ superProperties.put("object_arr",arr);// object group
383
+
384
+ JSONArray arr1 = new JSONArray();
385
+ arr1.put("value");
386
+ superProperties.put("arr",arr1);// array
387
+ // set super properties
388
+ TDAnalytics.*setSuperProperties*(superProperties);
389
+ } catch (JSONException e) {
390
+ e.printStackTrace();
391
+ }
392
+
393
+ // send event
394
+ try {
395
+ JSONObject properties = new JSONObject();
396
+ properties.put("product_name","product name");
397
+ TDAnalytics.*track*("product_buy", properties);
398
+ } catch (JSONException e) {
399
+ e.printStackTrace();
400
+ }
401
+
402
+ // set user properties
403
+ try {
404
+ JSONObject userProperties = new JSONObject();
405
+ userProperties.put("username","TA");
406
+ TDAnalytics.*userSet*(userProperties);
407
+ } catch (JSONException e) {
408
+ e.printStackTrace();
409
+ }
410
+ }
411
+
412
+ ```
413
+
414
+ :::
415
+
416
+ ::: el-tab-pane label=Kotlin
417
+
418
+ ```
419
+ if (privacy policy granted) {
420
+ TDAnalytics.*init*(this, APPID, SERVER_URL);
421
+ // If user is logged in, set account ID as unique identifier
422
+ TDAnalytics.*login*("TA");
423
+ // After setting super properties, every event will have common event properties
424
+ val superProperties = JSONObject().*apply ***{**
425
+ ** **put("channel", "ta") // string
426
+ put("age", 1) // number
427
+ put("isSuccess", true) // boolean
428
+ put("birthday", Date()) // time
429
+ put("object",JSONObject().*apply ***{ **// object
430
+ put("key", "value")
431
+ **}**)
432
+ put("object_arr",JSONArray().*apply ***{ **// object group
433
+ put(JSONObject().*apply ***{**
434
+ ** **put("key", "value")
435
+ **}**)
436
+ **}**)
437
+ put("arr",JSONArray().*apply ***{ **// array
438
+ put("value")
439
+ **}**)
440
+ **}**
441
+ // set super properties
442
+ TDAnalytics.*setSuperProperties*(superProperties);
443
+
444
+ // enable auto tracking events
445
+ TDAnalytics.enableAutoTrack(
446
+ TDAnalytics.TDAutoTrackEventType.*APP_START *or TDAnalytics.TDAutoTrackEventType.*APP_END*
447
+ * *or TDAnalytics.TDAutoTrackEventType.*APP_INSTALL*
448
+ )
449
+
450
+ // send event
451
+ val properties = JSONObject()
452
+ properties.put("product_name", "product name")
453
+ TDAnalytics.track("product_buy", properties)
454
+
455
+ // set user properties
456
+ JSONObject properties = new JSONObject();
457
+ properties.put("username","TA");
458
+ TDAnalytics.*userSet*(properties);
459
+ }
460
+
461
+ ```
462
+
463
+ :::
464
+
465
+ ::::
466
+
467
+ ---
468
+
469
+ # Advanced Guide
470
+
471
+ ### 1. Set User Identifier
472
+
473
+ SDK instance uses random UUID as default visitor ID, This ID serves as identity for unauthenticated users.Note: Visitor ID changes on reinstall or device change.
474
+
475
+ #### 1.1 Set Visitor ID
476
+
477
+ ::: tip Tip
478
+
479
+ Generally, you don't need to customize visitor ID. Make sure you understand user identification rules before setting visitor ID.
480
+
481
+ If you need to replace visitor ID, call immediately after SDK initialization, Do not call multiple times to avoid creating useless accounts
482
+
483
+ :::
484
+
485
+ If your App has its own visitor ID management system, then you can call *`setDistinctId`* to set visitor ID:
486
+
487
+ :::: el-tabs
488
+
489
+ ::: el-tab-pane label=Java
490
+
491
+ ```
492
+ // Set visitor ID to Thinker
493
+ TDAnalytics.*setDistinctId*("Thinker");
494
+ ```
495
+
496
+ :::
497
+
498
+ ::: el-tab-pane label=Kotlin
499
+
500
+ ```
501
+ // Set visitor ID to Thinker
502
+ TDAnalytics.setDistinctId("Thinker")
503
+ ```
504
+
505
+ :::
506
+
507
+ ::::
508
+
509
+ To get current visitor ID, call `getDistinctId`:
510
+
511
+ :::: el-tabs
512
+
513
+ ::: el-tab-pane label=Java
514
+
515
+ ```
516
+ // return visitor ID
517
+ String distinctId = TDAnalytics.*getDistinctId*();
518
+ ```
519
+
520
+ :::
521
+
522
+ ::: el-tab-pane label=Kotlin
523
+
524
+ ```
525
+ // return visitor ID
526
+ val distinctId = TDAnalytics.getDistinctId()
527
+ ```
528
+
529
+ :::
530
+
531
+ ::::
532
+
533
+ #### 1.2 Set Account ID
534
+
535
+ When user logs in, call `login` to set account ID, TE platform will use account ID as the identity ID, and the account ID will remain until `logout` is called.Multiple calls to `login` will override the previous account ID.
536
+
537
+ :::: el-tabs
538
+
539
+ ::: el-tab-pane label=Java
540
+
541
+ ```
542
+ // User login unique identifier, corresponds to #account_id in reported data, now #account_id is TA
543
+ TDAnalytics.*login*("TA");
544
+ ```
545
+
546
+ :::
547
+
548
+ ::: el-tab-pane label=Kotlin
549
+
550
+ ```
551
+ // User login unique identifier, corresponds to #account_id in reported data, now #account_id is TA
552
+ TDAnalytics.*login*("TA")
553
+ ```
554
+
555
+ :::
556
+
557
+ ::::
558
+
559
+ <!-- unsupported block: 34 -->
560
+
561
+ **This method does not upload login event**
562
+
563
+ #### 1.3 Clear Account ID
564
+
565
+ When user logs out, call `logout` to clear account ID, Before next `login` call, visitor ID will be used as identity.
566
+
567
+ :::: el-tabs
568
+
569
+ ::: el-tab-pane label=Java
570
+
571
+ ```
572
+ TDAnalytics.*logout*();
573
+ ```
574
+
575
+ :::
576
+
577
+ ::: el-tab-pane label=Kotlin
578
+
579
+ ```
580
+ TDAnalytics.*logout*()
581
+ ```
582
+
583
+ :::
584
+
585
+ ::::
586
+
587
+ We recommend calling `logout` only on explicit logout events, such as when user explicitly deregisters account, not needed when closing App.
588
+
589
+ <!-- unsupported block: 34 -->
590
+
591
+ **This method does not upload logout event**
592
+
593
+ ### 2. Track Events
594
+
595
+ After SDK initialization, you can start data tracking, to collect user behavior information.Normal events usually meet business requirements, You can also use first events, updatable events based on your needs.
596
+
597
+ #### 2.1 Normal Event
598
+
599
+ You can call `track` to upload events, We recommend setting event properties based on your tracking plan, Here is an example of user purchasing a product:
600
+
601
+ :::: el-tabs
602
+
603
+ ::: el-tab-pane label=Java
604
+
605
+ ```
606
+ // Store purchase event
607
+ try {
608
+ JSONObject properties = new JSONObject();
609
+ properties.put("product_name","product name");
610
+ TDAnalytics.*track*("product_buy",properties);
611
+ } catch (JSONException e) {
612
+ e.printStackTrace();
613
+ }
614
+ ```
615
+
616
+ :::
617
+
618
+ ::: el-tab-pane label=Kotlin
619
+
620
+ ```
621
+ // Store purchase event
622
+ val properties = JSONObject()
623
+ properties.put("product_name", "product name")
624
+ TDAnalytics.track("product_buy", properties)
625
+ ```
626
+
627
+ :::
628
+
629
+ ::::
630
+
631
+ #### 2.2 First Event
632
+
633
+ First event is recorded only once per device or other dimension ID.For example, you may want to record device activation event, you can use first event to report.
634
+
635
+ :::: el-tabs
636
+
637
+ ::: el-tab-pane label=Java
638
+
639
+ ```
640
+ JSONObject properties = new JSONObject();
641
+ try {
642
+ properties.put("key", "value");
643
+ } catch (JSONException e) {
644
+ e.printStackTrace();
645
+ }
646
+
647
+ TDAnalytics.*track*(new TDFirstEventModel("device_activation", properties));
648
+ ```
649
+
650
+ :::
651
+
652
+ ::: el-tab-pane label=Kotlin
653
+
654
+ ```
655
+ val properties = JSONObject()
656
+ properties.put("key", "value")
657
+ TDAnalytics.track(TDFirstEventModel("device_activation", properties))
658
+ ```
659
+
660
+ :::
661
+
662
+ ::::
663
+
664
+ If you want to judge first by other dimension than device, you can customize first_check_id for first event:
665
+
666
+ :::: el-tabs
667
+
668
+ ::: el-tab-pane label=Java
669
+
670
+ ```
671
+ // Set user ID as first_check_id to track user first activation event
672
+ TDFirstEventModel model = new TDFirstEventModel("device_activation", properties);
673
+ model.setFirstCheckId("TA");
674
+ TDAnalytics.*track*(model);
675
+ ```
676
+
677
+ :::
678
+
679
+ ::: el-tab-pane label=Kotlin
680
+
681
+ ```
682
+ // Set user ID as first_check_id to track user first activation event
683
+ val model = TDFirstEventModel("device_activation", properties)
684
+ model.setFirstCheckId("TA")
685
+ TDAnalytics.track(model)
686
+ ```
687
+
688
+ :::
689
+
690
+ ::::
691
+
692
+ <!-- unsupported block: 34 -->
693
+
694
+ Note: First events are validated on server, default delay 1 hour before storage.
695
+
696
+ #### 2.3 Updatable Event
697
+
698
+ Updatable events allow modifying event data in specific scenarios.Updatable event requires specifying event ID when creating.TE determines data to update by event name and event ID.
699
+
700
+ :::: el-tabs
701
+
702
+ ::: el-tab-pane label=Java
703
+
704
+ ```
705
+ // Example: Report updatable event, assume event name UPDATABLE_EVENT
706
+ // After report, status is 3, price is 100
707
+ JSONObject properties = new JSONObject();
708
+ try {
709
+ properties.put("status", 3);
710
+ properties.put("price", 100);
711
+ } catch (JSONException e) {
712
+ e.printStackTrace();
713
+ }
714
+ TDAnalytics.*track*(new TDUpdatableEventModel("UPDATABLE_EVENT", properties, "test_event_id"));
715
+ // After report, status updated to 5, price unchanged
716
+ JSONObject properties_new = new JSONObject();
717
+ try {
718
+ properties_new.put("status", 5);
719
+ } catch (JSONException e) {
720
+ e.printStackTrace();
721
+ }
722
+ TDAnalytics.*track*(new TDUpdatableEventModel("UPDATABLE_EVENT", properties_new, "test_event_id"));
723
+ ```
724
+
725
+ :::
726
+
727
+ ::: el-tab-pane label=Kotlin
728
+
729
+ ```
730
+ // Example: Report updatable event, assume event name UPDATABLE_EVENT
731
+ // After report, status is 3, price is 100
732
+ val properties = JSONObject()
733
+ properties.put("status", 3)
734
+ properties.put("price", 100)
735
+ TDAnalytics.track(TDUpdatableEventModel("UPDATABLE_EVENT", properties, "test_event_id"))
736
+ // After report, status updated to 5, price unchanged
737
+ val properties_new = JSONObject()
738
+ properties_new.put("status", 5)
739
+ TDAnalytics.track(TDUpdatableEventModel("UPDATABLE_EVENT", properties_new, "test_event_id"))
740
+ ```
741
+
742
+ :::
743
+
744
+ ::::
745
+
746
+ #### 2.4 Overwriteable Event
747
+
748
+ Overwriteable event is similar to updatable event, difference is overwriteable event completely overwrites historical data, effectively deleting previous data and storing new data.TE determines data to update by event name and event ID.
749
+
750
+ :::: el-tabs
751
+
752
+ ::: el-tab-pane label=Java
753
+
754
+ ```
755
+ // Example: Report overwriteable event, assume event name OVERWRITE_EVENT
756
+ // After report, status is 3, price is 100
757
+ JSONObject properties = new JSONObject();
758
+ try {
759
+ properties.put("status", 3);
760
+ properties.put("price", 100);
761
+ } catch (JSONException e) {
762
+ e.printStackTrace();
763
+ }
764
+ TDAnalytics.*track*(new TDOverWritableEventModel("OVERWRITE_EVENT", properties, "test_event_id"));
765
+ // After report, status updated to 5, price property deleted
766
+ JSONObject properties_new = new JSONObject();
767
+ try {
768
+ properties_new.put("status", 5);
769
+ } catch (JSONException e) {
770
+ e.printStackTrace();
771
+ }
772
+ TDAnalytics.*track*(new TDOverWritableEventModel("OVERWRITE_EVENT", properties_new, "test_event_id"));
773
+ ```
774
+
775
+ :::
776
+
777
+ ::: el-tab-pane label=Kotlin
778
+
779
+ ```
780
+ // Example: Report overwriteable event, assume event name OVERWRITE_EVENT
781
+ // After report, status is 3, price is 100
782
+ val properties = JSONObject()
783
+ properties.put("status", 3)
784
+ properties.put("price", 100)
785
+ TDAnalytics.track(TDOverWritableEventModel("OVERWRITE_EVENT", properties, "test_event_id"))
786
+ // After report, status updated to 5, price property deleted
787
+ val properties_new = JSONObject()
788
+ properties_new.put("status", 5)
789
+ TDAnalytics.track(TDOverWritableEventModel("OVERWRITE_EVENT", properties_new, "test_event_id"))
790
+ ```
791
+
792
+ :::
793
+
794
+ ::::
795
+
796
+ #### 2.5 Super Properties
797
+
798
+ Super properties are properties uploaded with every event.By update frequency, super properties are static and dynamic.Choose different methods based on your business needs;we recommend setting super properties before sending events.When super property, custom property, preset property have same Key, priority: custom > dynamic super > static super > preset.
799
+
800
+ ##### 2.5.1 Static Super Properties
801
+
802
+ Static super properties are low-frequency properties like membership level.After setting static super properties via `setSuperProperties`, SDK will get these properties during event collection.
803
+
804
+ :::: el-tabs
805
+
806
+ ::: el-tab-pane label=Java
807
+
808
+ ```
809
+ // set super properties
810
+ try {
811
+ JSONObject superProperties = new JSONObject();
812
+ superProperties.put("vip_level",2);
813
+ TDAnalytics.*setSuperProperties*(superProperties);
814
+ } catch (JSONException e) {
815
+ e.printStackTrace();
816
+ }
817
+ ```
818
+
819
+ :::
820
+
821
+ ::: el-tab-pane label=Kotlin
822
+
823
+ ```
824
+ // set super properties
825
+ val superProperties = JSONObject()
826
+ superProperties.put("vip_level", 2)
827
+ TDAnalytics.setSuperProperties(superProperties)
828
+ ```
829
+
830
+ :::
831
+
832
+ ::::
833
+
834
+ Static super properties will be saved to cache, no need to call every time App starts. If the property already exists, the newly set property will override the previous value; if the property did not exist before, it will be created. In addition to property setting, we also provide other APIs to manage static common event properties to meet daily business needs.
835
+
836
+ :::: el-tabs
837
+
838
+ ::: el-tab-pane label=Java
839
+
840
+ ```
841
+ // clear a super property
842
+ TDAnalytics.*unsetSuperProperty*("Channel");
843
+ // clear all super properties
844
+ TDAnalytics.*clearSuperProperties*();
845
+ // get all super properties
846
+ TDAnalytics.*getSuperProperties*();
847
+ ```
848
+
849
+ :::
850
+
851
+ ::: el-tab-pane label=Kotlin
852
+
853
+ ```
854
+ // clear a super property
855
+ TDAnalytics.*unsetSuperProperty*("Channel")
856
+ // clear all super properties
857
+ TDAnalytics.*clearSuperProperties*()
858
+ // get all super properties
859
+ TDAnalytics.*getSuperProperties*()
860
+ ```
861
+
862
+ :::
863
+
864
+ ::::
865
+
866
+ ##### 2.5.2 Dynamic Super Properties
867
+
868
+ Dynamic super properties are high-frequency properties like coin count.After setting dynamic super properties via `setDynamicSuperPropertiesTracker`, SDK will automatically get properties from `getDynamicSuperProperties`, and add them to triggered events.
869
+
870
+ :::: el-tabs
871
+
872
+ ::: el-tab-pane label=Java
873
+
874
+ ```
875
+ int coin = 0;
876
+ TDAnalytics.*setDynamicSuperProperties*(new TDAnalytics.TDDynamicSuperPropertiesHandler() {
877
+ @Override
878
+ public JSONObject getDynamicSuperProperties() {
879
+ JSONObject dynamicSuperProperties = new JSONObject();
880
+ coin++;// coin count updates frequently
881
+ try {
882
+ dynamicSuperProperties.put("coin",coin);
883
+ } catch (JSONException e) {
884
+ e.printStackTrace();
885
+ }
886
+ return dynamicSuperProperties;
887
+ }
888
+ });
889
+ ```
890
+
891
+ :::
892
+
893
+ ::: el-tab-pane label=Kotlin
894
+
895
+ ```
896
+ var coin = 0
897
+ TDAnalytics.setDynamicSuperProperties(object :TDDynamicSuperPropertiesHandler{
898
+ override fun getDynamicSuperProperties(): JSONObject {
899
+ val dynamicSuperProperties = JSONObject()
900
+ coin++ // coin count updates frequently
901
+ dynamicSuperProperties.put("coin", coin)
902
+ return dynamicSuperProperties
903
+ }
904
+ })
905
+ ```
906
+
907
+ :::
908
+
909
+ ::::
910
+
911
+ #### 2.6 Time Event
912
+
913
+ To record event duration, call `timeEvent` to start timing.Configure the event name to time, When you upload the event, `#duration` will be added automatically, in seconds. Note: Only one timing task per event name.
914
+
915
+ :::: el-tabs
916
+
917
+ ::: el-tab-pane label=Java
918
+
919
+ ```
920
+ // Example: track user stay duration on product page
921
+ try {
922
+ // User enters product page, start timing
923
+ TDAnalytics.*timeEvent*("stay_shop");
924
+ /**do someting
925
+ .......
926
+ **/
927
+ // User leaves product page, timing ends, "stay_shop" event will have #duration property
928
+ TDAnalytics.*track*("stay_shop");
929
+ } catch (JSONException e) {
930
+ e.printStackTrace();
931
+ }
932
+ ```
933
+
934
+ :::
935
+
936
+ ::: el-tab-pane label=Kotlin
937
+
938
+ ```
939
+ // Example: track user stay duration on product page
940
+ // User enters product page, start timing
941
+ TDAnalytics.timeEvent("stay_shop")
942
+ */**do someting*
943
+ * * .......*
944
+ * */*
945
+ // User leaves product page, timing ends, "stay_shop" event will have #duration property
946
+ TDAnalytics.track("stay_shop")
947
+ ```
948
+
949
+ :::
950
+
951
+ ::::
952
+
953
+ ### 3. User Properties
954
+
955
+ TE supports user property APIs: `userSet`, `userSetOnce`, `userAdd`, `userUnset`, `userDelete`, `userAppend`, `userUniqAppend`
956
+
957
+ #### 3.1 userSet
958
+
959
+ For general user properties, you can call `userSet` to set them. Properties uploaded via this interface will override existing values, If property doesn't exist, it will be created, Type matches the uploaded property type, Here is an example of setting username:
960
+
961
+ :::: el-tabs
962
+
963
+ ::: el-tab-pane label=Java
964
+
965
+ ```
966
+ try {
967
+ // now username is TA
968
+ JSONObject properties = new JSONObject();
969
+ properties.put("username","TA");
970
+ TDAnalytics.*userSet*(properties);
971
+ // now username is TE
972
+ JSONObject newProperties = new JSONObject();
973
+ newProperties.put("username","TE");
974
+ TDAnalytics.*userSet*(newProperties);
975
+ } catch (JSONException e) {
976
+ e.printStackTrace();
977
+ }
978
+ ```
979
+
980
+ :::
981
+
982
+ ::: el-tab-pane label=Kotlin
983
+
984
+ ```
985
+ // now username is TA
986
+ val properties = JSONObject()
987
+ properties.put("username", "TA")
988
+ TDAnalytics.userSet(properties)
989
+ // now username is TE
990
+ val newProperties = JSONObject()
991
+ newProperties.put("username", "TE")
992
+ TDAnalytics.userSet(newProperties)
993
+ ```
994
+
995
+ :::
996
+
997
+ ::::
998
+
999
+ #### 3.2 userSetOnce
1000
+
1001
+ If you want to set user property only once, call `userSetOnce`, If property already has value, this call will be ignored, Example: setting first payment time:
1002
+
1003
+ :::: el-tabs
1004
+
1005
+ ::: el-tab-pane label=Java
1006
+
1007
+ ```
1008
+ try {
1009
+ // first_payment_time is 2018-01-01 01:23:45.678
1010
+ JSONObject properties = new JSONObject();
1011
+ properties.put("first_payment_time","2018-01-01 01:23:45.678");
1012
+ TDAnalytics.*userSetOnce*(properties);
1013
+
1014
+ // first_payment_time still 2018-01-01 01:23:45.678
1015
+ JSONObject newProperties = new JSONObject();
1016
+ newProperties.put("first_payment_time","2018-12-31 01:23:45.678");
1017
+ TDAnalytics.*userSetOnce*(newProperties);
1018
+
1019
+ } catch (JSONException e) {
1020
+ e.printStackTrace();
1021
+ }
1022
+ ```
1023
+
1024
+ :::
1025
+
1026
+ ::: el-tab-pane label=Kotlin
1027
+
1028
+ ```
1029
+ // first_payment_time is 2018-01-01 01:23:45.678
1030
+ val properties = JSONObject()
1031
+ properties.put("first_payment_time", "2018-01-01 01:23:45.678")
1032
+ TDAnalytics.userSetOnce(properties)
1033
+
1034
+ // first_payment_time still 2018-01-01 01:23:45.678
1035
+ val newProperties = JSONObject()
1036
+ newProperties.put("first_payment_time", "2018-12-31 01:23:45.678")
1037
+ TDAnalytics.userSetOnce(newProperties)
1038
+ ```
1039
+
1040
+ :::
1041
+
1042
+ ::::
1043
+
1044
+ #### 3.3 userAdd
1045
+
1046
+ For numeric property accumulation, call `userAdd`.If property not set, it will be initialized to 0 then calculated, Negative values allowed (subtraction). Example: cumulative payment amount:
1047
+
1048
+ :::: el-tabs
1049
+
1050
+ ::: el-tab-pane label=Java
1051
+
1052
+ ```
1053
+ try {
1054
+ // now total_revenue is 30
1055
+ JSONObject properties = new JSONObject();
1056
+ properties.put("total_revenue",30);
1057
+ TDAnalytics.*userAdd*(properties);
1058
+
1059
+ // now total_revenue is 678
1060
+ JSONObject newProperties = new JSONObject();
1061
+ newProperties.put("total_revenue",648);
1062
+ TDAnalytics.*userAdd*(newProperties);
1063
+ } catch (JSONException e) {
1064
+ e.printStackTrace();
1065
+ }
1066
+ ```
1067
+
1068
+ :::
1069
+
1070
+ ::: el-tab-pane label=Kotlin
1071
+
1072
+ ```
1073
+ // now total_revenue is 30
1074
+ val properties = JSONObject()
1075
+ properties.put("total_revenue", 30)
1076
+ TDAnalytics.userAdd(properties)
1077
+
1078
+ // now total_revenue is 678
1079
+ val newProperties = JSONObject()
1080
+ newProperties.put("total_revenue", 648)
1081
+ TDAnalytics.userAdd(newProperties)
1082
+ ```
1083
+
1084
+ :::
1085
+
1086
+ ::::
1087
+
1088
+ #### 3.4 userUnset
1089
+
1090
+ To clear user property value, call `userUnset` for specified property, if the property has not been created in the cluster yet, `userUnset` **will not** create the property
1091
+
1092
+ :::: el-tabs
1093
+
1094
+ ::: el-tab-pane label=Java
1095
+
1096
+ ```
1097
+ // Reset single user property
1098
+ TDAnalytics.*userUnset*("key1");
1099
+ // Reset multiple user properties
1100
+ TDAnalytics.*userUnset*("key1", "key2", "key3");
1101
+ ```
1102
+
1103
+ :::
1104
+
1105
+ ::: el-tab-pane label=Kotlin
1106
+
1107
+ ```
1108
+ // Reset single user property
1109
+ TDAnalytics.*userUnset*("key1")
1110
+ // Reset multiple user properties
1111
+ TDAnalytics.*userUnset*("key1", "key2", "key3")
1112
+ ```
1113
+
1114
+ :::
1115
+
1116
+ ::::
1117
+
1118
+ #### 3.5 userDelete
1119
+
1120
+ To delete a user, call `userDelete`, You won't be able to query user properties, but events remain queryable.
1121
+
1122
+ :::: el-tabs
1123
+
1124
+ ::: el-tab-pane label=Java
1125
+
1126
+ ```
1127
+ TDAnalytics.*userDelete*();
1128
+ ```
1129
+
1130
+ :::
1131
+
1132
+ ::: el-tab-pane label=Kotlin
1133
+
1134
+ ```
1135
+ TDAnalytics.*userDelete*()
1136
+ ```
1137
+
1138
+ :::
1139
+
1140
+ ::::
1141
+
1142
+ #### 3.6 userAppend
1143
+
1144
+ Call `userAppend` to append elements to array-type user property.
1145
+
1146
+ :::: el-tabs
1147
+
1148
+ ::: el-tab-pane label=Java
1149
+
1150
+ ```
1151
+ try {
1152
+ // list is user property user_list value, JSONArray type
1153
+ JSONArray list = new JSONArray("[\"apple\", \"ball\"]");
1154
+ JSONObject properties = new JSONObject();
1155
+ properties.put("user_list", list);
1156
+ // Call user_append to append to user_list. If not exists, will create.
1157
+ TDAnalytics.*userAppend*(properties);
1158
+ } catch (JSONException e) {
1159
+ e.printStackTrace();
1160
+ }
1161
+ ```
1162
+
1163
+ :::
1164
+
1165
+ ::: el-tab-pane label=Kotlin
1166
+
1167
+ ```
1168
+ // list is user property user_list value, JSONArray type
1169
+ val list = JSONArray("[\"apple\", \"ball\"]")
1170
+ val properties = JSONObject()
1171
+ properties.put("user_list", list)
1172
+ // Call user_append to append to user_list. If not exists, will create.
1173
+ TDAnalytics.userAppend(properties)
1174
+ ```
1175
+
1176
+ :::
1177
+
1178
+ ::::
1179
+
1180
+ #### 3.7 userUniqAppend
1181
+
1182
+ Call `userUniqAppend` to append to array-type user property.`userUniqAppend` deduplicates appended properties, `userAppend` doesn't deduplicate, properties can be duplicated.
1183
+
1184
+ :::: el-tabs
1185
+
1186
+ ::: el-tab-pane label=Java
1187
+
1188
+ ```
1189
+ try {
1190
+ // list is user property user_list value, JSONArray type
1191
+ // now user_list property value is["apple", "ball"]
1192
+ JSONArray list = new JSONArray("[\"apple\", \"ball\"]");
1193
+ JSONObject properties = new JSONObject();
1194
+ properties.put("user_list", list);
1195
+ TDAnalytics.*userAppend*(properties);
1196
+
1197
+
1198
+ // now user_list property value is["apple","apple","ball","cube"]
1199
+ JSONArray list1 = new JSONArray("[\"apple\", \"cube\"]");
1200
+ JSONObject properties1 = new JSONObject();
1201
+ properties1.put("user_list", list1);
1202
+ TDAnalytics.*userAppend*(properties1);
1203
+
1204
+ // now user_list property value is["apple", "ball","cube"]
1205
+ TDAnalytics.*userUniqAppend*(properties1);
1206
+
1207
+ } catch (JSONException e) {
1208
+ e.printStackTrace();
1209
+ }
1210
+ ```
1211
+
1212
+ :::
1213
+
1214
+ ::: el-tab-pane label=Kotlin
1215
+
1216
+ ```
1217
+ // list is user property user_list value, JSONArray type
1218
+ // now user_list property value is["apple", "ball"]
1219
+ val list = JSONArray("[\"apple\", \"ball\"]")
1220
+ val properties = JSONObject()
1221
+ properties.put("user_list", list)
1222
+ TDAnalytics.userAppend(properties)
1223
+
1224
+ // now user_list property value is["apple","apple","ball","cube"]
1225
+ val list1 = JSONArray("[\"apple\", \"cube\"]")
1226
+ val properties1 = JSONObject()
1227
+ properties1.put("user_list", list1)
1228
+ TDAnalytics.userAppend(properties1)
1229
+
1230
+ // now user_list property value is["apple", "ball","cube"]
1231
+ TDAnalytics.userUniqAppend(properties1)
1232
+ ```
1233
+
1234
+ :::
1235
+
1236
+ ::::
1237
+
1238
+ ### 4. Encryption
1239
+
1240
+ From v2.8.0, SDK supports AES+RSA encryption.Encryption requires client and server coordination, Please consult customer success for details.
1241
+
1242
+ :::: el-tabs
1243
+
1244
+ ::: el-tab-pane label=Java
1245
+
1246
+ ```
1247
+ TDConfig config = TDConfig.getInstance(mContext,TA_APP_ID,TA_SERVER_URL);
1248
+ // enable encryption, set public key
1249
+ config.enableEncrypt(1,"publicKey")
1250
+ ```
1251
+
1252
+ :::
1253
+
1254
+ ::: el-tab-pane label=Kotlin
1255
+
1256
+ ```
1257
+ val config = TDConfig.getInstance(mContext,TA_APP_ID,TA_SERVER_URL)
1258
+ // enable encryption, set public key
1259
+ config.enableEncrypt(1,"publicKey")
1260
+ ```
1261
+
1262
+ :::
1263
+
1264
+ ::::
1265
+
1266
+ ### 5. H5 Integration
1267
+
1268
+ To integrate with JavaScript SDK for H5 pages, call the following interface when initializing `WebView`, See H5 and APP SDK Integration section for details
1269
+
1270
+ :::: el-tabs
1271
+
1272
+ ::: el-tab-pane label=Java
1273
+
1274
+ ```
1275
+ // Integrate H5 page data
1276
+ TDAnalytics.setJsBridge(webView);
1277
+ ```
1278
+
1279
+ :::
1280
+
1281
+ ::: el-tab-pane label=Kotlin
1282
+
1283
+ ```
1284
+ // Integrate H5 page data
1285
+ TDAnalytics.setJsBridge(webView)
1286
+ ```
1287
+
1288
+ :::
1289
+
1290
+ ::::
1291
+
1292
+ ### 6. Other Features
1293
+
1294
+ #### 6.1 Get Device ID
1295
+
1296
+ Get device ID by calling `getDeviceId`:
1297
+
1298
+ :::: el-tabs
1299
+
1300
+ ::: el-tab-pane label=Java
1301
+
1302
+ ```
1303
+ String deviceID = TDAnalytics.*getDeviceId*();// Device ID is Android ID
1304
+ ```
1305
+
1306
+ :::
1307
+
1308
+ ::: el-tab-pane label=Kotlin
1309
+
1310
+ ```
1311
+ val deviceID = TDAnalytics.getDeviceId() // Device ID is Android ID
1312
+ ```
1313
+
1314
+ :::
1315
+
1316
+ ::::
1317
+
1318
+ #### 6.2 Set Default Timezone
1319
+
1320
+ By default, SDK uses local time as event time.You can also specify timezone via default timezone interface, so all events will be aligned to your timezone:
1321
+
1322
+ :::: el-tabs
1323
+
1324
+ ::: el-tab-pane label=Java
1325
+
1326
+ ```
1327
+ // Get TDConfig instance
1328
+ TDConfig config = TDConfig.getInstance(this, TA_APP_ID, TA_SERVER_URL);
1329
+ // Set default timezone to UTC
1330
+ config.setDefaultTimeZone(TimeZone.getTimeZone("UTC"));
1331
+ // Initialize SDK
1332
+ TDAnalytics.*init*(config);
1333
+ ```
1334
+
1335
+ :::
1336
+
1337
+ ::: el-tab-pane label=Kotlin
1338
+
1339
+ ```
1340
+ // Get TDConfig instance
1341
+ val config = TDConfig.getInstance(this, TA_APP_ID, TA_SERVER_URL)
1342
+ // Set default timezone to UTC
1343
+ config.*defaultTimeZone *= TimeZone.getTimeZone("UTC")
1344
+ // Initialize SDK
1345
+ TDAnalytics.init(config)
1346
+ ```
1347
+
1348
+ :::
1349
+
1350
+ ::::
1351
+
1352
+ <!-- unsupported block: 34 -->
1353
+
1354
+ Aligning event time with specified timezone loses local timezone info.If you need local timezone, add it as event property yourself.
1355
+
1356
+ #### 6.3 Calibrate Time
1357
+
1358
+ SDK uses local time as event time by default, If user manually modifies device time, it affects your analysis, You can calibrate time to ensure accuracy.We provide timestamp and NTP calibration methods.
1359
+
1360
+ - You can calibrate SDK time using server timestamp.All calls without specified time will use calibrated time.
1361
+ :::: el-tabs
1362
+
1363
+ ::: el-tab-pane label=Java
1364
+
1365
+ ```
1366
+ // 1585633785954 is unix timestamp in ms, Beijing time 2020-03-31 13:49:45
1367
+ TDAnalytics.calibrateTime(1585633785954);
1368
+ ```
1369
+
1370
+ :::
1371
+
1372
+ ::: el-tab-pane label=Kotlin
1373
+
1374
+ ```
1375
+ // 1585633785954 is unix timestamp in ms, Beijing time 2020-03-31 13:49:45
1376
+ TDAnalytics.calibrateTime(1585633785954)
1377
+ ```
1378
+
1379
+ :::
1380
+
1381
+ ::::
1382
+
1383
+ - You can also set NTP server address, SDK will try to get current time from NTP and calibrate.If correct result not obtained within 3 seconds timeout, local time will be used for reporting.
1384
+ :::: el-tabs
1385
+
1386
+ ::: el-tab-pane label=Java
1387
+
1388
+ ```
1389
+ // Use Apple NTP service for time calibration
1390
+ TDAnalytics.calibrateTimeWithNtp("time.apple.com");
1391
+ ```
1392
+
1393
+ :::
1394
+
1395
+ ::: el-tab-pane label=Kotlin
1396
+
1397
+ ```
1398
+ // Use Apple NTP service for time calibration
1399
+ TDAnalytics.calibrateTimeWithNtp("time.apple.com")
1400
+ ```
1401
+
1402
+ :::
1403
+
1404
+ ::::
1405
+
1406
+ <!-- unsupported block: 34 -->
1407
+
1408
+ 1. NTP calibration has some uncertainty, We recommend timestamp calibration
1409
+
1410
+ 2. Choose NTP server address carefully, to ensure devices can quickly get server time
1411
+
1412
+ #### 6.4 Flush Data
1413
+
1414
+ In some scenarios, if you want to report data immediately, call `flush` interface
1415
+
1416
+ :::: el-tabs
1417
+
1418
+ ::: el-tab-pane label=Java
1419
+
1420
+ ```
1421
+ TDAnalytics.flush();
1422
+ ```
1423
+
1424
+ :::
1425
+
1426
+ ::: el-tab-pane label=Kotlin
1427
+
1428
+ ```
1429
+ TDAnalytics.flush()
1430
+ ```
1431
+
1432
+ :::
1433
+
1434
+ ::::
1435
+
1436
+ #### 6.5 Get Country/Region Code
1437
+
1438
+ In some scenarios, if you need country/region code, call `getLocalRegion`
1439
+
1440
+ :::: el-tabs
1441
+
1442
+ ::: el-tab-pane label=Java
1443
+
1444
+ ```
1445
+ TDAnalytics.getLocalRegion();
1446
+ ```
1447
+
1448
+ :::
1449
+
1450
+ ::: el-tab-pane label=Kotlin
1451
+
1452
+ ```
1453
+ TDAnalytics.getLocalRegion()
1454
+ ```
1455
+
1456
+ :::
1457
+
1458
+ ::::
1459
+
1460
+ #### 6.6 Disable AndroidID Collection
1461
+
1462
+ If you don't want AndroidID collection code in project, use plugin to isolate sensitive properties like AndroidID.
1463
+
1464
+ Android SDK Version
1465
+
1466
+ Plugin Version
1467
+
1468
+ [oldest - 3.0.0)
1469
+
1470
+ 1.2.0
1471
+
1472
+ [3.0.0 - 3.1.0]
1473
+
1474
+ 2.1.0
1475
+
1476
+ (3.1.0 - latest]
1477
+
1478
+ 2.2.0
1479
+
1480
+ ```
1481
+ buildscript {
1482
+ repositories {
1483
+ google()
1484
+ jcenter()
1485
+ }
1486
+ dependencies {
1487
+ classpath 'cn.thinkingdata.android:android-gradle-plugin2:2.2.0'
1488
+ }
1489
+ }
1490
+ // Configure disableAndroidID to true in the project build.gradle file
1491
+ apply plugin: 'cn.thinkingdata.android'
1492
+ android {}
1493
+ ThinkingAnalytics {
1494
+ debug = true
1495
+ sdk{
1496
+ disableAndroidID = true
1497
+ }
1498
+ }
1499
+ ```
1500
+
1501
+ Parameter Details:
1502
+
1503
+ - debug : Whether to enable compile log, true to enable, default false.
1504
+ - exclude : Exclude scanning classes under certain path, can be set via exclude = ['cn.thinkingdata.android','android.support'].
1505
+ - useInclude , include: Only scan classes under certain path, can be set via useInclude = true, include= ['cn.thinkingdata.android','android.support'].
1506
+ - disableAndroidID : Whether to disable system API for AndroidID, From plugin V2.1.0, set disableAndroidID = true.
1507
+
1508
+ #### 6.7 Support IP Reporting
1509
+
1510
+ To prevent/solve DNS hijacking issues, SDK parses ServerUrl to get IP and reports directly. Example:
1511
+
1512
+ :::: el-tabs
1513
+
1514
+ ::: el-tab-pane label=Java
1515
+
1516
+ ```
1517
+ TDConfig config = TDConfig.getInstance(this, APPID, TE_SERVER_URL);
1518
+ List<TDConfig.TDDNSService> list = new ArrayList<>();
1519
+ list.add(TDConfig.TDDNSService.*CLOUD_ALI*);
1520
+ list.add(TDConfig.TDDNSService.*CLOUD_FLARE*);
1521
+ list.add(TDConfig.TDDNSService.*CLOUD_GOOGLE*);
1522
+ config.enableDNSService(list);
1523
+ ```
1524
+
1525
+ :::
1526
+
1527
+ ::: el-tab-pane label=Kotlin
1528
+
1529
+ ```
1530
+ val config = TDConfig.getInstance(this, APPID, TE_SERVER_URL)
1531
+ val list: MutableList<TDDNSService> = ArrayList()
1532
+ list.add(TDDNSService.*CLOUD_ALI*)
1533
+ list.add(TDDNSService.*CLOUD_FLARE*)
1534
+ list.add(TDDNSService.*CLOUD_GOOGLE*)
1535
+ config.enableDNSService(list)
1536
+ ```
1537
+
1538
+ :::
1539
+
1540
+ ::::
1541
+
1542
+ #### 6.8 Support SDK Error Callback
1543
+
1544
+ <!-- unsupported block: 19 -->
1545
+
1546
+ Requires Android SDK version >= 3.2.0
1547
+
1548
+ In some scenarios, you may want custom handling on network failure, You can register errorCallback, example:
1549
+
1550
+ :::: el-tabs
1551
+
1552
+ ::: el-tab-pane label=Java
1553
+
1554
+ ```
1555
+ TDAnalytics.*registerErrorCallback*(new TDAnalytics.TDSendDataErrorCallback() {
1556
+ @Override
1557
+ public void onSDKErrorCallback(int code, String errorMsg, String ext) {
1558
+ // *todo*
1559
+ * *}
1560
+ });
1561
+ ```
1562
+
1563
+ :::
1564
+
1565
+ ::: el-tab-pane label=Kotlin
1566
+
1567
+ ```
1568
+ TDAnalytics.registerErrorCallback(object : TDAnalytics.TDSendDataErrorCallback {
1569
+ override fun onSDKErrorCallback(code: Int, errorMsg: String?, ext: String?) {
1570
+ // *todo*
1571
+ * *}
1572
+ })
1573
+ ```
1574
+
1575
+ :::
1576
+
1577
+ ::::
1578
+
1579
+ Error Code
1580
+
1581
+ Error Code
1582
+
1583
+ Description
1584
+
1585
+ 1001
1586
+
1587
+ Network request failed
1588
+
1589
+ ---
1590
+
1591
+ # Third-party Data
1592
+
1593
+ <!-- unsupported block: 19 -->
1594
+
1595
+ If the SDK version is below 3.0.0, Plugin Version should be 1.3.0; if the SDK version is 3.0.0 or above, Plugin Version should be 2.0.0 or above
1596
+
1597
+ ```
1598
+ implementation 'cn.thinkingdata.android:TAThirdParty:2.0.2'
1599
+ ```
1600
+
1601
+ Sample code for syncing multiple platforms:
1602
+
1603
+ :::: el-tabs
1604
+
1605
+ ::: el-tab-pane label=Java
1606
+
1607
+ ```
1608
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*APPS_FLYER *| TDThirdPartyType.*ADJUST*);
1609
+ ```
1610
+
1611
+ :::
1612
+
1613
+ ::: el-tab-pane label=Kotlin
1614
+
1615
+ ```
1616
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.APPS_FLYER or TDThirdPartyType.ADJUST)
1617
+ ```
1618
+
1619
+ :::
1620
+
1621
+ ::::
1622
+
1623
+ <!-- unsupported block: 34 -->
1624
+
1625
+ For additional parameters, use`enableThirdPartySharing(int var1, Map<String, Object> var2)`, This API doesn't support bitwise operations
1626
+
1627
+ If using proguard, add the following to config:
1628
+
1629
+ ```
1630
+ -dontwarn cn.thinkingdata.thirdparty.**
1631
+ -keep class cn.thinkingdata.thirdparty.** { *; }
1632
+ -keep class cn.thinkingdata.module.routes.** { *; }
1633
+ ```
1634
+
1635
+ ### 1. Appsflyer
1636
+
1637
+ Call API before AppsFlyer SDK start method:
1638
+
1639
+ :::: el-tabs
1640
+
1641
+ ::: el-tab-pane label=Java
1642
+
1643
+ ```
1644
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.*APPS_FLYER*);
1645
+ ```
1646
+
1647
+ :::
1648
+
1649
+ ::: el-tab-pane label=Kotlin
1650
+
1651
+ ```
1652
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.*APPS_FLYER*)
1653
+ ```
1654
+
1655
+ :::
1656
+
1657
+ ::::
1658
+
1659
+ After character creation (optional):
1660
+
1661
+ :::: el-tabs
1662
+
1663
+ ::: el-tab-pane label=Java
1664
+
1665
+ ```
1666
+ TDAnalytics.login("account_id")
1667
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.*APPS_FLYER*);
1668
+ ```
1669
+
1670
+ :::
1671
+
1672
+ ::: el-tab-pane label=Kotlin
1673
+
1674
+ ```
1675
+ TDAnalytics.login("account_id")
1676
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.*APPS_FLYER*)
1677
+ ```
1678
+
1679
+ :::
1680
+
1681
+ ::::
1682
+
1683
+ After TE login or identify, call enableThirdPartySharing to update user ID.
1684
+
1685
+ Note: AppsFlyer setAdditionalData overwrites user ID on each call.You can set parameters via our `enableThirdPartySharing`:
1686
+
1687
+ :::: el-tabs
1688
+
1689
+ ::: el-tab-pane label=Java
1690
+
1691
+ ```
1692
+ Map<String, Object> additionalData = new HashMap<>();
1693
+ additionalData.put("af_test_key1", "test1");
1694
+ additionalData.put("af_test_key2", "test2");
1695
+ TDAnalytics.enableThirdPartySharing(
1696
+ TDThirdPartyType.*APPS_FLYER*,
1697
+ additionalData
1698
+ )
1699
+ ```
1700
+
1701
+ :::
1702
+
1703
+ ::: el-tab-pane label=Kotlin
1704
+
1705
+ ```
1706
+ val additionalData: MutableMap<String, Any> = HashMap()
1707
+ additionalData["af_test_key1"] = "test1"
1708
+ additionalData["af_test_key2"] = "test2"
1709
+ TDAnalytics.enableThirdPartySharing(
1710
+ TDThirdPartyType.*APPS_FLYER*,
1711
+ additionalData
1712
+ )
1713
+ ```
1714
+
1715
+ :::
1716
+
1717
+ ::::
1718
+
1719
+ ### 2. Adjust
1720
+
1721
+ Call before Adjust SDK initialization:
1722
+
1723
+ :::: el-tabs
1724
+
1725
+ ::: el-tab-pane label=Java
1726
+
1727
+ ```
1728
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.*ADJUST*);
1729
+ ```
1730
+
1731
+ :::
1732
+
1733
+ ::: el-tab-pane label=Kotlin
1734
+
1735
+ ```
1736
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.*ADJUST*)
1737
+ ```
1738
+
1739
+ :::
1740
+
1741
+ ::::
1742
+
1743
+ After character creation (optional):
1744
+
1745
+ :::: el-tabs
1746
+
1747
+ ::: el-tab-pane label=Java
1748
+
1749
+ ```
1750
+ TDAnalytics.login("accoount_id")
1751
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.*ADJUST*);
1752
+ ```
1753
+
1754
+ :::
1755
+
1756
+ ::: el-tab-pane label=Kotlin
1757
+
1758
+ ```
1759
+ TDAnalytics.login("accoount_id")
1760
+ TDAnalytics.enableThirdPartySharing(TDThirdPartyType.*ADJUST*)
1761
+ ```
1762
+
1763
+ :::
1764
+
1765
+ ::::
1766
+
1767
+ ### 3. Branch
1768
+
1769
+ Call before Branch session initialization:
1770
+
1771
+ :::: el-tabs
1772
+
1773
+ ::: el-tab-pane label=Java
1774
+
1775
+ ```
1776
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*BRANCH*);
1777
+ ```
1778
+
1779
+ :::
1780
+
1781
+ ::: el-tab-pane label=Kotlin
1782
+
1783
+ ```
1784
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*BRANCH*)
1785
+ ```
1786
+
1787
+ :::
1788
+
1789
+ ::::
1790
+
1791
+ After character creation (optional):
1792
+
1793
+ :::: el-tabs
1794
+
1795
+ ::: el-tab-pane label=Java
1796
+
1797
+ ```
1798
+ TDAnalytics.login("accoount_id")
1799
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*BRANCH*);
1800
+ ```
1801
+
1802
+ :::
1803
+
1804
+ ::: el-tab-pane label=Kotlin
1805
+
1806
+ ```
1807
+ TDAnalytics.login("accoount_id")
1808
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*BRANCH*)
1809
+ ```
1810
+
1811
+ :::
1812
+
1813
+ ::::
1814
+
1815
+ ### 4. TopOn
1816
+
1817
+ Call before ATSDK initialization:
1818
+
1819
+ :::: el-tabs
1820
+
1821
+ ::: el-tab-pane label=Java
1822
+
1823
+ ```
1824
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*TOP_ON*);
1825
+ ```
1826
+
1827
+ :::
1828
+
1829
+ ::: el-tab-pane label=Kotlin
1830
+
1831
+ ```
1832
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*TOP_ON*)
1833
+ ```
1834
+
1835
+ :::
1836
+
1837
+ ::::
1838
+
1839
+ After TE login/identify, call enableThirdPartySharing again.
1840
+
1841
+ Note: TopOn initCustomMap overwrites user ID on each call.You can set parameters via our `enableThirdPartySharing`:
1842
+
1843
+ :::: el-tabs
1844
+
1845
+ ::: el-tab-pane label=Java
1846
+
1847
+ ```
1848
+ Map<String, Object> customMap = new HashMap<>();
1849
+ customMap.put("key1", "value1");
1850
+ customMap.put("key2", "value2");
1851
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*TOP_ON, customMap*);
1852
+ ```
1853
+
1854
+ :::
1855
+
1856
+ ::: el-tab-pane label=Kotlin
1857
+
1858
+ ```
1859
+ val customMap: MutableMap<String, Any> = HashMap()
1860
+ customMap["key1"] = "value1"
1861
+ customMap["key2"] = "value2"
1862
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*TOP_ON, customMap*)
1863
+ ```
1864
+
1865
+ :::
1866
+
1867
+ ::::
1868
+
1869
+ ### 5. Tradplus
1870
+
1871
+ Call before TradPlusSdk initialization:
1872
+
1873
+ :::: el-tabs
1874
+
1875
+ ::: el-tab-pane label=Java
1876
+
1877
+ ```
1878
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*TRAD_PLUS*);
1879
+ ```
1880
+
1881
+ :::
1882
+
1883
+ ::: el-tab-pane label=Kotlin
1884
+
1885
+ ```
1886
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*TRAD_PLUS*)
1887
+ ```
1888
+
1889
+ :::
1890
+
1891
+ ::::
1892
+
1893
+ ### 6. IronSource
1894
+
1895
+ Call after IronSourceSdk initialization:
1896
+
1897
+ :::: el-tabs
1898
+
1899
+ ::: el-tab-pane label=Java
1900
+
1901
+ ```
1902
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*IRON_SOURCE*);
1903
+ ```
1904
+
1905
+ :::
1906
+
1907
+ ::: el-tab-pane label=Kotlin
1908
+
1909
+ ```
1910
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*IRON_SOURCE*)
1911
+ ```
1912
+
1913
+ :::
1914
+
1915
+ ::::
1916
+
1917
+ ### 7. AppLovin
1918
+
1919
+ - Impression Level
1920
+ Call before AppLovinSdk initialization:
1921
+
1922
+ :::: el-tabs
1923
+
1924
+ ::: el-tab-pane label=Java
1925
+
1926
+ ```
1927
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*APPLOVIN_IMPRESSION*);
1928
+ ```
1929
+
1930
+ :::
1931
+
1932
+ ::: el-tab-pane label=Kotlin
1933
+
1934
+ ```
1935
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*APPLOVIN_IMPRESSION*)
1936
+ ```
1937
+
1938
+ :::
1939
+
1940
+ ::::
1941
+
1942
+ - User Level
1943
+ To get monetization data, create `MaxAdRevenueListener`, and override `onAdRevenuePaid()` method, get monetization data and report via TE SDK `enableThirdPartySharing`, then pass listener to setRevenueListener(), Example code:
1944
+
1945
+ ```
1946
+ void onAdRevenuePaid(final MaxAd ad){
1947
+ TDAnalytics.*enableThirdPartySharing*(TDThirdPartyType.*APPLOVIN_USER,ad*);
1948
+ }
1949
+ ```
1950
+
1951
+ ---
1952
+
1953
+ # Multiple Instances
1954
+
1955
+ ### 1. Feature Introduction
1956
+
1957
+ We support multiple APPIDs to create SDK instances (multiple instances).With multiple instances, you can report to different projects.
1958
+
1959
+ ### 2. Create Multiple Instances
1960
+
1961
+ Pass different APP IDs to initialize SDK for multiple instances:
1962
+
1963
+ :::: el-tabs
1964
+
1965
+ ::: el-tab-pane label=Java
1966
+
1967
+ ```
1968
+ // Initialize SDK
1969
+ TDAnalytics.init(this, TA_APP_ID, TA_SERVER_URL);
1970
+ TDAnalyticsAPI.track("some_event",properties, TA_APP_ID);
1971
+
1972
+ TDAnalytics.init(this, ANOTHER_TA_APP_ID, TA_SERVER_URL);
1973
+ TDAnalyticsAPI.track("some_event",properties, ANOTHER_TA_APP_ID)
1974
+
1975
+ TDAnalytics.init(this, TA_APP_ID, TA_SERVER_URL, NAME);
1976
+ TDAnalyticsAPI.track("some_event",properties, NAME);
1977
+ ```
1978
+
1979
+ :::
1980
+
1981
+ ::: el-tab-pane label=Kotlin
1982
+
1983
+ ```
1984
+ TDAnalytics.init(this, TA_APP_ID, TA_SERVER_URL)
1985
+ TDAnalytics.init(this, ANOTHER_TA_APP_ID, TA_SERVER_URL)
1986
+
1987
+ TDAnalyticsAPI.track("some_event",properties, TA_APP_ID)
1988
+ TDAnalyticsAPI.track("some_event",properties, ANOTHER_TA_APP_ID)
1989
+ ```
1990
+
1991
+ :::
1992
+
1993
+ ::::
1994
+
1995
+ Note: Multiple SDK instances must have different APP IDs, Most data between instances is not shared, for details, see section 4 “Data and Settings Sharing Across Multiple Instances”.
1996
+
1997
+ ### 3. Create Light Instance
1998
+
1999
+ You can create multiple instances under same APPID via light instance
2000
+
2001
+ :::: el-tabs
2002
+
2003
+ ::: el-tab-pane label=Java
2004
+
2005
+ ```
2006
+ // First create an SDK instance
2007
+ TDAnalytics.init(this, TA_APP_ID, TA_SERVER_URL);
2008
+ // Call *lightInstance* from the previously created instance to generate a light instance
2009
+ String uuid = TDAnalytics.*lightInstance*();
2010
+ TDAnalyticsAPI.login("anotherAccount",uuid);
2011
+ TDAnalyticsAPI.track("some_event",properties,uuid);
2012
+ ```
2013
+
2014
+ :::
2015
+
2016
+ ::: el-tab-pane label=Kotlin
2017
+
2018
+ ```
2019
+ // First create an SDK instance
2020
+ TDAnalytics.init(this, TA_APP_ID, TA_SERVER_URL)
2021
+ // Call lightInstance from the previously created instance to generate a light instance
2022
+ val uuid = TDAnalytics.lightInstance()
2023
+ TDAnalyticsAPI.login("anotherAccount", uuid)
2024
+ TDAnalyticsAPI.track("some_event", properties, uuid)
2025
+ ```
2026
+
2027
+ :::
2028
+
2029
+ ::::
2030
+
2031
+ The light instance shares the same APPID, reporting URL, and some settings as the parent instance, but other information is not shared. For details, see section 4 “Data and Settings Sharing Across Multiple Instances”.
2032
+
2033
+ ### 4. Data and Settings Sharing Across Multiple Instances
2034
+
2035
+ Most interfaces are called by instance objects, so most data and settings are not shared across multiple APPID instances, parent instances, and light instances. However, some data and settings apply to all instances. Below is a detailed description of whether all data and settings are shared across multiple instances:
2036
+
2037
+ 1. Account-related information
2038
+
2039
+ - System-generated visitor ID `#distinct_id`: Shared
2040
+ - Visitor ID `#distinct_id` set via `identify`: Not shared
2041
+ - Account ID `#account_id` set via `login`: Not shared
2042
+
2043
+ 1. Event reporting `track` and user property reporting `user_set`, `user_setOnce`, `user_add`, `user_delete`: Not shared
2044
+ 1. Common properties `setSuperProperties` and dynamic common properties `setDynamicSuperPropertiesTracker`: Not shared
2045
+ 1. SDK configuration information sharing across multiple instances:
2046
+
2047
+ - Reporting strategy related (i.e., reporting interval and batch data size): Shared, determined by the project data of the first instantiated APPID
2048
+ - Network condition for upload `setNetworkType`: Shared
2049
+ - Print upload data log `EnableTrackLogging`: Shared
2050
+
2051
+ 1. Auto tracking events
2052
+
2053
+ - It is recommended to enable auto tracking events on only one instance
2054
+ - Supports reporting auto tracking events to multiple APP IDs
2055
+ - Whether auto tracking event configurations are shared across multiple instances:
2056
+ - Set control ID `setViewID`: Not shared
2057
+ - Custom control properties `setViewProperties` etc.: Not shared
2058
+ - Ignore auto tracking events for a specific page `ignoreAutoTrackActivity` etc.: Not shared
2059
+ - Ignore click events for a specific control type `ignoreViewType`: Not shared
2060
+ - Ignore a specific control `ignoreView`: Not shared
2061
+ - All annotations: You can specify the effective instance by setting the appId parameter. If not set, the configuration is shared across all instances, for example:
2062
+
2063
+ ```
2064
+ @ThinkingDataIgnoreTrackAppViewScreen(appId = "debug-appid")
2065
+ ```
2066
+
2067
+ 1. Record event duration `timeEvent`: Not shared
2068
+
2069
+ ---
2070
+
2071
+ # Real-time Debugging
2072
+
2073
+ During SDK integration, you can view SDK logs in the IDE console or use TE's Debug feature for real-time debugging.
2074
+
2075
+ ### 1. Print SDK Logs
2076
+
2077
+ :::: el-tabs
2078
+
2079
+ ::: el-tab-pane label=Java
2080
+
2081
+ ```
2082
+ TDAnalytics.enableLog(true);
2083
+ ```
2084
+
2085
+ :::
2086
+
2087
+ ::: el-tab-pane label=Kotlin
2088
+
2089
+ ```
2090
+ TDAnalytics.enableLog(true)
2091
+ ```
2092
+
2093
+ :::
2094
+
2095
+ ::::
2096
+
2097
+ <!-- unsupported block: 34 -->
2098
+
2099
+ After enabling logs, you can filter ThinkingAnalytics-related logs in the IDE to observe SDK data reporting.
2100
+
2101
+ ### 2. Enable Debug Mode
2102
+
2103
+ Enabling Debug mode requires the following two steps:
2104
+
2105
+ 1. Enable Debug mode on the client
2106
+ Here is the sample code to enable Debug mode on the client:
2107
+
2108
+ :::: el-tabs
2109
+
2110
+ ::: el-tab-pane label=Java
2111
+
2112
+ ```
2113
+ // Get TDConfig instance
2114
+ TDConfig config = TDConfig.getInstance(this, TA_APP_ID, TA_SERVER_URL);
2115
+ /*
2116
+ Set the run mode to Debug mode
2117
+ NORMAL mode: Data will be stored in cache and reported according to a certain cache policy, default is NORMAL mode; recommended for production environment
2118
+ Debug mode: Data is reported one by one. When problems occur, it will prompt users via logs and exceptions; not recommended for production environment
2119
+ DebugOnly mode: Only validates data, will not store it; not recommended for production environment
2120
+ */
2121
+ config.setMode(TDConfig.TDMode.DEBUG);
2122
+ // Initialize SDK
2123
+ TDAnalytics.*init*(config);
2124
+ ```
2125
+
2126
+ :::
2127
+
2128
+ ::: el-tab-pane label=Kotlin
2129
+
2130
+ ```
2131
+ // Get TDConfig instance
2132
+ val config = TDConfig.getInstance(this, TA_APP_ID, TA_SERVER_URL)
2133
+ /*
2134
+ Set the run mode to Debug mode
2135
+ NORMAL mode: Data will be stored in cache and reported according to a certain cache policy, default is NORMAL mode; recommended for production environment
2136
+ Debug mode: Data is reported one by one. When problems occur, it will prompt users via logs and exceptions; not recommended for production environment
2137
+ DebugOnly mode: Only validates data, will not store it; not recommended for production environment
2138
+ */
2139
+ config.setMode(TDConfig.TDMode.*DEBUG*)
2140
+ // Initialize SDK
2141
+ TDAnalytics.init(config)
2142
+ ```
2143
+
2144
+ :::
2145
+
2146
+ ::::
2147
+
2148
+ 1. Add debug device in TE backend
2149
+ To prevent Debug mode from going live in production, only specified devices can enable Debug mode. Debug mode can only be enabled when the client has Debug mode enabled and the device ID is configured in the "Debug Data" section of the "Tracking Management" page in the TE backend.
2150
+
2151
+ Device ID can be obtained in the following three ways:
2152
+
2153
+ - The #device_id property in event data on the TE platform
2154
+ - Client logs: SDK will print the device DeviceId after initialization
2155
+ - Via instance interface call: Get Device ID
2156
+ <!-- unsupported block: 34 -->
2157
+
2158
+ Debug mode may affect data collection quality and App stability, only use it for data verification during integration, do not use in production environment.
2159
+
2160
+ ---
2161
+
2162
+ # Auto Tracking
2163
+
2164
+ Android SDK supports automatic collection of events including install, start, and end.
2165
+
2166
+ ### 1. Introduction
2167
+
2168
+ The TE system provides interfaces for automated data collection. You can choose the data to collect automatically based on your business needs.
2169
+
2170
+ Currently supported auto tracking event types:
2171
+
2172
+ 1. Install event: Records APP installation behavior
2173
+ 1. Start event: Includes opening APP and opening APP from background
2174
+ 1. End event: Includes closing APP and APP entering background, also collects start duration
2175
+ 1. View event: User browsing pages (`Activity`) in the APP
2176
+ 1. Click event: User clicking controls in the APP
2177
+ 1. Crash event: Records crash information when APP crashes
2178
+ Next, we will introduce the collection method for each type of data in detail
2179
+
2180
+ ### 2. Enable Auto Tracking
2181
+
2182
+ You can call `enableAutoTrack` to enable auto tracking:
2183
+
2184
+ :::: el-tabs
2185
+
2186
+ ::: el-tab-pane label=Java
2187
+
2188
+ ```
2189
+ // APP install event TDAnalytics.TDAutoTrackEventType.*APP_INSTALL*
2190
+ // APP start event TDAnalytics.TDAutoTrackEventType.*APP_START*
2191
+ // APP end event TDAnalytics.TDAutoTrackEventType.*APP_END*
2192
+ // APP page view event TDAnalytics.TDAutoTrackEventType.*APP_VIEW_SCREEN*
2193
+ // APP click control event TDAnalytics.TDAutoTrackEventType.*APP_CLICK*
2194
+ // APP crash event TDAnalytics.TDAutoTrackEventType.*APP_CRASH*
2195
+ // enable auto tracking events
2196
+ TDAnalytics.*enableAutoTrack*(TDAnalytics.TDAutoTrackEventType.*APP_START *| TDAnalytics.TDAutoTrackEventType.*APP_END*
2197
+ * *| TDAnalytics.TDAutoTrackEventType.*APP_INSTALL *| TDAnalytics.TDAutoTrackEventType.*APP_VIEW_SCREEN *| TDAnalytics.TDAutoTrackEventType.*APP_CLICK*
2198
+ * *| TDAnalytics.TDAutoTrackEventType.*APP_CRASH*);
2199
+ ```
2200
+
2201
+ :::
2202
+
2203
+ ::: el-tab-pane label=Kotlin
2204
+
2205
+ ```
2206
+ // APP install event TDAnalytics.TDAutoTrackEventType.*APP_INSTALL*
2207
+ // APP start event TDAnalytics.TDAutoTrackEventType.*APP_START*
2208
+ // APP end event TDAnalytics.TDAutoTrackEventType.*APP_END*
2209
+ // APP page view event TDAnalytics.TDAutoTrackEventType.*APP_VIEW_SCREEN*
2210
+ // APP click control event TDAnalytics.TDAutoTrackEventType.*APP_CLICK*
2211
+ // APP crash event TDAnalytics.TDAutoTrackEventType.*APP_CRASH*
2212
+ // enable auto tracking events
2213
+ TDAnalytics.enableAutoTrack(
2214
+ TDAnalytics.TDAutoTrackEventType.*APP_START *or TDAnalytics.TDAutoTrackEventType.*APP_END*
2215
+ * *or TDAnalytics.TDAutoTrackEventType.*APP_INSTALL *or TDAnalytics.TDAutoTrackEventType.*APP_VIEW_SCREEN *or TDAnalytics.TDAutoTrackEventType.*APP_CLICK*
2216
+ * *or TDAnalytics.TDAutoTrackEventType.*APP_CRASH*
2217
+ )
2218
+ ```
2219
+
2220
+ :::
2221
+
2222
+ ::::
2223
+
2224
+ ::: tip Tip
2225
+
2226
+ If you need to collect control click events or Fragment view events, you need to integrate the auto tracking plugin. See section 7 of this page.
2227
+
2228
+ :::
2229
+
2230
+ ### 3. Detailed Introduction
2231
+
2232
+ #### 3.1 Install Event
2233
+
2234
+ The APP install event records the actual installation of the APP, reported when the APP starts. The event trigger time is the first launch time after APP installation. APP upgrades do not trigger install events, but uninstalling and reinstalling will report an install event.
2235
+
2236
+ - Event name: ta_app_install
2237
+
2238
+ #### 3.2 Start Event
2239
+
2240
+ The APP start event is triggered when the user opens the APP or wakes the APP from the background. Detailed event description:
2241
+
2242
+ - Event name: ta_app_start
2243
+ - Preset property: `#resume_from_background`, boolean type, indicates whether the APP was opened by the user or woken from the background. Value true means woken from the background, false means directly opened.
2244
+ - Note: Starting from V2.8.1, SDK no longer allows start events triggered by background silent launch (such as directly starting a background service or push) by default. You can enable it by adding a resource file `ta_public_config.xml` under res/values
2245
+
2246
+ ```
2247
+ <?xml version="1.0" encoding="utf-8"?>
2248
+ <resources>
2249
+ <bool name="TAEnableBackgroundStartEvent">true</bool>
2250
+ </resources>
2251
+ ```
2252
+
2253
+ #### 3.3 End Event
2254
+
2255
+ The APP end event is triggered when the user closes the APP or moves the APP to the background. Detailed event description:
2256
+
2257
+ - Event name: ta_app_end
2258
+ - Preset property: `#duration`, numeric type, indicates the duration of the APP visit (from start to end), in seconds.
2259
+
2260
+ #### 3.4 Page View Event
2261
+
2262
+ The APP page view event is triggered when the user browses a page (`Activity`). Detailed event description:
2263
+
2264
+ - Event name: ta_app_view
2265
+ - Preset properties:
2266
+ `#screen_name`, string type, the package name.class name of the `Activity`
2267
+
2268
+ `#title`, string type, the title of the `Activity`, the value is the `title` property of the `Activity`
2269
+
2270
+ You can add other properties to the page view event to extend its analytical value. Below are methods for customizing page view event properties
2271
+
2272
+ ##### 3.4.1 Enable Auto Tracking for Fragment Page View Events
2273
+
2274
+ For Fragments of `android.support.v4.app.Fragment`, you can use the following method to auto track page view events:
2275
+
2276
+ After SDK initialization, call the following method to enable Fragment auto tracking
2277
+
2278
+ :::: el-tabs
2279
+
2280
+ ::: el-tab-pane label=Java
2281
+
2282
+ ```
2283
+ TDAnalytics.trackFragmentAppViewScreen();
2284
+ ```
2285
+
2286
+ :::
2287
+
2288
+ ::: el-tab-pane label=Kotlin
2289
+
2290
+ ```
2291
+ TDAnalytics.trackFragmentAppViewScreen()
2292
+ ```
2293
+
2294
+ :::
2295
+
2296
+ ::::
2297
+
2298
+ For Fragments of `android.app.Fragment`, you can manually call the page view event using the following method:
2299
+
2300
+ :::: el-tabs
2301
+
2302
+ ::: el-tab-pane label=Java
2303
+
2304
+ ```
2305
+ TDAnalytics.trackViewScreen(targetFragment);
2306
+ ```
2307
+
2308
+ :::
2309
+
2310
+ ::: el-tab-pane label=Kotlin
2311
+
2312
+ ```
2313
+ TDAnalytics.trackViewScreen(targetFragment)
2314
+ ```
2315
+
2316
+ :::
2317
+
2318
+ ::::
2319
+
2320
+ - `targetFragment` can be replaced with the Fragment for which you want to upload page view events
2321
+
2322
+ ##### 3.4.2 Customize Page View Event Properties
2323
+
2324
+ For page view events of `Activity`, you can add properties by implementing the `ScreenAutoTracker` interface. Through the following two methods, you can add page URL information and other custom properties to the page view event:
2325
+
2326
+ :::: el-tabs
2327
+
2328
+ ::: el-tab-pane label=Java
2329
+
2330
+ ```
2331
+ public class MainActivity extends AppCompatActivity implements ScreenAutoTracker {
2332
+ private Context mContext;
2333
+
2334
+ @Override
2335
+ public String getScreenUrl() {
2336
+ return "thinkingdata://page/main";
2337
+ }
2338
+
2339
+ @Override
2340
+ public JSONObject getTrackProperties() throws JSONException {
2341
+ JSONObject jsonObject = new JSONObject();
2342
+ jsonObject.put("param1", "ABCD");
2343
+ jsonObject.put("param2", "thinkingdata");
2344
+ return jsonObject;
2345
+ }
2346
+ }
2347
+ ```
2348
+
2349
+ :::
2350
+
2351
+ ::: el-tab-pane label=Kotlin
2352
+
2353
+ ```
2354
+ class MainActivity : AppCompatActivity(), ScreenAutoTracker {
2355
+
2356
+ override fun getScreenUrl(): String {
2357
+ return "thinkingdata://page/main";
2358
+ }
2359
+
2360
+ override fun getTrackProperties(): JSONObject {
2361
+ val jsonObject = JSONObject()
2362
+ jsonObject.put("param1", "ABCD")
2363
+ jsonObject.put("param2", "thinkingdata")
2364
+ return jsonObject
2365
+ }
2366
+ }
2367
+ ```
2368
+
2369
+ :::
2370
+
2371
+ ::::
2372
+
2373
+ The return value of `getScreenUrl` will serve as the URL Schema of the `Activity`. When the page view event is triggered, the preset property `#url` will be added with the value of the current page's URL Schema; at the same time, the SDK will get the URL Schema of the previous page, and if available, it will be added to the preset property `#referrer` as the referring address.
2374
+
2375
+ The return value of `getTrackProperties` is the custom property of the page view event, which will be automatically added to the page view event
2376
+
2377
+ For page view events of `Fragment`, we provide two ways to add properties
2378
+
2379
+ - Add properties via `@ThinkingDataFragmentTitle`
2380
+ :::: el-tabs
2381
+
2382
+ ::: el-tab-pane label=Java
2383
+
2384
+ ```
2385
+ @ThinkingDataFragmentTitle(title = "myFragment")
2386
+ public class ListViewFragment extends BaseFragment {
2387
+ // your fragment implementations
2388
+ }
2389
+ ```
2390
+
2391
+ :::
2392
+
2393
+ ::: el-tab-pane label=Kotlin
2394
+
2395
+ ```
2396
+ @ThinkingDataFragmentTitle(title = "myFragment")
2397
+ class ListViewFragment : BaseFragment() {
2398
+ // your fragment implementations
2399
+ }
2400
+ ```
2401
+
2402
+ :::
2403
+
2404
+ ::::
2405
+
2406
+ - Implement the `ScreenAutoTracker` interface
2407
+ :::: el-tabs
2408
+
2409
+ ::: el-tab-pane label=Java
2410
+
2411
+ ```
2412
+ @Override
2413
+ public JSONObject getTrackProperties() {
2414
+ try {
2415
+ JSONObject properties = new JSONObject();
2416
+ properties.put("#title", "RecyclerViewFragment");
2417
+ return properties;
2418
+ } catch (JSONException e) {
2419
+ // ignore
2420
+ }
2421
+ return null;
2422
+ }
2423
+ ```
2424
+
2425
+ :::
2426
+
2427
+ ::: el-tab-pane label=Kotlin
2428
+
2429
+ ```
2430
+ override fun getTrackProperties(): JSONObject {
2431
+ val jsonObject = JSONObject()
2432
+ properties.put("#title", "RecyclerViewFragment");
2433
+ return jsonObject
2434
+ }
2435
+ ```
2436
+
2437
+ :::
2438
+
2439
+ ::::
2440
+
2441
+ #### 3.5 Click Event
2442
+
2443
+ The APP control click event is triggered when the user clicks a control (view)
2444
+
2445
+ - Event name: ta_app_click
2446
+ - Preset properties:
2447
+ `#screen_name`, string type, the package name.class name of the `Activity` the control belongs to
2448
+
2449
+ `#title`, string type, the title of the `Activity` the control belongs to, the value is the `title` property of the `Activity`
2450
+
2451
+ `#element_content`, string type, the content of the control
2452
+
2453
+ `#element_type`, string type, the type of the control
2454
+
2455
+ `#element_id`, string type, the ID of the control, defaults to `android:id`
2456
+
2457
+ `#element_position`, string type, only uploaded when the control has a `position` attribute
2458
+
2459
+ `#element_selector`, string type, the concatenation of the control's `viewPath`
2460
+
2461
+ For click events of Views on the page, there are multiple ways to set more properties to extend their analytical value:
2462
+
2463
+ ##### 3.5.1 Customize Control ID
2464
+
2465
+ The control ID defaults to `android:id`. If this property cannot be obtained, or you want to customize the control ID, you can use the following method to override the `#element_id` property
2466
+
2467
+ :::: el-tabs
2468
+
2469
+ ::: el-tab-pane label=Java
2470
+
2471
+ ```
2472
+ TDAnalytics.setViewID(view,viewID);
2473
+ ```
2474
+
2475
+ :::
2476
+
2477
+ ::: el-tab-pane label=Kotlin
2478
+
2479
+ ```
2480
+ TDAnalytics.setViewID(view,viewID)
2481
+ ```
2482
+
2483
+ :::
2484
+
2485
+ ::::
2486
+
2487
+ For `Dialog`, you can use the following method:
2488
+
2489
+ :::: el-tabs
2490
+
2491
+ ::: el-tab-pane label=Java
2492
+
2493
+ ```
2494
+ //android.app.Dialog
2495
+ TDAnalytics.setViewID(view,viewID);
2496
+ ```
2497
+
2498
+ :::
2499
+
2500
+ ::: el-tab-pane label=Kotlin
2501
+
2502
+ ```
2503
+ //android.app.Dialog
2504
+ TDAnalytics.setViewID(view,viewID)
2505
+ ```
2506
+
2507
+ :::
2508
+
2509
+ ::::
2510
+
2511
+ Or
2512
+
2513
+ :::: el-tabs
2514
+
2515
+ ::: el-tab-pane label=Java
2516
+
2517
+ ```
2518
+ //android.support.v7.app.AlertDialog
2519
+ TDAnalytics.setViewID(view,viewID);
2520
+ ```
2521
+
2522
+ :::
2523
+
2524
+ ::: el-tab-pane label=Kotlin
2525
+
2526
+ ```
2527
+ //android.support.v7.app.AlertDialog
2528
+ TDAnalytics.setViewID(view,viewID)
2529
+ ```
2530
+
2531
+ :::
2532
+
2533
+ ::::
2534
+
2535
+ The parameter `view` is the view for which you need to set the control ID, and the parameter `viewID` is the control ID to set. When the click event of this control is uploaded, the value of `#element_id` will be the value passed in here
2536
+
2537
+ ##### 3.5.2 Customize Control Click Event Properties
2538
+
2539
+ You can add custom properties to the click event of a control (view) using the following method:
2540
+
2541
+ :::: el-tabs
2542
+
2543
+ ::: el-tab-pane label=Java
2544
+
2545
+ ```
2546
+ TDAnalytics.setViewProperties(view,properties);
2547
+ ```
2548
+
2549
+ :::
2550
+
2551
+ ::: el-tab-pane label=Kotlin
2552
+
2553
+ ```
2554
+ TDAnalytics.setViewProperties(view,properties);
2555
+ ```
2556
+
2557
+ :::
2558
+
2559
+ ::::
2560
+
2561
+ The parameter `view` is the view for which you need to set custom properties, and the parameter `properties` is of type `JSONObject`, representing the custom properties to set. When the click event of this control is uploaded, these properties will be added.
2562
+
2563
+ Additionally, for `ExpandableListView`, `ListView`, and `GridView`, you can implement interfaces via the Adapter to add custom properties when clicking an item.
2564
+
2565
+ - `ExpandableListView` needs to implement the `ThinkingExpandableListViewItemTrackProperties` interface
2566
+
2567
+ ```
2568
+ public interface ThinkingExpandableListViewItemTrackProperties {
2569
+ /**
2570
+ * Add properties for clicking the item at groupPosition, childPosition
2571
+ * @param groupPosition
2572
+ * @param childPosition
2573
+ * @return
2574
+ * @throws JSONException
2575
+ */
2576
+ JSONObject getThinkingChildItemTrackProperties(int groupPosition, int childPosition) throws JSONException;
2577
+
2578
+ /**
2579
+ * Add properties for clicking the item at groupPosition
2580
+ * @param groupPosition
2581
+ * @return
2582
+ * @throws JSONException
2583
+ */
2584
+ JSONObject getThinkingGroupItemTrackProperties(int groupPosition) throws JSONException;
2585
+ }
2586
+ ```
2587
+
2588
+ - `ListView` and `GridView` need to implement the `ThinkingAdapterViewItemTrackProperties` interface
2589
+
2590
+ ```
2591
+ public interface ThinkingAdapterViewItemTrackProperties {
2592
+ /**
2593
+ * Add properties for clicking the item at position
2594
+ * @param position
2595
+ * @return
2596
+ * @throws JSONException
2597
+ */
2598
+ JSONObject getThinkingItemTrackProperties(int position) throws JSONException;
2599
+ }
2600
+ ```
2601
+
2602
+ ##### 3.5.3 Add Page (`Activity`) Information to `AlertDialog` Click Events
2603
+
2604
+ For click events of `AlertDialog` (`android.app.AlertDialog` and `android.support.v7.app.AlertDialog`), you can bind the associated page (`Activity`) using the following method, and the `#screen_name` and `#title` properties of the associated page will be added to the click event.
2605
+
2606
+ - If you display the dialog by calling `dialog.show()`, use the following method:
2607
+
2608
+ ```
2609
+ dialog.setOwnerActivity(targetActivity);
2610
+ ```
2611
+
2612
+ - If you display the dialog by calling `builder.show()`, use the following method:
2613
+
2614
+ ```
2615
+ builder.show().setOwnerActivity(activity);
2616
+ ```
2617
+
2618
+ ##### 3.5.4 Upload Control Click Events via Annotation `@ThinkingDataTrackViewOnClick`
2619
+
2620
+ If you use `android:onclick` to add click event handler methods for controls (view), you can add the annotation `@ThinkingDataTrackViewOnClick` to the handler method. When the handler method is executed, the SDK will upload the control click event
2621
+
2622
+ ```
2623
+ @ThinkingDataTrackViewOnClick
2624
+ public void buttonOnClick(View v){}
2625
+ ```
2626
+
2627
+ If the method `buttonOnClick` is called, a control click event will be uploaded
2628
+
2629
+ #### 3.6 Crash Event
2630
+
2631
+ When the APP encounters an uncaught exception, an APP crash event will be reported
2632
+
2633
+ - Event name: ta_app_crash
2634
+ - Preset property: `#app_crashed_reason`, string type, records the stack trace at the time of crash
2635
+
2636
+ ### 4. Ignore Auto Tracking Events
2637
+
2638
+ You can ignore auto tracking events for a specific page or control using the following methods
2639
+
2640
+ #### 4.1 Ignore Page Auto Tracking Events
2641
+
2642
+ For certain pages (`Activity`), if you don't want to transmit auto tracking events (including page view and control click events), you can ignore them using the following method:
2643
+
2644
+ :::: el-tabs
2645
+
2646
+ ::: el-tab-pane label=Java
2647
+
2648
+ ```
2649
+ // Ignore single page
2650
+ TDAnalytics.ignoreAutoTrackActivity(MainActivity.class);
2651
+ // Ignore multiple pages
2652
+ List<Class<?>> classList = new ArrayList<>();
2653
+ classList.add(MainActivity.class);
2654
+ TDAnalytics.ignoreAutoTrackActivities(classList);
2655
+ ```
2656
+
2657
+ :::
2658
+
2659
+ ::: el-tab-pane label=Kotlin
2660
+
2661
+ ```
2662
+ // Ignore single page
2663
+ TDAnalytics.ignoreAutoTrackActivity(MainActivity::class.*java*)
2664
+ // Ignore multiple pages
2665
+ val classList: MutableList<Class<*>> = ArrayList()
2666
+ classList.add(MainActivity::class.*java*)
2667
+ TDAnalytics.ignoreAutoTrackActivities(classList)
2668
+ ```
2669
+
2670
+ :::
2671
+
2672
+ ::::
2673
+
2674
+ You can also add the annotation `@ThinkingDataIgnoreTrackAppViewScreen` before `Activity` or `Fragment` to ignore the page view event of a specific `Activity` or `Fragment`
2675
+
2676
+ :::: el-tabs
2677
+
2678
+ ::: el-tab-pane label=Java
2679
+
2680
+ ```
2681
+ // Ignore TestActivity page view event
2682
+ @ThinkingDataIgnoreTrackAppViewScreen
2683
+ public class TestActivity extends AppCompatActivity {
2684
+ ...
2685
+ }
2686
+ ```
2687
+
2688
+ :::
2689
+
2690
+ ::: el-tab-pane label=Kotlin
2691
+
2692
+ ```
2693
+ // Ignore TestActivity page view event
2694
+ @ThinkingDataIgnoreTrackAppViewScreen
2695
+ class TestActivity : AppCompatActivity() {
2696
+ ...
2697
+ }
2698
+ ```
2699
+
2700
+ :::
2701
+
2702
+ ::::
2703
+
2704
+ Add the annotation `@ThinkingDataIgnoreTrackAppViewScreenAndAppClick` before `Activity` to ignore the page view event and control click events on that page for a specific `Activity`
2705
+
2706
+ :::: el-tabs
2707
+
2708
+ ::: el-tab-pane label=Java
2709
+
2710
+ ```
2711
+ // Ignore TestActivity page view event and control click events on that page
2712
+ @ThinkingDataIgnoreTrackAppViewScreenAndAppClick
2713
+ public class TestActivity extends AppCompatActivity {
2714
+ ...
2715
+ }
2716
+ ```
2717
+
2718
+ :::
2719
+
2720
+ ::: el-tab-pane label=Kotlin
2721
+
2722
+ ```
2723
+ // Ignore TestActivity page view event and control click events on that page
2724
+ @ThinkingDataIgnoreTrackAppViewScreenAndAppClick
2725
+ class TestActivity : AppCompatActivity() {
2726
+ ...
2727
+ }
2728
+ ```
2729
+
2730
+ :::
2731
+
2732
+ ::::
2733
+
2734
+ #### 4.2 Ignore Click Events for a Specific Control Type
2735
+
2736
+ If you need to ignore click events for a specific control type, you can use the following method
2737
+
2738
+ :::: el-tabs
2739
+
2740
+ ::: el-tab-pane label=Java
2741
+
2742
+ ```
2743
+ TDAnalytics.ignoreViewType(ignoredClass);
2744
+ ```
2745
+
2746
+ :::
2747
+
2748
+ ::: el-tab-pane label=Kotlin
2749
+
2750
+ ```
2751
+ TDAnalytics.ignoreViewType(ignoredClass)
2752
+ ```
2753
+
2754
+ :::
2755
+
2756
+ ::::
2757
+
2758
+ - `ignoredClass` is the control type to ignore, such as `Dialog`, `Checkbox`, etc.
2759
+
2760
+ #### 4.3 Ignore Click Events for a Specific Element (View)
2761
+
2762
+ If you want to ignore click events for a specific element (View), you can use the following method
2763
+
2764
+ :::: el-tabs
2765
+
2766
+ ::: el-tab-pane label=Java
2767
+
2768
+ ```
2769
+ TDAnalytics.ignoreView(targetView);
2770
+ ```
2771
+
2772
+ :::
2773
+
2774
+ ::: el-tab-pane label=Kotlin
2775
+
2776
+ ```
2777
+ TDAnalytics.ignoreView(targetView)
2778
+ ```
2779
+
2780
+ :::
2781
+
2782
+ ::::
2783
+
2784
+ - `targetView` is the View to ignore
2785
+
2786
+ ### 5. Use Annotations to Quickly Set Events
2787
+
2788
+ If you need to monitor the call count of a method, or need to upload an event as soon as a method is called, you can use the annotation `@ThinkingDataTrackEvent` to quickly set the event to upload. Note that properties cannot be passed as variables, so this is only suitable for uploading simple events
2789
+
2790
+ ```
2791
+ // Use annotation
2792
+ @ThinkingDataTrackEvent(eventName = "event_name", properties = "{\"paramString\":\"value\",\"paramNumber\":123,\"paramBoolean\":true}")
2793
+ public void fun(){}
2794
+ ```
2795
+
2796
+ At this point, if the method `fun` is called, an event with name `event_name` and properties `"paramString":"value"`, `"paramNumber":123`, and `"paramBoolean":true` will be uploaded
2797
+
2798
+ ### 6. Preset Properties for Auto Tracking Events
2799
+
2800
+ The following preset properties are unique to each auto tracking event
2801
+
2802
+ - Preset properties for APP start event (ta_app_start)
2803
+ **Property Name**
2804
+
2805
+ **English Name**
2806
+
2807
+ **Property Type**
2808
+
2809
+ **Description**
2810
+
2811
+ #resume_from_background
2812
+
2813
+ Resumed from background
2814
+
2815
+ Boolean
2816
+
2817
+ Indicates whether the APP was opened or woken from the background. Value true means woken from the background, false means directly opened
2818
+
2819
+ #start_reason
2820
+
2821
+ App start source
2822
+
2823
+ Text
2824
+
2825
+ Content is a JSON string; when the APP is opened via URL or intent, the URL content and intent data are automatically recorded, example: `{url:"thinkingdata://","data":{}}`
2826
+
2827
+ #background_duration
2828
+
2829
+ Background duration
2830
+
2831
+ Numeric
2832
+
2833
+ Records the duration the APP was in the background between two start events, in seconds
2834
+
2835
+ - Preset properties for APP end event (ta_app_end)
2836
+ **Property Name**
2837
+
2838
+ **English Name**
2839
+
2840
+ **Property Type**
2841
+
2842
+ **Description**
2843
+
2844
+ #duration
2845
+
2846
+ Event duration
2847
+
2848
+ Numeric
2849
+
2850
+ Indicates the duration of the APP visit (from start to end), in seconds
2851
+
2852
+ - Preset properties for APP page view event (ta_app_view)
2853
+ **Property Name**
2854
+
2855
+ **English Name**
2856
+
2857
+ **Property Type**
2858
+
2859
+ **Description**
2860
+
2861
+ #title
2862
+
2863
+ Page title
2864
+
2865
+ Text
2866
+
2867
+ The title of the `Activity` the control belongs to, the value is the `title` property of the `Activity`
2868
+
2869
+ #screen_name
2870
+
2871
+ Page name
2872
+
2873
+ Text
2874
+
2875
+ The package name.class name of the `Activity` the control belongs to
2876
+
2877
+ #url
2878
+
2879
+ Page URL
2880
+
2881
+ Text
2882
+
2883
+ The URL of the current page, requires calling `getScreenUrl` to set the URL
2884
+
2885
+ #referrer
2886
+
2887
+ Referrer URL
2888
+
2889
+ Text
2890
+
2891
+ The URL of the previous page, the previous page also needs to call `getScreenUrl` to set the URL
2892
+
2893
+ - Preset properties for APP control click event (ta_app_click)
2894
+ **Property Name**
2895
+
2896
+ **English Name**
2897
+
2898
+ **Property Type**
2899
+
2900
+ **Description**
2901
+
2902
+ #title
2903
+
2904
+ Page title
2905
+
2906
+ Text
2907
+
2908
+ The title of the `Activity` the control belongs to, the value is the `title` property of the `Activity`
2909
+
2910
+ #screen_name
2911
+
2912
+ Page name
2913
+
2914
+ Text
2915
+
2916
+ The package name.class name of the `Activity` the control belongs to
2917
+
2918
+ #element_id
2919
+
2920
+ Element ID
2921
+
2922
+ Text
2923
+
2924
+ The ID of the control, defaults to `android:id`, can be set via `setViewID`
2925
+
2926
+ #element_type
2927
+
2928
+ Element type
2929
+
2930
+ Text
2931
+
2932
+ The type of the control
2933
+
2934
+ #element_selector
2935
+
2936
+ Element selector
2937
+
2938
+ Text
2939
+
2940
+ The concatenation of the control's `viewPath`
2941
+
2942
+ #element_position
2943
+
2944
+ Element position
2945
+
2946
+ Text
2947
+
2948
+ The position information of the control, only uploaded when the control has a `position` attribute
2949
+
2950
+ #element_content
2951
+
2952
+ Element content
2953
+
2954
+ Text
2955
+
2956
+ The content on the control
2957
+
2958
+ - Preset properties for APP crash event (ta_app_crash)
2959
+ **Property Name**
2960
+
2961
+ **English Name**
2962
+
2963
+ **Property Type**
2964
+
2965
+ **Description**
2966
+
2967
+ #app_crashed_reason
2968
+
2969
+ Exception information
2970
+
2971
+ Text
2972
+
2973
+ String type, records the stack trace at the time of crash
2974
+
2975
+ ### 7. Optional Plugin
2976
+
2977
+ ::: tip Tip
2978
+
2979
+ You only need to integrate this plugin when you want to enable control click events and Fragment page view events.
2980
+
2981
+ :::
2982
+
2983
+ ::: tip Tip
2984
+
2985
+ Starting from version 2.1.0, compatible with Gradle 8.0.
2986
+
2987
+ :::
2988
+
2989
+ Android SDK Version
2990
+
2991
+ Plugin Version
2992
+
2993
+ [oldest - 3.0.0)
2994
+
2995
+ 1.2.0
2996
+
2997
+ [3.0.0 - 3.1.0]
2998
+
2999
+ 2.1.0
3000
+
3001
+ (3.1.0 - latest]
3002
+
3003
+ 2.2.0
3004
+
3005
+ ```
3006
+ buildscript {
3007
+ repositories {
3008
+ google()
3009
+ jcenter()
3010
+ }
3011
+ dependencies {
3012
+ classpath 'cn.thinkingdata.android:android-gradle-plugin2:2.2.0'
3013
+ }
3014
+ }
3015
+ ```
3016
+
3017
+ You can configure plugin-related parameters in the project build.gradle file
3018
+
3019
+ ```
3020
+ apply plugin: 'cn.thinkingdata.android'
3021
+ android **{**
3022
+
3023
+ **}**
3024
+ ThinkingAnalytics **{**
3025
+ ** **debug = true
3026
+ exclude = []
3027
+ sdk**{**
3028
+ ** **disableAndroidID = false
3029
+ **}**
3030
+ **}**
3031
+ ```
3032
+
3033
+ Parameter Details:
3034
+
3035
+ - debug : Whether to enable compile log, true to enable, default false.
3036
+ - exclude : Exclude scanning classes under certain path, can be set via exclude = ['cn.thinkingdata.android','android.support'].
3037
+ - useInclude , include: Only scan classes under certain path, can be set via useInclude = true, include= ['cn.thinkingdata.android','android.support'].
3038
+ - disableAndroidID : Whether to disable system API for AndroidID, From plugin V2.1.0, set disableAndroidID = true.
3039
+
3040
+ ### 8. Set Custom Properties
3041
+
3042
+ You can call `enableAutoTrack(List<ThinkingAnalyticsSDK.AutoTrackEventType>, JSONObject)` to enable auto tracking and set custom properties at the same time
3043
+
3044
+ :::: el-tabs
3045
+
3046
+ ::: el-tab-pane label=Java
3047
+
3048
+ ```
3049
+ JSONObject properties = new JSONObject();
3050
+ try {
3051
+ properties.put("auto_self_define_key", "auto_self_define_value");
3052
+ } catch (Exception e) {
3053
+ e.printStackTrace();
3054
+ }
3055
+ TDAnalytics.enableAutoTrack(typeList, properties);
3056
+ ```
3057
+
3058
+ :::
3059
+
3060
+ ::: el-tab-pane label=Kotlin
3061
+
3062
+ ```
3063
+ val properties = JSONObject()
3064
+ properties.put("auto_self_define_key", "auto_self_define_value")
3065
+ TDAnalytics.enableAutoTrack(typeList, properties)
3066
+ ```
3067
+
3068
+ :::
3069
+
3070
+ ::::
3071
+
3072
+ ### 9. Auto Tracking Event Callback
3073
+
3074
+ You can set a callback to get the event type and event properties when an enabled auto tracking event occurs, and add additional properties to report by **setting the return value**.
3075
+
3076
+ :::: el-tabs
3077
+
3078
+ ::: el-tab-pane label=Java
3079
+
3080
+ ```
3081
+ TDAnalytics.*enableAutoTrack*(TDAnalytics.TDAutoTrackEventType.*APP_END *| TDAnalytics.TDAutoTrackEventType.*APP_START*, new TDAnalytics.TDAutoTrackEventHandler() {
3082
+ @Override
3083
+ public JSONObject getPropertiesWithEventType(int eventType, JSONObject properties) {
3084
+ try {
3085
+ return new JSONObject("{\"keykey\":\"value1111\"}");
3086
+ } catch (JSONException e) {
3087
+ e.printStackTrace();
3088
+ return null;
3089
+ }
3090
+ }
3091
+ });
3092
+ ```
3093
+
3094
+ :::
3095
+
3096
+ ::: el-tab-pane label=Kotlin
3097
+
3098
+ ```
3099
+ TDAnalytics.enableAutoTrack(
3100
+ TDAnalytics.TDAutoTrackEventType.*APP_END *or TDAnalytics.TDAutoTrackEventType.*APP_START*,
3101
+ object : TDAutoTrackEventHandler {
3102
+ override fun getAutoTrackEventProperties(p0: Int, p1: JSONObject?): JSONObject {
3103
+ return JSONObject("{\"keykey\":\"value1111\"}");
3104
+ }
3105
+ })
3106
+ ```
3107
+
3108
+ :::
3109
+
3110
+ ::::
3111
+
3112
+ ---
3113
+
3114
+ # Preset Properties
3115
+
3116
+ ### 1. Preset Properties for All Events
3117
+
3118
+ The following preset properties are included in all events (including auto tracking events) in the Android SDK
3119
+
3120
+ **Property Name**
3121
+
3122
+ **English Name**
3123
+
3124
+ **Property Type**
3125
+
3126
+ **Collection Time**
3127
+
3128
+ **Description**
3129
+
3130
+ #ip
3131
+
3132
+ IP address
3133
+
3134
+ Text
3135
+
3136
+ Server-side collection
3137
+
3138
+ User's IP address, TE will use this to obtain the user's geographic location information
3139
+
3140
+ #country
3141
+
3142
+ Country
3143
+
3144
+ Text
3145
+
3146
+ Server-side collection
3147
+
3148
+ User's country, generated from IP address
3149
+
3150
+ #country_code
3151
+
3152
+ Country code
3153
+
3154
+ Text
3155
+
3156
+ Server-side collection
3157
+
3158
+ User's country code (ISO 3166-1 alpha-2, i.e., two uppercase letters), generated from IP address
3159
+
3160
+ #province
3161
+
3162
+ Province
3163
+
3164
+ Text
3165
+
3166
+ Server-side collection
3167
+
3168
+ User's province, generated from IP address
3169
+
3170
+ #city
3171
+
3172
+ City
3173
+
3174
+ Text
3175
+
3176
+ Server-side collection
3177
+
3178
+ User's city, generated from IP address
3179
+
3180
+ #os_version
3181
+
3182
+ Operating system version
3183
+
3184
+ Text
3185
+
3186
+ Collected once at initialization
3187
+
3188
+ iOS 11.2.2, Android 8.0.0, etc.
3189
+
3190
+ #manufacturer
3191
+
3192
+ Device manufacturer
3193
+
3194
+ Text
3195
+
3196
+ Collected once at initialization
3197
+
3198
+ Device manufacturer, such as Apple, vivo, etc.
3199
+
3200
+ #os
3201
+
3202
+ Operating system
3203
+
3204
+ Text
3205
+
3206
+ Collected once at initialization
3207
+
3208
+ Such as Android, iOS, etc.
3209
+
3210
+ #device_id
3211
+
3212
+ Device ID
3213
+
3214
+ Text
3215
+
3216
+ Collected once at initialization
3217
+
3218
+ User's device ID, iOS uses IDFV or UUID, Android uses androidID
3219
+
3220
+ #screen_height
3221
+
3222
+ Screen height
3223
+
3224
+ Numeric
3225
+
3226
+ Collected once at initialization
3227
+
3228
+ Device screen height, such as 1920, etc.
3229
+
3230
+ #screen_width
3231
+
3232
+ Screen width
3233
+
3234
+ Numeric
3235
+
3236
+ Collected once at initialization
3237
+
3238
+ Device screen width, such as 1080, etc.
3239
+
3240
+ #device_model
3241
+
3242
+ Device model
3243
+
3244
+ Text
3245
+
3246
+ Collected once at initialization
3247
+
3248
+ Device model, such as iPhone 8, etc.
3249
+
3250
+ #device_type
3251
+
3252
+ Device type
3253
+
3254
+ Text
3255
+
3256
+ Collected once at initialization
3257
+
3258
+ Device type, such as "Tablet", "Phone"
3259
+
3260
+ #app_version
3261
+
3262
+ APP version
3263
+
3264
+ Text
3265
+
3266
+ Collected once at initialization
3267
+
3268
+ Your APP version
3269
+
3270
+ #bundle_id
3271
+
3272
+ App unique identifier
3273
+
3274
+ Text
3275
+
3276
+ Collected once at initialization
3277
+
3278
+ App package name or process name
3279
+
3280
+ #lib
3281
+
3282
+ SDK type
3283
+
3284
+ Text
3285
+
3286
+ Collected once at initialization
3287
+
3288
+ Type of SDK integrated, such as Android, iOS, etc.
3289
+
3290
+ #lib_version
3291
+
3292
+ SDK version
3293
+
3294
+ Text
3295
+
3296
+ Collected once at initialization
3297
+
3298
+ Version of SDK integrated
3299
+
3300
+ #network_type
3301
+
3302
+ Network status
3303
+
3304
+ Text
3305
+
3306
+ Collected once at initialization, also on network status change
3307
+
3308
+ Network status when uploading events, such as WIFI, 3G, 4G, etc.
3309
+
3310
+ #carrier
3311
+
3312
+ Network carrier
3313
+
3314
+ Text
3315
+
3316
+ Collected once at initialization
3317
+
3318
+ User's network carrier, such as China Mobile, China Telecom, etc.
3319
+
3320
+ #zone_offset
3321
+
3322
+ Timezone offset
3323
+
3324
+ Numeric
3325
+
3326
+ Collected at event time
3327
+
3328
+ Hour offset of data time relative to UTC
3329
+
3330
+ #install_time
3331
+
3332
+ App installation time
3333
+
3334
+ Time
3335
+
3336
+ Collected once at initialization
3337
+
3338
+ User's app installation time, value from system
3339
+
3340
+ #simulator
3341
+
3342
+ Is simulator
3343
+
3344
+ Numeric
3345
+
3346
+ Collected once at initialization
3347
+
3348
+ Whether the device is a simulator true/false
3349
+
3350
+ #ram
3351
+
3352
+ Device RAM status
3353
+
3354
+ Text
3355
+
3356
+ Collected at event time
3357
+
3358
+ Current remaining memory and total memory of the device, in GB, such as 1.4/2.4 (not collected by default in versions 3.2.0 and later)
3359
+
3360
+ #disk
3361
+
3362
+ Device storage status
3363
+
3364
+ Text
3365
+
3366
+ Collected at event time
3367
+
3368
+ Current remaining storage and total storage of the device, in GB, such as 30/200 (not collected by default in versions 3.2.0 and later)
3369
+
3370
+ #fps
3371
+
3372
+ Device frame rate
3373
+
3374
+ Numeric
3375
+
3376
+ Collected at event time
3377
+
3378
+ Current frames per second of the device, such as 60 (not collected by default in versions 3.2.0 and later)
3379
+
3380
+ #system_language
3381
+
3382
+ System language
3383
+
3384
+ Text
3385
+
3386
+ Collected once at initialization
3387
+
3388
+ User's system language (ISO 639-1, i.e., two lowercase letters), such as zh, en, etc.
3389
+
3390
+ ### 2. Preset Properties for Auto Tracking Events
3391
+
3392
+ The following preset properties are unique to each auto tracking event
3393
+
3394
+ - Preset properties for APP start event (ta_app_start)
3395
+ **Property Name**
3396
+
3397
+ **English Name**
3398
+
3399
+ **Property Type**
3400
+
3401
+ **Description**
3402
+
3403
+ #resume_from_background
3404
+
3405
+ Resumed from background
3406
+
3407
+ Boolean
3408
+
3409
+ Indicates whether the APP was opened or woken from the background. Value true means woken from the background, false means directly opened
3410
+
3411
+ #start_reason
3412
+
3413
+ App start source
3414
+
3415
+ Text
3416
+
3417
+ Content is a JSON string; when the APP is opened via URL or intent, the URL content and intent data are automatically recorded, example: `{url:"thinkingdata://","data":{}}`
3418
+
3419
+ #background_duration
3420
+
3421
+ Background duration
3422
+
3423
+ Numeric
3424
+
3425
+ Records the duration the APP was in the background between two start events, in seconds
3426
+
3427
+ - Preset properties for APP end event (ta_app_end)
3428
+ **Property Name**
3429
+
3430
+ **English Name**
3431
+
3432
+ **Property Type**
3433
+
3434
+ **Description**
3435
+
3436
+ #duration
3437
+
3438
+ Event duration
3439
+
3440
+ Numeric
3441
+
3442
+ Indicates the duration of the APP visit (from start to end), in seconds
3443
+
3444
+ - Preset properties for APP page view event (ta_app_view)
3445
+ **Property Name**
3446
+
3447
+ **English Name**
3448
+
3449
+ **Property Type**
3450
+
3451
+ **Description**
3452
+
3453
+ #title
3454
+
3455
+ Page title
3456
+
3457
+ Text
3458
+
3459
+ The title of the Activity the control belongs to, the value is the title property
3460
+
3461
+ #screen_name
3462
+
3463
+ Page name
3464
+
3465
+ Text
3466
+
3467
+ The package name.class name of the Activity the control belongs to
3468
+
3469
+ #url
3470
+
3471
+ Page URL
3472
+
3473
+ Text
3474
+
3475
+ The URL of the current page, requires calling getScreenUrl to set the URL
3476
+
3477
+ #referrer
3478
+
3479
+ Referrer URL
3480
+
3481
+ Text
3482
+
3483
+ The URL of the previous page, the previous page also needs to call getScreenUrl to set the URL
3484
+
3485
+ - Preset properties for APP control click event (ta_app_click)
3486
+ **Property Name**
3487
+
3488
+ **English Name**
3489
+
3490
+ **Property Type**
3491
+
3492
+ **Description**
3493
+
3494
+ #title
3495
+
3496
+ Page title
3497
+
3498
+ Text
3499
+
3500
+ The title of the Activity the control belongs to, the value is the title property of the Activity
3501
+
3502
+ #screen_name
3503
+
3504
+ Page name
3505
+
3506
+ Text
3507
+
3508
+ The package name.class name of the Activity the control belongs to
3509
+
3510
+ #element_id
3511
+
3512
+ Element ID
3513
+
3514
+ Text
3515
+
3516
+ The ID of the control, defaults to android:id, can be set via setViewID
3517
+
3518
+ #element_type
3519
+
3520
+ Element type
3521
+
3522
+ Text
3523
+
3524
+ The type of the control
3525
+
3526
+ #element_selector
3527
+
3528
+ Element selector
3529
+
3530
+ Text
3531
+
3532
+ The concatenation of the control's viewPath
3533
+
3534
+ #element_position
3535
+
3536
+ Element position
3537
+
3538
+ Text
3539
+
3540
+ The position information of the control, only uploaded when the control has a position attribute
3541
+
3542
+ #element_content
3543
+
3544
+ Element content
3545
+
3546
+ Text
3547
+
3548
+ The content on the control
3549
+
3550
+ - Preset properties for APP crash event (ta_app_crash)
3551
+ **Property Name**
3552
+
3553
+ **English Name**
3554
+
3555
+ **Property Type**
3556
+
3557
+ **Description**
3558
+
3559
+ #app_crashed_reason
3560
+
3561
+ Exception information
3562
+
3563
+ Text
3564
+
3565
+ String type, records the stack trace at the time of crash
3566
+
3567
+ ### 3. Other Preset Properties
3568
+
3569
+ In addition to the preset properties mentioned above, some preset properties require calling the corresponding interface to be recorded:
3570
+
3571
+ **Property Name**
3572
+
3573
+ **English Name**
3574
+
3575
+ **Property Type**
3576
+
3577
+ **Description**
3578
+
3579
+ #duration
3580
+
3581
+ Event duration
3582
+
3583
+ Numeric
3584
+
3585
+ Requires calling the timing function timeEvent, records the event duration, in seconds
3586
+
3587
+ #background_duration
3588
+
3589
+ Background duration
3590
+
3591
+ Numeric
3592
+
3593
+ Requires calling the timing function timeEvent, records the duration the APP was in the background during the event interval, in seconds
3594
+
3595
+ ### 4. Get Preset Properties
3596
+
3597
+ Versions v2.7.0 and later can call the `getPresetProperties()` method to get preset properties.
3598
+
3599
+ When server-side tracking needs some preset properties from the App side, you can use this method to get the App's preset properties and pass them to the server side.
3600
+
3601
+ :::: el-tabs
3602
+
3603
+ ::: el-tab-pane label=Java
3604
+
3605
+ ```
3606
+ // Get properties object
3607
+ TDPresetProperties presetProperties = TDAnalytics.getPresetProperties();
3608
+
3609
+ // Generate event preset properties
3610
+ JSONObject properties = presetProperties.toEventPresetProperties();
3611
+ /*
3612
+ {
3613
+ "#carrier": "T-Mobile",
3614
+ "#os": "Android",
3615
+ "#device_id": "dd4a508df0dbff08",
3616
+ "#screen_height": 2560,
3617
+ "#bundle_id": "cn.thinkingdata.android.demo",
3618
+ "#device_model": "sdk_gphone64_arm64",
3619
+ "#screen_width": 1440,
3620
+ "#system_language": "en",
3621
+ "#install_time": "2022-08-19 17:31:52.398",
3622
+ "#simulator": true,
3623
+ "#manufacturer": "Google",
3624
+ "#os_version": "12",
3625
+ "#app_version": "1.0",
3626
+ "#network_type": "3G",
3627
+ "#zone_offset": 8,
3628
+ "#ram": "0.8\/1.9",
3629
+ "#disk": "0.1\/0.8",
3630
+ "#fps": 60
3631
+ }
3632
+ */
3633
+
3634
+ // Get a specific preset property
3635
+ String bundle_id = presetProperties.bundleId;// Package name
3636
+ String os = presetProperties.os;// OS type, such as Android
3637
+ String system_language = presetProperties.systemLanguage;// Phone system language type
3638
+ int screen_width = presetProperties.screenWidth;// Screen width
3639
+ int screen_height = presetProperties.screenHeight;// Screen height
3640
+ String device_model = presetProperties.deviceModel;// Device model
3641
+ String device_id = presetProperties.deviceId;// Device unique identifier
3642
+ String carrier = presetProperties.carrier;// Phone SIM card carrier info, for dual SIM, uses primary SIM carrier info
3643
+ String manufacture = presetProperties.manufacture;// Phone manufacturer, such as HuaWei
3644
+ String network_type = presetProperties.networkType;// Network type
3645
+ String os_version = presetProperties.osVersion;// System version number
3646
+ String app_version = presetProperties.appVersion;// App version number
3647
+ double zone_offset = presetProperties.zoneOffset;// Timezone offset value
3648
+ String ram = presetProperties.ram;// Memory usage
3649
+ String disk = presetProperties.disk;// Disk usage
3650
+ int fps = presetProperties.fps;// fps
3651
+ String installTime = presetProperties.installTime;// App installation time
3652
+ boolean isSimulator = presetProperties.isSimulator;// Whether device is a simulator
3653
+
3654
+ ```
3655
+
3656
+ :::
3657
+
3658
+ ::: el-tab-pane label=Kotlin
3659
+
3660
+ ```
3661
+ // Get properties object
3662
+ val presetProperties = TDAnalytics.getPresetProperties()
3663
+
3664
+ // Generate event preset properties
3665
+ val properties = presetProperties.toEventPresetProperties()
3666
+ /*
3667
+ {
3668
+ "#carrier": "T-Mobile",
3669
+ "#os": "Android",
3670
+ "#device_id": "dd4a508df0dbff08",
3671
+ "#screen_height": 2560,
3672
+ "#bundle_id": "cn.thinkingdata.android.demo",
3673
+ "#device_model": "sdk_gphone64_arm64",
3674
+ "#screen_width": 1440,
3675
+ "#system_language": "en",
3676
+ "#install_time": "2022-08-19 17:31:52.398",
3677
+ "#simulator": true,
3678
+ "#manufacturer": "Google",
3679
+ "#os_version": "12",
3680
+ "#app_version": "1.0",
3681
+ "#network_type": "3G",
3682
+ "#zone_offset": 8,
3683
+ "#ram": "0.8\/1.9",
3684
+ "#disk": "0.1\/0.8",
3685
+ "#fps": 60
3686
+ }
3687
+ */
3688
+ // Get a specific preset property
3689
+ val bundle_id: String = presetProperties.bundleId // Package name
3690
+
3691
+ val os = presetProperties.os // OS type, such as Android
3692
+
3693
+ val system_language: String = presetProperties.systemLanguage // Phone system language type
3694
+
3695
+ val screen_width: Int = presetProperties.screenWidth // Screen width
3696
+
3697
+ val screen_height: Int = presetProperties.screenHeight // Screen height
3698
+
3699
+ val device_model: String = presetProperties.deviceModel // Device model
3700
+
3701
+ val device_id: String = presetProperties.deviceId // Device unique identifier
3702
+
3703
+ val carrier = presetProperties.carrier // Phone SIM card carrier info, for dual SIM, uses primary SIM carrier info
3704
+
3705
+ val manufacture = presetProperties.manufacture // Phone manufacturer, such as HuaWei
3706
+
3707
+ val network_type: String = presetProperties.networkType // Network type
3708
+
3709
+ val os_version: String = presetProperties.osVersion // System version number
3710
+
3711
+ val app_version: String = presetProperties.appVersion // App version number
3712
+
3713
+ val zone_offset: Double = presetProperties.zoneOffset // Timezone offset value
3714
+
3715
+ val ram = presetProperties.ram // Memory usage
3716
+
3717
+ val disk = presetProperties.disk // Disk usage
3718
+
3719
+ val fps = presetProperties.fps // fps
3720
+
3721
+ val installTime = presetProperties.installTime // App installation time
3722
+
3723
+ val isSimulator = presetProperties.isSimulator // Whether device is a simulator
3724
+ ```
3725
+
3726
+ :::
3727
+
3728
+ ::::
3729
+
3730
+ <!-- unsupported block: 34 -->
3731
+
3732
+ IP, country, and city information is parsed and generated by the server side. The client does not provide interfaces to obtain these properties.
3733
+
3734
+ ### 5. Disable Preset Property Collection
3735
+
3736
+ In some scenarios, for compliance or actual business needs, you may want to disable the collection of certain preset properties. You can add a ta_public_config.xml file in the res/values directory of your project to configure the array of properties to disable.
3737
+
3738
+ ```
3739
+ <?xml version="1.0" encoding="utf-8"?>
3740
+ <resources>
3741
+ <!-- ThinkingAnalytics DisablePresetProperties start -->
3742
+ <string-array name="TDDisPresetProperties">
3743
+ <!-- <item>#disk</item>-->
3744
+ <!-- <item>#fps</item>-->
3745
+ <!-- <item>#ram</item>-->
3746
+ <!-- <item>#app_version</item>-->
3747
+ <!-- <item>#os_version</item>-->
3748
+ <!-- <item>#manufacturer</item>-->
3749
+ <!-- <item>#device_model</item>-->
3750
+ <!-- <item>#screen_height</item>-->
3751
+ <!-- <item>#screen_width</item>-->
3752
+ <!-- <item>#carrier</item>-->
3753
+ <!-- <item>#device_id</item>-->
3754
+ <!-- <item>#system_language</item>-->
3755
+ <!-- <item>#lib</item>-->
3756
+ <!-- <item>#lib_version</item>-->
3757
+ <!-- <item>#os</item>-->
3758
+ <!-- <item>#bundle_id</item>-->
3759
+ <!-- <item>#install_time</item>-->
3760
+ <!-- <item>#start_reason</item>-->
3761
+ <!-- <item>#simulator</item>-->
3762
+ <!-- <item>#network_type</item>-->
3763
+ <!-- <item>#zone_offset</item>-->
3764
+ <!-- <item>#start_reason</item>-->
3765
+ <!-- <item>#resume_from_background</item>-->
3766
+ <!-- <item>#title</item>-->
3767
+ <!-- <item>#screen_name</item>-->
3768
+ <!-- <item>#url</item>-->
3769
+ <!-- <item>#referrer</item>-->
3770
+ <!-- <item>#element_type</item>-->
3771
+ <!-- <item>#element_id</item>-->
3772
+ <!-- <item>#element_position</item>-->
3773
+ <!-- <item>#element_content</item>-->
3774
+ <!-- <item>#element_selector</item>-->
3775
+ <!-- <item>#app_crashed_reason</item>-->
3776
+ <!-- <item>#background_duration</item>-->
3777
+ <!-- <item>#duration</item>-->
3778
+ </string-array>
3779
+ <!-- ThinkingAnalytics DisablePresetProperties end -->
3780
+ </resources>
3781
+ ```
3782
+
3783
+ <!-- unsupported block: 34 -->
3784
+
3785
+ If you disable the device ID and need to use first events, make sure to fill in the first_check_id property.
3786
+
3787
+ For the Android ID property, we support code-level complete isolation, meaning after isolation, the app will no longer contain code related to obtaining that property. For details, see the Auto Tracking Plugin Configuration section.