visual-buried-point-platform-h5 1.3.5 → 2.0.1

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 CHANGED
@@ -2,13 +2,16 @@
2
2
  # 可视化埋点JS SDK接入指南
3
3
 
4
4
  ### SDK更新日志
5
- - 1.2.0 新增页面浏览时长统计功能、优化埋点精度、统计事件绑定用户标识等;
6
- - 1.2.7 新增可自定义事件埋点接口、增加元素名称、访问途径等采集;
7
- - 1.2.8 新增PV/UV统计、元数据配置,访问链路追踪等;
8
- - 1.3.2 新的数据结构和修改PV/UV流量上报方式;
9
- - 1.3.3 自定义埋点数据结构增加page对象和事件标识符eventCode;
10
- - 1.3.4 调整SDK上报接口入参、删除appkey参数配置;
11
- - 1.3.5 上报数据结构增加url;
5
+ - v1.2.0 新增页面浏览时长统计功能、优化埋点精度、统计事件绑定用户标识等;
6
+ - v1.2.7 新增可自定义事件埋点接口、增加元素名称、访问途径等采集;
7
+ - v1.2.8 新增PV/UV统计、元数据配置,访问链路追踪等;
8
+ - v1.3.2 新的数据结构和修改PV/UV流量上报方式;
9
+ - v1.3.3 自定义埋点数据结构增加page对象和事件标识符eventCode;
10
+ - v1.3.4 调整SDK上报接口入参、删除appkey参数配置;
11
+ - v1.3.5 上报数据结构增加url;
12
+ - v1.3.6 调整上报数据结构circulation和duration计算规则;
13
+ - v2.0.0 调整SDK内部PVUV采集模式,分原有start方法采集及自动采集,支持获取埋点sdk内的跟踪ID;【详见1,3,4,7,10】
14
+
12
15
 
13
16
  ### 1.基本原理
14
17
 
@@ -40,112 +43,59 @@ Web SDK 的原理,主要是通过原生 JavaScript 代码,去监控页面的
40
43
 
41
44
  <!-- // TODO:lodash -->
42
45
 
43
- ## 用法
46
+ ## 1.用法
44
47
 
45
- token在可视化埋点后台申请
48
+ ### 一、 npm | yarn、并添加配置文件 buried-point.ts ,或者直接导入 buried-point-h5.js 包
46
49
 
47
- ### 方法一 npm | yarn、并添加配置文件 buried-point.ts
48
50
  ```javascript
49
- npm i visual-buried-point-platform-h5 -S --registry=http://verdaccio.gogdev.cn/
50
-
51
51
  yarn add visual-buried-point-platform-h5 --registry=http://verdaccio.gogdev.cn/
52
- ```
53
52
 
54
- ### 方法二 、导入 buried-point-h5.js 包,并添加配置文件 buried-point.ts【推荐】
55
- ```js
56
- import * as BuriedPointH5 from 'visual-buried-point-platform-h5';
57
- ts declare module 'visual-buried-point-platform-h5';
58
-
59
- export const buriedPoint = new BuriedPointH5({
60
- //配置
61
- token: 'xxx',
62
- environment: 'test',
63
- reportUrl: ''
64
- ...
65
- ...
66
- })
67
-
68
- // uniapp兼容写法
69
- import * as BuriedPointH5 from 'visual-buried-point-platform-h5';
70
- const BP = BuriedPointH5.default || BuriedPointH5
71
- export const buriedPoint = new BP({
72
- //配置
73
- token: 'xxx',
74
- environment: 'test',
75
- reportUrl: ''
76
- ...
77
- ...
78
- })
53
+ npm i visual-buried-point-platform-h5 -S --registry=http://verdaccio.gogdev.cn/
79
54
  ```
80
55
 
81
- ## 添加buried-point.ts配置文件
56
+ ### 二 、添加buried-point.ts配置文件
82
57
 
83
58
  - 注:t_name、token、t_version 对应修改
84
59
 
