@thinkingai/ae-cli 6.0.61 → 6.0.62
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 +2 -0
- package/README.zh.md +2 -0
- package/dist/{ai-monitor-NUKSJPLE.js → ai-monitor-X5GL44JT.js} +5 -5
- package/dist/ai-monitor.js +7 -7
- package/dist/{auth-MVAEBGBP.js → auth-SPQ46XQ3.js} +3 -3
- package/dist/{automation-6L6IAYRK.js → automation-7XC3VBZI.js} +85 -9
- package/dist/{capability-74N7AN5X.js → capability-JZP4KXZC.js} +3 -3
- package/dist/{chunk-SVNED423.js → chunk-2VKMHNUU.js} +4 -4
- package/dist/{chunk-JZY6WWAP.js → chunk-6HOM2FOJ.js} +10 -1
- package/dist/{chunk-COOMXFUG.js → chunk-AAN6KBUK.js} +2 -2
- package/dist/{chunk-H35VDOAE.js → chunk-E457FREE.js} +2 -2
- package/dist/{chunk-VLOGOM7N.js → chunk-ETQXIZFP.js} +2 -1
- package/dist/{chunk-XZDKAR4N.js → chunk-F36ORPI6.js} +3 -28
- package/dist/{chunk-7WBCSJL6.js → chunk-F7TCQPQX.js} +1 -1
- package/dist/{chunk-HRFYYEXR.js → chunk-FGGEF7MI.js} +2 -2
- package/dist/chunk-N2MAYIRU.js +32 -0
- package/dist/{chunk-RB26WNLM.js → chunk-PRCHMOWT.js} +1 -1
- package/dist/{chunk-LPKIMGIU.js → chunk-RYY5NJK3.js} +2 -2
- package/dist/{chunk-OTZ4JQDU.js → chunk-VR2D54AA.js} +1 -1
- package/dist/{chunk-THTROEGD.js → chunk-YIG3L4RC.js} +1 -1
- package/dist/{chunk-XPARQSYS.js → chunk-YJYC5PLL.js} +2 -3
- package/dist/{chunk-HIMOBNEY.js → chunk-ZVUXAHEV.js} +1 -1
- package/dist/{compat-check-W4XC27RG.js → compat-check-JD5D77ET.js} +1 -1
- package/dist/{config-264GB6C7.js → config-IIMRATTP.js} +3 -3
- package/dist/{context-SOQDFZIB.js → context-BXHIPIIX.js} +1 -1
- package/dist/{data-integration-UNJ7EPW2.js → data-integration-VRJQ3HVK.js} +2 -1
- package/dist/index.js +33 -31
- package/dist/{memory-ZLTTULZK.js → memory-B44LY27L.js} +3 -3
- package/dist/{metadata-EN2IWCDI.js → metadata-ZVPG2MIA.js} +5 -5
- package/dist/{model-NAKQWK4W.js → model-ANZBYVST.js} +1 -1
- package/dist/{personal-semantic-preference-UGN67KTN.js → personal-semantic-preference-YNCV4QG3.js} +4 -4
- package/dist/{project-semantic-5OP3YPZD.js → project-semantic-E7ZAQL5S.js} +4 -4
- package/dist/{sync-LDJQZRQH.js → sync-Y4OZRQAY.js} +3 -3
- package/dist/{te-agent-WNNAD4AJ.js → te-agent-RKAUTYJZ.js} +4 -4
- package/dist/{te-analysis-KIMH6AGU.js → te-analysis-7N5VC4JB.js} +5 -5
- package/dist/{te-community-P7NNBVCS.js → te-community-SIA2UHTS.js} +4 -4
- package/dist/{te-dataops-ZRKSG4R7.js → te-dataops-5MJQCODU.js} +2 -2
- package/dist/{te-engage-PVBVNRSU.js → te-engage-ZTLOMKO3.js} +68 -16
- package/dist/{te-kb-W7PRC7QN.js → te-kb-LDL3MF2Y.js} +44 -13
- package/dist/{te-system-F4ZU2HRQ.js → te-system-473I5O53.js} +1 -1
- package/dist/{te-team-5ONMRGKF.js → te-team-JOWHCMZA.js} +87 -6
- package/dist/{things-PFENSIF4.js → things-DOQ2L3O2.js} +4 -4
- package/dist/{update-EUZ4GNND.js → update-KUS6TCPB.js} +2 -2
- package/dist/{workspace-Z7L33OBQ.js → workspace-MJFPIV7C.js} +3 -3
- package/package.json +3 -3
- package/skills/ae-automation/SKILL.md +6 -2
- package/skills/ae-automation/references/cli.md +9 -3
- package/skills/ae-engage/SKILL.md +6 -1
- package/skills/ae-engage/references/common-metric.md +47 -1
- package/skills/ae-engage/references/flow-metric-update.md +1 -1
- package/skills/ae-engage/references/task-metric-update.md +1 -1
- package/skills/ae-kb/SKILL.md +8 -6
- package/skills/ae-kb/references/query-workflow.md +5 -1
- package/skills/ae-team/SKILL.md +7 -3
- package/skills/ae-team/references/copy-to-personal.md +7 -0
- package/skills/ae-team/references/promote.md +7 -0
- package/skills/ae-team/references/update.md +3 -3
- package/skills/ae-tracking-matrix/SKILL.md +0 -170
- 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 +0 -12
- package/skills/ae-tracking-matrix/references/ae-capabilities.md +0 -93
- package/skills/ae-tracking-matrix/references/business-semantic-checks.md +0 -30
- package/skills/ae-tracking-matrix/references/categories/acquaintance_social_tracking_plan_template.md +0 -256
- package/skills/ae-tracking-matrix/references/categories/blockchain_game_tracking_plan_template.md +0 -213
- package/skills/ae-tracking-matrix/references/categories/card_game_tracking_plan_template.md +0 -407
- package/skills/ae-tracking-matrix/references/categories/casual_game_tracking_plan_template.md +0 -218
- package/skills/ae-tracking-matrix/references/categories/casual_music.md +0 -112
- package/skills/ae-tracking-matrix/references/categories/chess_cards_tracking_plan_template.md +0 -301
- package/skills/ae-tracking-matrix/references/categories/ecommerce_tracking_plan_template.md +0 -356
- package/skills/ae-tracking-matrix/references/categories/fishing.md +0 -775
- package/skills/ae-tracking-matrix/references/categories/game_basic_module_tracking_plan.md +0 -89
- package/skills/ae-tracking-matrix/references/categories/idle_card.md +0 -27
- package/skills/ae-tracking-matrix/references/categories/idle_game_tracking_plan_template.md +0 -415
- package/skills/ae-tracking-matrix/references/categories/interactive_video.md +0 -133
- package/skills/ae-tracking-matrix/references/categories/merge.md +0 -639
- package/skills/ae-tracking-matrix/references/categories/mmo_mobile_tracking_plan_template.md +0 -406
- package/skills/ae-tracking-matrix/references/categories/mmo_web.md +0 -230
- package/skills/ae-tracking-matrix/references/categories/music.md +0 -137
- package/skills/ae-tracking-matrix/references/categories/online_education_tracking_plan_template.md +0 -414
- package/skills/ae-tracking-matrix/references/categories/qipai_mj.md +0 -199
- package/skills/ae-tracking-matrix/references/categories/reading_tracking_plan_template.md +0 -158
- package/skills/ae-tracking-matrix/references/categories/roguelike_tracking_plan_template.md +0 -546
- package/skills/ae-tracking-matrix/references/categories/rpg.md +0 -195
- package/skills/ae-tracking-matrix/references/categories/short_drama_tracking_plan_template.md +0 -115
- package/skills/ae-tracking-matrix/references/categories/simulation_business_tracking_plan_template.md +0 -151
- package/skills/ae-tracking-matrix/references/categories/slg_tracking_plan_template.md +0 -260
- package/skills/ae-tracking-matrix/references/categories/slots_tracking_plan_template.md +0 -232
- package/skills/ae-tracking-matrix/references/categories/stranger_social_tracking_plan_template.md +0 -359
- package/skills/ae-tracking-matrix/references/categories/tower_defense.md +0 -365
- package/skills/ae-tracking-matrix/references/categories/video_editor_tracking_plan_template.md +0 -211
- package/skills/ae-tracking-matrix/references/categories/wechat_minigame.md +0 -132
- package/skills/ae-tracking-matrix/references/category-registry.md +0 -77
- package/skills/ae-tracking-matrix/references/data-verification/diagnosis_kb.md +0 -230
- package/skills/ae-tracking-matrix/references/data-verification/sql_checks.md +0 -406
- package/skills/ae-tracking-matrix/references/data-verification/tracking_plan_comparison.md +0 -128
- package/skills/ae-tracking-matrix/references/eval-cases.md +0 -74
- package/skills/ae-tracking-matrix/references/naming-dict.md +0 -238
- package/skills/ae-tracking-matrix/references/optimization-checklist.md +0 -85
- package/skills/ae-tracking-matrix/references/plan-generation/export-schema.md +0 -142
- package/skills/ae-tracking-matrix/references/plan-generation/module-baseline.md +0 -47
- package/skills/ae-tracking-matrix/references/plan-generation/reference.md +0 -794
- package/skills/ae-tracking-matrix/references/plan-generation/template-catalog.md +0 -94
- package/skills/ae-tracking-matrix/references/scene-routing.md +0 -80
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/android.md +0 -3787
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/c.md +0 -827
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-lua.md +0 -655
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocos2d-x.md +0 -953
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/cocoscreator.md +0 -1128
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/corona.md +0 -714
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/egret.md +0 -1268
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/flutter.md +0 -776
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/h5-and-app-sdk-integration.md +0 -182
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/ios.md +0 -2755
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/javascript.md +0 -1182
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/layaair.md +0 -1300
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/macos.md +0 -1369
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/mini-program-mini-game.md +0 -1692
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/openharmony.md +0 -902
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/react-native.md +0 -763
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/uni-app.md +0 -1107
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/unity.md +0 -1532
- package/skills/ae-tracking-matrix/references/sdk/client-sdk/unreal.md +0 -845
- package/skills/ae-tracking-matrix/references/sdk/faq/android_sdk_faq.md +0 -228
- package/skills/ae-tracking-matrix/references/sdk/faq/ios_sdk_faq.md +0 -149
- package/skills/ae-tracking-matrix/references/sdk/faq/java_sdk_faq.md +0 -407
- package/skills/ae-tracking-matrix/references/sdk/faq/javascript_sdk_faq.md +0 -163
- package/skills/ae-tracking-matrix/references/sdk/faq/minigame_sdk_faq.md +0 -149
- package/skills/ae-tracking-matrix/references/sdk/faq/miniprogram_sdk_faq.md +0 -153
- package/skills/ae-tracking-matrix/references/sdk/faq/python_sdk_faq.md +0 -232
- package/skills/ae-tracking-matrix/references/sdk/faq/sdk_log_guide.md +0 -314
- package/skills/ae-tracking-matrix/references/sdk/faq/sdk_usage_notes.md +0 -117
- package/skills/ae-tracking-matrix/references/sdk/faq/unity_sdk_faq.md +0 -148
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/filebeat-logstash-guide.md +0 -645
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_guide.md +0 -307
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/logbus2_parser_plugin.md +0 -347
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/restful_api_notes.md +0 -72
- package/skills/ae-tracking-matrix/references/sdk/integration-tools/ta-datax-writer-guide.md +0 -264
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/c.md +0 -566
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/erlang.md +0 -409
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/golang.md +0 -446
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/java.md +0 -557
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/lua.md +0 -457
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/nodejs.md +0 -490
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/php.md +0 -523
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/python.md +0 -484
- package/skills/ae-tracking-matrix/references/sdk/server-sdk/ruby.md +0 -442
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/data-rules.md +0 -391
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/first-event-validation.md +0 -91
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/preset-properties-system-fields.md +0 -635
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/updatable-events.md +0 -113
- package/skills/ae-tracking-matrix/references/sdk/te-data-rules/user-identification-rules.md +0 -466
- package/skills/ae-tracking-matrix/references/standard-base/README.md +0 -22
- package/skills/ae-tracking-matrix/references/standard-base/basic_event_data.md +0 -174
- package/skills/ae-tracking-matrix/references/standard-base/common_event_properties.md +0 -20
- package/skills/ae-tracking-matrix/references/standard-base/common_event_properties_setup.md +0 -7
- package/skills/ae-tracking-matrix/references/standard-base/data_type_design_principles.md +0 -14
- package/skills/ae-tracking-matrix/references/standard-base/gameplay_event_data.md +0 -370
- package/skills/ae-tracking-matrix/references/standard-base/id_system_faq.md +0 -47
- package/skills/ae-tracking-matrix/references/standard-base/integration_must_know.md +0 -37
- package/skills/ae-tracking-matrix/references/standard-base/multi_platform_integration_notes.md +0 -27
- package/skills/ae-tracking-matrix/references/standard-base/multi_user_id_system_recommendations.md +0 -23
- package/skills/ae-tracking-matrix/references/standard-base/tracking_notes.md +0 -14
- package/skills/ae-tracking-matrix/references/standard-base/user_data.md +0 -46
- package/skills/ae-tracking-matrix/references/standard-base/user_id_system.md +0 -13
- package/skills/ae-tracking-matrix/references/system-fields.md +0 -297
- package/skills/ae-tracking-matrix/references/te-field-translations.md +0 -1791
- package/skills/ae-tracking-matrix/references/workflows/data-verification.md +0 -232
- package/skills/ae-tracking-matrix/references/workflows/feasibility-analysis.md +0 -829
- package/skills/ae-tracking-matrix/references/workflows/integration-qna.md +0 -355
- package/skills/ae-tracking-matrix/references/workflows/plan-generation.md +0 -283
- package/skills/ae-tracking-matrix/references/workflows/plan-lint.md +0 -168
- package/skills/ae-tracking-matrix/references/workflows/plan-review-optimize.md +0 -205
- package/skills/ae-tracking-matrix/references/workflows/prd-to-suggestions.md +0 -75
- package/skills/ae-tracking-matrix/references/workflows/troubleshooting.md +0 -36
- package/skills/ae-tracking-matrix/references/workflows/validated-upload.md +0 -107
- package/skills/ae-tracking-matrix/scripts/build_template_catalog.py +0 -114
- package/skills/ae-tracking-matrix/scripts/export_tracking_plan.py +0 -53
- package/skills/ae-tracking-matrix/scripts/finalize_plan.py +0 -166
- package/skills/ae-tracking-matrix/scripts/lint_tracking_plan.py +0 -674
- package/skills/ae-tracking-matrix/scripts/plan_contract.py +0 -200
- package/skills/ae-tracking-matrix/scripts/plan_types.py +0 -60
- package/skills/ae-tracking-matrix/scripts/prepare_delivery.py +0 -169
- package/skills/ae-tracking-matrix/scripts/sync_plan.py +0 -296
- package/skills/ae-tracking-matrix/scripts/upload_plan.py +0 -340
|
@@ -1,902 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
code: openharmony_sdk_installation
|
|
3
|
-
name: "OpenHarmony"
|
|
4
|
-
wikiToken: CdewwjvM9irVHckq2lvctVPNnhf
|
|
5
|
-
parentWikiToken: FTcTwinIOi3OiRkK4MPc2Ex7neg
|
|
6
|
-
updateTime: 1768296999000
|
|
7
|
-
sourceUrl: https://docs-v2.thinkingdata.cn/?version=6.0&lan=zh-CN&code=openharmony_sdk_installation
|
|
8
|
-
---
|
|
9
|
-
|
|
10
|
-
# OpenHarmony
|
|
11
|
-
|
|
12
|
-
::: tip Tip
|
|
13
|
-
|
|
14
|
-
Before integration, please read the Pre-Integration Guide first.
|
|
15
|
-
|
|
16
|
-
SDK requires minimum system version of API 10
|
|
17
|
-
|
|
18
|
-
SDK (har format) size is approximately 56 KB
|
|
19
|
-
|
|
20
|
-
SDK Name: ThinkingData SDK
|
|
21
|
-
|
|
22
|
-
Developer: ThinkingData Information Technology (Shanghai) Co., Ltd.
|
|
23
|
-
|
|
24
|
-
Version: 1.7.6
|
|
25
|
-
|
|
26
|
-
Function: SDK collects client logs through events and user properties, with capabilities for statistics on daily active users, usage duration, retention behavior analysis, etc.
|
|
27
|
-
|
|
28
|
-
Privacy Statement: ThinkingData SDK Privacy Statement
|
|
29
|
-
|
|
30
|
-
Compliance Guide: ThinkingData SDK Compliance Guide
|
|
31
|
-
|
|
32
|
-
:::
|
|
33
|
-
|
|
34
|
-
**Latest Version:** 1.7.6
|
|
35
|
-
|
|
36
|
-
**Resource Download:** SDK Download
|
|
37
|
-
|
|
38
|
-
**SDK Package Name:** @thinkingdata/analytics
|
|
39
|
-
|
|
40
|
-
**MD5 Value:** 1b29126f457d46724e4287fecb0e4cdc
|
|
41
|
-
|
|
42
|
-
**Update Time:** 2026-01-05
|
|
43
|
-
|
|
44
|
-
### 1. SDK Integration
|
|
45
|
-
|
|
46
|
-
1. Import SDK
|
|
47
|
-
|
|
48
|
-
- Execute the following command
|
|
49
|
-
|
|
50
|
-
```
|
|
51
|
-
ohpm i @thinkingdata/analytics
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
- Or manually add dependency in oh-packages.json5 under dependencies, then IDE will prompt ohpm install, click to install
|
|
55
|
-
|
|
56
|
-
```
|
|
57
|
-
"dependencies": {
|
|
58
|
-
"@thinkingdata/analytics": "1.7.6",
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### 2. Initialization
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
import { TDAnalytics, TDConfig, TDMode } from '@thinkingdata/analytics';
|
|
66
|
-
|
|
67
|
-
// Method 1
|
|
68
|
-
TDAnalytics.init(context, "appId", "serverUrl")
|
|
69
|
-
|
|
70
|
-
// Method 2
|
|
71
|
-
let config = new TDConfig()
|
|
72
|
-
config.appId = 'appId'
|
|
73
|
-
config.serverUrl = 'serverUrl'
|
|
74
|
-
config.mode = TDMode.NORMAL
|
|
75
|
-
config.enableAutoCalibrated = true
|
|
76
|
-
TDAnalytics.initWithConfig(context, config)
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
During SDK initialization, it collects operating system version, device manufacturer, operating system, screen resolution, device model, APP version, network status, network carrier, application installation time, system language and other information for statistical analysis functions.
|
|
80
|
-
|
|
81
|
-
Parameter description:
|
|
82
|
-
|
|
83
|
-
- `APPID`: Your project's APPID, can be obtained through TE project management page
|
|
84
|
-
- `SERVER_URL`: Data upload URL
|
|
85
|
-
- If you are connecting to cloud service, please check the reporting address in Project Management -> Integration Configuration.
|
|
86
|
-
- If you use privately deployed version, you can customize the data collection address.
|
|
87
|
-
- `mode`: SDK reporting mode, default is Normal mode.
|
|
88
|
-
- `enableAutoCalibrated`: Automatically enable time calibration.
|
|
89
|
-
|
|
90
|
-
### 3. Common Features
|
|
91
|
-
|
|
92
|
-
Before using common features, we recommend you understand user identification rules first; SDK will generate random number as visitor ID by default, and persist visitor ID locally; before user logs in, visitor ID will be used as identity identification ID. Note: Visitor ID will change when user reinstalls App or changes device.
|
|
93
|
-
|
|
94
|
-
#### 3.1 Set Account ID
|
|
95
|
-
|
|
96
|
-
When user logs in, you can call `login` to set user's account ID, TE platform will use account ID as identity identification ID, and the set account ID will be retained until `logout` is called. Calling `login` multiple times will overwrite the previous account ID.
|
|
97
|
-
|
|
98
|
-
```
|
|
99
|
-
// User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
|
|
100
|
-
TDAnalytics.login("TA");
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
**This method will not upload login event**
|
|
104
|
-
|
|
105
|
-
#### 3.2 Set Public Event Properties
|
|
106
|
-
|
|
107
|
-
Public event properties are properties that every event will have, you can call `setSuperProperties` to set public event properties, we recommend you set public event properties before sending events. For some important properties, such as user's membership level, source channel, etc., these properties need to be set in every event, you can set these properties as public event properties.
|
|
108
|
-
|
|
109
|
-
```
|
|
110
|
-
let superProperties = {};
|
|
111
|
-
superProperties["channel"] = "ta";//String
|
|
112
|
-
superProperties["age"] = 1;//Number
|
|
113
|
-
superProperties["isSuccess"] = true;//Boolean
|
|
114
|
-
superProperties["birthday"] = new Date();//Time
|
|
115
|
-
superProperties["object"] = {key:"value"};//Object
|
|
116
|
-
superProperties["object_arr"] = [{key:"value"}];//Object array
|
|
117
|
-
superProperties["arr"] = ["value"];//Array
|
|
118
|
-
TDAnalytics.setSuperProperties(superProperties)
|
|
119
|
-
```
|
|
120
|
-
|
|
121
|
-
Public event properties will be saved to cache, no need to call every time when starting App. If `setSuperProperties` is called to upload previously set public event properties, it will overwrite previous properties.
|
|
122
|
-
|
|
123
|
-
#### 3.3 Enable Auto-tracking
|
|
124
|
-
|
|
125
|
-
It is recommended to enable enableAutoTrack after onWindowStageCreate, the following code example enables all auto-tracking events:
|
|
126
|
-
|
|
127
|
-
```
|
|
128
|
-
//APP install event TDAutoTrackEventType.APP_INSTALL
|
|
129
|
-
//APP start event TDAutoTrackEventType.APP_START
|
|
130
|
-
//APP end event TDAutoTrackEventType.APP_END
|
|
131
|
-
//APP page view event TDAutoTrackEventType.APP_VIEW_SCREEN
|
|
132
|
-
//APP control click event TDAnalytics.TDAutoTrackEventType.APP_CLICK
|
|
133
|
-
//APP crash event TDAutoTrackEventType.APP_CRASH
|
|
134
|
-
TDAnalytics.enableAutoTrack(context,TDAutoTrackEventType.APP_START | TDAutoTrackEventType.APP_INSTALL | TDAutoTrackEventType.APP_END | TDAutoTrackEventType.APP_VIEW_SCREEN | TDAutoTrackEventType.APP_CLICK | TDAutoTrackEventType.APP_CRASH)
|
|
135
|
-
```
|
|
136
|
-
|
|
137
|
-
#### 3.4 Send Event
|
|
138
|
-
|
|
139
|
-
You can call `track` to upload events, we recommend you set event properties according to the previously prepared tracking document, here we use user purchasing a product as an example:
|
|
140
|
-
|
|
141
|
-
```
|
|
142
|
-
TDAnalytics.track({
|
|
143
|
-
eventName: 'product_buy',
|
|
144
|
-
properties:{
|
|
145
|
-
product_name:"Product Name"
|
|
146
|
-
}
|
|
147
|
-
})
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
Event name is string type, must start with letter, can contain numbers, letters and underscore "\_".
|
|
151
|
-
|
|
152
|
-
#### 3.5 Set User Properties
|
|
153
|
-
|
|
154
|
-
For general user properties, you can call `userSet` to set them, properties uploaded using this interface will overwrite existing property values; if the user property did not exist before, it will create a new user property with the same type as the passed property type, here we use setting username as an example:
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
// username is TA
|
|
158
|
-
TDAnalytics.userSet({
|
|
159
|
-
properties: {
|
|
160
|
-
username: "TA"
|
|
161
|
-
}
|
|
162
|
-
})
|
|
163
|
-
//username is TE
|
|
164
|
-
TDAnalytics.userSet({
|
|
165
|
-
properties: {
|
|
166
|
-
username: "TE"
|
|
167
|
-
}
|
|
168
|
-
})
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### 4. Best Practices
|
|
172
|
-
|
|
173
|
-
The following example code includes all the above operations, we recommend using the following steps:
|
|
174
|
-
|
|
175
|
-
```
|
|
176
|
-
import { TDAnalytics, TDConfig, TDMode } from '@thinkingdata/analytics';
|
|
177
|
-
let config = new TDConfig()
|
|
178
|
-
config.appId = 'appId'
|
|
179
|
-
config.serverUrl = 'serverUrl'
|
|
180
|
-
config.enableAutoCalibrated = true
|
|
181
|
-
config.mode = TDMode.NORMAL
|
|
182
|
-
// Initialize
|
|
183
|
-
TDAnalytics.initWithConfig(this.context, config)
|
|
184
|
-
//Enable auto-tracking
|
|
185
|
-
TDAnalytics.enableAutoTrack(context,TDAutoTrackEventType.APP_START | TDAutoTrackEventType.APP_INSTALL | TDAutoTrackEventType.APP_END | TDAutoTrackEventType.APP_VIEW_SCREEN | TDAutoTrackEventType.APP_CLICK | TDAutoTrackEventType.APP_CRASH)
|
|
186
|
-
// User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
|
|
187
|
-
TDAnalytics.login("TA");
|
|
188
|
-
//Set public event properties
|
|
189
|
-
let superProperties = {
|
|
190
|
-
channel : "ta", //String
|
|
191
|
-
age : 1,//Number
|
|
192
|
-
isSuccess : true,//Boolean
|
|
193
|
-
birthday : new Date(),//Object
|
|
194
|
-
object : { key : "value" },//Object
|
|
195
|
-
object_arr : [ { key : "value" } ],//Object array
|
|
196
|
-
arr : [ "value" ]//Array
|
|
197
|
-
};
|
|
198
|
-
TDAnalytics.setSuperProperties(superProperties);
|
|
199
|
-
//Send event
|
|
200
|
-
TDAnalytics.track({
|
|
201
|
-
eventName: "product_buy", // Event name
|
|
202
|
-
properties: {
|
|
203
|
-
product_name: "Product Name"
|
|
204
|
-
} //Event properties
|
|
205
|
-
});
|
|
206
|
-
//Set user properties
|
|
207
|
-
TDAnalytics.userSet({
|
|
208
|
-
properties: {
|
|
209
|
-
username: "TE"
|
|
210
|
-
}
|
|
211
|
-
});
|
|
212
|
-
```
|
|
213
|
-
|
|
214
|
-
---
|
|
215
|
-
|
|
216
|
-
# Advanced Guide
|
|
217
|
-
|
|
218
|
-
### 1. Set User Identification
|
|
219
|
-
|
|
220
|
-
SDK instance will use random UUID as default visitor ID for each user by default, this ID will be used as identity identification ID for user in unlogged state. Note that visitor ID will change when user reinstalls App or changes device.
|
|
221
|
-
|
|
222
|
-
#### 1.1 Set Visitor ID
|
|
223
|
-
|
|
224
|
-
::: tip Tip
|
|
225
|
-
|
|
226
|
-
Generally, you don't need to customize visitor ID. Please make sure you understand user identification rules before setting visitor ID.
|
|
227
|
-
|
|
228
|
-
If you need to replace visitor ID, you should call it immediately after SDK initialization ends, do not call multiple times to avoid creating useless accounts
|
|
229
|
-
|
|
230
|
-
:::
|
|
231
|
-
|
|
232
|
-
If your App has its own visitor ID management system for each user, you can call `setDistinctId` to set visitor ID:
|
|
233
|
-
|
|
234
|
-
```
|
|
235
|
-
// Set visitor ID to Thinker
|
|
236
|
-
TDAnalytics.setDistinctId("Thinker");
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
If you need to get current visitor ID, you can call `getDistinctId` to get:
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
//Return visitor ID
|
|
243
|
-
let distinctId = TDAnalytics.getDistinctId();
|
|
244
|
-
```
|
|
245
|
-
|
|
246
|
-
#### 1.2 Set Account ID
|
|
247
|
-
|
|
248
|
-
When user logs in, you can call `login` to set user's account ID, TE platform will use account ID as identity identification ID, and the set account ID will be retained until `logout` is called. Calling `login` multiple times will overwrite the previous account ID.
|
|
249
|
-
|
|
250
|
-
```
|
|
251
|
-
//User's unique login identifier, this data corresponds to #account_id in reported data, at this time #account_id value is TA
|
|
252
|
-
TDAnalytics.login("TA");
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
**This method will not upload login event**
|
|
256
|
-
|
|
257
|
-
#### 1.3 Clear Account ID
|
|
258
|
-
|
|
259
|
-
After user logs out, you can call `logout` to clear account ID, before calling `login` next time, visitor ID will be used as identity identification ID.
|
|
260
|
-
|
|
261
|
-
```
|
|
262
|
-
// Remove #account_id from reported data, subsequent data will not have #account_id
|
|
263
|
-
TDAnalytics.logout();
|
|
264
|
-
```
|
|
265
|
-
|
|
266
|
-
We recommend you call `logout` when there is an explicit logout event, such as when user performs account cancellation action, rather than calling it when closing App.
|
|
267
|
-
|
|
268
|
-
**This method will not upload logout event**
|
|
269
|
-
|
|
270
|
-
### 2. Send Event
|
|
271
|
-
|
|
272
|
-
After SDK initialization is complete, you can perform data tracking and collect user behavior information. Generally, normal events can meet business scenario requirements, you can also use first, updatable and other events according to your actual business scenarios.
|
|
273
|
-
|
|
274
|
-
#### 2.1 Normal Event
|
|
275
|
-
|
|
276
|
-
You can call `track` to upload events, we recommend you set event properties and conditions for sending events according to the previously prepared document, here we use user purchasing a product as an example:
|
|
277
|
-
|
|
278
|
-
```
|
|
279
|
-
TDAnalytics.track({
|
|
280
|
-
eventName: "product_buy", // Event name
|
|
281
|
-
properties: {
|
|
282
|
-
product_name: "Product Name"
|
|
283
|
-
} //Event properties
|
|
284
|
-
});
|
|
285
|
-
```
|
|
286
|
-
|
|
287
|
-
#### 2.2 First Event
|
|
288
|
-
|
|
289
|
-
First event refers to events that will only be recorded once for a certain device or other dimension ID. For example, in some scenarios, you may want to record the activation event on a certain device, then you can use first event to report data.
|
|
290
|
-
|
|
291
|
-
```
|
|
292
|
-
TDAnalytics.trackFirst({
|
|
293
|
-
eventName: "device_activation",
|
|
294
|
-
properties: { key: "value" }
|
|
295
|
-
});
|
|
296
|
-
```
|
|
297
|
-
|
|
298
|
-
If you want to determine whether it's the first time based on dimensions other than device, you can customize first_check_id for first event:
|
|
299
|
-
|
|
300
|
-
```
|
|
301
|
-
// Set user ID as first_check_id for first event, to collect user's first activation event
|
|
302
|
-
TDAnalytics.trackFirst({
|
|
303
|
-
eventName: "account_activation",
|
|
304
|
-
firstCheckId: "TA",
|
|
305
|
-
properties: { key: "value" }
|
|
306
|
-
});
|
|
307
|
-
```
|
|
308
|
-
|
|
309
|
-
Note: Since the verification of whether it's the first time is completed on the server side, first event will be delayed by 1 hour before entering the database by default.
|
|
310
|
-
|
|
311
|
-
#### 2.3 Updatable Event
|
|
312
|
-
|
|
313
|
-
You can use updatable event to achieve the requirement of modifying event data in specific scenarios. Updatable event needs to specify the ID that identifies the event and pass it when creating the updatable event object. TE will determine the data that needs to be updated based on event name and event ID.
|
|
314
|
-
|
|
315
|
-
```
|
|
316
|
-
// Example: Report an updatable event, assume event name is UPDATABLE_EVENT
|
|
317
|
-
// After reporting, event property status is 3, price is 100
|
|
318
|
-
TDAnalytics.trackUpdate({
|
|
319
|
-
eventName: "UPDATABLE_EVENT",
|
|
320
|
-
properties: { status: 3, price: 100 },
|
|
321
|
-
eventId: "test_event_id"
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
// After reporting, event property status is updated to 5, price unchanged
|
|
325
|
-
TDAnalytics.trackUpdate({
|
|
326
|
-
eventName: "UPDATABLE_EVENT",
|
|
327
|
-
properties: { status: 5 },
|
|
328
|
-
eventId: "test_event_id"
|
|
329
|
-
});
|
|
330
|
-
```
|
|
331
|
-
|
|
332
|
-
#### 2.4 Overwritable Event
|
|
333
|
-
|
|
334
|
-
Overwritable event is similar to updatable event, the difference is that overwritable event will completely overwrite historical data with the latest data, from the effect it's equivalent to deleting the previous data and storing the latest data in the database. TE will determine the data that needs to be updated based on event name and event ID.
|
|
335
|
-
|
|
336
|
-
```
|
|
337
|
-
// Example: Report an overwritable event, assume event name is OVERWRITE_EVENT
|
|
338
|
-
// After reporting, event property status is 3, price is 100
|
|
339
|
-
TDAnalytics.trackOverwrite({
|
|
340
|
-
eventName: "OVERWRITE_EVENT",
|
|
341
|
-
properties: { status: 3, price: 100 },
|
|
342
|
-
eventId: "test_event_id"
|
|
343
|
-
});
|
|
344
|
-
|
|
345
|
-
// After reporting, event property status is updated to 5, price property is deleted
|
|
346
|
-
TDAnalytics.trackOverwrite({
|
|
347
|
-
eventName: "OVERWRITE_EVENT",
|
|
348
|
-
properties: { status: 5 },
|
|
349
|
-
eventId: "test_event_id"
|
|
350
|
-
});
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
#### 2.5 Public Event Properties
|
|
354
|
-
|
|
355
|
-
For some important properties, such as user's device ID, source channel, user status, etc., these properties need to be set in every event, you can set these properties as public properties, i.e. properties that every event will have. We recommend you set public properties before sending events.
|
|
356
|
-
|
|
357
|
-
##### 2.5.1 Static Public Event Properties
|
|
358
|
-
|
|
359
|
-
For some important properties, such as user's channel, nickname, ID, etc., these properties need to be set in every event, you can call `setSuperProperties` to set static public event properties, static public event properties will be globally effective.
|
|
360
|
-
|
|
361
|
-
```
|
|
362
|
-
// Set public event properties, all data events will have these properties
|
|
363
|
-
TDAnalytics.setSuperProperties({
|
|
364
|
-
channel: "Channel Name",
|
|
365
|
-
user_name: "Username"
|
|
366
|
-
});
|
|
367
|
-
```
|
|
368
|
-
|
|
369
|
-
Besides property setting, we also provide other APIs to operate static public event properties to meet daily business needs.
|
|
370
|
-
|
|
371
|
-
```
|
|
372
|
-
// Get static public event properties
|
|
373
|
-
let superProperties = TDAnalytics.getSuperProperties();
|
|
374
|
-
// Clear a static public event property, for example clear previously set 'channel' property, subsequent data will not have this property
|
|
375
|
-
TDAnalytics.unsetSuperProperty("channel");
|
|
376
|
-
// Clear all static public event properties
|
|
377
|
-
TDAnalytics.clearSuperProperties();
|
|
378
|
-
```
|
|
379
|
-
|
|
380
|
-
##### 2.5.2 Dynamic Public Event Properties
|
|
381
|
-
|
|
382
|
-
Set dynamic public property callback function through `setDynamicSuperProperties`, SDK will trigger callback function when reporting events and add the returned JSON object to event properties. `setDynamicSuperProperties` parameter is a function, the function needs to return a JSON object.
|
|
383
|
-
|
|
384
|
-
```
|
|
385
|
-
// Set dynamic public properties, trigger callback function when reporting events and add returned JSON object to event properties
|
|
386
|
-
TDAnalytics.setDynamicSuperProperties(() => {
|
|
387
|
-
return {
|
|
388
|
-
dy_name: 'xxx',
|
|
389
|
-
dy_age: 18
|
|
390
|
-
}
|
|
391
|
-
})
|
|
392
|
-
```
|
|
393
|
-
|
|
394
|
-
#### 2.6 Record Event Duration
|
|
395
|
-
|
|
396
|
-
If you need to record the duration of an event, you can call `timeEvent` to start timing. Configure the event name you want to time, when you upload that event, it will automatically add `#duration` property in your event properties to represent the recorded duration, unit is seconds. Note that the same event name can only have one timing task.
|
|
397
|
-
|
|
398
|
-
```
|
|
399
|
-
//The following example completes the statistics of user's stay duration on a product page
|
|
400
|
-
TDAnalytics.timeEvent("stay_shop");
|
|
401
|
-
/**do something
|
|
402
|
-
.......
|
|
403
|
-
**/
|
|
404
|
-
//User leaves product page, timing ends, "stay_shop" event will have #duration property representing event duration
|
|
405
|
-
TDAnalytics.track({
|
|
406
|
-
eventName: "stay_shop",
|
|
407
|
-
properties: {
|
|
408
|
-
product_name: "Product Name"
|
|
409
|
-
}
|
|
410
|
-
});
|
|
411
|
-
```
|
|
412
|
-
|
|
413
|
-
### 3. User Properties
|
|
414
|
-
|
|
415
|
-
TE platform supported user property setting APIs are: `userSet`, `userSetOnce`, `userAdd`, `userUnset`, `userDelete`, `userAppend`, `userUniqAppend`.
|
|
416
|
-
|
|
417
|
-
#### 3.1 userSet
|
|
418
|
-
|
|
419
|
-
For general user properties, you can call `userSet` to set them. Properties uploaded using this interface will overwrite existing property values, if the user property did not exist before, it will create a new user property with the same type as the passed property type, here we use setting username as an example:
|
|
420
|
-
|
|
421
|
-
```
|
|
422
|
-
// username is TA
|
|
423
|
-
TDAnalytics.userSet({
|
|
424
|
-
properties: {
|
|
425
|
-
username: "TA"
|
|
426
|
-
}
|
|
427
|
-
});
|
|
428
|
-
//username is TE
|
|
429
|
-
TDAnalytics.userSet({
|
|
430
|
-
properties: {
|
|
431
|
-
username: "TE"
|
|
432
|
-
}
|
|
433
|
-
});
|
|
434
|
-
```
|
|
435
|
-
|
|
436
|
-
#### 3.2 userSetOnce
|
|
437
|
-
|
|
438
|
-
If the user property you want to upload only needs to be set once, you can call `userSetOnce` to set it, when the property already has a value before, this message will be ignored, here we use setting first payment time as an example:
|
|
439
|
-
|
|
440
|
-
```
|
|
441
|
-
//first_payment_time is 2018-01-01 01:23:45.678
|
|
442
|
-
TDAnalytics.userSetOnce({
|
|
443
|
-
properties: {
|
|
444
|
-
first_payment_time: "2018-01-01 01:23:45.678"
|
|
445
|
-
}
|
|
446
|
-
});
|
|
447
|
-
//first_payment_time is still 2018-01-01 01:23:45.678
|
|
448
|
-
TDAnalytics.userSetOnce({
|
|
449
|
-
properties: {
|
|
450
|
-
first_payment_time: "2018-12-31 01:23:45.678"
|
|
451
|
-
}
|
|
452
|
-
});
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
#### 3.3 userAdd
|
|
456
|
-
|
|
457
|
-
When you want to upload numeric properties, you can call `userAdd` to accumulate the property, if the property hasn't been set yet, it will assign 0 before calculation. If negative value is passed, it's equivalent to subtraction operation.
|
|
458
|
-
|
|
459
|
-
```
|
|
460
|
-
//At this time total_revenue is 30
|
|
461
|
-
TDAnalytics.userAdd({
|
|
462
|
-
properties: {
|
|
463
|
-
total_revenue: 30
|
|
464
|
-
}
|
|
465
|
-
});
|
|
466
|
-
//At this time total_revenue is 678
|
|
467
|
-
TDAnalytics.userAdd({
|
|
468
|
-
properties: {
|
|
469
|
-
total_revenue: 648
|
|
470
|
-
}
|
|
471
|
-
});
|
|
472
|
-
```
|
|
473
|
-
|
|
474
|
-
#### 3.4 userUnset
|
|
475
|
-
|
|
476
|
-
When you want to clear user's user property value, you can call `userUnset` to clear the specified property, if the property has not been created in the cluster yet, `userUnset` will **not** create the property
|
|
477
|
-
|
|
478
|
-
```
|
|
479
|
-
// Clear user property value with property name userPropertykey, i.e. set to NULL
|
|
480
|
-
TDAnalytics.userUnset({
|
|
481
|
-
property: "userPropertykey"
|
|
482
|
-
});
|
|
483
|
-
```
|
|
484
|
-
|
|
485
|
-
#### 3.5 userDelete
|
|
486
|
-
|
|
487
|
-
If you want to delete a user, you can call `userDelete` to delete this user, you will no longer be able to query this user's user properties, but the events generated by this user can still be queried.
|
|
488
|
-
|
|
489
|
-
```
|
|
490
|
-
TDAnalytics.userDelete();
|
|
491
|
-
```
|
|
492
|
-
|
|
493
|
-
#### 3.6 userAppend
|
|
494
|
-
|
|
495
|
-
You can call `userAppend` to append elements to array type user data.
|
|
496
|
-
|
|
497
|
-
```
|
|
498
|
-
TDAnalytics.userAppend({
|
|
499
|
-
properties: {
|
|
500
|
-
user_list: ["apple", "ball"]
|
|
501
|
-
}
|
|
502
|
-
});
|
|
503
|
-
```
|
|
504
|
-
|
|
505
|
-
#### 3.7 userUniqAppend
|
|
506
|
-
|
|
507
|
-
You can call `userUniqAppend` to append unique elements to Array (List) type user data. Calling `userUniqAppend` interface will deduplicate the appended user properties, `userAppend` interface does not deduplicate, user properties can have duplicates.
|
|
508
|
-
|
|
509
|
-
```
|
|
510
|
-
//At this time user_list property value is ["apple", "ball"]
|
|
511
|
-
TDAnalytics.userAppend({
|
|
512
|
-
properties: {
|
|
513
|
-
user_list: ["apple", "ball"]
|
|
514
|
-
}
|
|
515
|
-
});
|
|
516
|
-
//At this time user_list property value is ["apple", "apple", "ball", "cube"]
|
|
517
|
-
TDAnalytics.userAppend({
|
|
518
|
-
properties: {
|
|
519
|
-
user_list: ["apple", "cube"]
|
|
520
|
-
}
|
|
521
|
-
});
|
|
522
|
-
//At this time user_list property value is ["apple", "ball", "cube"]
|
|
523
|
-
TDAnalytics.userUniqAppend({
|
|
524
|
-
properties: {
|
|
525
|
-
user_list: ["apple", "cube"]
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
```
|
|
529
|
-
|
|
530
|
-
### 4. Encryption Feature
|
|
531
|
-
|
|
532
|
-
SDK supports using AES+RSA to encrypt data. Data encryption feature needs client and server to cooperate, please consult customer success personnel for specific usage method.
|
|
533
|
-
|
|
534
|
-
```
|
|
535
|
-
let config = new TDConfig()
|
|
536
|
-
config.appId = 'app_id'
|
|
537
|
-
config.serverUrl = 'server_url'
|
|
538
|
-
//Enable encryption feature, set public key information
|
|
539
|
-
config.enableEncrypt(1,'publicKey')
|
|
540
|
-
TDAnalytics.initWithConfig(context, config)
|
|
541
|
-
```
|
|
542
|
-
|
|
543
|
-
### 5. Enable Integration with H5 Pages
|
|
544
|
-
|
|
545
|
-
If you need to integrate with JavaScript SDK that collects H5 page data, call the following interface when initializing `WebView`
|
|
546
|
-
|
|
547
|
-
```
|
|
548
|
-
controller: webview.WebviewController = new webview.WebviewController();
|
|
549
|
-
TDAnalytics.setJsBridge(controller)
|
|
550
|
-
```
|
|
551
|
-
|
|
552
|
-
### 6. Other Features
|
|
553
|
-
|
|
554
|
-
#### 5.1 Get Device ID
|
|
555
|
-
|
|
556
|
-
You can call `getDeviceId()` to get device ID.
|
|
557
|
-
|
|
558
|
-
```
|
|
559
|
-
let deviceId = TDAnalytics.getDeviceId();
|
|
560
|
-
```
|
|
561
|
-
|
|
562
|
-
**Device ID will be saved in cache, if user clears cache, device ID will be reset.**
|
|
563
|
-
|
|
564
|
-
#### 5.2 Calibrate Time
|
|
565
|
-
|
|
566
|
-
SDK will use local time as event occurrence time by default, if user manually modifies device time it will affect your business analysis, you can ensure the accuracy of event occurrence time through time calibration operation. We provide `timestamp` and `automatic` two time calibration methods.
|
|
567
|
-
|
|
568
|
-
- You can use the current timestamp obtained from server to calibrate SDK time. After that, all calls without specified time, including event data and user property setting operations, will use calibrated time as occurrence time.
|
|
569
|
-
|
|
570
|
-
```
|
|
571
|
-
// 1585633785954 is current unix timestamp, unit is milliseconds, corresponding to Beijing time 2020-03-31 13:49:45
|
|
572
|
-
TDAnalytics.calibrateTime(1585633785954)
|
|
573
|
-
```
|
|
574
|
-
|
|
575
|
-
- You can also set automatic time calibration, after that SDK will try to get current time from config interface and calibrate SDK time. If correct return result is not obtained, subsequent data will be reported using local time.
|
|
576
|
-
|
|
577
|
-
```
|
|
578
|
-
let config = new TDConfig()
|
|
579
|
-
config.appId = 'appId'
|
|
580
|
-
config.serverUrl = 'serverUrl'
|
|
581
|
-
//Set to true to enable automatic time calibration
|
|
582
|
-
config.enableAutoCalibrated = true
|
|
583
|
-
TDAnalytics.initWithConfig(context, config)
|
|
584
|
-
```
|
|
585
|
-
|
|
586
|
-
#### 5.3 Set Default Timezone
|
|
587
|
-
|
|
588
|
-
By default, SDK will use local time as event occurrence time. You can also set default timezone interface to specify timezone, so all events will align event time according to your set timezone:
|
|
589
|
-
|
|
590
|
-
```
|
|
591
|
-
import I18n from '@ohos.i18n';
|
|
592
|
-
let config = new TDConfig()
|
|
593
|
-
config.appId = 'appId'
|
|
594
|
-
config.serverUrl = 'serverUrl'
|
|
595
|
-
config.defaultTimeZone = I18n.getTimeZone('Australia/Sydney')
|
|
596
|
-
TDAnalytics.initWithConfig(this.context, config)
|
|
597
|
-
```
|
|
598
|
-
|
|
599
|
-
Aligning event time with specified timezone will lose device local timezone information. If you need to preserve device local timezone information, currently you need to add related properties to events yourself.
|
|
600
|
-
|
|
601
|
-
#### 5.4 Flush Data Immediately
|
|
602
|
-
|
|
603
|
-
In some business scenarios, if you expect data to be reported to TE server immediately, you can call `flush` interface to complete
|
|
604
|
-
|
|
605
|
-
```
|
|
606
|
-
TDAnalytics.flush();
|
|
607
|
-
```
|
|
608
|
-
|
|
609
|
-
---
|
|
610
|
-
|
|
611
|
-
# Multi-Instance
|
|
612
|
-
|
|
613
|
-
### 1. Feature Introduction
|
|
614
|
-
|
|
615
|
-
We support using multiple AppIds to create SDK instances, we call it multi-instance. Through multi-instance feature, you can report data to different projects.
|
|
616
|
-
|
|
617
|
-
### 2. Create Multi-Instance
|
|
618
|
-
|
|
619
|
-
Pass different APP ID to complete SDK initialization, you can create multiple SDK instances:
|
|
620
|
-
|
|
621
|
-
```
|
|
622
|
-
//Initialize config 1
|
|
623
|
-
var config_1 = {
|
|
624
|
-
appId: "app-id-1",
|
|
625
|
-
serverUrl: "https://youserverurl.1.com"
|
|
626
|
-
};
|
|
627
|
-
TDAnalytics.init(config_1);
|
|
628
|
-
|
|
629
|
-
//Initialize config 2
|
|
630
|
-
var config_2 = {
|
|
631
|
-
appId: "app-id-2",
|
|
632
|
-
serverUrl: "https://youserverurl.2.com"
|
|
633
|
-
};
|
|
634
|
-
TDAnalytics.init(config_2);
|
|
635
|
-
|
|
636
|
-
//Report event to config 1 (without app-id, default reports to config 1)
|
|
637
|
-
TDAnalytics.track({
|
|
638
|
-
eventName: 'event_from_appid_1'
|
|
639
|
-
});
|
|
640
|
-
//Report event to config 1 (specify app-id-1)
|
|
641
|
-
TDAnalytics.track({
|
|
642
|
-
eventName: 'event_from_appid_1'
|
|
643
|
-
}, 'app-id-1');
|
|
644
|
-
//Report event to config 2 (specify app-id-2)
|
|
645
|
-
TDAnalytics.track({
|
|
646
|
-
eventName: 'event_from_appid_2'
|
|
647
|
-
}, 'app-id-2');
|
|
648
|
-
```
|
|
649
|
-
|
|
650
|
-
Please note that multiple SDK instances' APP IDs must be different, most data between multi-instances is not shared, details can be referred to Section 4 "Data and Settings Sharing between Multi-Instances".
|
|
651
|
-
|
|
652
|
-
### 3. Data Sharing between Multi-Instances
|
|
653
|
-
|
|
654
|
-
Most interfaces are called by instance objects, so most data and settings are not shared between multi-APPID instances, parent instances and lightweight instances, but some data and settings will take effect for all instances, here is the detailed explanation of whether all data and settings are shared between multi-instances:
|
|
655
|
-
|
|
656
|
-
1. Account related information
|
|
657
|
-
|
|
658
|
-
- System default generated visitor ID `#distinct_id`: Shared
|
|
659
|
-
- Visitor ID `#distinct_id` set by calling `identify`: Not shared
|
|
660
|
-
- Account ID `#account_id` set by calling `login`: Not shared
|
|
661
|
-
|
|
662
|
-
1. Event reporting `track` and user property reporting `user_set`, `user_setOnce`, `user_add`, `user_delete`: Not shared
|
|
663
|
-
1. Public properties `setSuperProperties` and dynamic public properties `setDynamicSuperPropertiesTracker`: Not shared
|
|
664
|
-
1. Record event duration `timeEvent`: Not shared
|
|
665
|
-
|
|
666
|
-
---
|
|
667
|
-
|
|
668
|
-
# Real-time Debugging
|
|
669
|
-
|
|
670
|
-
During SDK integration, you can perform real-time debugging by viewing SDK logs in IDE console or using TE's Debug feature.
|
|
671
|
-
|
|
672
|
-
### 1. Print SDK Logs
|
|
673
|
-
|
|
674
|
-
```
|
|
675
|
-
TDAnalytics.enableLog(true)
|
|
676
|
-
```
|
|
677
|
-
|
|
678
|
-
After enabling logs, you can observe SDK data reporting in IDE.
|
|
679
|
-
|
|
680
|
-
### 2. Enable Debug Mode
|
|
681
|
-
|
|
682
|
-
Enabling Debug mode requires the following two steps:
|
|
683
|
-
|
|
684
|
-
1. Client enables Debug mode
|
|
685
|
-
Here is the client Debug mode enable example code:
|
|
686
|
-
|
|
687
|
-
```
|
|
688
|
-
/*
|
|
689
|
-
Set running mode to Debug mode
|
|
690
|
-
TDMode.NORMAL: Data will be stored in cache and reported according to certain cache strategy, default is NORMAL mode; recommended for production environment
|
|
691
|
-
TDMode.DEBUG: Data is reported one by one. When problems occur, it will prompt users with logs and exceptions; not recommended for production environment
|
|
692
|
-
TDMode.DEBUG_ONLY: Only validates data, will not store in database; not recommended for production environment
|
|
693
|
-
*/
|
|
694
|
-
let config = new TDConfig()
|
|
695
|
-
config.appId = 'appID'
|
|
696
|
-
config.serverUrl = 'serverUrl'
|
|
697
|
-
config.mode = TDMode.DEBUG
|
|
698
|
-
await TDAnalytics.initWithConfig(this.context, config)
|
|
699
|
-
```
|
|
700
|
-
|
|
701
|
-
1. TE backend adds Debug device
|
|
702
|
-
To avoid Debug mode going live in production environment, it is specified that only designated devices can enable Debug mode. Only when client has enabled Debug mode and device ID is configured in TE backend's "Tracking Management" page's "Debug Data" section can Debug mode be enabled.
|
|
703
|
-
|
|
704
|
-
Device ID can be obtained through the following three ways:
|
|
705
|
-
|
|
706
|
-
- #device_id property in event data on TE platform
|
|
707
|
-
- Client log: SDK will print device DeviceId after initialization is complete
|
|
708
|
-
- Call through instance interface: Get Device ID
|
|
709
|
-
|
|
710
|
-
Debug mode may affect data collection quality and App stability, only use for integration phase data validation, do not use in production environment.
|
|
711
|
-
|
|
712
|
-
---
|
|
713
|
-
|
|
714
|
-
# Auto-tracking
|
|
715
|
-
|
|
716
|
-
OpenHarmony SDK supports auto-tracking of events including installation, start, end, etc.
|
|
717
|
-
|
|
718
|
-
### 1. Introduction
|
|
719
|
-
|
|
720
|
-
TE system provides automated data collection interface, you can choose the data that needs to be automatically collected according to business needs.
|
|
721
|
-
|
|
722
|
-
Currently supported auto-tracking event types are:
|
|
723
|
-
|
|
724
|
-
1. Install event: Records APP installation behavior
|
|
725
|
-
1. Start event: Including opening APP and opening APP from background
|
|
726
|
-
1. End event: Including closing APP and App entering background
|
|
727
|
-
1. View event: User browsing page (Ability) in APP
|
|
728
|
-
1. Click event: User clicking control in APP
|
|
729
|
-
1. Crash event: APP records crash information when crash occurs (native layer crash is not supported temporarily)
|
|
730
|
-
|
|
731
|
-
Next we will introduce each data collection method in detail
|
|
732
|
-
|
|
733
|
-
### 2. Enable Auto-tracking
|
|
734
|
-
|
|
735
|
-
You can call `enableAutoTrack` to enable auto-tracking feature:
|
|
736
|
-
|
|
737
|
-
```
|
|
738
|
-
//APP install event TDAutoTrackEventType.APP_INSTALL
|
|
739
|
-
//APP start event TDAutoTrackEventType.APP_START
|
|
740
|
-
//APP end event TDAutoTrackEventType.APP_END
|
|
741
|
-
//APP page view event TDAutoTrackEventType.APP_VIEW_SCREEN
|
|
742
|
-
//APP control click event TDAnalytics.TDAutoTrackEventType.APP_CLICK
|
|
743
|
-
//APP crash event TDAutoTrackEventType.APP_CRASH
|
|
744
|
-
TDAnalytics.enableAutoTrack(context,TDAutoTrackEventType.APP_START | TDAutoTrackEventType.APP_INSTALL | TDAutoTrackEventType.APP_END | TDAutoTrackEventType.APP_VIEW_SCREEN | TDAutoTrackEventType.APP_CLICK | TDAutoTrackEventType.APP_CRASH)
|
|
745
|
-
```
|
|
746
|
-
|
|
747
|
-
Note: enableAutoTrack needs to be called in main thread. If you need to initialize SDK in work thread, you can refer to the following code
|
|
748
|
-
|
|
749
|
-
```
|
|
750
|
-
const workerInstance = new worker.ThreadWorker("./workers/worker.ets");
|
|
751
|
-
TDAnalytics.enableAutoTrack(this.context,
|
|
752
|
-
TDAutoTrackEventType.APP_START | TDAutoTrackEventType.APP_INSTALL | TDAutoTrackEventType.APP_END |
|
|
753
|
-
TDAutoTrackEventType.APP_VIEW_SCREEN | TDAutoTrackEventType.APP_CRASH |
|
|
754
|
-
TDAutoTrackEventType.APP_CLICK,
|
|
755
|
-
(command: string, params: Object, appId?: string) => {
|
|
756
|
-
//Here will callback the auto-tracking events that need to be triggered, need to send message to work thread to process
|
|
757
|
-
workerInstance.postMessage({
|
|
758
|
-
type: command,
|
|
759
|
-
params: params
|
|
760
|
-
})
|
|
761
|
-
})
|
|
762
|
-
```
|
|
763
|
-
|
|
764
|
-
```
|
|
765
|
-
const workerPort = worker.workerPort;
|
|
766
|
-
|
|
767
|
-
workerPort.onmessage = (d: MessageEvents): void => {
|
|
768
|
-
if (d.data.type === 'track') {
|
|
769
|
-
TDAnalytics.track(d.data.params);
|
|
770
|
-
} else if (d.data.type === 'timeEvent') {
|
|
771
|
-
TDAnalytics.timeEvent(d.data.params);
|
|
772
|
-
} else if (d.data.type === 'flush') {
|
|
773
|
-
TDAnalytics.flush()
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
```
|
|
777
|
-
|
|
778
|
-
### 3. Detailed Introduction
|
|
779
|
-
|
|
780
|
-
##### 3.1 Install Event
|
|
781
|
-
|
|
782
|
-
APP install event will record the actual installation of APP, reported when APP starts, event trigger time is the time of first start after APP installation, APP upgrade will not trigger install event, but delete and reinstall will report install event.
|
|
783
|
-
|
|
784
|
-
- Event name: ta_app_install
|
|
785
|
-
|
|
786
|
-
##### 3.2 Start Event
|
|
787
|
-
|
|
788
|
-
APP start event will be triggered when user opens APP or wakes APP from background, detailed event introduction:
|
|
789
|
-
|
|
790
|
-
- Event name: ta_app_start
|
|
791
|
-
- Preset property: `#resume_from_background`, boolean type, indicates whether APP is user opened or woke from background, value true means woke from background, false means directly opened.
|
|
792
|
-
- Triggered through onApplicationForeground callback in ApplicationStateChangeCallback
|
|
793
|
-
|
|
794
|
-
##### 3.3 End Event
|
|
795
|
-
|
|
796
|
-
APP end event will be triggered when user closes APP or puts APP into background, detailed event introduction:
|
|
797
|
-
|
|
798
|
-
- Event name: ta_app_end
|
|
799
|
-
- Preset property: `#duration`, numeric type, indicates the duration of this APP visit (from start to end), unit is seconds.
|
|
800
|
-
- Triggered through onApplicationBackground callback in ApplicationStateChangeCallback
|
|
801
|
-
|
|
802
|
-
##### 3.4 Page View Event
|
|
803
|
-
|
|
804
|
-
APP page view event will be triggered when user browses page (`Ability`), detailed event introduction:
|
|
805
|
-
|
|
806
|
-
- Event name: ta_app_view
|
|
807
|
-
- Preset properties:
|
|
808
|
-
`#screen_name`, string type, is `Ability`'s simple class name
|
|
809
|
-
|
|
810
|
-
##### 3.5 Click Event
|
|
811
|
-
|
|
812
|
-
APP control click event will be triggered when user clicks control (view)
|
|
813
|
-
|
|
814
|
-
- Event name: ta_app_click
|
|
815
|
-
- Preset properties:
|
|
816
|
-
`#screen_name`, string type, is package name.class name of control's belonging `Activity`
|
|
817
|
-
|
|
818
|
-
`#element_type`, string type, is control's type
|
|
819
|
-
|
|
820
|
-
`#element_id`, string type, is control's ID
|
|
821
|
-
|
|
822
|
-
##### 3.6 Crash Event
|
|
823
|
-
|
|
824
|
-
When APP encounters uncaught exception, APP crash event will be reported
|
|
825
|
-
|
|
826
|
-
- Event name: ta_app_crash
|
|
827
|
-
- Preset property: `#app_crashed_reason`, character type, records crash stack trace
|
|
828
|
-
- Monitored through ErrorObserver's onUnhandledException, native crash collection is not supported temporarily.
|
|
829
|
-
|
|
830
|
-
---
|
|
831
|
-
|
|
832
|
-
# Preset Properties
|
|
833
|
-
|
|
834
|
-
### 1. Preset Properties for All Events
|
|
835
|
-
|
|
836
|
-
The following preset properties are preset properties that all events (including auto-tracking events) in OpenHarmony SDK will have
|
|
837
|
-
|
|
838
|
-
**Property Name** | **Chinese Name** | **Property Type** | **Collection Time** | **Description**
|
|
839
|
-
#ip | IP Address | Text | Server collection | User's IP address, TE will use this to get user's geographic location information
|
|
840
|
-
#country | Country | Text | Server collection | User's country, generated based on IP address
|
|
841
|
-
#country_code | Country Code | Text | Server collection | User's country code (ISO 3166-1 alpha-2, i.e. two uppercase English letters), generated based on IP address
|
|
842
|
-
#province | Province | Text | Server collection | User's province, generated based on IP address
|
|
843
|
-
#city | City | Text | Server collection | User's city, generated based on IP address
|
|
844
|
-
#os_version | Operating System Version | Text | Collected once at initialization | iOS 11.2.2, Android 8.0.0, etc.
|
|
845
|
-
#manufacturer | Device Manufacturer | Text | Collected once at initialization | User device's manufacturer, such as Apple, vivo, etc.
|
|
846
|
-
#os | Operating System | Text | Collected once at initialization | Such as Android, iOS, HarmonyOS, etc.
|
|
847
|
-
#device_id | Device ID | Text | Collected once at initialization | User's device ID, iOS takes user's IDFV or UUID, Android takes androidID
|
|
848
|
-
#screen_height | Screen Height | Number | Collected once at initialization | User device's screen height, such as 1920
|
|
849
|
-
#screen_width | Screen Width | Number | Collected once at initialization | User device's screen height, such as 1080
|
|
850
|
-
#device_model | Device Model | Text | Collected once at initialization | User device's model, such as iPhone 8
|
|
851
|
-
#device_type | Device Type | Text | Collected once at initialization | Device type, such as "Tablet", "Phone"
|
|
852
|
-
#app_version | APP Version | Text | Collected once at initialization | Your APP's version
|
|
853
|
-
#bundle_id | Application Unique Identifier | Text | Collected once at initialization | Application package name or process name
|
|
854
|
-
#lib | SDK Type | Text | Collected once at initialization | SDK type you integrated, such as Android, iOS, etc.
|
|
855
|
-
#lib_version | SDK Version | Text | Collected once at initialization | SDK version you integrated
|
|
856
|
-
#network_type | Network Status | Text | Collected once at initialization, collected when network status changes | Network status when uploading event, such as WIFI, 3G, 4G, etc.
|
|
857
|
-
#carrier | Network Carrier | Text | Collected once at initialization | User device's network carrier, such as China Mobile, China Telecom, etc.
|
|
858
|
-
#zone_offset | Timezone Offset | Number | Collected when event occurs | Data time offset hours relative to UTC time
|
|
859
|
-
#install_time | Program Installation Time | Time | Collected once at initialization | User's application installation time, value comes from system
|
|
860
|
-
#system_language | System Language | Text | Collected once at initialization | User device's system language (ISO 639-1, i.e. two lowercase English letters), such as zh, en, etc.
|
|
861
|
-
|
|
862
|
-
### 2. Get Preset Properties
|
|
863
|
-
|
|
864
|
-
You can call `getPresetProperties()` method to get preset properties.
|
|
865
|
-
|
|
866
|
-
When server tracking needs some preset properties from App side, you can get App side preset properties through this method, then pass to server.
|
|
867
|
-
|
|
868
|
-
```
|
|
869
|
-
TDAnalytics.getPresetProperties()
|
|
870
|
-
|
|
871
|
-
/**
|
|
872
|
-
{
|
|
873
|
-
"#os": "HarmonyOS",
|
|
874
|
-
"#os_version": 10,
|
|
875
|
-
"#bundle_id": "com.example.tdharmonyosdemo",
|
|
876
|
-
"#install_time": "2023-10-19 18:46:00.105",
|
|
877
|
-
"#manufacturer": "HUAWEI",
|
|
878
|
-
"#device_model": "NOH-AN00",
|
|
879
|
-
"#device_type": "phone",
|
|
880
|
-
"#screen_width": 1344,
|
|
881
|
-
"#screen_height": 2772,
|
|
882
|
-
"#system_language": "zh-Hans",
|
|
883
|
-
"#carrier": "China Telecom",
|
|
884
|
-
"#app_version": "1.0.1",
|
|
885
|
-
"#device_id": "9811b90b-ee24-45c1-950a-77ee0ffc7a1c",
|
|
886
|
-
"#zone_offset": 8
|
|
887
|
-
}
|
|
888
|
-
*/
|
|
889
|
-
```
|
|
890
|
-
|
|
891
|
-
### 3. Disable Preset Properties
|
|
892
|
-
|
|
893
|
-
In some scenarios,for compliance, actual business requirements, and other considerations, you may want to disable collection of certain preset properties. You can configure `disablePresetProperties` parameter during SDK initialization to configure the array of properties that need to be disabled. Example code:
|
|
894
|
-
|
|
895
|
-
```
|
|
896
|
-
let config = new TDConfig()
|
|
897
|
-
config.appId = 'appId'
|
|
898
|
-
config.serverUrl = 'url'
|
|
899
|
-
config.disablePresetProperties =["#lib", "#lib_version", "#os", "#os_version", "#bundle_id", "#install_time", "#manufacturer", "#device_model",
|
|
900
|
-
"#device_type", "#screen_width", "#screen_height","#system_language","#carrier","#app_version","#device_id","#network_type","#ip"]
|
|
901
|
-
TDAnalytics.initWithConfig(context, config)
|
|
902
|
-
```
|