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