85
- ```js
86
- // import * as BuriedPointH5 from 'visual-buried-point-platform-h5';
87
- // eslint-disable-next-line @typescript-eslint/no-var-requires
88
- const BuriedPointH5 = require("./buried-point-h5.js");
89
- export const BuriedPoint = new BuriedPointH5({
90
- /** 上报地址(可选) */
91
- reportUrl: 'http://localhost:8000',
60
+ ```javascript
61
+ // eslint-disable-next-line
62
+ // const BuriedPointH5 = require("./buried-point-h5.js");
63
+ import BuriedPointH5 from "visual-buried-point-platform-h5";
64
+ export const buriedPoint = new BuriedPointH5({
92
65
  /** 上报参数。需填入管理端生成的token 与 ·enableJavaScriptBridge·字段互斥 */
93
66
  token: '',
94
- /** appkey (可选)*/
95
- appkey: '';
67
+ // 页面载体环境
68
+ ecology: "",
69
+ /** domain */
70
+ domain: "",
96
71
  /** 业务板块 (可选)*/
97
72
  busSegment: '';
98
73
  /** 业务模块 (可选)*/
99
74
  module: '';
100
- // app版本
101
- appVersion: '1.0.0',
102
- // 环境 取值 `dev` `test` `prod`。当开启环境配置参数后上报地址随环境变化 可以不配置上报地址
103
- environment: 'dev',
104
- // 脚本延迟上报时间
105
- outtime: 3000,
75
+ // 环境 取值 `test` `prod`。当开启环境配置参数后上报地址随环境变化 可以不配置上报地址
76
+ environment: 'test',
106
77
  // 开启单页面?
107
78
  enableSPA: true,
108
- // 是否自动上报pv
109
- autoSendPv: true,
110
- // 是否上报页面性能数据
111
- isPage: true,
112
- // 是否上报ajax性能数据
113
- isAjax: true,
114
- // 是否上报页面资源数据
115
- isResource: true,
116
- // 是否上报错误信息
117
- isError: true,
118
- // 是否录屏
119
- isRecord: true,
120
- // 是否上报行为
121
- isBehavior: true,
122
- // 是否开启了CSS HASH值,(默认开启) [针对商品列表情况埋点,建议false]
79
+ // 是否开启了CSS HASH值,(默认开启) [针对有商品列表多的情况,建议false]
123
80
  isOpenCSSHash: true,
124
81
  // 业务线流量上报的应用 name
125
82
  t_name: '购物',
126
83
  // 业务线流量上报的当前应用 version
127
84
  t_version: 'v1.0.0',
128
- ignore: {
129
- ignoreErrors: [],
130
- ignoreUrls: [],
131
- ignoreApis: ['/api/v1/report/web', 'livereload.js?snipver=1', '/sockjs-node/info'],
132
- },
133
- behavior: {
134
- console: ['log', 'error'], // 取值可以是"debug", "info", "warn", "log", "error"
135
- click: true,
136
- },
137
- // 最长上报数据长度
138
- maxLength: 1000,
139
85
  // Web JS SDK 的 H5 页面,在嵌入到 App 后,H5 内的事件可以通过 App 进行发送 默认关闭
140
86
  // 当开启次字段配置 token字段失效 打通APP上报数据依据所在环境判断 必须配置 androidToken与iosToken字段
141
87
  enableJavaScriptBridge: false,
142
88
  // 打通H5与APP通信后,上报数据ID
143
89
  androidToken: null,
144
- iosToken: null
90
+ iosToken: null,
91
+ // 是否兼容已埋点方案,true兼容(业务方需调用start方法采集PV流量),false不兼容(SDK内部自动采集,但前提业务方需要预置参数)
92
+ isCompatible: true
93
+ // 需要单独采集的页面path,设置isCompatible为false使用
94
+ signTrackPathArray: ["/home", "/personal-auth"],
145
95
  });
146
96
  ```
147
97
 
148
- ## 初始化
98
+ ## 2.初始化【可省略】
149
99
 
150
100
  ```javascript
151
101
  // buried-point-h5.js和buried-point.ts放入utils文件夹中
