visual-buried-point-platform-uni 1.0.0-alpha → 1.0.0-alpha.2
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 +160 -57
- package/index.js +18 -20
- package/package.json +2 -2
- package/tools.js +5 -17
package/README.md
CHANGED
|
@@ -1,93 +1,196 @@
|
|
|
1
|
-
|
|
1
|
+
## Uni版自定义埋点SDK集成文档
|
|
2
2
|
|
|
3
|
+
### 1、引入方式
|
|
3
4
|
|
|
5
|
+
```js
|
|
6
|
+
npm install visual-buried-point-platform-uni -S --registry=http://verdaccio.gogdev.cn/
|
|
7
|
+
工具-构建npm
|
|
8
|
+
```
|
|
4
9
|
|
|
5
|
-
|
|
10
|
+
### 2、初始化方式
|
|
11
|
+
|
|
12
|
+
**app.js**
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
//require引入
|
|
16
|
+
import { init } from 'visual-buried-point-platform-uni'
|
|
17
|
+
onLaunch: function() {
|
|
18
|
+
//初始化sdk
|
|
19
|
+
init({
|
|
20
|
+
env: 'test', //环境变量 test production
|
|
21
|
+
token: '3212414516342554624', //热果平台-可视化埋点管理端-创建对应的项目生成.
|
|
22
|
+
sourceDomain: 'com.gzdzswy.onetravel', // 非必填,访问来源域名,取优先级:单次调用上报值 > 全局初始化值
|
|
23
|
+
})
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
```
|
|
6
27
|
|
|
7
|
-
|
|
28
|
+
### 3、设置绑定用户ID
|
|
8
29
|
|
|
9
|
-
|
|
30
|
+
- sdk初始化后,可通过 ***setUserId()*** 方法关联用户,sdk会默认生成一个游客ID
|
|
10
31
|
|
|
11
|
-
|
|
32
|
+
```js
|
|
33
|
+
// 应用在注册或登录成功后,可调用下面API设置用户ID,后续产生的统计事件将会与该用户关联起来
|
|
34
|
+
setUserId("登录成功-用户ID")
|
|
35
|
+
```
|
|
12
36
|
|
|
13
|
-
|
|
14
|
-
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
|
|
37
|
+
**示例:**
|
|
15
38
|
|
|
39
|
+
```js
|
|
40
|
+
import { setUserId } from 'visual-buried-point-platform-uni'
|
|
41
|
+
setUserId(123456);
|
|
16
42
|
```
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
43
|
+
|
|
44
|
+
**注:为保持数据统计精确,在退出登录的时候建议调用一次清空:**
|
|
45
|
+
|
|
46
|
+
```js
|
|
47
|
+
setUserId("");
|
|
21
48
|
```
|
|
22
49
|
|
|
23
|
-
## Integrate with your tools
|
|
24
50
|
|
|
25
|
-
- [ ] [Set up project integrations](http://10.10.11.151:20216/teg/bigdata-center/buried-point/front-end/visual-buried-point-platform-uni/-/settings/integrations)
|
|
26
51
|
|
|
27
|
-
|
|
52
|
+
### 4、自定义事件上报
|
|
28
53
|
|
|
29
|
-
-
|
|
30
|
-
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
|
|
31
|
-
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
|
|
32
|
-
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
|
|
33
|
-
- [ ] [Set auto-merge](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
|
|
54
|
+
- sdk初始化后,可通过 ***setCustomEvent()*** 方法上报自定义埋点事件,并为事件添加属性值:
|
|
34
55
|
|
|
35
|
-
|
|
56
|
+
#### 4.1 事件类型:
|
|
36
57
|
|
|
37
|
-
|
|
58
|
+
- 仅能选择埋点提供的事件类型,各事件类型的触发、上报由各业务平台埋点自行确认。事件类型如下:
|
|
59
|
+
- **搜索事件【 search 】**
|
|
60
|
+
- **动作事件【 action 】**
|
|
61
|
+
- **点击事件【 click 】**
|
|
62
|
+
- **浏览事件【 browse 】**
|
|
38
63
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
|
|
64
|
+
```js
|
|
65
|
+
// 调用自定义上报
|
|
66
|
+
setCustomEvent(data)
|
|
67
|
+
```
|
|
44
68
|
|
|
45
|
-
|
|
69
|
+
**配置:**
|
|
46
70
|
|
|
47
|
-
|
|
71
|
+
| 参数 | 必填 | 描述 |
|
|
72
|
+
| ------------- | ---- | ------------------------------ |
|
|
73
|
+
| $event_id | 是 | 对应创建的事件ID 【图2】 |
|
|
74
|
+
| $extend_param | 否 | 扩展字段,建议根据业务需求填上 |
|
|
75
|
+
| $busSegment | 否 | 业务板块 【表1】各自业务板块 |
|
|
76
|
+
| $module | 否 | 业务模块【表1】各自业务模块 |
|
|
48
77
|
|
|
49
|
-
|
|
78
|
+
表1
|
|
50
79
|
|
|
51
|
-
|
|
80
|
+
```js
|
|
81
|
+
示例如下:
|
|
82
|
+
业务板块 业务模块
|
|
83
|
+
busSegment module
|
|
84
|
+
1.景区/门票 1.门票
|
|
85
|
+
2.民宿/酒店 1.民宿 2.酒店
|
|
86
|
+
```
|
|
52
87
|
|
|
53
|
-
|
|
88
|
+
**示例:**
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
```js
|
|
92
|
+
// 注:
|
|
93
|
+
data: JSON字符串
|
|
94
|
+
{
|
|
95
|
+
$event_id: 对应创建的事件ID 【必填字段】
|
|
96
|
+
$extend_param: 扩展参数(JSON字符串) 【非必填字段,建议根据业务需求填上】
|
|
97
|
+
$busSegment: 业务板块 【非必填字段,建议业务填上, 否则数据统计可能出现缺失】
|
|
98
|
+
$module: 业务模块 【非必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
|
|
99
|
+
$ctk: 渠道推广编码 【非必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
|
|
100
|
+
$duration: 停留时长 【非必填字段】
|
|
101
|
+
$event_code: 事件标识符 【必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
|
|
102
|
+
$page: 当前页对象 【非必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
|
|
103
|
+
$path: 埋点组件的路径 【必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
|
|
104
|
+
}
|
|
105
|
+
// 参考:【点击事件】
|
|
106
|
+
const params = {
|
|
107
|
+
$event_id: "3213106620739878912",
|
|
108
|
+
$busSegment: 1,
|
|
109
|
+
$module: 1,
|
|
110
|
+
$ctk: "",
|
|
111
|
+
$extend_param: {
|
|
112
|
+
title: "自定义[点击事件]上报-点击_密码登录按钮",
|
|
113
|
+
clickContent: "密码登录",
|
|
114
|
+
....
|
|
115
|
+
....
|
|
116
|
+
},
|
|
117
|
+
$event_code: "",
|
|
118
|
+
$page: {
|
|
119
|
+
domain: "",
|
|
120
|
+
path: "",
|
|
121
|
+
title: "",
|
|
122
|
+
},
|
|
123
|
+
$path: "",
|
|
124
|
+
}
|
|
125
|
+
setCustomEvent(params)
|
|
126
|
+
```
|
|
54
127
|
|
|
55
|
-
|
|
56
|
-
|
|
128
|
+
### 5、流量上报
|
|
129
|
+
|
|
130
|
+
- sdk初始化后,可通过**onStartTrack(params)** 方法注册上报流量,并为上报添加属性值:
|
|
131
|
+
|
|
132
|
+
**注册上报流量:onStartTrack(params)**
|
|
133
|
+
|
|
134
|
+
**配置:**【以下配置参数建议上报】
|
|
135
|
+
|
|
136
|
+
| 参数 | 必填 | 类型 | 描述 |
|
|
137
|
+
| ------------ | ---- | ------------------- | ---------------- |
|
|
138
|
+
| domain | 是 | string | 域名 |
|
|
139
|
+
| path | 是 | string | 路径 |
|
|
140
|
+
| circulation | 否 | number | 页面访问类型 |
|
|
141
|
+
| ctk | 否 | string | 渠道推广编码 |
|
|
142
|
+
| duration | 否 | number | 停留时长 |
|
|
143
|
+
| busSegment | 否 | string | 业务板块 【表1】 |
|
|
144
|
+
| module | 否 | string | 业务模块 【表1】 |
|
|
145
|
+
| extend_param | 否 | JSON对象 {} | 扩展参数 |
|
|
146
|
+
| sourceDomain | 否 | string | 访问来源域名 |
|
|
147
|
+
| sourceUrl | 否 | string | 访问来源url |
|
|
148
|
+
| title | 否 | string | 页面名称 |
|
|
149
|
+
| traceId | 否 | string | 追踪id |
|
|
150
|
+
| visitPage | 否 | number | 访问深度 |
|
|
151
|
+
| visitTime | 否 | yyyy-MM-dd HH:mm:ss | 访问时间 |
|
|
152
|
+
|
|
153
|
+
**示例:**
|
|
154
|
+
|
|
155
|
+
```js
|
|
156
|
+
// 注:
|
|
157
|
+
data: JSON对象
|
|
158
|
+
const params = {
|
|
159
|
+
domain: "xxxx",
|
|
160
|
+
busSegment: 1,
|
|
161
|
+
module: 1,
|
|
162
|
+
title: "店铺详情",
|
|
163
|
+
sourceDomain: 'com.gzdzswy.onetravel',
|
|
164
|
+
extend_param: {
|
|
165
|
+
goods_id: 123456, //商品id 【根据业务确定】
|
|
166
|
+
store_id: 1111, //店铺id 【...】
|
|
167
|
+
business_id: 222, //商户id 【...】
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
onStartTrack(params)
|
|
171
|
+
```
|
|
57
172
|
|
|
58
|
-
|
|
59
|
-
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
|
173
|
+
**销毁上报流量:调用onDestroyTrack()进行销毁**
|
|
60
174
|
|
|
61
|
-
|
|
62
|
-
|
|
175
|
+
**示例:**
|
|
176
|
+
|
|
177
|
+
```js
|
|
178
|
+
onDestroyTrack()
|
|
179
|
+
```
|
|
63
180
|
|
|
64
|
-
|
|
65
|
-
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
|
181
|
+
注: 上报数据是否成功可查看NetWork栏,调用流量上报 **track 接口** 和 自定义上报 **event 接口**的 response
|
|
66
182
|
|
|
67
|
-
|
|
68
|
-
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
|
183
|
+
#### 6、埋点后台管理系统
|
|
69
184
|
|
|
70
|
-
|
|
71
|
-
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
|
185
|
+
##### 云测管理端地址
|
|
72
186
|
|
|
73
|
-
|
|
74
|
-
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
|
187
|
+
- chameleon.gcongo.com.cn
|
|
75
188
|
|
|
76
|
-
|
|
77
|
-
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
|
189
|
+
#### 7、SDK 文档
|
|
78
190
|
|
|
79
|
-
|
|
80
|
-
State if you are open to contributions and what your requirements are for accepting them.
|
|
191
|
+
http://verdaccio.gogdev.cn/-/web/detail/visual-buried-point-platform-uni
|
|
81
192
|
|
|
82
|
-
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
|
83
193
|
|
|
84
|
-
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
|
85
194
|
|
|
86
|
-
## Authors and acknowledgment
|
|
87
|
-
Show your appreciation to those who have contributed to the project.
|
|
88
195
|
|
|
89
|
-
## License
|
|
90
|
-
For open source projects, say how it is licensed.
|
|
91
196
|
|
|
92
|
-
## Project status
|
|
93
|
-
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
package/index.js
CHANGED
|
@@ -43,7 +43,6 @@ export function init(config) {
|
|
|
43
43
|
let _cf = setReportUrl(config.env ? config.env : "");
|
|
44
44
|
reportUrl = _cf.reportUrl;
|
|
45
45
|
reportTrackUrl = _cf.reportTrackUrl;
|
|
46
|
-
eventListUrl = _cf.eventListUrl;
|
|
47
46
|
if (config.flushInterval) {
|
|
48
47
|
if (config.flushInterval < 5) {
|
|
49
48
|
config.flushInterval = 15;
|
|
@@ -75,14 +74,14 @@ export function init(config) {
|
|
|
75
74
|
startGlobalTime();
|
|
76
75
|
}
|
|
77
76
|
|
|
78
|
-
//the general custom
|
|
77
|
+
//the general custom reportCustom interval is enabled
|
|
79
78
|
function startGlobalTime() {
|
|
80
79
|
clearInterval(cInterval);
|
|
81
80
|
cInterval = setInterval(() => {
|
|
82
81
|
let cData = getSData();
|
|
83
|
-
console.log("storage data " + cData);
|
|
82
|
+
console.log("storage data " + JSON.stringify(cData));
|
|
84
83
|
if (cData) {
|
|
85
|
-
|
|
84
|
+
reportCustom(cData);
|
|
86
85
|
delSData();
|
|
87
86
|
}
|
|
88
87
|
}, _config.flushInterval * 1000);
|
|
@@ -130,13 +129,14 @@ export function setCustomEvent(data) {
|
|
|
130
129
|
addCache(reportData);
|
|
131
130
|
const data = getCache();
|
|
132
131
|
if (data.length) {
|
|
132
|
+
console.log("customData: ", JSON.stringify(data));
|
|
133
133
|
addSData(data);
|
|
134
134
|
clearCache();
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
function
|
|
139
|
+
function reportCustom(data) {
|
|
140
140
|
if (!reportUrl) {
|
|
141
141
|
//console.error("please set upload data url");
|
|
142
142
|
return;
|
|
@@ -146,21 +146,19 @@ function report(data) {
|
|
|
146
146
|
...comData,
|
|
147
147
|
dataAbstract: MD5(JSON.stringify(comData)),
|
|
148
148
|
};
|
|
149
|
-
uni.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
},
|
|
163
|
-
});
|
|
149
|
+
uni.request({
|
|
150
|
+
url: reportUrl,
|
|
151
|
+
method: "POST",
|
|
152
|
+
header: {
|
|
153
|
+
"Content-Type": "application/json",
|
|
154
|
+
appKey: _config.token,
|
|
155
|
+
projectId: _config.token,
|
|
156
|
+
},
|
|
157
|
+
data: reportData,
|
|
158
|
+
success: function (res) {},
|
|
159
|
+
fail: function (error) {
|
|
160
|
+
console.error(error);
|
|
161
|
+
},
|
|
164
162
|
});
|
|
165
163
|
}
|
|
166
164
|
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visual-buried-point-platform-uni",
|
|
3
|
-
"version": "1.0.0-alpha",
|
|
4
|
-
"lsi": "
|
|
3
|
+
"version": "1.0.0-alpha.02",
|
|
4
|
+
"lsi": "f0ca171a9f641657370a83f2f7ed65c7",
|
|
5
5
|
"description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"scripts": {
|
package/tools.js
CHANGED
|
@@ -168,9 +168,9 @@ export function getTrackObj(busObj) {
|
|
|
168
168
|
const pages = getCurrentPages();
|
|
169
169
|
const gcp = pages[pages.length - 1];
|
|
170
170
|
//h5
|
|
171
|
-
let wl = window.location;
|
|
172
|
-
let docTitle = document.title;
|
|
173
|
-
let refurl = document.referrer;
|
|
171
|
+
// let wl = window.location;
|
|
172
|
+
// let docTitle = document.title;
|
|
173
|
+
// let refurl = document.referrer;
|
|
174
174
|
let parsedUrl;
|
|
175
175
|
if (refurl) {
|
|
176
176
|
parsedUrl = new URL(refurl);
|
|
@@ -183,22 +183,10 @@ export function getTrackObj(busObj) {
|
|
|
183
183
|
}
|
|
184
184
|
}
|
|
185
185
|
if (gcp) {
|
|
186
|
-
let domain = "";
|
|
187
|
-
let url = "";
|
|
188
|
-
if (busObj.domain) {
|
|
189
|
-
domain = busObj.domain;
|
|
190
|
-
} else {
|
|
191
|
-
domain = wl.hostname ? wl.hostname : "";
|
|
192
|
-
}
|
|
193
|
-
if (busObj.url) {
|
|
194
|
-
url = busObj.url;
|
|
195
|
-
} else {
|
|
196
|
-
url = wl.href ? wl.href : "";
|
|
197
|
-
}
|
|
198
186
|
return {
|
|
199
187
|
path: gcp.route,
|
|
200
|
-
domain: domain,
|
|
201
|
-
url: url,
|
|
188
|
+
domain: busObj.domain ? busObj.domain : "",
|
|
189
|
+
url: busObj.url ? busObj.url : "",
|
|
202
190
|
circulation: gcp.length > 1 ? 2 : 1,
|
|
203
191
|
visitPage: gcp.length,
|
|
204
192
|
sourceDomain: parsedUrl ? parsedUrl.hostname : "",
|