visual-buried-point-platform-uni 1.0.0-alpha.18 → 1.0.0-alpha.19
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/autoutils.js +177 -0
- package/bpstorage.js +29 -0
- package/cache.js +28 -0
- package/config.js +25 -0
- package/eventutils.js +90 -0
- package/index.js +6 -7
- package/lsi-md5.js +22 -0
- package/manualutils.js +87 -0
- package/package.json +4 -6
- package/pageListener.js +71 -0
- package/tools.js +308 -0
- package/webpack.config.js +17 -0
- package/dist/buried-point-uni.js +0 -2
- package/dist/buried-point-uni.js.LICENSE.txt +0 -6
package/autoutils.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { reportTrackEventServer } from "./index.js";
|
|
2
|
+
import {
|
|
3
|
+
sdkTrackIdVal,
|
|
4
|
+
Global,
|
|
5
|
+
pagesArray,
|
|
6
|
+
timeToStr,
|
|
7
|
+
randomUUID,
|
|
8
|
+
} from "./tools.js";
|
|
9
|
+
|
|
10
|
+
export const AUTOTRACKTYPE = {
|
|
11
|
+
ENTER: "enter",
|
|
12
|
+
LOOP: "loop",
|
|
13
|
+
LEAVE: "leave",
|
|
14
|
+
};
|
|
15
|
+
// PVUV存储的key值
|
|
16
|
+
const BPNPVUV = "UNIBPNPVUVSrcData";
|
|
17
|
+
const BPNPVUVFail = "UNIBPNPVUVFailData";
|
|
18
|
+
// 采集数据
|
|
19
|
+
let atDuration;
|
|
20
|
+
let atEnterTimeLong;
|
|
21
|
+
let atLoopTimeLong;
|
|
22
|
+
let cirtemp;
|
|
23
|
+
let atObj;
|
|
24
|
+
let atInterval = null;
|
|
25
|
+
let cUUId = null;
|
|
26
|
+
|
|
27
|
+
function clearUAData() {
|
|
28
|
+
clearInterval(atInterval);
|
|
29
|
+
atDuration = 0;
|
|
30
|
+
atEnterTimeLong = 0;
|
|
31
|
+
atLoopTimeLong = 0;
|
|
32
|
+
cirtemp = 1;
|
|
33
|
+
atObj = null;
|
|
34
|
+
atInterval = null;
|
|
35
|
+
cUUId = 0;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const uAutoStartTrackPVData = (objParams) => {
|
|
39
|
+
if (atInterval) {
|
|
40
|
+
autoStopTrackPVUV();
|
|
41
|
+
} else {
|
|
42
|
+
clearUAData();
|
|
43
|
+
atObj = objParams;
|
|
44
|
+
autoTrackData(AUTOTRACKTYPE.ENTER);
|
|
45
|
+
atInterval = setInterval(() => {
|
|
46
|
+
autoTrackData(AUTOTRACKTYPE.LOOP);
|
|
47
|
+
}, 15000);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const autoStopTrackPVUV = () => {
|
|
52
|
+
autoTrackData(AUTOTRACKTYPE.LEAVE);
|
|
53
|
+
clearInterval(atInterval);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
function autoTrackData(type) {
|
|
57
|
+
if (type === AUTOTRACKTYPE.ENTER) {
|
|
58
|
+
cirtemp = 1;
|
|
59
|
+
atDuration = 0;
|
|
60
|
+
atEnterTimeLong = Date.now();
|
|
61
|
+
atLoopTimeLong = atEnterTimeLong;
|
|
62
|
+
cUUId = randomUUID();
|
|
63
|
+
} else if (type === AUTOTRACKTYPE.LOOP) {
|
|
64
|
+
cirtemp = 2;
|
|
65
|
+
atDuration = 15;
|
|
66
|
+
atLoopTimeLong = Date.now();
|
|
67
|
+
} else if (type === AUTOTRACKTYPE.LEAVE) {
|
|
68
|
+
cirtemp = 3;
|
|
69
|
+
atDuration = Math.ceil((Date.now() - atLoopTimeLong) / 1000);
|
|
70
|
+
}
|
|
71
|
+
if (atObj) {
|
|
72
|
+
const puvData = {
|
|
73
|
+
busSegment: atObj.busSegment || "",
|
|
74
|
+
circulation: cirtemp,
|
|
75
|
+
domain: atObj.domain,
|
|
76
|
+
duration: atDuration,
|
|
77
|
+
module: atObj.module || "",
|
|
78
|
+
path: atObj.path,
|
|
79
|
+
url: atObj.url,
|
|
80
|
+
sourceDomain: atObj.sourceDomain,
|
|
81
|
+
sourceUrl: atObj.sourceUrl,
|
|
82
|
+
properties: atObj.properties,
|
|
83
|
+
title: atObj.title,
|
|
84
|
+
traceId: "",
|
|
85
|
+
trackId: sdkTrackIdVal(),
|
|
86
|
+
visitPage: atObj.visitPage,
|
|
87
|
+
visitTime: timeToStr(atEnterTimeLong),
|
|
88
|
+
pageUUId: cUUId,
|
|
89
|
+
};
|
|
90
|
+
if (puvData) {
|
|
91
|
+
insertPVUVData(puvData, cUUId);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// 插入数据
|
|
97
|
+
export function insertPVUVData(pData, pUUId) {
|
|
98
|
+
let td = uni.getStorageSync(BPNPVUV);
|
|
99
|
+
let mPVData = td ? JSON.parse(td) : [];
|
|
100
|
+
if (mPVData.length > 0) {
|
|
101
|
+
const index = mPVData.findIndex((obj) => obj.pageUUId === pUUId);
|
|
102
|
+
if (index !== -1) {
|
|
103
|
+
mPVData[index] = { ...mPVData[index], ...pData };
|
|
104
|
+
} else {
|
|
105
|
+
mPVData.push(pData);
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
mPVData.push(pData);
|
|
109
|
+
}
|
|
110
|
+
uni.setStorageSync(BPNPVUV, JSON.stringify(mPVData));
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// 自动采集对象
|
|
114
|
+
export function autoPageObj(cpath, clength, cpages) {
|
|
115
|
+
let _pObj = pagesArray.find((obj) => obj.path === cpath);
|
|
116
|
+
let pf = Global.platform;
|
|
117
|
+
let url = "";
|
|
118
|
+
let domain = "";
|
|
119
|
+
let srcUrl = "";
|
|
120
|
+
let srcDomain = "";
|
|
121
|
+
if (pf) {
|
|
122
|
+
if (pf === "web" || pf === "h5") {
|
|
123
|
+
url = window.location.href;
|
|
124
|
+
domain = window.location.hostname;
|
|
125
|
+
if (document.referrer) {
|
|
126
|
+
let parsedUrl = new URL(document.referrer);
|
|
127
|
+
srcUrl = parsedUrl || "";
|
|
128
|
+
srcDomain = parsedUrl.hostname || "";
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
url = cpath;
|
|
132
|
+
if (clength > 1) {
|
|
133
|
+
let beforePage = cpages[clength - 2];
|
|
134
|
+
srcUrl = beforePage.route;
|
|
135
|
+
}
|
|
136
|
+
domain = Global.domain ? Global.domain : cpath;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
return {
|
|
140
|
+
path: _pObj && _pObj.path ? _pObj.path : cpath,
|
|
141
|
+
busSegment:
|
|
142
|
+
_pObj && _pObj.busSegment ? _pObj.busSegment : Global.busSegment || "",
|
|
143
|
+
module: _pObj && _pObj.module ? _pObj.module : Global.module || "",
|
|
144
|
+
properties: _pObj && _pObj.properties ? _pObj.properties : "",
|
|
145
|
+
domain: domain,
|
|
146
|
+
url: url,
|
|
147
|
+
visitPage: clength,
|
|
148
|
+
sourceDomain: srcDomain,
|
|
149
|
+
sourceUrl: srcUrl,
|
|
150
|
+
title: _pObj && _pObj.title ? _pObj.title : "",
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* 查询数据
|
|
156
|
+
* 0 未上报 2上报失败
|
|
157
|
+
*/
|
|
158
|
+
export function queryTrackDataUpload() {
|
|
159
|
+
let td = uni.getStorageSync(BPNPVUV);
|
|
160
|
+
uni.setStorageSync(BPNPVUV, "");
|
|
161
|
+
const arr = td ? JSON.parse(td) : [];
|
|
162
|
+
let uploadArray = [];
|
|
163
|
+
let ftd = uni.getStorageSync(BPNPVUVFail);
|
|
164
|
+
const failArr = ftd ? JSON.parse(ftd) : [];
|
|
165
|
+
if (arr.length) {
|
|
166
|
+
uploadArray.push(...arr);
|
|
167
|
+
}
|
|
168
|
+
if (failArr.length) {
|
|
169
|
+
uploadArray.push(...failArr);
|
|
170
|
+
}
|
|
171
|
+
if (uploadArray && uploadArray.length) {
|
|
172
|
+
uploadArray.forEach((item) => {
|
|
173
|
+
delete item.pageUUId;
|
|
174
|
+
});
|
|
175
|
+
reportTrackEventServer("track", uploadArray, BPNPVUVFail);
|
|
176
|
+
}
|
|
177
|
+
}
|
package/bpstorage.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
const storgkeyName = "buriedPointKey";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 新增数据
|
|
5
|
+
*/
|
|
6
|
+
export function addSData(data) {
|
|
7
|
+
if (data) {
|
|
8
|
+
uni.setStorageSync(storgkeyName, JSON.stringify(data));
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 读取数据
|
|
14
|
+
*/
|
|
15
|
+
export function getSData() {
|
|
16
|
+
let allData = uni.getStorageSync(storgkeyName);
|
|
17
|
+
if (allData) {
|
|
18
|
+
return JSON.parse(allData);
|
|
19
|
+
} else {
|
|
20
|
+
return "";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 删除数据
|
|
26
|
+
*/
|
|
27
|
+
export function delSData() {
|
|
28
|
+
uni.setStorageSync(storgkeyName, "");
|
|
29
|
+
}
|
package/cache.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
const deepCopy = (target) => {
|
|
2
|
+
if (typeof target === "object") {
|
|
3
|
+
const result = Array.isArray(target) ? [] : {};
|
|
4
|
+
for (const key in target) {
|
|
5
|
+
if (typeof target[key] == "object") {
|
|
6
|
+
result[key] = deepCopy(target[key]);
|
|
7
|
+
} else {
|
|
8
|
+
result[key] = target[key];
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
return result;
|
|
12
|
+
}
|
|
13
|
+
return target;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
const cacheData = [];
|
|
17
|
+
|
|
18
|
+
export const addCache = (data) => {
|
|
19
|
+
cacheData.push(data);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const getCache = () => {
|
|
23
|
+
return deepCopy(cacheData);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const clearCache = () => {
|
|
27
|
+
cacheData.length = 0;
|
|
28
|
+
};
|
package/config.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export function setReportUrl(env) {
|
|
2
|
+
switch (env) {
|
|
3
|
+
case "test":
|
|
4
|
+
return {
|
|
5
|
+
reportUrl: "https://buryingpoint.gcongo.com.cn/client/api/event",
|
|
6
|
+
reportTrackUrl: "https://buryingpoint.gcongo.com.cn/client/api/track",
|
|
7
|
+
eventListUrl:
|
|
8
|
+
"https://buryingpoint.gcongo.com.cn/api/event/query/eventList",
|
|
9
|
+
};
|
|
10
|
+
case "production":
|
|
11
|
+
return {
|
|
12
|
+
reportUrl: "https://buryingpoint.onebuygz.com/client/api/event",
|
|
13
|
+
reportTrackUrl: "https://buryingpoint.onebuygz.com/client/api/track",
|
|
14
|
+
eventListUrl:
|
|
15
|
+
"https://buryingpoint.onebuygz.com/api/event/query/eventList",
|
|
16
|
+
};
|
|
17
|
+
default:
|
|
18
|
+
return {
|
|
19
|
+
reportUrl: "https://buryingpoint.onebuygz.com/client/api/event",
|
|
20
|
+
reportTrackUrl: "https://buryingpoint.onebuygz.com/client/api/track",
|
|
21
|
+
eventListUrl:
|
|
22
|
+
"https://buryingpoint.onebuygz.com/api/event/query/eventList",
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
package/eventutils.js
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import MD5 from "md5";
|
|
2
|
+
import { addCache, clearCache, getCache } from "./cache.js";
|
|
3
|
+
import { reportTrackEventServer } from "./index.js";
|
|
4
|
+
import { getUtmObj, sdkTrackIdVal, timeToStr } from "./tools.js";
|
|
5
|
+
|
|
6
|
+
//Event存储的key值
|
|
7
|
+
const BPNEvent = "UNIBPNEventSrcData";
|
|
8
|
+
const BPNEventFail = "UNIBPNEventFailData";
|
|
9
|
+
let timerCustom;
|
|
10
|
+
|
|
11
|
+
function getCurPath() {
|
|
12
|
+
const pages = getCurrentPages();
|
|
13
|
+
const gcp = pages[pages.length - 1];
|
|
14
|
+
return gcp ? gcp.route : "/";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// 自定义部分 type=>custom event=>到四种具体事件类型 extend_param 扩展字段
|
|
18
|
+
export function eventCommonStore(data) {
|
|
19
|
+
if (!data) return;
|
|
20
|
+
const _page = data.$page ? data.$page : "";
|
|
21
|
+
const _path = _page.path ? _page.path : getCurPath();
|
|
22
|
+
let reportEventData = {
|
|
23
|
+
utm: data.$utm ? data.$utm : getUtmObj(),
|
|
24
|
+
duration: "",
|
|
25
|
+
element: data.$element ? data.$element : null,
|
|
26
|
+
eventId: data.$event_id ? data.$event_id : "",
|
|
27
|
+
event: data.$event_code ? data.$event_code : "",
|
|
28
|
+
groupId: "",
|
|
29
|
+
busSegment: data.$busSegment ? data.$busSegment : "",
|
|
30
|
+
module: data.$module ? data.$module : "",
|
|
31
|
+
page: {
|
|
32
|
+
domain: _page.domain ? _page.domain : "",
|
|
33
|
+
pageId: MD5(_path),
|
|
34
|
+
path: _path || "",
|
|
35
|
+
title: _page.title || "",
|
|
36
|
+
url: _path || "",
|
|
37
|
+
},
|
|
38
|
+
properties: data.$extend_param ? JSON.stringify(data.$extend_param) : "",
|
|
39
|
+
traceId: "",
|
|
40
|
+
trackId: sdkTrackIdVal(),
|
|
41
|
+
triggerTime: timeToStr(Date.now()),
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
if (reportEventData) {
|
|
45
|
+
addCache(reportEventData);
|
|
46
|
+
clearTimeout(timerCustom);
|
|
47
|
+
timerCustom = setTimeout(() => {
|
|
48
|
+
const data = getCache();
|
|
49
|
+
if (data.length) {
|
|
50
|
+
insertEventData(data);
|
|
51
|
+
clearCache();
|
|
52
|
+
}
|
|
53
|
+
}, 2000);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* 插入Event数据合并
|
|
59
|
+
*/
|
|
60
|
+
export function insertEventData(cData) {
|
|
61
|
+
const cd = uni.getStorageSync(BPNEvent);
|
|
62
|
+
let allEventData = cd ? JSON.parse(cd) : [];
|
|
63
|
+
if (cData && cData.length) {
|
|
64
|
+
// concat方法
|
|
65
|
+
allEventData.concat(cData);
|
|
66
|
+
uni.setStorageSync(BPNEvent, JSON.stringify(allEventData));
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* 查询自定义数据
|
|
72
|
+
* 0 未上报/上报失败
|
|
73
|
+
*/
|
|
74
|
+
export function queryEventDataUpload() {
|
|
75
|
+
let cd = uni.getStorageSync(BPNEvent);
|
|
76
|
+
uni.setStorageSync(BPNEvent, "");
|
|
77
|
+
const arr = cd ? JSON.parse(cd) : [];
|
|
78
|
+
let uploadArray = [];
|
|
79
|
+
let fcd = uni.getStorageSync(BPNEventFail);
|
|
80
|
+
const failArr = fcd ? JSON.parse(fcd) : [];
|
|
81
|
+
if (arr.length) {
|
|
82
|
+
uploadArray.push(...arr);
|
|
83
|
+
}
|
|
84
|
+
if (failArr.length) {
|
|
85
|
+
uploadArray.push(...failArr);
|
|
86
|
+
}
|
|
87
|
+
if (uploadArray && uploadArray.length) {
|
|
88
|
+
reportTrackEventServer("event", uploadArray, BPNEventFail);
|
|
89
|
+
}
|
|
90
|
+
}
|
package/index.js
CHANGED
|
@@ -42,10 +42,9 @@ export function init(config) {
|
|
|
42
42
|
} else {
|
|
43
43
|
console.log("init config error, please check config!");
|
|
44
44
|
}
|
|
45
|
-
|
|
46
|
-
// 开启全局定时器
|
|
45
|
+
// Enabling a global timer
|
|
47
46
|
startGlobalTime();
|
|
48
|
-
//
|
|
47
|
+
// Monitor page loading and unloading
|
|
49
48
|
uniInterceptorListener();
|
|
50
49
|
}
|
|
51
50
|
|
|
@@ -69,7 +68,7 @@ export function setUserId(userId) {
|
|
|
69
68
|
}
|
|
70
69
|
}
|
|
71
70
|
|
|
72
|
-
|
|
71
|
+
// get trackId
|
|
73
72
|
export function getTrackId() {
|
|
74
73
|
return sdkTrackIdVal();
|
|
75
74
|
}
|
|
@@ -89,12 +88,12 @@ export function onDestroyTrack() {
|
|
|
89
88
|
uStopTrackPVData();
|
|
90
89
|
}
|
|
91
90
|
|
|
92
|
-
// auto track
|
|
91
|
+
// auto track Preset attribute
|
|
93
92
|
export function setPageExtraObj(tData) {
|
|
94
93
|
uUpdatePageExtraArray(tData);
|
|
95
94
|
}
|
|
96
95
|
|
|
97
|
-
//
|
|
96
|
+
// data upload
|
|
98
97
|
export function reportTrackEventServer(upType, data, sFailKey) {
|
|
99
98
|
if (!upType) {
|
|
100
99
|
console.error("please set upload data upType");
|
|
@@ -142,7 +141,7 @@ function commonData(allData) {
|
|
|
142
141
|
};
|
|
143
142
|
}
|
|
144
143
|
|
|
145
|
-
|
|
144
|
+
// get baseInfo
|
|
146
145
|
function getBaseicInfo() {
|
|
147
146
|
uni.getSystemInfo({
|
|
148
147
|
success: function (res) {
|
package/lsi-md5.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// 此js在npm build,根据name + version + md5后会自动修改package.json中的lsi
|
|
2
|
+
// 注:发给后端,作为标识依据和上报字段lsi值
|
|
3
|
+
import fs from "fs";
|
|
4
|
+
import MD5 from "md5";
|
|
5
|
+
// const fs = require("fs");
|
|
6
|
+
// const MD5 = require("md5");
|
|
7
|
+
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf-8"));
|
|
8
|
+
|
|
9
|
+
const { name, version } = packageJson;
|
|
10
|
+
// MD5
|
|
11
|
+
const combinedString = name + "-" + version;
|
|
12
|
+
const md5Str = MD5(combinedString);
|
|
13
|
+
packageJson.lsi = md5Str + "#" + version;
|
|
14
|
+
//base64
|
|
15
|
+
// const combinedString = name.substring(0, 16) + "v" + version;
|
|
16
|
+
// const base64Str = btoa(combinedString);
|
|
17
|
+
// packageJson.lsi = base64Str;
|
|
18
|
+
|
|
19
|
+
const updatedPackageJson = JSON.stringify(packageJson, null, 2);
|
|
20
|
+
fs.writeFileSync("./package.json", updatedPackageJson, "utf8");
|
|
21
|
+
|
|
22
|
+
console.log('write package.json "lsi" value success ');
|
package/manualutils.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { AUTOTRACKTYPE, insertPVUVData } from "./autoutils.js";
|
|
2
|
+
import {
|
|
3
|
+
getTrackObj,
|
|
4
|
+
getUtmObj,
|
|
5
|
+
randomUUID,
|
|
6
|
+
sdkTrackIdVal,
|
|
7
|
+
timeToStr,
|
|
8
|
+
} from "./tools.js";
|
|
9
|
+
|
|
10
|
+
// 流量上报采集
|
|
11
|
+
let startTime = 0;
|
|
12
|
+
let enterTimeLong = 0;
|
|
13
|
+
let loopTimeLong = 0;
|
|
14
|
+
let cirtemp = -1;
|
|
15
|
+
let mObj = null;
|
|
16
|
+
let umlInterval = null;
|
|
17
|
+
let cUUId = 0;
|
|
18
|
+
|
|
19
|
+
function clearUMlData() {
|
|
20
|
+
clearInterval(umlInterval);
|
|
21
|
+
startTime = 0;
|
|
22
|
+
enterTimeLong = 0;
|
|
23
|
+
loopTimeLong = 0;
|
|
24
|
+
cirtemp = 1;
|
|
25
|
+
mObj = null;
|
|
26
|
+
umlInterval = null;
|
|
27
|
+
cUUId = 0;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// start pv
|
|
31
|
+
export const uStartTrackPVData = (tData) => {
|
|
32
|
+
if (umlInterval) {
|
|
33
|
+
uStopTrackPVData();
|
|
34
|
+
} else {
|
|
35
|
+
if (tData) {
|
|
36
|
+
clearUMlData();
|
|
37
|
+
uTrackPVData(AUTOTRACKTYPE.ENTER, tData);
|
|
38
|
+
umlInterval = setInterval(() => {
|
|
39
|
+
uTrackPVData(AUTOTRACKTYPE.LOOP, null);
|
|
40
|
+
}, 15000);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
// stop pv
|
|
46
|
+
export const uStopTrackPVData = () => {
|
|
47
|
+
uTrackPVData(AUTOTRACKTYPE.LEAVE);
|
|
48
|
+
clearUMlData();
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
function uTrackPVData(type, tData) {
|
|
52
|
+
if (type === AUTOTRACKTYPE.ENTER) {
|
|
53
|
+
cUUId = randomUUID();
|
|
54
|
+
enterTimeLong = Date.now();
|
|
55
|
+
loopTimeLong = enterTimeLong;
|
|
56
|
+
mObj = getTrackObj(tData);
|
|
57
|
+
} else if (type === AUTOTRACKTYPE.LOOP) {
|
|
58
|
+
cirtemp = 2;
|
|
59
|
+
startTime = 15;
|
|
60
|
+
loopTimeLong = Date.now();
|
|
61
|
+
} else if (type === AUTOTRACKTYPE.LEAVE) {
|
|
62
|
+
cirtemp = 3;
|
|
63
|
+
startTime = Math.ceil((Date.now() - loopTimeLong) / 1000);
|
|
64
|
+
}
|
|
65
|
+
const puvData = {
|
|
66
|
+
busSegment: mObj.busSegment,
|
|
67
|
+
circulation: cirtemp,
|
|
68
|
+
domain: mObj.domain,
|
|
69
|
+
duration: startTime,
|
|
70
|
+
module: mObj.module,
|
|
71
|
+
path: mObj.path,
|
|
72
|
+
properties: mObj.properties,
|
|
73
|
+
sourceDomain: mObj.sourceDomain,
|
|
74
|
+
sourceUrl: mObj.sourceUrl,
|
|
75
|
+
title: mObj.title,
|
|
76
|
+
traceId: "",
|
|
77
|
+
trackId: sdkTrackIdVal(),
|
|
78
|
+
url: mObj.url,
|
|
79
|
+
visitPage: mObj.visitPage,
|
|
80
|
+
visitTime: timeToStr(enterTimeLong),
|
|
81
|
+
utm: getUtmObj(),
|
|
82
|
+
pageUUId: cUUId,
|
|
83
|
+
};
|
|
84
|
+
if (puvData) {
|
|
85
|
+
insertPVUVData(puvData, cUUId);
|
|
86
|
+
}
|
|
87
|
+
}
|
package/package.json
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visual-buried-point-platform-uni",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"lsi": "
|
|
3
|
+
"version": "1.0.0-alpha.19",
|
|
4
|
+
"lsi": "76e68a623e8df7515867ffd998b9f487#1.0.0-alpha.19",
|
|
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": {
|
|
8
8
|
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
-
"build": "webpack --mode production && npm run lsi-md5",
|
|
9
|
+
"build": "rimraf dist && webpack --mode production && npm run lsi-md5",
|
|
10
10
|
"lsi-md5": "node lsi-md5.js"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": ""
|
|
15
15
|
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
16
|
"type": "module",
|
|
20
17
|
"keywords": [],
|
|
21
18
|
"author": "",
|
|
@@ -24,6 +21,7 @@
|
|
|
24
21
|
"md5": "^2.3.0"
|
|
25
22
|
},
|
|
26
23
|
"devDependencies": {
|
|
24
|
+
"rimraf": "^6.0.1",
|
|
27
25
|
"webpack": "^5.72.1",
|
|
28
26
|
"webpack-cli": "4.9.2"
|
|
29
27
|
}
|
package/pageListener.js
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import {
|
|
2
|
+
autoPageObj,
|
|
3
|
+
uAutoStartTrackPVData,
|
|
4
|
+
autoStopTrackPVUV
|
|
5
|
+
} from "./autoutils.js";
|
|
6
|
+
import { Global } from "./tools.js";
|
|
7
|
+
|
|
8
|
+
export function uniInterceptorListener() {
|
|
9
|
+
uni.addInterceptor("navigateTo", {
|
|
10
|
+
invoke(args) {
|
|
11
|
+
// {"url":"/pages/Home/Home/Home"}
|
|
12
|
+
routerMsgHandler("leave");
|
|
13
|
+
},
|
|
14
|
+
success(args) {
|
|
15
|
+
// {"errMsg":"switchTab:ok"}
|
|
16
|
+
routerMsgHandler("pv");
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
uni.addInterceptor("switchTab", {
|
|
20
|
+
invoke(args) {
|
|
21
|
+
routerMsgHandler("leave");
|
|
22
|
+
},
|
|
23
|
+
success(args) {
|
|
24
|
+
routerMsgHandler("pv");
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
uni.addInterceptor("navigateBack", {
|
|
28
|
+
invoke(args) {
|
|
29
|
+
routerMsgHandler("leave");
|
|
30
|
+
},
|
|
31
|
+
success(args) {
|
|
32
|
+
routerMsgHandler("pv");
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
// 切换到前台
|
|
36
|
+
// uni.onAppShow((res) => {
|
|
37
|
+
// console.log("-----onAppShow--");
|
|
38
|
+
// //routerMsgHandler("pv");
|
|
39
|
+
// });
|
|
40
|
+
// // 切换到后台
|
|
41
|
+
// uni.onAppHide(() => {
|
|
42
|
+
// console.log("-----onAppHide--");
|
|
43
|
+
// //routerMsgHandler("leave");
|
|
44
|
+
// });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 路由消息统一处理
|
|
48
|
+
let pathExist = false;
|
|
49
|
+
function routerMsgHandler(msg) {
|
|
50
|
+
if (Global.isCompatible) {
|
|
51
|
+
} else {
|
|
52
|
+
if (msg === "pv") {
|
|
53
|
+
const pages = getCurrentPages();
|
|
54
|
+
const page = pages[pages.length - 1];
|
|
55
|
+
if (Global.signTrackArray && Global.signTrackArray.length) {
|
|
56
|
+
pathExist = Global.signTrackArray.find((obj) => obj === page.route);
|
|
57
|
+
if (pathExist) {
|
|
58
|
+
pathExist = true;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
pathExist = false;
|
|
63
|
+
const pageObj = autoPageObj(page.route, pages.length, pages);
|
|
64
|
+
uAutoStartTrackPVData(pageObj);
|
|
65
|
+
} else if (msg === "leave") {
|
|
66
|
+
if (!pathExist) {
|
|
67
|
+
autoStopTrackPVUV();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
package/tools.js
ADDED
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
export const AUTOTRACKTYPE = {
|
|
2
|
+
ENTER: "enter",
|
|
3
|
+
LOOP: "loop",
|
|
4
|
+
LEAVE: "leave",
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
export let Global = {
|
|
8
|
+
// 项目的域名
|
|
9
|
+
domain: "",
|
|
10
|
+
// 全局业务类型
|
|
11
|
+
busSegment: "",
|
|
12
|
+
// 全局业务版本
|
|
13
|
+
module: "",
|
|
14
|
+
// 定时上报周期
|
|
15
|
+
flushInterval: "",
|
|
16
|
+
// 每个页面PV采集的周期
|
|
17
|
+
pageInterval: "",
|
|
18
|
+
// 项目id
|
|
19
|
+
token: "",
|
|
20
|
+
// 版本号(如果在H5使用,建议传)
|
|
21
|
+
version: "",
|
|
22
|
+
// 全局单次访问链路id
|
|
23
|
+
trackId: "",
|
|
24
|
+
// 当前平台
|
|
25
|
+
platform: "",
|
|
26
|
+
// 全局uAgent
|
|
27
|
+
uAgent: "",
|
|
28
|
+
// 上报的事件url
|
|
29
|
+
upEventUrl: "",
|
|
30
|
+
// 上报的流量url
|
|
31
|
+
upTrackUrl: "",
|
|
32
|
+
// 是否兼容老方案 默认true兼容
|
|
33
|
+
isCompatible: true,
|
|
34
|
+
// 需要单个采集的页面path
|
|
35
|
+
signTrackArray: [],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// 本地记录每个页面设置的属性值例如:module...
|
|
39
|
+
export let pagesArray = [];
|
|
40
|
+
|
|
41
|
+
export const sdkTrackIdVal = () => {
|
|
42
|
+
if (Global.trackId) {
|
|
43
|
+
return Global.trackId;
|
|
44
|
+
}
|
|
45
|
+
const tId = Date.now().toString();
|
|
46
|
+
Global.trackId = tId;
|
|
47
|
+
return tId;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export function randomUUID() {
|
|
51
|
+
let uuid = "xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function (c) {
|
|
52
|
+
let r = (Math.random() * 16) | 0,
|
|
53
|
+
v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
54
|
+
return v.toString(16);
|
|
55
|
+
});
|
|
56
|
+
return uuid;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function timeToStr(timestamp) {
|
|
60
|
+
const date = new Date(timestamp);
|
|
61
|
+
const year = date.getFullYear();
|
|
62
|
+
const month =
|
|
63
|
+
date.getMonth() + 1 < 10
|
|
64
|
+
? "0" + (date.getMonth() + 1)
|
|
65
|
+
: date.getMonth() + 1;
|
|
66
|
+
const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
|
67
|
+
const hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
|
68
|
+
const minute =
|
|
69
|
+
date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
|
70
|
+
const second =
|
|
71
|
+
date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
|
72
|
+
const formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
|
73
|
+
return formattedDate;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
//web或者h5的appInfo
|
|
77
|
+
export function getWebH5Info(result) {
|
|
78
|
+
let ecology = "unknown";
|
|
79
|
+
let ua = result.ua.toLowerCase();
|
|
80
|
+
let hostname = window.location.hostname;
|
|
81
|
+
let titleName = document.title;
|
|
82
|
+
let isMobile =
|
|
83
|
+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua);
|
|
84
|
+
if (isMobile) {
|
|
85
|
+
ecology = "app";
|
|
86
|
+
} else {
|
|
87
|
+
ecology = "brower";
|
|
88
|
+
}
|
|
89
|
+
if (ua.includes("alipay")) {
|
|
90
|
+
ecology = "alipay";
|
|
91
|
+
} else if (ua.includes("unionPay")) {
|
|
92
|
+
ecology = "unionPay";
|
|
93
|
+
} else if (ua.includes("onbuygz")) {
|
|
94
|
+
ecology = "onbuygz";
|
|
95
|
+
} else if (ua.includes("onetravel")) {
|
|
96
|
+
ecology = "onetravel";
|
|
97
|
+
}
|
|
98
|
+
if (ua.includes("micromessenger")) {
|
|
99
|
+
if (ua.includes("miniprogram")) {
|
|
100
|
+
ecology = "wechat";
|
|
101
|
+
} else {
|
|
102
|
+
ecology = "brower";
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return {
|
|
106
|
+
name: titleName ? titleName : "",
|
|
107
|
+
packageName: hostname ? hostname : "",
|
|
108
|
+
version: "",
|
|
109
|
+
carrier: "h5",
|
|
110
|
+
ecology: "h5",
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
//微信的appInfo
|
|
115
|
+
export function getWXInfo() {
|
|
116
|
+
const accInfo = uni.getAccountInfoSync();
|
|
117
|
+
const bInfo = uni.getAppBaseInfo();
|
|
118
|
+
return {
|
|
119
|
+
name: bInfo.appName ? bInfo.appName : "",
|
|
120
|
+
packageName: accInfo ? accInfo.miniProgram.appId : "",
|
|
121
|
+
version: accInfo
|
|
122
|
+
? accInfo.miniProgram.envVersion + accInfo.miniProgram.version
|
|
123
|
+
: "",
|
|
124
|
+
carrier: "mini",
|
|
125
|
+
ecology: "mini",
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
//app的appInfo
|
|
130
|
+
export function getAppInfo(result) {
|
|
131
|
+
let version = plus.runtime.version;
|
|
132
|
+
let app = {
|
|
133
|
+
name: result.appName,
|
|
134
|
+
version: version ? version : "",
|
|
135
|
+
carrier: "app",
|
|
136
|
+
packageName: "",
|
|
137
|
+
ecology: "",
|
|
138
|
+
};
|
|
139
|
+
if (result.platform === "android") {
|
|
140
|
+
let osName = "Android";
|
|
141
|
+
let pkName = plus.android.runtimeMainActivity().getPackageName();
|
|
142
|
+
if (result.romName.includes("HarmonyOS")) {
|
|
143
|
+
osName = "Harmony OS";
|
|
144
|
+
}
|
|
145
|
+
app.packageName = pkName ? pkName : "";
|
|
146
|
+
app.ecology = osName;
|
|
147
|
+
} else if (result.platform === "ios") {
|
|
148
|
+
let pkName = plus.ios
|
|
149
|
+
.importClass("NSBundle")
|
|
150
|
+
.mainBundle()
|
|
151
|
+
.bundleIdentifier();
|
|
152
|
+
app.packageName = pkName ? pkName : "";
|
|
153
|
+
app.ecology = "iOS";
|
|
154
|
+
} else {
|
|
155
|
+
app.ecology = "unknown";
|
|
156
|
+
}
|
|
157
|
+
return app;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
function getCurDeviceType(res) {
|
|
161
|
+
if (Global.platform === "web" || platform === "h5") {
|
|
162
|
+
const userAgent = res.ua.toLowerCase();
|
|
163
|
+
if (/(windows|win32|win64|wow64)/.test(userAgent)) {
|
|
164
|
+
return 1;
|
|
165
|
+
} else if (/(linux|android)/.test(userAgent)) {
|
|
166
|
+
return 2;
|
|
167
|
+
} else if (/(macintosh|mac os x|iphone|ipad|ipod)/.test(userAgent)) {
|
|
168
|
+
return 2;
|
|
169
|
+
} else {
|
|
170
|
+
return 2;
|
|
171
|
+
}
|
|
172
|
+
} else {
|
|
173
|
+
if (res.deviceType === "pc") {
|
|
174
|
+
return 1;
|
|
175
|
+
} else {
|
|
176
|
+
return 2;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
//获取设备信息
|
|
182
|
+
export function getDeviceInfo(res) {
|
|
183
|
+
let device = {
|
|
184
|
+
lang: res.osLanguage ? res.osLanguage : res.hostLanguage,
|
|
185
|
+
brand: res.deviceBrand + " " + res.deviceModel,
|
|
186
|
+
os: res.osName,
|
|
187
|
+
osVersion: res.osVersion,
|
|
188
|
+
resolution: res.screenWidth + "x" + res.screenHeight,
|
|
189
|
+
browser: res.browserName,
|
|
190
|
+
browserVersion: res.browserVersion,
|
|
191
|
+
color: "",
|
|
192
|
+
deviceId: res.deviceId,
|
|
193
|
+
deviceType: getCurDeviceType(res),
|
|
194
|
+
network: "",
|
|
195
|
+
};
|
|
196
|
+
return device;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
//error默认获取设备信息
|
|
200
|
+
export function getDeviceInfoError() {
|
|
201
|
+
return {
|
|
202
|
+
lang: "",
|
|
203
|
+
brand: "",
|
|
204
|
+
os: "",
|
|
205
|
+
osVersion: "",
|
|
206
|
+
resolution: "",
|
|
207
|
+
browser: "",
|
|
208
|
+
browserVersion: "",
|
|
209
|
+
color: "",
|
|
210
|
+
deviceId: "",
|
|
211
|
+
deviceType: "",
|
|
212
|
+
network: "",
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
//uni 通用h5、app、wx拿到当前路由栈
|
|
217
|
+
export function getTrackObj(tData) {
|
|
218
|
+
const pages = getCurrentPages();
|
|
219
|
+
const gcp = pages[pages.length - 1];
|
|
220
|
+
let pf = Global.platform;
|
|
221
|
+
let url = "";
|
|
222
|
+
let domain = "";
|
|
223
|
+
let srcUrl = "";
|
|
224
|
+
let srcDomain = "";
|
|
225
|
+
if (pf) {
|
|
226
|
+
if (pf === "web" || pf === "h5") {
|
|
227
|
+
url = window.location.href;
|
|
228
|
+
domain = window.location.hostname;
|
|
229
|
+
if (document.referrer) {
|
|
230
|
+
let parsedUrl = new URL(document.referrer);
|
|
231
|
+
srcUrl = parsedUrl || "";
|
|
232
|
+
srcDomain = parsedUrl.hostname || "";
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
url = gcp.route;
|
|
236
|
+
if (pages.length > 1) {
|
|
237
|
+
let beforePage = pages[pages.length - 2];
|
|
238
|
+
srcUrl = beforePage.route;
|
|
239
|
+
}
|
|
240
|
+
domain = Global.domain ? Global.domain : gcp.route;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
if (gcp) {
|
|
244
|
+
return {
|
|
245
|
+
path: gcp.route,
|
|
246
|
+
busSegment: tData.busSegment ? tData.busSegment : "",
|
|
247
|
+
module: tData.module ? tData.module : "",
|
|
248
|
+
properties: tData.extend_param ? JSON.stringify(tData.extend_param) : "",
|
|
249
|
+
title: tData.title ? tData.title : "",
|
|
250
|
+
domain: domain,
|
|
251
|
+
url: url,
|
|
252
|
+
visitPage: pages.length,
|
|
253
|
+
sourceDomain: srcDomain,
|
|
254
|
+
sourceUrl: srcUrl,
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
// 更新当前页的业务方设置的对象
|
|
260
|
+
export function uUpdatePageExtraArray(d) {
|
|
261
|
+
const pages = getCurrentPages();
|
|
262
|
+
let page = pages[pages.length - 1];
|
|
263
|
+
const index = pagesArray.findIndex((item) => item.path === page.route);
|
|
264
|
+
let temp = {
|
|
265
|
+
path: page.route,
|
|
266
|
+
properties: d.properties ? JSON.stringify(d.properties) : "",
|
|
267
|
+
busSegment: d.busSegment ? d.busSegment : "",
|
|
268
|
+
module: d.module ? d.module : "",
|
|
269
|
+
title: d.title ? d.title : "",
|
|
270
|
+
};
|
|
271
|
+
if (index !== -1) {
|
|
272
|
+
pagesArray[index] = temp;
|
|
273
|
+
} else {
|
|
274
|
+
pagesArray.push(temp);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// 得到utm
|
|
279
|
+
export function getUtmObj() {
|
|
280
|
+
if (Global.platform === "web" || Global.platform === "h5") {
|
|
281
|
+
let utm = {
|
|
282
|
+
utmSource: "",
|
|
283
|
+
utmCampaign: "",
|
|
284
|
+
utmTerm: "",
|
|
285
|
+
utmContent: "",
|
|
286
|
+
ctk: "",
|
|
287
|
+
};
|
|
288
|
+
if (window.location.href) {
|
|
289
|
+
const paramsUrl = window.location.href.split("?")[1] || "";
|
|
290
|
+
if (paramsUrl) {
|
|
291
|
+
const urlParams = new URLSearchParams(paramsUrl);
|
|
292
|
+
// 渠道来源
|
|
293
|
+
utm.utmSource = urlParams.get("utmSource") || "";
|
|
294
|
+
// 活动名称
|
|
295
|
+
utm.utmCampaign = urlParams.get("utmCampaign") || "";
|
|
296
|
+
// 渠道媒介
|
|
297
|
+
utm.utmTerm = urlParams.get("utmTerm") || "";
|
|
298
|
+
// 内容
|
|
299
|
+
utm.utmContent = urlParams.get("utmContent") || "";
|
|
300
|
+
// 关键词
|
|
301
|
+
utm.ctk = urlParams.get("ctk") || "";
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return utm;
|
|
305
|
+
} else {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
4
|
+
const __dirname = path.dirname(__filename);
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
entry: "./index.js",
|
|
8
|
+
output: {
|
|
9
|
+
path: path.resolve(__dirname, "dist"),
|
|
10
|
+
filename: "buried-point-uni.js",
|
|
11
|
+
libraryTarget: "umd",
|
|
12
|
+
},
|
|
13
|
+
resolve: {
|
|
14
|
+
extensions: [".js"],
|
|
15
|
+
},
|
|
16
|
+
mode: "production",
|
|
17
|
+
};
|
package/dist/buried-point-uni.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/*! For license information please see buried-point-uni.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{var e={151:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},206:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},503:(e,t,n)=>{var r,o,i,a,u;r=n(939),o=n(151).utf8,i=n(206),a=n(151).bin,(u=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?a.stringToBytes(e):o.stringToBytes(e):i(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),s=8*e.length,c=1732584193,l=-271733879,g=-1732584194,p=271733878,d=0;d<n.length;d++)n[d]=16711935&(n[d]<<8|n[d]>>>24)|4278255360&(n[d]<<24|n[d]>>>8);n[s>>>5]|=128<<s%32,n[14+(s+64>>>9<<4)]=s;var f=u._ff,m=u._gg,y=u._hh,h=u._ii;for(d=0;d<n.length;d+=16){var v=c,S=l,b=g,I=p;c=f(c,l,g,p,n[d+0],7,-680876936),p=f(p,c,l,g,n[d+1],12,-389564586),g=f(g,p,c,l,n[d+2],17,606105819),l=f(l,g,p,c,n[d+3],22,-1044525330),c=f(c,l,g,p,n[d+4],7,-176418897),p=f(p,c,l,g,n[d+5],12,1200080426),g=f(g,p,c,l,n[d+6],17,-1473231341),l=f(l,g,p,c,n[d+7],22,-45705983),c=f(c,l,g,p,n[d+8],7,1770035416),p=f(p,c,l,g,n[d+9],12,-1958414417),g=f(g,p,c,l,n[d+10],17,-42063),l=f(l,g,p,c,n[d+11],22,-1990404162),c=f(c,l,g,p,n[d+12],7,1804603682),p=f(p,c,l,g,n[d+13],12,-40341101),g=f(g,p,c,l,n[d+14],17,-1502002290),c=m(c,l=f(l,g,p,c,n[d+15],22,1236535329),g,p,n[d+1],5,-165796510),p=m(p,c,l,g,n[d+6],9,-1069501632),g=m(g,p,c,l,n[d+11],14,643717713),l=m(l,g,p,c,n[d+0],20,-373897302),c=m(c,l,g,p,n[d+5],5,-701558691),p=m(p,c,l,g,n[d+10],9,38016083),g=m(g,p,c,l,n[d+15],14,-660478335),l=m(l,g,p,c,n[d+4],20,-405537848),c=m(c,l,g,p,n[d+9],5,568446438),p=m(p,c,l,g,n[d+14],9,-1019803690),g=m(g,p,c,l,n[d+3],14,-187363961),l=m(l,g,p,c,n[d+8],20,1163531501),c=m(c,l,g,p,n[d+13],5,-1444681467),p=m(p,c,l,g,n[d+2],9,-51403784),g=m(g,p,c,l,n[d+7],14,1735328473),c=y(c,l=m(l,g,p,c,n[d+12],20,-1926607734),g,p,n[d+5],4,-378558),p=y(p,c,l,g,n[d+8],11,-2022574463),g=y(g,p,c,l,n[d+11],16,1839030562),l=y(l,g,p,c,n[d+14],23,-35309556),c=y(c,l,g,p,n[d+1],4,-1530992060),p=y(p,c,l,g,n[d+4],11,1272893353),g=y(g,p,c,l,n[d+7],16,-155497632),l=y(l,g,p,c,n[d+10],23,-1094730640),c=y(c,l,g,p,n[d+13],4,681279174),p=y(p,c,l,g,n[d+0],11,-358537222),g=y(g,p,c,l,n[d+3],16,-722521979),l=y(l,g,p,c,n[d+6],23,76029189),c=y(c,l,g,p,n[d+9],4,-640364487),p=y(p,c,l,g,n[d+12],11,-421815835),g=y(g,p,c,l,n[d+15],16,530742520),c=h(c,l=y(l,g,p,c,n[d+2],23,-995338651),g,p,n[d+0],6,-198630844),p=h(p,c,l,g,n[d+7],10,1126891415),g=h(g,p,c,l,n[d+14],15,-1416354905),l=h(l,g,p,c,n[d+5],21,-57434055),c=h(c,l,g,p,n[d+12],6,1700485571),p=h(p,c,l,g,n[d+3],10,-1894986606),g=h(g,p,c,l,n[d+10],15,-1051523),l=h(l,g,p,c,n[d+1],21,-2054922799),c=h(c,l,g,p,n[d+8],6,1873313359),p=h(p,c,l,g,n[d+15],10,-30611744),g=h(g,p,c,l,n[d+6],15,-1560198380),l=h(l,g,p,c,n[d+13],21,1309151649),c=h(c,l,g,p,n[d+4],6,-145523070),p=h(p,c,l,g,n[d+11],10,-1120210379),g=h(g,p,c,l,n[d+2],15,718787259),l=h(l,g,p,c,n[d+9],21,-343485551),c=c+v>>>0,l=l+S>>>0,g=g+b>>>0,p=p+I>>>0}return r.endian([c,l,g,p])})._ff=function(e,t,n,r,o,i,a){var u=e+(t&n|~t&r)+(o>>>0)+a;return(u<<i|u>>>32-i)+t},u._gg=function(e,t,n,r,o,i,a){var u=e+(t&r|n&~r)+(o>>>0)+a;return(u<<i|u>>>32-i)+t},u._hh=function(e,t,n,r,o,i,a){var u=e+(t^n^r)+(o>>>0)+a;return(u<<i|u>>>32-i)+t},u._ii=function(e,t,n,r,o,i,a){var u=e+(n^(t|~r))+(o>>>0)+a;return(u<<i|u>>>32-i)+t},u._blocksize=16,u._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(u(e,t));return t&&t.asBytes?n:t&&t.asString?a.bytesToString(n):r.bytesToHex(n)}},939:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var o=e[r]<<16|e[r+1]<<8|e[r+2],i=0;i<4;i++)8*r+6*i<=8*e.length?n.push(t.charAt(o>>>6*(3-i)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],r=0,o=0;r<e.length;o=++r%4)0!=o&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*o+8)-1)<<2*o|t.indexOf(e.charAt(r))>>>6-2*o);return n}},e.exports=n}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{getTrackId:()=>ee,init:()=>Q,onDestroyTrack:()=>re,onStartTrack:()=>ne,reportTrackEventServer:()=>ie,setCustomEvent:()=>te,setPageExtraObj:()=>oe,setUserId:()=>X});var e=n(503);let t={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},o=[];const i=()=>{if(t.trackId)return t.trackId;const e=Date.now().toString();return t.trackId=e,e};function a(){return"xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g,(function(e){let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function u(e){const t=new Date(e);return`${t.getFullYear()}-${t.getMonth()+1<10?"0"+(t.getMonth()+1):t.getMonth()+1}-${t.getDate()<10?"0"+t.getDate():t.getDate()} ${t.getHours()<10?"0"+t.getHours():t.getHours()}:${t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes()}:${t.getSeconds()<10?"0"+t.getSeconds():t.getSeconds()}`}function s(e){if("web"===t.platform||"h5"===platform){const t=e.ua.toLowerCase();return/(windows|win32|win64|wow64)/.test(t)?1:(/(linux|android)/.test(t)||/(macintosh|mac os x|iphone|ipad|ipod)/.test(t),2)}return"pc"===e.deviceType?1:2}function c(){if("web"===t.platform||"h5"===t.platform){let e={utmSource:"",utmCampaign:"",utmTerm:"",utmContent:"",ctk:""};if(window.location.href){const t=window.location.href.split("?")[1]||"";if(t){const n=new URLSearchParams(t);e.utmSource=n.get("utmSource")||"",e.utmCampaign=n.get("utmCampaign")||"",e.utmTerm=n.get("utmTerm")||"",e.utmContent=n.get("utmContent")||"",e.ctk=n.get("ctk")||""}}return e}return null}const l="enter",g="loop",p="leave",d="UNIBPNPVUVSrcData",f="UNIBPNPVUVFailData";let m,y,h,v,S,b=null,I=null;const w=e=>{b?k():(clearInterval(b),m=0,y=0,h=0,v=1,S=null,b=null,I=0,S=e,T(l),b=setInterval((()=>{T(g)}),15e3))},k=()=>{T(p),clearInterval(b)};function T(e){if(e===l?(v=1,m=0,y=Date.now(),h=y,I=a()):e===g?(v=2,m=15,h=Date.now()):e===p&&(v=3,m=Math.ceil((Date.now()-h)/1e3)),S){const e={busSegment:S.busSegment||"",circulation:v,domain:S.domain,duration:m,module:S.module||"",path:S.path,url:S.url,sourceDomain:S.sourceDomain,sourceUrl:S.sourceUrl,properties:S.properties,title:S.title,traceId:"",trackId:i(),visitPage:S.visitPage,visitTime:u(y),pageUUId:I};e&&x(e,I)}}function x(e,t){let n=uni.getStorageSync(d),r=n?JSON.parse(n):[];if(r.length>0){const n=r.findIndex((e=>e.pageUUId===t));-1!==n?r[n]={...r[n],...e}:r.push(e)}else r.push(e);uni.setStorageSync(d,JSON.stringify(r))}const U=e=>{if("object"==typeof e){const t=Array.isArray(e)?[]:{};for(const n in e)"object"==typeof e[n]?t[n]=U(e[n]):t[n]=e[n];return t}return e},N=[],P=e=>{N.push(e)},O=()=>U(N),B=()=>{N.length=0},_="UNIBPNEventSrcData",A="UNIBPNEventFailData";let D;let C=0,$=0,M=0,j=-1,J=null,L=null,E=0;function V(){clearInterval(L),C=0,$=0,M=0,j=1,J=null,L=null,E=0}const H=e=>{L?z():e&&(V(),R(l,e),L=setInterval((()=>{R(g,null)}),15e3))},z=()=>{R(p),V()};function R(e,n){e===l?(E=a(),$=Date.now(),M=$,J=function(e){const n=getCurrentPages(),r=n[n.length-1];let o=t.platform,i="",a="",u="",s="";if(o)if("web"===o||"h5"===o){if(i=window.location.href,a=window.location.hostname,document.referrer){let e=new URL(document.referrer);u=e||"",s=e.hostname||""}}else i=r.route,n.length>1&&(u=n[n.length-2].route),a=t.domain?t.domain:r.route;if(r)return{path:r.route,busSegment:e.busSegment?e.busSegment:"",module:e.module?e.module:"",properties:e.extend_param?JSON.stringify(e.extend_param):"",title:e.title?e.title:"",domain:a,url:i,visitPage:n.length,sourceDomain:s,sourceUrl:u}}(n)):e===g?(j=2,C=15,M=Date.now()):e===p&&(j=3,C=Math.ceil((Date.now()-M)/1e3));const r={busSegment:J.busSegment,circulation:j,domain:J.domain,duration:C,module:J.module,path:J.path,properties:J.properties,sourceDomain:J.sourceDomain,sourceUrl:J.sourceUrl,title:J.title,traceId:"",trackId:i(),url:J.url,visitPage:J.visitPage,visitTime:u($),utm:c(),pageUUId:E};r&&x(r,E)}let F=!1;function q(e){if(t.isCompatible);else if("pv"===e){const e=getCurrentPages(),n=e[e.length-1];if(t.signTrackArray&&t.signTrackArray.length&&(F=t.signTrackArray.find((e=>e===n.route)),F))return void(F=!0);F=!1;const r=function(e,n,r){let i=o.find((t=>t.path===e)),a=t.platform,u="",s="",c="",l="";if(a)if("web"===a||"h5"===a){if(u=window.location.href,s=window.location.hostname,document.referrer){let e=new URL(document.referrer);c=e||"",l=e.hostname||""}}else u=e,n>1&&(c=r[n-2].route),s=t.domain?t.domain:e;return{path:i&&i.path?i.path:e,busSegment:i&&i.busSegment?i.busSegment:t.busSegment||"",module:i&&i.module?i.module:t.module||"",properties:i&&i.properties?i.properties:"",domain:s,url:u,visitPage:n,sourceDomain:l,sourceUrl:c,title:i&&i.title?i.title:""}}(n.route,e.length,e);w(r)}else"leave"===e&&(F||k())}const W=JSON.parse('{"dr":"2df7d9fee02691e293eb3e32b4593ade#1.0.0-alpha.17"}').dr;let K={distinctId:"",anonymousId:""},Y={},Z={},G=null;function Q(e){if(e){let n="test"===(e.env?e.env:"")?{reportUrl:"https://buryingpoint.gcongo.com.cn/client/api/event",reportTrackUrl:"https://buryingpoint.gcongo.com.cn/client/api/track",eventListUrl:"https://buryingpoint.gcongo.com.cn/api/event/query/eventList"}:{reportUrl:"https://buryingpoint.onebuygz.com/client/api/event",reportTrackUrl:"https://buryingpoint.onebuygz.com/client/api/track",eventListUrl:"https://buryingpoint.onebuygz.com/api/event/query/eventList"};t.upEventUrl=n.reportUrl,t.upTrackUrl=n.reportTrackUrl,Object.assign(t,e),uni.getSystemInfo({success:function(e){t.uAgent=e.ua;let n=e.uniPlatform;if(n.includes("app"))t.platform=e.osName,Y=function(e){let t=plus.runtime.version,n={name:e.appName,version:t||"",carrier:"app",packageName:"",ecology:""};if("android"===e.platform){let t="Android",r=plus.android.runtimeMainActivity().getPackageName();e.romName.includes("HarmonyOS")&&(t="Harmony OS"),n.packageName=r||"",n.ecology=t}else if("ios"===e.platform){let e=plus.ios.importClass("NSBundle").mainBundle().bundleIdentifier();n.packageName=e||"",n.ecology="iOS"}else n.ecology="unknown";return n}(e);else if(n.includes("web")||n.includes("h5")){t.platform=n;let r=function(e){let t="unknown",n=e.ua.toLowerCase(),r=window.location.hostname,o=document.title;return t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(n)?"app":"brower",n.includes("alipay")?t="alipay":n.includes("unionPay")?t="unionPay":n.includes("onbuygz")?t="onbuygz":n.includes("onetravel")&&(t="onetravel"),n.includes("micromessenger")&&(t=n.includes("miniprogram")?"wechat":"brower"),{name:o||"",packageName:r||"",version:"",carrier:"h5",ecology:"h5"}}(e);Y={...r,version:t.version?t.version:"unknown"}}else n.includes("weixin")&&(t.platform="weixin",Y=function(){const e=uni.getAccountInfoSync(),t=uni.getAppBaseInfo();return{name:t.appName?t.appName:"",packageName:e?e.miniProgram.appId:"",version:e?e.miniProgram.envVersion+e.miniProgram.version:"",carrier:"mini",ecology:"mini"}}());Z=function(e){return{lang:e.osLanguage?e.osLanguage:e.hostLanguage,brand:e.deviceBrand+" "+e.deviceModel,os:e.osName,osVersion:e.osVersion,resolution:e.screenWidth+"x"+e.screenHeight,browser:e.browserName,browserVersion:e.browserVersion,color:"",deviceId:e.deviceId,deviceType:s(e),network:""}}(e)},fail:function(e){Z={lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}},complete:function(){uni.getNetworkType({success(e){Z.network=e.networkType}})}}),K.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",K.anonymousId=uni.getStorageSync("v_anonId"),K.anonymousId||(K.anonymousId=a(),uni.setStorageSync("v_anonId",K.anonymousId)),i()}else console.log("init config error, please check config!");console.log("global:: ",t),clearInterval(G),G=setInterval((()=>{!function(){let e=uni.getStorageSync(_);uni.setStorageSync(_,"");const t=e?JSON.parse(e):[];let n=[],r=uni.getStorageSync(A);const o=r?JSON.parse(r):[];t.length&&n.push(...t),o.length&&n.push(...o),n&&n.length&&ie("event",n,A)}(),function(){let e=uni.getStorageSync(d);uni.setStorageSync(d,"");const t=e?JSON.parse(e):[];let n=[],r=uni.getStorageSync(f);const o=r?JSON.parse(r):[];t.length&&n.push(...t),o.length&&n.push(...o),n&&n.length&&(n.forEach((e=>{delete e.pageUUId})),ie("track",n,f))}()}),15e3),uni.addInterceptor("navigateTo",{invoke(e){q("leave")},success(e){q("pv")}}),uni.addInterceptor("switchTab",{invoke(e){q("leave")},success(e){q("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){q("leave")},success(e){q("pv")}})}function X(e){e?(K.distinctId=e,uni.setStorageSync("v_userId",e)):(K.distinctId="",uni.setStorageSync("v_userId",""))}function ee(){return i()}function te(t){!function(t){if(!t)return;const n=t.$page?t.$page:"",r=n.path?n.path:function(){const e=getCurrentPages(),t=e[e.length-1];return t?t.route:"/"}();let o={utm:t.$utm?t.$utm:c(),duration:"",element:t.$element?t.$element:null,eventId:t.$event_id?t.$event_id:"",event:t.$event_code?t.$event_code:"",groupId:"",busSegment:t.$busSegment?t.$busSegment:"",module:t.$module?t.$module:"",page:{domain:n.domain?n.domain:"",pageId:e(r),path:r||"",title:n.title||"",url:r||""},properties:t.$extend_param?JSON.stringify(t.$extend_param):"",traceId:"",trackId:i(),triggerTime:u(Date.now())};o&&(P(o),clearTimeout(D),D=setTimeout((()=>{const e=O();e.length&&(function(e){const t=uni.getStorageSync(_);let n=t?JSON.parse(t):[];e&&e.length&&(n.concat(e),uni.setStorageSync(_,JSON.stringify(n)))}(e),B())}),2e3))}(t)}function ne(e){H(e)}function re(){z()}function oe(e){!function(e){const t=getCurrentPages();let n=t[t.length-1];const r=o.findIndex((e=>e.path===n.route));let i={path:n.route,properties:e.properties?JSON.stringify(e.properties):"",busSegment:e.busSegment?e.busSegment:"",module:e.module?e.module:"",title:e.title?e.title:""};-1!==r?o[r]=i:o.push(i)}(e)}function ie(n,r,o){if(!n)return void console.error("please set upload data upType");const i={app:Y,data:r,device:Z,lsi:W,projectId:t.token,userAgent:t.uAgent||"",anonymousId:K.anonymousId,userId:K.distinctId},a={...i,dataAbstract:e(JSON.stringify(i))};uni.request({url:"event"===n?t.upEventUrl:t.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:t.token,projectId:t.token},data:a,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(o,JSON.stringify(r)):uni.setStorageSync(o,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(o,JSON.stringify(r))}})}})(),r})()));
|