@@ -153,24 +103,57 @@ export const BuriedPoint = new BuriedPointH5({
153
103
  import "./utils/buried-point";
154
104
  ```
155
105
 
156
- ## 3.设置绑定用户ID
106
+ ## 3.设置当前页面自动采集PVUV数据
157
107
 
158
108
  ```js
109
+ //在任意页面
110
+ import { buriedPoint } from '@/utils/buried-point';
111
+ //vue
112
+ onMounted(async () => {
113
+ buriedPoint.setPageExtraObj(
114
+ {
115
+ properties: {test: '123'}, //扩展参数
116
+ busSegment: '8', //业务板块
117
+ module: '4', //业务模块
118
+ }
119
+ )
120
+ })
121
+ //react
122
+ useEffect(() => {
123
+ buriedPoint.setPageExtraObj({
124
+ properties: {test: '123'}, //扩展参数
125
+ busSegment: '8', //业务板块
126
+ module: '4', //业务模块
127
+ })
128
+ }, [])
129
+ ```
130
+
131
+ ## 4.获取埋点SDK内跟踪ID
132
+
133
+ ```js
134
+ import { buriedPoint } from '@/utils/buried-point';
135
+ buriedPoint.getTrackId()
136
+ ```
137
+
138
+ ## 5.设置绑定用户ID
139
+
140
+ ```js
141
+ import { buriedPoint } from '@/utils/buried-point';
159
142
  // 应用登录成功后,调用下面API设置用户ID,后续产生的统计事件将会与该用户关联起来
160
143
  buriedPoint.setUserInfo(xxxx)
161
144
  ```
162
145
 
163
- ## 4.自定义上报
146
+ ## 6.自定义上报
164
147
 
165
- ### 4.1 自定义埋点事件对接可视化埋点平台说明
148
+ ### 6.1 自定义埋点事件对接可视化埋点平台说明
166
149
 
167
- #### 4.1.1 事件名称规范:
150
+ #### 6.1.1 事件名称规范:
168
151
 
169
152
  - 事件名称需按照事件类型_元素名称/页面名称_平台规则填写,例如“浏览_首页_ web”“点击_xxx商品_ web”
170
153
 
171
154
  - 事件名称需唯一
172
155
 
173
- #### 4.1.2 事件类型:
156
+ #### 6.1.2 事件类型:
174
157
 
175
158
  - 事件类型仅能选择可视化埋点提供的事件类型,各个事件类型的触发、上报由各自定义埋点业务平台自行确认,事件类型包括以下四种:
176
159
 
@@ -182,7 +165,7 @@ buriedPoint.setUserInfo(xxxx)
182
165
 
183
166
  - **浏览事件【 browse 】**
184
167
 
185
- #### 4.1.3自定义埋点事件包含事件内容说明:
168
+ #### 6.1.3自定义埋点事件包含事件内容说明:
186
169
 
187
170
  - 事件ID
188
171
 
@@ -194,7 +177,7 @@ buriedPoint.setUserInfo(xxxx)
194
177
 
195
178
  - 扩展参数,参数内容为自定义埋点平台自行定义,该事件需要额外传到可视化平台上的事件内容,以json字符串方式上传;json字符串长度限制为500字符,大于500字符参数可正常上报,做截断展示。
196
179
 
197
- ## 5.设置自定义上报
180
+ ## 7.设置自定义上报
198
181
 
199
182
  ```javascript
200
183
  // 调用自定义上报
@@ -208,25 +191,23 @@ data: json字符串
208
191
  $extend_param: 扩展参数(JSON) [ 非必填字段(建议根据业务需求填上) ]
209
192
  $event_code: 事件标识符 【必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
210
193
  $page: 当前页对象 【非必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
211
- $path: 埋点组件的路径 【必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
212
194
  }
213
195
  // 参考例子:【搜素事件】
214
196
  import { BuriedPoint } from "@/utils/buried-point";
215
197
  const params = {
216
198
  $event_id: "3156566905601572864",
199
+ $event_code: "",
217
200
  $busSegment: 1,
218
201
  $module: 1,
219
202
  $extend_param: {
220
203
  title: "自定义[搜索事件]上报-搜索_首页搜索框",
221
204
  searchContent: "猕猴桃"
222
205
  },
223
- $event_code: "",
224
206
  $page: {
225
207
  domain: "",
226
208
  path: "",
227
209
  title: "",
228
210
  },
229
- $path: "",
230
211
  }
231
212
  buriedPoint.setCustomEvent(params)
232
213
  ```
@@ -241,7 +222,7 @@ busSegment module
241
222
  2.民宿/酒店 1.民宿 2.酒店
242
223
  ```
243
224
 
244
- ## 6、流量上报
225
+ ## 8、流量上报
245
226
 
246
227
  - sdk初始化后,可通过**onStartTrack(params)** 方法注册上报流量,并为上报添加属性值:
247
228
 
@@ -286,7 +267,7 @@ buriedPoint.onStartTrack(params)
286
267
  buriedPoint.onDestroyTrack()
287
268
  ```
288
269
 
289
- ## 6、批量创建事件ID
270
+ ## 9、批量创建事件ID
290
271
 
291
272
  ## main.py
292
273
 
@@ -330,9 +311,9 @@ pip install requests
330
311
 
331
312
  先执行 `batchCreate` 方法将数据推到埋点后台管理系统中,再执行 `batchWrite` 方法,将后台管理中的数据写入到本地文件中
332
313
 
333
- #### 4、执行脚本
314
+ ### 4、执行脚本
334
315
 
335
- ##### 方式一(推荐)
316
+ #### 方式一(推荐)
336
317
 
337
318
  在命令后增加**业务模块文件夹**名称,自动执行该文件夹下的参数文件
338
319
 
@@ -426,11 +407,20 @@ export default connect(({trade}) => {
426
407
 
427
408
  ##### 云测管理端地址
428
409
 
429
- - chameleon.gcongo.com.cn
410
+ - https://chameleon.gcongo.com.cn
430
411
 
431
412
  #### 8、SDK 文档
432
413
 
433
414
  http://verdaccio.gogdev.cn/-/web/detail/visual-buried-point-platform-miniprogram
434
415
 
416
+ ## 10 问题记录
417
+
418
+ 1、在buried-point.ts配置文件中,提示无法找到模块“visual-buried-point-platform-h5”的声明文件。
419
+
420
+ 在src下创建文件shims-vue.d.ts或者typings.d.ts,写入如下:
421
+
422
+ declare module '@/utils/buried-point-h5.js';
423
+ declare module 'visual-buried-point-platform-h5';
424
+
435
425
 
436
426