visual-buried-point-platform-uni 1.0.0-alpha.15 → 1.0.0-alpha.17

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 ADDED
@@ -0,0 +1,178 @@
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
+ ctk: "",
76
+ domain: atObj.domain,
77
+ duration: atDuration,
78
+ module: atObj.module || "",
79
+ path: atObj.path,
80
+ url: atObj.url,
81
+ sourceDomain: atObj.sourceDomain,
82
+ sourceUrl: atObj.sourceUrl,
83
+ properties: atObj.properties,
84
+ title: atObj.title,
85
+ traceId: "",
86
+ trackId: sdkTrackIdVal(),
87
+ visitPage: atObj.visitPage,
88
+ visitTime: timeToStr(atEnterTimeLong),
89
+ pageUUId: cUUId,
90
+ };
91
+ if (puvData) {
92
+ insertPVUVData(puvData, cUUId);
93
+ }
94
+ }
95
+ }
96
+
97
+ // 插入数据
98
+ export function insertPVUVData(pData, pUUId) {
99
+ let td = uni.getStorageSync(BPNPVUV);
100
+ let mPVData = td ? JSON.parse(td) : [];
101
+ if (mPVData.length > 0) {
102
+ const index = mPVData.findIndex((obj) => obj.pageUUId === pUUId);
103
+ if (index !== -1) {
104
+ mPVData[index] = { ...mPVData[index], ...pData };
105
+ } else {
106
+ mPVData.push(pData);
107
+ }
108
+ } else {
109
+ mPVData.push(pData);
110
+ }
111
+ uni.setStorageSync(BPNPVUV, JSON.stringify(mPVData));
112
+ }
113
+
114
+ // 自动采集对象
115
+ export function autoPageObj(cpath, clength, cpages) {
116
+ let _pObj = pagesArray.find((obj) => obj.path === cpath);
117
+ let pf = Global.platform;
118
+ let url = "";
119
+ let domain = "";
120
+ let srcUrl = "";
121
+ let srcDomain = "";
122
+ if (pf) {
123
+ if (pf === "web" || pf === "h5") {
124
+ url = window.location.href;
125
+ domain = window.location.hostname;
126
+ if (document.referrer) {
127
+ let parsedUrl = new URL(document.referrer);
128
+ srcUrl = parsedUrl || "";
129
+ srcDomain = parsedUrl.hostname || "";
130
+ }
131
+ } else {
132
+ url = cpath;
133
+ if (clength > 1) {
134
+ let beforePage = cpages[clength - 2];
135
+ srcUrl = beforePage.route;
136
+ }
137
+ domain = Global.domain ? Global.domain : cpath;
138
+ }
139
+ }
140
+ return {
141
+ path: _pObj && _pObj.path ? _pObj.path : cpath,
142
+ busSegment:
143
+ _pObj && _pObj.busSegment ? _pObj.busSegment : Global.busSegment || "",
144
+ module: _pObj && _pObj.module ? _pObj.module : Global.module || "",
145
+ properties: _pObj && _pObj.properties ? _pObj.properties : "",
146
+ domain: domain,
147
+ url: url,
148
+ visitPage: clength,
149
+ sourceDomain: srcDomain,
150
+ sourceUrl: srcUrl,
151
+ title: _pObj && _pObj.title ? _pObj.title : "",
152
+ };
153
+ }
154
+
155
+ /**
156
+ * 查询数据
157
+ * 0 未上报 2上报失败
158
+ */
159
+ export function queryTrackDataUpload() {
160
+ let td = uni.getStorageSync(BPNPVUV);
161
+ uni.setStorageSync(BPNPVUV, "");
162
+ const arr = td ? JSON.parse(td) : [];
163
+ let uploadArray = [];
164
+ let ftd = uni.getStorageSync(BPNPVUVFail);
165
+ const failArr = ftd ? JSON.parse(ftd) : [];
166
+ if (arr.length) {
167
+ uploadArray.push(...arr);
168
+ }
169
+ if (failArr.length) {
170
+ uploadArray.push(...failArr);
171
+ }
172
+ if (uploadArray && uploadArray.length) {
173
+ uploadArray.forEach((item) => {
174
+ delete item.pageUUId;
175
+ });
176
+ reportTrackEventServer("track", uploadArray, BPNPVUVFail);
177
+ }
178
+ }
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,92 @@
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
+ const _page = data.$page ? data.$page : "";
20
+ const _path = _page.path ? _page.path : getCurPath();
21
+ let reportEventData = {
22
+ utm: data.$utm ? data.$utm : getUtmObj(),
23
+ duration: "",
24
+ element: data.$element ? data.$element : null,
25
+ eventId: data.$event_id ? data.$event_id : "",
26
+ event: data.$event_code ? data.$event_code : "",
27
+ groupId: "",
28
+ busSegment: data.$busSegment,
29
+ module: data.$module,
30
+ page: {
31
+ domain: _page.domain ? _page.domain : "",
32
+ pageId: MD5(_path),
33
+ path: _path || "",
34
+ title: _page.title || "",
35
+ url: _path || "",
36
+ },
37
+ properties: data.$extend_param ? JSON.stringify(data.$extend_param) : "",
38
+ traceId: "",
39
+ trackId: sdkTrackIdVal(),
40
+ triggerTime: timeToStr(Date.now()),
41
+ };
42
+
43
+ if (reportEventData) {
44
+ addCache(reportEventData);
45
+ clearTimeout(timerCustom);
46
+ timerCustom = setTimeout(() => {
47
+ const data = getCache();
48
+ if (data.length) {
49
+ insertEventData(data);
50
+ clearCache();
51
+ }
52
+ }, 2000);
53
+ }
54
+ }
55
+
56
+ /**
57
+ * 插入Event数据合并
58
+ */
59
+ export function insertEventData(cData) {
60
+ console.log("写入Event数据 ", 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
+ // ...方法
67
+ // allEventData = { ...allEventData, ...cData };
68
+ uni.setStorageSync(BPNEvent, JSON.stringify(allEventData));
69
+ }
70
+ }
71
+
72
+ /**
73
+ * 查询自定义数据
74
+ * 0 未上报/上报失败
75
+ */
76
+ export function queryEventDataUpload() {
77
+ let cd = uni.getStorageSync(BPNEvent);
78
+ uni.setStorageSync(BPNEvent, "");
79
+ const arr = cd ? JSON.parse(cd) : [];
80
+ let uploadArray = [];
81
+ let fcd = uni.getStorageSync(BPNEventFail);
82
+ const failArr = fcd ? JSON.parse(fcd) : [];
83
+ if (arr.length) {
84
+ uploadArray.push(...arr);
85
+ }
86
+ if (failArr.length) {
87
+ uploadArray.push(...failArr);
88
+ }
89
+ if (uploadArray && uploadArray.length) {
90
+ reportTrackEventServer("event", uploadArray, BPNEventFail);
91
+ }
92
+ }
package/index.js ADDED
@@ -0,0 +1,178 @@
1
+ import MD5 from "md5";
2
+ import { queryTrackDataUpload } from "./autoutils.js";
3
+ import { setReportUrl } from "./config.js";
4
+ import { eventCommonStore, queryEventDataUpload } from "./eventutils.js";
5
+ import { uStopTrackPVData, uStartTrackPVData } from "./manualutils.js";
6
+ import pk from "./package.json";
7
+ import { uniInterceptorListener } from "./pageListener.js";
8
+ import {
9
+ getAppInfo,
10
+ getDeviceInfo,
11
+ getDeviceInfoError,
12
+ getWebH5Info,
13
+ getWXInfo,
14
+ Global,
15
+ randomUUID,
16
+ sdkTrackIdVal,
17
+ uUpdatePageExtraArray,
18
+ } from "./tools.js";
19
+
20
+ const localLsi = pk.lsi;
21
+ let _comInfo = { distinctId: "", anonymousId: "" };
22
+ let appData = {};
23
+ let deviceData = {};
24
+ //common global upload interval
25
+ let uglInterval = null;
26
+ export function init(config) {
27
+ if (config) {
28
+ let _cf = setReportUrl(config.env ? config.env : "");
29
+ Global.upEventUrl = _cf.reportUrl;
30
+ Global.upTrackUrl = _cf.reportTrackUrl;
31
+ Object.assign(Global, config);
32
+ console.log("global:: ", Global);
33
+ getBaseicInfo();
34
+ _comInfo.distinctId = uni.getStorageSync("v_userId")
35
+ ? uni.getStorageSync("v_userId")
36
+ : "";
37
+ _comInfo.anonymousId = uni.getStorageSync("v_anonId");
38
+ if (!_comInfo.anonymousId) {
39
+ _comInfo.anonymousId = randomUUID();
40
+ uni.setStorageSync("v_anonId", _comInfo.anonymousId);
41
+ }
42
+ sdkTrackIdVal();
43
+ } else {
44
+ console.log("init config error, please check config!");
45
+ }
46
+ // 开启全局定时器
47
+ startGlobalTime();
48
+ // 监听页面的加载、卸载
49
+ uniInterceptorListener();
50
+ }
51
+
52
+ //the general custom reportCustom interval is enabled
53
+ function startGlobalTime() {
54
+ clearInterval(uglInterval);
55
+ uglInterval = setInterval(() => {
56
+ queryEventDataUpload();
57
+ queryTrackDataUpload();
58
+ }, 15000);
59
+ }
60
+
61
+ //bind userID
62
+ export function setUserId(userId) {
63
+ if (userId) {
64
+ _comInfo.distinctId = userId;
65
+ uni.setStorageSync("v_userId", userId);
66
+ } else {
67
+ _comInfo.distinctId = "";
68
+ uni.setStorageSync("v_userId", "");
69
+ }
70
+ }
71
+
72
+ //对外开放,获取跟踪Id
73
+ export function getTrackId() {
74
+ return sdkTrackIdVal();
75
+ }
76
+
77
+ // set custom event
78
+ export function setCustomEvent(data) {
79
+ eventCommonStore(data);
80
+ }
81
+
82
+ //track upload-registry
83
+ export function onStartTrack(tData) {
84
+ uStartTrackPVData(tData);
85
+ }
86
+
87
+ //track upload-Destroy
88
+ export function onDestroyTrack() {
89
+ uStopTrackPVData();
90
+ }
91
+
92
+ // auto track 预置的属性
93
+ export function setPageExtraObj(tData) {
94
+ uUpdatePageExtraArray(tData);
95
+ }
96
+
97
+ // 数据上报
98
+ export function reportTrackEventServer(upType, data, sFailKey) {
99
+ if (!upType) {
100
+ console.error("please set upload data upType");
101
+ return;
102
+ }
103
+ const comData = commonData(data);
104
+ const reportData = {
105
+ ...comData,
106
+ dataAbstract: MD5(JSON.stringify(comData)),
107
+ };
108
+ uni.request({
109
+ url: upType === "event" ? Global.upEventUrl : Global.upTrackUrl,
110
+ method: "POST",
111
+ header: {
112
+ "Content-Type": "application/json",
113
+ appKey: Global.token,
114
+ projectId: Global.token,
115
+ },
116
+ data: reportData,
117
+ success: function (res) {
118
+ console.log("res: ", JSON.stringify(res));
119
+ if (res && res.data) {
120
+ uni.setStorageSync(sFailKey, JSON.stringify(data));
121
+ } else {
122
+ uni.setStorageSync(sFailKey, "");
123
+ }
124
+ },
125
+ fail: function (error) {
126
+ console.log("error: ", error);
127
+ uni.setStorageSync(sFailKey, JSON.stringify(data));
128
+ },
129
+ });
130
+ }
131
+
132
+ function commonData(allData) {
133
+ return {
134
+ app: appData,
135
+ data: allData,
136
+ device: deviceData,
137
+ lsi: localLsi,
138
+ projectId: Global.token,
139
+ userAgent: Global.uAgent || "",
140
+ anonymousId: _comInfo.anonymousId,
141
+ userId: _comInfo.distinctId,
142
+ };
143
+ }
144
+
145
+ //获取基本信息
146
+ function getBaseicInfo() {
147
+ uni.getSystemInfo({
148
+ success: function (res) {
149
+ Global.uAgent = res.ua;
150
+ let uniPlatform = res.uniPlatform;
151
+ if (uniPlatform.includes("app")) {
152
+ Global.platform = res.osName;
153
+ appData = getAppInfo(res);
154
+ } else if (uniPlatform.includes("web") || uniPlatform.includes("h5")) {
155
+ Global.platform = uniPlatform;
156
+ let wh5Info = getWebH5Info(res);
157
+ appData = {
158
+ ...wh5Info,
159
+ version: Global.version ? Global.version : "unknown",
160
+ };
161
+ } else if (uniPlatform.includes("weixin")) {
162
+ Global.platform = "weixin";
163
+ appData = getWXInfo();
164
+ }
165
+ deviceData = getDeviceInfo(res, Global.platform);
166
+ },
167
+ fail: function (error) {
168
+ deviceData = getDeviceInfoError();
169
+ },
170
+ complete: function () {
171
+ uni.getNetworkType({
172
+ success(res) {
173
+ deviceData.network = res.networkType;
174
+ },
175
+ });
176
+ },
177
+ });
178
+ }
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,86 @@
1
+ import { AUTOTRACKTYPE, insertPVUVData } from "./autoutils.js";
2
+ import {
3
+ getTrackObj,
4
+ getUtmObj, randomUUID,
5
+ sdkTrackIdVal,
6
+ timeToStr
7
+ } from "./tools.js";
8
+
9
+ // 流量上报采集
10
+ let startTime = 0;
11
+ let enterTimeLong = 0;
12
+ let loopTimeLong = 0;
13
+ let cirtemp = -1;
14
+ let mObj = null;
15
+ let umlInterval = null;
16
+ let cUUId = 0;
17
+
18
+ function clearUMlData() {
19
+ clearInterval(umlInterval);
20
+ startTime = 0;
21
+ enterTimeLong = 0;
22
+ loopTimeLong = 0;
23
+ cirtemp = 1;
24
+ mObj = null;
25
+ umlInterval = null;
26
+ cUUId = 0;
27
+ }
28
+
29
+ // start pv
30
+ export const uStartTrackPVData = (tData) => {
31
+ if (umlInterval) {
32
+ uStopTrackPVData();
33
+ } else {
34
+ if (tData) {
35
+ clearUMlData();
36
+ uTrackPVData(AUTOTRACKTYPE.ENTER, tData);
37
+ umlInterval = setInterval(() => {
38
+ uTrackPVData(AUTOTRACKTYPE.LOOP, null);
39
+ }, 15000);
40
+ }
41
+ }
42
+ };
43
+
44
+ // stop pv
45
+ export const uStopTrackPVData = () => {
46
+ uTrackPVData(AUTOTRACKTYPE.LEAVE);
47
+ clearUMlData();
48
+ };
49
+
50
+ function uTrackPVData(type, tData) {
51
+ if (type === AUTOTRACKTYPE.ENTER) {
52
+ cUUId = randomUUID();
53
+ enterTimeLong = Date.now();
54
+ loopTimeLong = enterTimeLong;
55
+ mObj = getTrackObj(tData);
56
+ } else if (type === AUTOTRACKTYPE.LOOP) {
57
+ cirtemp = 2;
58
+ startTime = 15;
59
+ loopTimeLong = Date.now();
60
+ } else if (type === AUTOTRACKTYPE.LEAVE) {
61
+ cirtemp = 3;
62
+ startTime = Math.ceil((Date.now() - loopTimeLong) / 1000);
63
+ }
64
+ const puvData = {
65
+ busSegment: mObj.busSegment,
66
+ circulation: cirtemp,
67
+ domain: mObj.domain,
68
+ duration: startTime,
69
+ module: mObj.module,
70
+ path: mObj.path,
71
+ properties: mObj.properties,
72
+ sourceDomain: mObj.sourceDomain,
73
+ sourceUrl: mObj.sourceUrl,
74
+ title: mObj.title,
75
+ traceId: "",
76
+ trackId: sdkTrackIdVal(),
77
+ url: mObj.url,
78
+ visitPage: mObj.visitPage,
79
+ visitTime: timeToStr(enterTimeLong),
80
+ utm: getUtmObj(),
81
+ pageUUId: cUUId,
82
+ };
83
+ if (puvData) {
84
+ insertPVUVData(puvData, cUUId);
85
+ }
86
+ }
package/package.json CHANGED
@@ -1,21 +1,19 @@
1
1
  {
2
2
  "name": "visual-buried-point-platform-uni",
3
- "version": "1.0.0-alpha.15",
4
- "lsi": "f880f051db0e276f9777a7cc4d4c947c#1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.17",
4
+ "lsi": "2df7d9fee02691e293eb3e32b4593ade#1.0.0-alpha.17",
5
5
  "description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.",
6
- "main": "dist/cjs/buried-point-uni.js",
7
- "module": "dist/esm/buried-point-uni.js",
6
+ "main": "index.js",
8
7
  "scripts": {
9
- "dev": "rollup -c -w",
10
- "build": "rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.js"
8
+ "test": "echo \"Error: no test specified\" && exit 1",
9
+ "build": "webpack --mode production && npm run lsi-md5",
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
- ],
16
+ "type": "module",
19
17
  "keywords": [],
20
18
  "author": "",
21
19
  "license": "MIT",
@@ -23,15 +21,7 @@
23
21
  "md5": "^2.3.0"
24
22
  },
25
23
  "devDependencies": {
26
- "@babel/core": "^7.5.5",
27
- "@rollup/plugin-json": "^6.0.1",
28
- "babel-preset-es2015": "^6.24.1",
29
- "rollup": "^1.20.2",
30
- "rollup-plugin-babel": "^4.3.3",
31
- "rollup-plugin-commonjs": "^10.0.2",
32
- "rollup-plugin-node-resolve": "^5.2.0",
33
- "rollup-plugin-replace": "^2.2.0",
34
- "rollup-plugin-uglify": "^6.0.2",
35
- "webpack": "^4.39.2"
24
+ "webpack": "^5.72.1",
25
+ "webpack-cli": "4.9.2"
36
26
  }
37
27
  }
@@ -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: ecology,
111
+ ecology: "h5",
112
+ };
113
+ }
114
+
115
+ //微信的appInfo
116
+ export function getWXInfo() {
117
+ const accInfo = uni.getAccountInfoSync();
118
+ const bInfo = uni.getAppBaseInfo();
119
+ return {
120
+ name: bInfo.appName ? bInfo.appName : "",
121
+ packageName: accInfo ? accInfo.miniProgram.appId : "",
122
+ version: accInfo
123
+ ? accInfo.miniProgram.envVersion + accInfo.miniProgram.version
124
+ : "",
125
+ carrier: "mini",
126
+ // ecology: "wechat",
127
+ ecology: "mini",
128
+ };
129
+ }
130
+
131
+ //app的appInfo
132
+ export function getAppInfo(result) {
133
+ let version = plus.runtime.version;
134
+ let app = {
135
+ name: result.appName,
136
+ version: version ? version : "",
137
+ carrier: "app",
138
+ packageName: "",
139
+ ecology: "",
140
+ };
141
+ if (result.platform === "android") {
142
+ let osName = "Android";
143
+ let pkName = plus.android.runtimeMainActivity().getPackageName();
144
+ if (result.romName.includes("HarmonyOS")) {
145
+ osName = "Harmony OS";
146
+ }
147
+ app.packageName = pkName ? pkName : "";
148
+ app.ecology = osName;
149
+ } else if (result.platform === "ios") {
150
+ let pkName = plus.ios
151
+ .importClass("NSBundle")
152
+ .mainBundle()
153
+ .bundleIdentifier();
154
+ app.packageName = pkName ? pkName : "";
155
+ app.ecology = "iOS";
156
+ } else {
157
+ app.ecology = "unknown";
158
+ }
159
+ return app;
160
+ }
161
+
162
+ function getCurDeviceType(res, platform) {
163
+ if (platform !== "wx") {
164
+ const userAgent = res.ua.toLowerCase();
165
+ if (/(windows|win32|win64|wow64)/.test(userAgent)) {
166
+ return 1;
167
+ } else if (/(linux|android)/.test(userAgent)) {
168
+ return 2;
169
+ } else if (/(macintosh|mac os x|iphone|ipad|ipod)/.test(userAgent)) {
170
+ return 2;
171
+ } else {
172
+ return 2;
173
+ }
174
+ } else {
175
+ if (res.deviceType === "pc") {
176
+ return 1;
177
+ } else {
178
+ return 2;
179
+ }
180
+ }
181
+ }
182
+
183
+ //获取设备信息
184
+ export function getDeviceInfo(res, platform) {
185
+ let device = {
186
+ lang: res.osLanguage ? res.osLanguage : res.hostLanguage,
187
+ brand: res.deviceBrand + " " + res.deviceModel,
188
+ os: res.osName,
189
+ osVersion: res.osVersion,
190
+ resolution: res.screenWidth + "x" + res.screenHeight,
191
+ browser: res.browserName,
192
+ browserVersion: res.browserVersion,
193
+ color: "",
194
+ deviceId: res.deviceId,
195
+ deviceType: getCurDeviceType(res, platform),
196
+ network: "",
197
+ };
198
+ return device;
199
+ }
200
+
201
+ //error默认获取设备信息
202
+ export function getDeviceInfoError() {
203
+ return {
204
+ lang: "",
205
+ brand: "",
206
+ os: "",
207
+ osVersion: "",
208
+ resolution: "",
209
+ browser: "",
210
+ browserVersion: "",
211
+ color: "",
212
+ deviceId: "",
213
+ deviceType: "",
214
+ network: "",
215
+ };
216
+ }
217
+
218
+ //uni 通用h5、app、wx拿到当前路由栈
219
+ export function getTrackObj(tData) {
220
+ const pages = getCurrentPages();
221
+ const gcp = pages[pages.length - 1];
222
+ let pf = Global.platform;
223
+ let url = "";
224
+ let domain = "";
225
+ let srcUrl = "";
226
+ let srcDomain = "";
227
+ if (pf) {
228
+ if (pf === "web" || pf === "h5") {
229
+ url = window.location.href;
230
+ domain = window.location.hostname;
231
+ if (document.referrer) {
232
+ let parsedUrl = new URL(document.referrer);
233
+ srcUrl = parsedUrl || "";
234
+ srcDomain = parsedUrl.hostname || "";
235
+ }
236
+ } else {
237
+ url = gcp.route;
238
+ if (pages.length > 1) {
239
+ let beforePage = pages[pages.length - 2];
240
+ srcUrl = beforePage.route;
241
+ }
242
+ domain = Global.domain ? Global.domain : gcp.route;
243
+ }
244
+ }
245
+ if (gcp) {
246
+ return {
247
+ path: gcp.route,
248
+ busSegment: tData.busSegment ? tData.busSegment : "",
249
+ module: tData.module ? tData.module : "",
250
+ properties: tData.extend_param ? JSON.stringify(tData.extend_param) : "",
251
+ title: tData.title ? tData.title : "",
252
+ domain: domain,
253
+ url: url,
254
+ visitPage: pages.length,
255
+ sourceDomain: srcDomain,
256
+ sourceUrl: srcUrl,
257
+ };
258
+ }
259
+ }
260
+
261
+ // 更新当前页的业务方设置的对象
262
+ export function uUpdatePageExtraArray(d) {
263
+ const pages = getCurrentPages();
264
+ let page = pages[pages.length - 1];
265
+ const index = pagesArray.findIndex((item) => item.path === page.route);
266
+ let temp = {
267
+ path: page.route,
268
+ properties: d.properties ? JSON.stringify(d.properties) : "",
269
+ busSegment: d.busSegment ? d.busSegment : "",
270
+ module: d.module ? d.module : "",
271
+ title: d.title ? d.title : "",
272
+ };
273
+ if (index !== -1) {
274
+ pagesArray[index] = temp;
275
+ } else {
276
+ pagesArray.push(temp);
277
+ }
278
+ }
279
+
280
+ // 得到utm
281
+ export function getUtmObj() {
282
+ let utm = {
283
+ utmSource: "",
284
+ utmCampaign: "",
285
+ utmTerm: "",
286
+ utmContent: "",
287
+ ctk: "",
288
+ };
289
+ if (Global.platform === "web" || Global.platform === "h5") {
290
+ if (window.location.href) {
291
+ const paramsUrl = window.location.href.split("?")[1] || "";
292
+ if (paramsUrl) {
293
+ const urlParams = new URLSearchParams(paramsUrl);
294
+ // 渠道来源
295
+ utm.utmSource = urlParams.get("utmSource") || "";
296
+ // 活动名称
297
+ utm.utmCampaign = urlParams.get("utmCampaign") || "";
298
+ // 渠道媒介
299
+ utm.utmTerm = urlParams.get("utmTerm") || "";
300
+ // 内容
301
+ utm.utmContent = urlParams.get("utmContent") || "";
302
+ // 关键词
303
+ utm.ctk = urlParams.get("ctk") || "";
304
+ }
305
+ }
306
+ }
307
+ return utm;
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
+ };
@@ -1 +0,0 @@
1
- "use strict";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}Object.defineProperty(exports,"__esModule",{value:!0});var crypt=createCommonjsModule(function(e){var o,r;o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={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&r.rotl(e,8)|4278255360&r.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=r.endian(e[t]);return e},randomBytes:function(e){for(var t=[];0<e;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],r=0,n=0;r<e.length;r++,n+=8)t[n>>>5]|=e[r]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},bytesToHex:function(e){for(var t=[],r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return t},bytesToBase64:function(e){for(var t=[],r=0;r<e.length;r+=3)for(var n=e[r]<<16|e[r+1]<<8|e[r+2],a=0;a<4;a++)8*r+6*a<=8*e.length?t.push(o.charAt(n>>>6*(3-a)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],r=0,n=0;r<e.length;n=++r%4)0!=n&&t.push((o.indexOf(e.charAt(r-1))&Math.pow(2,-2*n+8)-1)<<2*n|o.indexOf(e.charAt(r))>>>6-2*n);return t}},e.exports=r}),charenc={utf8:{stringToBytes:function(e){return charenc.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(charenc.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t},bytesToString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(String.fromCharCode(e[r]));return t.join("")}}},charenc_1=charenc,isBuffer_1=function(e){return null!=e&&(isBuffer(e)||isSlowBuffer(e)||!!e._isBuffer)};function isBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isBuffer(e.slice(0,0))}var md5=createCommonjsModule(function(e){function v(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?I:b).stringToBytes(e):h(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var r=T.bytesToWords(e),t=8*e.length,n=1732584193,a=-271733879,o=-1732584194,i=271733878,s=0;s<r.length;s++)r[s]=16711935&(r[s]<<8|r[s]>>>24)|4278255360&(r[s]<<24|r[s]>>>8);r[t>>>5]|=128<<t%32,r[14+(64+t>>>9<<4)]=t;for(var u=v._ff,c=v._gg,l=v._hh,p=v._ii,s=0;s<r.length;s+=16){var g=n,d=a,m=o,f=i,n=u(n,a,o,i,r[s+0],7,-680876936),i=u(i,n,a,o,r[s+1],12,-389564586),o=u(o,i,n,a,r[s+2],17,606105819),a=u(a,o,i,n,r[s+3],22,-1044525330);n=u(n,a,o,i,r[s+4],7,-176418897),i=u(i,n,a,o,r[s+5],12,1200080426),o=u(o,i,n,a,r[s+6],17,-1473231341),a=u(a,o,i,n,r[s+7],22,-45705983),n=u(n,a,o,i,r[s+8],7,1770035416),i=u(i,n,a,o,r[s+9],12,-1958414417),o=u(o,i,n,a,r[s+10],17,-42063),a=u(a,o,i,n,r[s+11],22,-1990404162),n=u(n,a,o,i,r[s+12],7,1804603682),i=u(i,n,a,o,r[s+13],12,-40341101),o=u(o,i,n,a,r[s+14],17,-1502002290),n=c(n,a=u(a,o,i,n,r[s+15],22,1236535329),o,i,r[s+1],5,-165796510),i=c(i,n,a,o,r[s+6],9,-1069501632),o=c(o,i,n,a,r[s+11],14,643717713),a=c(a,o,i,n,r[s+0],20,-373897302),n=c(n,a,o,i,r[s+5],5,-701558691),i=c(i,n,a,o,r[s+10],9,38016083),o=c(o,i,n,a,r[s+15],14,-660478335),a=c(a,o,i,n,r[s+4],20,-405537848),n=c(n,a,o,i,r[s+9],5,568446438),i=c(i,n,a,o,r[s+14],9,-1019803690),o=c(o,i,n,a,r[s+3],14,-187363961),a=c(a,o,i,n,r[s+8],20,1163531501),n=c(n,a,o,i,r[s+13],5,-1444681467),i=c(i,n,a,o,r[s+2],9,-51403784),o=c(o,i,n,a,r[s+7],14,1735328473),n=l(n,a=c(a,o,i,n,r[s+12],20,-1926607734),o,i,r[s+5],4,-378558),i=l(i,n,a,o,r[s+8],11,-2022574463),o=l(o,i,n,a,r[s+11],16,1839030562),a=l(a,o,i,n,r[s+14],23,-35309556),n=l(n,a,o,i,r[s+1],4,-1530992060),i=l(i,n,a,o,r[s+4],11,1272893353),o=l(o,i,n,a,r[s+7],16,-155497632),a=l(a,o,i,n,r[s+10],23,-1094730640),n=l(n,a,o,i,r[s+13],4,681279174),i=l(i,n,a,o,r[s+0],11,-358537222),o=l(o,i,n,a,r[s+3],16,-722521979),a=l(a,o,i,n,r[s+6],23,76029189),n=l(n,a,o,i,r[s+9],4,-640364487),i=l(i,n,a,o,r[s+12],11,-421815835),o=l(o,i,n,a,r[s+15],16,530742520),n=p(n,a=l(a,o,i,n,r[s+2],23,-995338651),o,i,r[s+0],6,-198630844),i=p(i,n,a,o,r[s+7],10,1126891415),o=p(o,i,n,a,r[s+14],15,-1416354905),a=p(a,o,i,n,r[s+5],21,-57434055),n=p(n,a,o,i,r[s+12],6,1700485571),i=p(i,n,a,o,r[s+3],10,-1894986606),o=p(o,i,n,a,r[s+10],15,-1051523),a=p(a,o,i,n,r[s+1],21,-2054922799),n=p(n,a,o,i,r[s+8],6,1873313359),i=p(i,n,a,o,r[s+15],10,-30611744),o=p(o,i,n,a,r[s+6],15,-1560198380),a=p(a,o,i,n,r[s+13],21,1309151649),n=p(n,a,o,i,r[s+4],6,-145523070),i=p(i,n,a,o,r[s+11],10,-1120210379),o=p(o,i,n,a,r[s+2],15,718787259),a=p(a,o,i,n,r[s+9],21,-343485551),n=n+g>>>0,a=a+d>>>0,o=o+m>>>0,i=i+f>>>0}return T.endian([n,a,o,i])}var T,b,h,I;T=crypt,b=charenc_1.utf8,h=isBuffer_1,I=charenc_1.bin,v._ff=function(e,t,r,n,a,o,i){e=e+(t&r|~t&n)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._gg=function(e,t,r,n,a,o,i){e=e+(t&n|r&~n)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._hh=function(e,t,r,n,a,o,i){e=e+(t^r^n)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._ii=function(e,t,r,n,a,o,i){e=e+(r^(t|~n))+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=T.wordsToBytes(v(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):T.bytesToHex(e)}});let Global={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},pagesArray=[];const sdkTrackIdVal=()=>{var e;return Global.trackId||(e=Date.now().toString(),Global.trackId=e)};function randomUUID(){return"xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function timeToStr(e){e=new Date(e);return e.getFullYear()+`-${e.getMonth()+1<10?"0"+(e.getMonth()+1):e.getMonth()+1}-${e.getDate()<10?"0"+e.getDate():e.getDate()} ${e.getHours()<10?"0"+e.getHours():e.getHours()}:${e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes()}:`+(e.getSeconds()<10?"0"+e.getSeconds():e.getSeconds())}function getWebH5Info(e){var e=e.ua.toLowerCase(),t=window.location.hostname,r=document.title;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e);return e.includes("alipay")||e.includes("unionPay")||e.includes("onbuygz")||e.includes("onetravel"),e.includes("micromessenger")&&e.includes("miniprogram"),{name:r||"",packageName:t||"",version:"",carrier:"h5",ecology:"h5"}}function getWXInfo(){var e=uni.getAccountInfoSync(),t=uni.getAppBaseInfo();return{name:t.appName||"",packageName:e?e.miniProgram.appId:"",version:e?e.miniProgram.envVersion+e.miniProgram.version:"",carrier:"mini",ecology:"mini"}}function getAppInfo(t){var r=plus.runtime.version,r={name:t.appName,version:r||"",carrier:"app",packageName:"",ecology:""};if("android"===t.platform){let e="Android";var n=plus.android.runtimeMainActivity().getPackageName();t.romName.includes("HarmonyOS")&&(e="Harmony OS"),r.packageName=n||"",r.ecology=e}else"ios"===t.platform?(n=plus.ios.importClass("NSBundle").mainBundle().bundleIdentifier(),r.packageName=n||"",r.ecology="iOS"):r.ecology="unknown";return r}function getCurDeviceType(e,t){return"wx"!==t?(t=e.ua.toLowerCase(),/(windows|win32|win64|wow64)/.test(t)?1:(/(linux|android)/.test(t)||/(macintosh|mac os x|iphone|ipad|ipod)/.test(t),2)):"pc"===e.deviceType?1:2}function getDeviceInfo(e,t){return{lang: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:getCurDeviceType(e,t),network:""}}function getDeviceInfoError(){return{lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}}function getTrackObj(e){var t=getCurrentPages(),r=t[t.length-1],n=Global.platform;let a="",o="",i="",s="";if(n&&("web"===n||"h5"===n?(a=window.location.href,o=window.location.hostname,document.referrer&&(n=new URL(document.referrer),i=n||"",s=n.hostname||"")):(a=r.route,1<t.length&&(n=t[t.length-2],i=n.route),o=Global.domain||r.route)),r)return{path:r.route,busSegment:e.busSegment||"",module:e.module||"",properties:e.extend_param?JSON.stringify(e.extend_param):"",title:e.title||"",domain:o,url:a,visitPage:t.length,sourceDomain:s,sourceUrl:i}}function uUpdatePageExtraArray(e){var t=getCurrentPages();let r=t[t.length-1];t=pagesArray.findIndex(e=>e.path===r.route),e={path:r.route,properties:e.properties?JSON.stringify(e.properties):"",busSegment:e.busSegment||"",module:e.module||"",title:e.title||""};-1!==t?pagesArray[t]=e:pagesArray.push(e)}const AUTOTRACKTYPE={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},BPNPVUV="UNIBPNPVUVSrcData",BPNPVUVFail="UNIBPNPVUVFailData";let atDuration,atEnterTimeLong,atLoopTimeLong,cirtemp,atObj,atInterval=null,cUUId=null;function clearUAData(){clearInterval(atInterval),atDuration=0,atEnterTimeLong=0,atLoopTimeLong=0,cirtemp=1,atObj=null,atInterval=null,cUUId=0}const uAutoStartTrackPVData=e=>{atInterval?autoStopTrackPVUV():(clearUAData(),atObj=e,autoTrackData(AUTOTRACKTYPE.ENTER),atInterval=setInterval(()=>{autoTrackData(AUTOTRACKTYPE.LOOP)},Global.pageInterval))},autoStopTrackPVUV=()=>{autoTrackData(AUTOTRACKTYPE.LEAVE),clearInterval(atInterval)};function autoTrackData(e){e===AUTOTRACKTYPE.ENTER?(cirtemp=1,atDuration=0,atEnterTimeLong=Date.now(),atLoopTimeLong=atEnterTimeLong,cUUId=randomUUID()):e===AUTOTRACKTYPE.LOOP?(cirtemp=2,atDuration=15,atLoopTimeLong=Date.now()):e===AUTOTRACKTYPE.LEAVE&&(cirtemp=3,atDuration=Math.ceil((Date.now()-atLoopTimeLong)/1e3)),atObj&&insertPVUVData({busSegment:atObj.busSegment||"",circulation:cirtemp,ctk:"",domain:atObj.domain,duration:atDuration,module:atObj.module||"",path:atObj.path,url:atObj.url,sourceDomain:atObj.sourceDomain,sourceUrl:atObj.sourceUrl,properties:atObj.properties,title:atObj.title,traceId:"",trackId:sdkTrackIdVal(),visitPage:atObj.visitPage,visitTime:timeToStr(atEnterTimeLong),pageUUId:cUUId},cUUId)}function insertPVUVData(e,t){var r,n=uni.getStorageSync(BPNPVUV),n=n?JSON.parse(n):[];0<n.length&&-1!==(r=n.findIndex(e=>e.pageUUId===t))?n[r]={...n[r],...e}:n.push(e),uni.setStorageSync(BPNPVUV,JSON.stringify(n))}function autoPageObj(t,e,r){var n=pagesArray.find(e=>e.path===t),a=Global.platform;let o="",i="",s="",u="";return a&&("web"===a||"h5"===a?(o=window.location.href,i=window.location.hostname,document.referrer&&(a=new URL(document.referrer),s=a||"",u=a.hostname||"")):(o=t,1<e&&(a=r[e-2],s=a.route),i=Global.domain||t)),{path:n&&n.path?n.path:t,busSegment:n&&n.busSegment?n.busSegment:Global.busSegment||"",module:n&&n.module?n.module:Global.module||"",properties:n&&n.properties?n.properties:"",domain:i,url:o,visitPage:e,sourceDomain:u,sourceUrl:s,title:n&&n.title?n.title:""}}function queryTrackDataUpload(){var e=uni.getStorageSync(BPNPVUV),e=(uni.setStorageSync(BPNPVUV,""),e?JSON.parse(e):[]),t=[],r=uni.getStorageSync(BPNPVUVFail),r=r?JSON.parse(r):[];e.length&&t.push(...e),r.length&&t.push(...r),t&&t.length&&(t.forEach(e=>{delete e.pageUUId}),reportTrackEventServer("track",t,BPNPVUVFail))}function setReportUrl(e){return"test"!==e?{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"}:{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"}}const deepCopy=e=>{if("object"!=typeof e)return e;var t=Array.isArray(e)?[]:{};for(const r in e)"object"==typeof e[r]?t[r]=deepCopy(e[r]):t[r]=e[r];return t},cacheData=[],addCache=e=>{cacheData.push(e)},getCache=()=>deepCopy(cacheData),clearCache=()=>{cacheData.length=0},BPNEvent="UNIBPNEventSrcData",BPNEventFail="UNIBPNEventFailData";let timerCustom;function getCurPath(){var e=getCurrentPages(),e=e[e.length-1];return e?e.route:"/"}function eventCommonStore(e){var t=e.$page||"",r=t.path||getCurPath(),t={utm:e.$utm||"",duration:"",element:e.$element||null,eventId:e.$event_id||"",event:e.$event_code||"",groupId:"",busSegment:e.$busSegment,module:e.$module,page:{domain:t.domain||"",pageId:md5(r),path:r||"",title:t.title||"",url:r||""},properties:e.$extend_param?JSON.stringify(e.$extend_param):"",traceId:"",trackId:sdkTrackIdVal(),triggerTime:timeToStr(Date.now())};addCache(t),clearTimeout(timerCustom),timerCustom=setTimeout(()=>{var e=getCache();e.length&&(insertEventData(e),clearCache())},2e3)}function insertEventData(e){console.log("写入Event数据 ",e);var t=uni.getStorageSync(BPNEvent),t=t?JSON.parse(t):[];e&&e.length&&(t.concat(e),uni.setStorageSync(BPNEvent,JSON.stringify(t)))}function queryEventDataUpload(){var e=uni.getStorageSync(BPNEvent),e=(uni.setStorageSync(BPNEvent,""),e?JSON.parse(e):[]),t=[],r=uni.getStorageSync(BPNEventFail),r=r?JSON.parse(r):[];e.length&&t.push(...e),r.length&&t.push(...r),t&&t.length&&reportTrackEventServer("event",t,BPNEventFail)}let startTime=0,enterTimeLong=0,loopTimeLong=0,cirtemp$1=-1,mObj=null,umlInterval=null,cUUId$1=0;function clearUMlData(){clearInterval(umlInterval),startTime=0,enterTimeLong=0,loopTimeLong=0,cirtemp$1=1,mObj=null,umlInterval=null,cUUId$1=0}const uStartTrackPVData=e=>{umlInterval?uStopTrackPVData():e&&(clearUMlData(),uTrackPVData(AUTOTRACKTYPE.ENTER,e),umlInterval=setInterval(()=>{uTrackPVData(AUTOTRACKTYPE.LOOP,null)},Global.pageInterval))},uStopTrackPVData=()=>{uTrackPVData(AUTOTRACKTYPE.LEAVE),clearUMlData()};function uTrackPVData(e,t){e===AUTOTRACKTYPE.ENTER?(cUUId$1=randomUUID(),enterTimeLong=Date.now(),loopTimeLong=enterTimeLong,mObj=getTrackObj(t)):e===AUTOTRACKTYPE.LOOP?(cirtemp$1=2,startTime=15,loopTimeLong=Date.now()):e===AUTOTRACKTYPE.LEAVE&&(cirtemp$1=3,startTime=Math.ceil((Date.now()-loopTimeLong)/1e3));t={busSegment:mObj.busSegment,circulation:cirtemp$1,domain:mObj.domain,duration:startTime,module:mObj.module,path:mObj.path,properties:mObj.properties,sourceDomain:mObj.sourceDomain,sourceUrl:mObj.sourceUrl,title:mObj.title,traceId:"",trackId:sdkTrackIdVal(),url:mObj.url,visitPage:mObj.visitPage,visitTime:timeToStr(enterTimeLong),utm:"",pageUUId:cUUId$1};insertPVUVData(t,cUUId$1)}var name="visual-buried-point-platform-uni",version="1.0.0-alpha.15",lsi="f880f051db0e276f9777a7cc4d4c947c#1.0.0-alpha.15",description="To make it easy for you to get started with GitLab, here's a list of recommended next steps.",main="dist/cjs/buried-point-uni.js",module$1="dist/esm/buried-point-uni.js",scripts={dev:"rollup -c -w",build:"rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.js"},repository={type:"git",url:""},files=["dist"],keywords=[],author="",license="MIT",dependencies={md5:"^2.3.0"},devDependencies={"@babel/core":"^7.5.5","@rollup/plugin-json":"^6.0.1","babel-preset-es2015":"^6.24.1",rollup:"^1.20.2","rollup-plugin-babel":"^4.3.3","rollup-plugin-commonjs":"^10.0.2","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-replace":"^2.2.0","rollup-plugin-uglify":"^6.0.2",webpack:"^4.39.2"},pk={name:name,version:version,lsi:lsi,description:description,main:main,module:module$1,scripts:scripts,repository:repository,files:files,keywords:keywords,author:author,license:license,dependencies:dependencies,devDependencies:devDependencies};function uniInterceptorListener(){uni.addInterceptor("navigateTo",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}}),uni.addInterceptor("switchTab",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}})}let pathExist=!1;function routerMsgHandler(e){if(!Global.isCompatible)if("pv"===e){var t=getCurrentPages();const r=t[t.length-1];Global.signTrackArray&&Global.signTrackArray.length&&(pathExist=Global.signTrackArray.find(e=>e===r.route))?pathExist=!0:(pathExist=!1,t=autoPageObj(r.route,t.length,t),uAutoStartTrackPVData(t))}else"leave"!==e||pathExist||autoStopTrackPVUV()}const localLsi=pk.lsi;let _comInfo={distinctId:"",anonymousId:""},appData={},deviceData={},uglInterval=null;function init(e){var t;e?(t=setReportUrl(e.env||""),Global.upEventUrl=t.reportUrl,Global.upTrackUrl=t.reportTrackUrl,(!e.flushInterval||e.flushInterval<5)&&(e.flushInterval=15),(!e.pageInterval||e.pageInterval<5)&&(e.pageInterval=15),Object.assign(Global,e),getBaseicInfo(),_comInfo.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",_comInfo.anonymousId=uni.getStorageSync("v_anonId"),_comInfo.anonymousId||(_comInfo.anonymousId=randomUUID(),uni.setStorageSync("v_anonId",_comInfo.anonymousId)),sdkTrackIdVal()):console.log("init config error, please check config!"),startGlobalTime(),uniInterceptorListener()}function startGlobalTime(){clearInterval(uglInterval),uglInterval=setInterval(()=>{queryEventDataUpload(),queryTrackDataUpload()},Global.flushInterval||15e3)}function setUserId(e){e?(_comInfo.distinctId=e,uni.setStorageSync("v_userId",e)):(_comInfo.distinctId="",uni.setStorageSync("v_userId",""))}function getTrackId(){return sdkTrackIdVal()}function setCustomEvent(e){eventCommonStore(e)}function onStartTrack(e){uStartTrackPVData(e)}function onDestroyTrack(){uStopTrackPVData()}function setPageExtraObj(e){uUpdatePageExtraArray(e)}function reportTrackEventServer(e,t,r){var n;e?(n={...n=commonData(t),dataAbstract:md5(JSON.stringify(n))},uni.request({url:"event"===e?Global.upEventUrl:Global.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:Global.token,projectId:Global.token},data:n,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(r,JSON.stringify(t)):uni.setStorageSync(r,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(r,JSON.stringify(t))}})):console.error("please set upload data upType")}function commonData(e){return{app:appData,data:e,device:deviceData,lsi:localLsi,projectId:Global.token,userAgent:Global.uAgent||"",anonymousId:_comInfo.anonymousId,userId:_comInfo.distinctId}}function getBaseicInfo(){uni.getSystemInfo({success:function(e){Global.uAgent=e.ua;var t,r=e.uniPlatform;r.includes("app")?(Global.platform=e.osName,appData=getAppInfo(e)):r.includes("web")||r.includes("h5")?(Global.platform=r,t=getWebH5Info(e),appData={...t,version:Global.version||"unknown"}):r.includes("weixin")&&(Global.platform="weixin",appData=getWXInfo()),deviceData=getDeviceInfo(e,Global.platform)},fail:function(e){deviceData=getDeviceInfoError()},complete:function(){uni.getNetworkType({success(e){deviceData.network=e.networkType}})}})}exports.getTrackId=getTrackId,exports.init=init,exports.onDestroyTrack=onDestroyTrack,exports.onStartTrack=onStartTrack,exports.reportTrackEventServer=reportTrackEventServer,exports.setCustomEvent=setCustomEvent,exports.setPageExtraObj=setPageExtraObj,exports.setUserId=setUserId;
@@ -1 +0,0 @@
1
- function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var crypt=createCommonjsModule(function(e){var o,n;o="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=[];0<e;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 t=[],n=0;n<e.length;n+=3)for(var r=e[n]<<16|e[n+1]<<8|e[n+2],a=0;a<4;a++)8*n+6*a<=8*e.length?t.push(o.charAt(r>>>6*(3-a)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,r=0;n<e.length;r=++n%4)0!=r&&t.push((o.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|o.indexOf(e.charAt(n))>>>6-2*r);return t}},e.exports=n}),charenc={utf8:{stringToBytes:function(e){return charenc.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(charenc.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("")}}},charenc_1=charenc,isBuffer_1=function(e){return null!=e&&(isBuffer(e)||isSlowBuffer(e)||!!e._isBuffer)};function isBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isBuffer(e.slice(0,0))}var md5=createCommonjsModule(function(e){function v(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?I:h).stringToBytes(e):b(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=T.bytesToWords(e),t=8*e.length,r=1732584193,a=-271733879,o=-1732584194,i=271733878,u=0;u<n.length;u++)n[u]=16711935&(n[u]<<8|n[u]>>>24)|4278255360&(n[u]<<24|n[u]>>>8);n[t>>>5]|=128<<t%32,n[14+(64+t>>>9<<4)]=t;for(var l=v._ff,c=v._gg,s=v._hh,p=v._ii,u=0;u<n.length;u+=16){var g=r,d=a,m=o,f=i,r=l(r,a,o,i,n[u+0],7,-680876936),i=l(i,r,a,o,n[u+1],12,-389564586),o=l(o,i,r,a,n[u+2],17,606105819),a=l(a,o,i,r,n[u+3],22,-1044525330);r=l(r,a,o,i,n[u+4],7,-176418897),i=l(i,r,a,o,n[u+5],12,1200080426),o=l(o,i,r,a,n[u+6],17,-1473231341),a=l(a,o,i,r,n[u+7],22,-45705983),r=l(r,a,o,i,n[u+8],7,1770035416),i=l(i,r,a,o,n[u+9],12,-1958414417),o=l(o,i,r,a,n[u+10],17,-42063),a=l(a,o,i,r,n[u+11],22,-1990404162),r=l(r,a,o,i,n[u+12],7,1804603682),i=l(i,r,a,o,n[u+13],12,-40341101),o=l(o,i,r,a,n[u+14],17,-1502002290),r=c(r,a=l(a,o,i,r,n[u+15],22,1236535329),o,i,n[u+1],5,-165796510),i=c(i,r,a,o,n[u+6],9,-1069501632),o=c(o,i,r,a,n[u+11],14,643717713),a=c(a,o,i,r,n[u+0],20,-373897302),r=c(r,a,o,i,n[u+5],5,-701558691),i=c(i,r,a,o,n[u+10],9,38016083),o=c(o,i,r,a,n[u+15],14,-660478335),a=c(a,o,i,r,n[u+4],20,-405537848),r=c(r,a,o,i,n[u+9],5,568446438),i=c(i,r,a,o,n[u+14],9,-1019803690),o=c(o,i,r,a,n[u+3],14,-187363961),a=c(a,o,i,r,n[u+8],20,1163531501),r=c(r,a,o,i,n[u+13],5,-1444681467),i=c(i,r,a,o,n[u+2],9,-51403784),o=c(o,i,r,a,n[u+7],14,1735328473),r=s(r,a=c(a,o,i,r,n[u+12],20,-1926607734),o,i,n[u+5],4,-378558),i=s(i,r,a,o,n[u+8],11,-2022574463),o=s(o,i,r,a,n[u+11],16,1839030562),a=s(a,o,i,r,n[u+14],23,-35309556),r=s(r,a,o,i,n[u+1],4,-1530992060),i=s(i,r,a,o,n[u+4],11,1272893353),o=s(o,i,r,a,n[u+7],16,-155497632),a=s(a,o,i,r,n[u+10],23,-1094730640),r=s(r,a,o,i,n[u+13],4,681279174),i=s(i,r,a,o,n[u+0],11,-358537222),o=s(o,i,r,a,n[u+3],16,-722521979),a=s(a,o,i,r,n[u+6],23,76029189),r=s(r,a,o,i,n[u+9],4,-640364487),i=s(i,r,a,o,n[u+12],11,-421815835),o=s(o,i,r,a,n[u+15],16,530742520),r=p(r,a=s(a,o,i,r,n[u+2],23,-995338651),o,i,n[u+0],6,-198630844),i=p(i,r,a,o,n[u+7],10,1126891415),o=p(o,i,r,a,n[u+14],15,-1416354905),a=p(a,o,i,r,n[u+5],21,-57434055),r=p(r,a,o,i,n[u+12],6,1700485571),i=p(i,r,a,o,n[u+3],10,-1894986606),o=p(o,i,r,a,n[u+10],15,-1051523),a=p(a,o,i,r,n[u+1],21,-2054922799),r=p(r,a,o,i,n[u+8],6,1873313359),i=p(i,r,a,o,n[u+15],10,-30611744),o=p(o,i,r,a,n[u+6],15,-1560198380),a=p(a,o,i,r,n[u+13],21,1309151649),r=p(r,a,o,i,n[u+4],6,-145523070),i=p(i,r,a,o,n[u+11],10,-1120210379),o=p(o,i,r,a,n[u+2],15,718787259),a=p(a,o,i,r,n[u+9],21,-343485551),r=r+g>>>0,a=a+d>>>0,o=o+m>>>0,i=i+f>>>0}return T.endian([r,a,o,i])}var T,h,b,I;T=crypt,h=charenc_1.utf8,b=isBuffer_1,I=charenc_1.bin,v._ff=function(e,t,n,r,a,o,i){e=e+(t&n|~t&r)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._gg=function(e,t,n,r,a,o,i){e=e+(t&r|n&~r)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._hh=function(e,t,n,r,a,o,i){e=e+(t^n^r)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._ii=function(e,t,n,r,a,o,i){e=e+(n^(t|~r))+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=T.wordsToBytes(v(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):T.bytesToHex(e)}});let Global={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},pagesArray=[];const sdkTrackIdVal=()=>{var e;return Global.trackId||(e=Date.now().toString(),Global.trackId=e)};function randomUUID(){return"xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function timeToStr(e){e=new Date(e);return e.getFullYear()+`-${e.getMonth()+1<10?"0"+(e.getMonth()+1):e.getMonth()+1}-${e.getDate()<10?"0"+e.getDate():e.getDate()} ${e.getHours()<10?"0"+e.getHours():e.getHours()}:${e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes()}:`+(e.getSeconds()<10?"0"+e.getSeconds():e.getSeconds())}function getWebH5Info(e){var e=e.ua.toLowerCase(),t=window.location.hostname,n=document.title;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e);return e.includes("alipay")||e.includes("unionPay")||e.includes("onbuygz")||e.includes("onetravel"),e.includes("micromessenger")&&e.includes("miniprogram"),{name:n||"",packageName:t||"",version:"",carrier:"h5",ecology:"h5"}}function getWXInfo(){var e=uni.getAccountInfoSync(),t=uni.getAppBaseInfo();return{name:t.appName||"",packageName:e?e.miniProgram.appId:"",version:e?e.miniProgram.envVersion+e.miniProgram.version:"",carrier:"mini",ecology:"mini"}}function getAppInfo(t){var n=plus.runtime.version,n={name:t.appName,version:n||"",carrier:"app",packageName:"",ecology:""};if("android"===t.platform){let e="Android";var r=plus.android.runtimeMainActivity().getPackageName();t.romName.includes("HarmonyOS")&&(e="Harmony OS"),n.packageName=r||"",n.ecology=e}else"ios"===t.platform?(r=plus.ios.importClass("NSBundle").mainBundle().bundleIdentifier(),n.packageName=r||"",n.ecology="iOS"):n.ecology="unknown";return n}function getCurDeviceType(e,t){return"wx"!==t?(t=e.ua.toLowerCase(),/(windows|win32|win64|wow64)/.test(t)?1:(/(linux|android)/.test(t)||/(macintosh|mac os x|iphone|ipad|ipod)/.test(t),2)):"pc"===e.deviceType?1:2}function getDeviceInfo(e,t){return{lang: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:getCurDeviceType(e,t),network:""}}function getDeviceInfoError(){return{lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}}function getTrackObj(e){var t=getCurrentPages(),n=t[t.length-1],r=Global.platform;let a="",o="",i="",u="";if(r&&("web"===r||"h5"===r?(a=window.location.href,o=window.location.hostname,document.referrer&&(r=new URL(document.referrer),i=r||"",u=r.hostname||"")):(a=n.route,1<t.length&&(r=t[t.length-2],i=r.route),o=Global.domain||n.route)),n)return{path:n.route,busSegment:e.busSegment||"",module:e.module||"",properties:e.extend_param?JSON.stringify(e.extend_param):"",title:e.title||"",domain:o,url:a,visitPage:t.length,sourceDomain:u,sourceUrl:i}}function uUpdatePageExtraArray(e){var t=getCurrentPages();let n=t[t.length-1];t=pagesArray.findIndex(e=>e.path===n.route),e={path:n.route,properties:e.properties?JSON.stringify(e.properties):"",busSegment:e.busSegment||"",module:e.module||"",title:e.title||""};-1!==t?pagesArray[t]=e:pagesArray.push(e)}const AUTOTRACKTYPE={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},BPNPVUV="UNIBPNPVUVSrcData",BPNPVUVFail="UNIBPNPVUVFailData";let atDuration,atEnterTimeLong,atLoopTimeLong,cirtemp,atObj,atInterval=null,cUUId=null;function clearUAData(){clearInterval(atInterval),atDuration=0,atEnterTimeLong=0,atLoopTimeLong=0,cirtemp=1,atObj=null,atInterval=null,cUUId=0}const uAutoStartTrackPVData=e=>{atInterval?autoStopTrackPVUV():(clearUAData(),atObj=e,autoTrackData(AUTOTRACKTYPE.ENTER),atInterval=setInterval(()=>{autoTrackData(AUTOTRACKTYPE.LOOP)},Global.pageInterval))},autoStopTrackPVUV=()=>{autoTrackData(AUTOTRACKTYPE.LEAVE),clearInterval(atInterval)};function autoTrackData(e){e===AUTOTRACKTYPE.ENTER?(cirtemp=1,atDuration=0,atEnterTimeLong=Date.now(),atLoopTimeLong=atEnterTimeLong,cUUId=randomUUID()):e===AUTOTRACKTYPE.LOOP?(cirtemp=2,atDuration=15,atLoopTimeLong=Date.now()):e===AUTOTRACKTYPE.LEAVE&&(cirtemp=3,atDuration=Math.ceil((Date.now()-atLoopTimeLong)/1e3)),atObj&&insertPVUVData({busSegment:atObj.busSegment||"",circulation:cirtemp,ctk:"",domain:atObj.domain,duration:atDuration,module:atObj.module||"",path:atObj.path,url:atObj.url,sourceDomain:atObj.sourceDomain,sourceUrl:atObj.sourceUrl,properties:atObj.properties,title:atObj.title,traceId:"",trackId:sdkTrackIdVal(),visitPage:atObj.visitPage,visitTime:timeToStr(atEnterTimeLong),pageUUId:cUUId},cUUId)}function insertPVUVData(e,t){var n,r=uni.getStorageSync(BPNPVUV),r=r?JSON.parse(r):[];0<r.length&&-1!==(n=r.findIndex(e=>e.pageUUId===t))?r[n]={...r[n],...e}:r.push(e),uni.setStorageSync(BPNPVUV,JSON.stringify(r))}function autoPageObj(t,e,n){var r=pagesArray.find(e=>e.path===t),a=Global.platform;let o="",i="",u="",l="";return a&&("web"===a||"h5"===a?(o=window.location.href,i=window.location.hostname,document.referrer&&(a=new URL(document.referrer),u=a||"",l=a.hostname||"")):(o=t,1<e&&(a=n[e-2],u=a.route),i=Global.domain||t)),{path:r&&r.path?r.path:t,busSegment:r&&r.busSegment?r.busSegment:Global.busSegment||"",module:r&&r.module?r.module:Global.module||"",properties:r&&r.properties?r.properties:"",domain:i,url:o,visitPage:e,sourceDomain:l,sourceUrl:u,title:r&&r.title?r.title:""}}function queryTrackDataUpload(){var e=uni.getStorageSync(BPNPVUV),e=(uni.setStorageSync(BPNPVUV,""),e?JSON.parse(e):[]),t=[],n=uni.getStorageSync(BPNPVUVFail),n=n?JSON.parse(n):[];e.length&&t.push(...e),n.length&&t.push(...n),t&&t.length&&(t.forEach(e=>{delete e.pageUUId}),reportTrackEventServer("track",t,BPNPVUVFail))}function setReportUrl(e){return"test"!==e?{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"}:{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"}}const deepCopy=e=>{if("object"!=typeof e)return e;var t=Array.isArray(e)?[]:{};for(const n in e)"object"==typeof e[n]?t[n]=deepCopy(e[n]):t[n]=e[n];return t},cacheData=[],addCache=e=>{cacheData.push(e)},getCache=()=>deepCopy(cacheData),clearCache=()=>{cacheData.length=0},BPNEvent="UNIBPNEventSrcData",BPNEventFail="UNIBPNEventFailData";let timerCustom;function getCurPath(){var e=getCurrentPages(),e=e[e.length-1];return e?e.route:"/"}function eventCommonStore(e){var t=e.$page||"",n=t.path||getCurPath(),t={utm:e.$utm||"",duration:"",element:e.$element||null,eventId:e.$event_id||"",event:e.$event_code||"",groupId:"",busSegment:e.$busSegment,module:e.$module,page:{domain:t.domain||"",pageId:md5(n),path:n||"",title:t.title||"",url:n||""},properties:e.$extend_param?JSON.stringify(e.$extend_param):"",traceId:"",trackId:sdkTrackIdVal(),triggerTime:timeToStr(Date.now())};addCache(t),clearTimeout(timerCustom),timerCustom=setTimeout(()=>{var e=getCache();e.length&&(insertEventData(e),clearCache())},2e3)}function insertEventData(e){console.log("写入Event数据 ",e);var t=uni.getStorageSync(BPNEvent),t=t?JSON.parse(t):[];e&&e.length&&(t.concat(e),uni.setStorageSync(BPNEvent,JSON.stringify(t)))}function queryEventDataUpload(){var e=uni.getStorageSync(BPNEvent),e=(uni.setStorageSync(BPNEvent,""),e?JSON.parse(e):[]),t=[],n=uni.getStorageSync(BPNEventFail),n=n?JSON.parse(n):[];e.length&&t.push(...e),n.length&&t.push(...n),t&&t.length&&reportTrackEventServer("event",t,BPNEventFail)}let startTime=0,enterTimeLong=0,loopTimeLong=0,cirtemp$1=-1,mObj=null,umlInterval=null,cUUId$1=0;function clearUMlData(){clearInterval(umlInterval),startTime=0,enterTimeLong=0,loopTimeLong=0,cirtemp$1=1,mObj=null,umlInterval=null,cUUId$1=0}const uStartTrackPVData=e=>{umlInterval?uStopTrackPVData():e&&(clearUMlData(),uTrackPVData(AUTOTRACKTYPE.ENTER,e),umlInterval=setInterval(()=>{uTrackPVData(AUTOTRACKTYPE.LOOP,null)},Global.pageInterval))},uStopTrackPVData=()=>{uTrackPVData(AUTOTRACKTYPE.LEAVE),clearUMlData()};function uTrackPVData(e,t){e===AUTOTRACKTYPE.ENTER?(cUUId$1=randomUUID(),enterTimeLong=Date.now(),loopTimeLong=enterTimeLong,mObj=getTrackObj(t)):e===AUTOTRACKTYPE.LOOP?(cirtemp$1=2,startTime=15,loopTimeLong=Date.now()):e===AUTOTRACKTYPE.LEAVE&&(cirtemp$1=3,startTime=Math.ceil((Date.now()-loopTimeLong)/1e3));t={busSegment:mObj.busSegment,circulation:cirtemp$1,domain:mObj.domain,duration:startTime,module:mObj.module,path:mObj.path,properties:mObj.properties,sourceDomain:mObj.sourceDomain,sourceUrl:mObj.sourceUrl,title:mObj.title,traceId:"",trackId:sdkTrackIdVal(),url:mObj.url,visitPage:mObj.visitPage,visitTime:timeToStr(enterTimeLong),utm:"",pageUUId:cUUId$1};insertPVUVData(t,cUUId$1)}var name="visual-buried-point-platform-uni",version="1.0.0-alpha.15",lsi="f880f051db0e276f9777a7cc4d4c947c#1.0.0-alpha.15",description="To make it easy for you to get started with GitLab, here's a list of recommended next steps.",main="dist/cjs/buried-point-uni.js",module="dist/esm/buried-point-uni.js",scripts={dev:"rollup -c -w",build:"rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.js"},repository={type:"git",url:""},files=["dist"],keywords=[],author="",license="MIT",dependencies={md5:"^2.3.0"},devDependencies={"@babel/core":"^7.5.5","@rollup/plugin-json":"^6.0.1","babel-preset-es2015":"^6.24.1",rollup:"^1.20.2","rollup-plugin-babel":"^4.3.3","rollup-plugin-commonjs":"^10.0.2","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-replace":"^2.2.0","rollup-plugin-uglify":"^6.0.2",webpack:"^4.39.2"},pk={name:name,version:version,lsi:lsi,description:description,main:main,module:module,scripts:scripts,repository:repository,files:files,keywords:keywords,author:author,license:license,dependencies:dependencies,devDependencies:devDependencies};function uniInterceptorListener(){uni.addInterceptor("navigateTo",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}}),uni.addInterceptor("switchTab",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}})}let pathExist=!1;function routerMsgHandler(e){if(!Global.isCompatible)if("pv"===e){var t=getCurrentPages();const n=t[t.length-1];Global.signTrackArray&&Global.signTrackArray.length&&(pathExist=Global.signTrackArray.find(e=>e===n.route))?pathExist=!0:(pathExist=!1,t=autoPageObj(n.route,t.length,t),uAutoStartTrackPVData(t))}else"leave"!==e||pathExist||autoStopTrackPVUV()}const localLsi=pk.lsi;let _comInfo={distinctId:"",anonymousId:""},appData={},deviceData={},uglInterval=null;function init(e){var t;e?(t=setReportUrl(e.env||""),Global.upEventUrl=t.reportUrl,Global.upTrackUrl=t.reportTrackUrl,(!e.flushInterval||e.flushInterval<5)&&(e.flushInterval=15),(!e.pageInterval||e.pageInterval<5)&&(e.pageInterval=15),Object.assign(Global,e),getBaseicInfo(),_comInfo.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",_comInfo.anonymousId=uni.getStorageSync("v_anonId"),_comInfo.anonymousId||(_comInfo.anonymousId=randomUUID(),uni.setStorageSync("v_anonId",_comInfo.anonymousId)),sdkTrackIdVal()):console.log("init config error, please check config!"),startGlobalTime(),uniInterceptorListener()}function startGlobalTime(){clearInterval(uglInterval),uglInterval=setInterval(()=>{queryEventDataUpload(),queryTrackDataUpload()},Global.flushInterval||15e3)}function setUserId(e){e?(_comInfo.distinctId=e,uni.setStorageSync("v_userId",e)):(_comInfo.distinctId="",uni.setStorageSync("v_userId",""))}function getTrackId(){return sdkTrackIdVal()}function setCustomEvent(e){eventCommonStore(e)}function onStartTrack(e){uStartTrackPVData(e)}function onDestroyTrack(){uStopTrackPVData()}function setPageExtraObj(e){uUpdatePageExtraArray(e)}function reportTrackEventServer(e,t,n){var r;e?(r={...r=commonData(t),dataAbstract:md5(JSON.stringify(r))},uni.request({url:"event"===e?Global.upEventUrl:Global.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:Global.token,projectId:Global.token},data:r,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(n,JSON.stringify(t)):uni.setStorageSync(n,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(n,JSON.stringify(t))}})):console.error("please set upload data upType")}function commonData(e){return{app:appData,data:e,device:deviceData,lsi:localLsi,projectId:Global.token,userAgent:Global.uAgent||"",anonymousId:_comInfo.anonymousId,userId:_comInfo.distinctId}}function getBaseicInfo(){uni.getSystemInfo({success:function(e){Global.uAgent=e.ua;var t,n=e.uniPlatform;n.includes("app")?(Global.platform=e.osName,appData=getAppInfo(e)):n.includes("web")||n.includes("h5")?(Global.platform=n,t=getWebH5Info(e),appData={...t,version:Global.version||"unknown"}):n.includes("weixin")&&(Global.platform="weixin",appData=getWXInfo()),deviceData=getDeviceInfo(e,Global.platform)},fail:function(e){deviceData=getDeviceInfoError()},complete:function(){uni.getNetworkType({success(e){deviceData.network=e.networkType}})}})}export{getTrackId,init,onDestroyTrack,onStartTrack,reportTrackEventServer,setCustomEvent,setPageExtraObj,setUserId};
@@ -1 +0,0 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).BuriedPointUni={})}(this,function(e){"use strict";function t(e,t){return e(t={exports:{}},t.exports),t.exports}function M(e){return null!=e&&(o(e)||"function"==typeof(t=e).readFloatLE&&"function"==typeof t.slice&&o(t.slice(0,0))||!!e._isBuffer);var t}var C=t(function(e){var i,n;i="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=[];0<e;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 t=[],n=0;n<e.length;n+=3)for(var r=e[n]<<16|e[n+1]<<8|e[n+2],o=0;o<4;o++)8*n+6*o<=8*e.length?t.push(i.charAt(r>>>6*(3-o)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,r=0;n<e.length;r=++n%4)0!=r&&t.push((i.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|i.indexOf(e.charAt(n))>>>6-2*r);return t}},e.exports=n}),n={utf8:{stringToBytes:function(e){return n.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(n.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("")}}},r=n;function o(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var V=t(function(e){function v(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?I:y).stringToBytes(e):S(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=h.bytesToWords(e),t=8*e.length,r=1732584193,o=-271733879,i=-1732584194,a=271733878,u=0;u<n.length;u++)n[u]=16711935&(n[u]<<8|n[u]>>>24)|4278255360&(n[u]<<24|n[u]>>>8);n[t>>>5]|=128<<t%32,n[14+(64+t>>>9<<4)]=t;for(var s=v._ff,c=v._gg,l=v._hh,g=v._ii,u=0;u<n.length;u+=16){var p=r,d=o,f=i,m=a,r=s(r,o,i,a,n[u+0],7,-680876936),a=s(a,r,o,i,n[u+1],12,-389564586),i=s(i,a,r,o,n[u+2],17,606105819),o=s(o,i,a,r,n[u+3],22,-1044525330);r=s(r,o,i,a,n[u+4],7,-176418897),a=s(a,r,o,i,n[u+5],12,1200080426),i=s(i,a,r,o,n[u+6],17,-1473231341),o=s(o,i,a,r,n[u+7],22,-45705983),r=s(r,o,i,a,n[u+8],7,1770035416),a=s(a,r,o,i,n[u+9],12,-1958414417),i=s(i,a,r,o,n[u+10],17,-42063),o=s(o,i,a,r,n[u+11],22,-1990404162),r=s(r,o,i,a,n[u+12],7,1804603682),a=s(a,r,o,i,n[u+13],12,-40341101),i=s(i,a,r,o,n[u+14],17,-1502002290),r=c(r,o=s(o,i,a,r,n[u+15],22,1236535329),i,a,n[u+1],5,-165796510),a=c(a,r,o,i,n[u+6],9,-1069501632),i=c(i,a,r,o,n[u+11],14,643717713),o=c(o,i,a,r,n[u+0],20,-373897302),r=c(r,o,i,a,n[u+5],5,-701558691),a=c(a,r,o,i,n[u+10],9,38016083),i=c(i,a,r,o,n[u+15],14,-660478335),o=c(o,i,a,r,n[u+4],20,-405537848),r=c(r,o,i,a,n[u+9],5,568446438),a=c(a,r,o,i,n[u+14],9,-1019803690),i=c(i,a,r,o,n[u+3],14,-187363961),o=c(o,i,a,r,n[u+8],20,1163531501),r=c(r,o,i,a,n[u+13],5,-1444681467),a=c(a,r,o,i,n[u+2],9,-51403784),i=c(i,a,r,o,n[u+7],14,1735328473),r=l(r,o=c(o,i,a,r,n[u+12],20,-1926607734),i,a,n[u+5],4,-378558),a=l(a,r,o,i,n[u+8],11,-2022574463),i=l(i,a,r,o,n[u+11],16,1839030562),o=l(o,i,a,r,n[u+14],23,-35309556),r=l(r,o,i,a,n[u+1],4,-1530992060),a=l(a,r,o,i,n[u+4],11,1272893353),i=l(i,a,r,o,n[u+7],16,-155497632),o=l(o,i,a,r,n[u+10],23,-1094730640),r=l(r,o,i,a,n[u+13],4,681279174),a=l(a,r,o,i,n[u+0],11,-358537222),i=l(i,a,r,o,n[u+3],16,-722521979),o=l(o,i,a,r,n[u+6],23,76029189),r=l(r,o,i,a,n[u+9],4,-640364487),a=l(a,r,o,i,n[u+12],11,-421815835),i=l(i,a,r,o,n[u+15],16,530742520),r=g(r,o=l(o,i,a,r,n[u+2],23,-995338651),i,a,n[u+0],6,-198630844),a=g(a,r,o,i,n[u+7],10,1126891415),i=g(i,a,r,o,n[u+14],15,-1416354905),o=g(o,i,a,r,n[u+5],21,-57434055),r=g(r,o,i,a,n[u+12],6,1700485571),a=g(a,r,o,i,n[u+3],10,-1894986606),i=g(i,a,r,o,n[u+10],15,-1051523),o=g(o,i,a,r,n[u+1],21,-2054922799),r=g(r,o,i,a,n[u+8],6,1873313359),a=g(a,r,o,i,n[u+15],10,-30611744),i=g(i,a,r,o,n[u+6],15,-1560198380),o=g(o,i,a,r,n[u+13],21,1309151649),r=g(r,o,i,a,n[u+4],6,-145523070),a=g(a,r,o,i,n[u+11],10,-1120210379),i=g(i,a,r,o,n[u+2],15,718787259),o=g(o,i,a,r,n[u+9],21,-343485551),r=r+p>>>0,o=o+d>>>0,i=i+f>>>0,a=a+m>>>0}return h.endian([r,o,i,a])}var h,y,S,I;h=C,y=r.utf8,S=M,I=r.bin,v._ff=function(e,t,n,r,o,i,a){e=e+(t&n|~t&r)+(o>>>0)+a;return(e<<i|e>>>32-i)+t},v._gg=function(e,t,n,r,o,i,a){e=e+(t&r|n&~r)+(o>>>0)+a;return(e<<i|e>>>32-i)+t},v._hh=function(e,t,n,r,o,i,a){e=e+(t^n^r)+(o>>>0)+a;return(e<<i|e>>>32-i)+t},v._ii=function(e,t,n,r,o,i,a){e=e+(n^(t|~r))+(o>>>0)+a;return(e<<i|e>>>32-i)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=h.wordsToBytes(v(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):h.bytesToHex(e)}});let c={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},l=[];const i=()=>{var e;return c.trackId||(e=Date.now().toString(),c.trackId=e)};function a(){return"xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function u(e){e=new Date(e);return e.getFullYear()+`-${e.getMonth()+1<10?"0"+(e.getMonth()+1):e.getMonth()+1}-${e.getDate()<10?"0"+e.getDate():e.getDate()} ${e.getHours()<10?"0"+e.getHours():e.getHours()}:${e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes()}:`+(e.getSeconds()<10?"0"+e.getSeconds():e.getSeconds())}const s={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},g="UNIBPNPVUVSrcData",J="UNIBPNPVUVFailData";let p,d,f,m,v,h=null,y=null;const j=e=>{h?$():(clearInterval(h),p=0,d=0,f=0,m=1,v=null,h=null,y=0,v=e,S(s.ENTER),h=setInterval(()=>{S(s.LOOP)},c.pageInterval))},$=()=>{S(s.LEAVE),clearInterval(h)};function S(e){e===s.ENTER?(m=1,p=0,d=Date.now(),f=d,y=a()):e===s.LOOP?(m=2,p=15,f=Date.now()):e===s.LEAVE&&(m=3,p=Math.ceil((Date.now()-f)/1e3)),v&&R({busSegment:v.busSegment||"",circulation:m,ctk:"",domain:v.domain,duration:p,module:v.module||"",path:v.path,url:v.url,sourceDomain:v.sourceDomain,sourceUrl:v.sourceUrl,properties:v.properties,title:v.title,traceId:"",trackId:i(),visitPage:v.visitPage,visitTime:u(d),pageUUId:y},y)}function R(e,t){var n,r=uni.getStorageSync(g),r=r?JSON.parse(r):[];0<r.length&&-1!==(n=r.findIndex(e=>e.pageUUId===t))?r[n]={...r[n],...e}:r.push(e),uni.setStorageSync(g,JSON.stringify(r))}const H=e=>{if("object"!=typeof e)return e;var t=Array.isArray(e)?[]:{};for(const n in e)"object"==typeof e[n]?t[n]=H(e[n]):t[n]=e[n];return t},I=[],z=e=>{I.push(e)},F=()=>H(I),q=()=>{I.length=0},b="UNIBPNEventSrcData",W="UNIBPNEventFailData";let K;function Y(e){var t=e.$page||"",n=t.path||((n=(n=getCurrentPages())[n.length-1])?n.route:"/"),t={utm:e.$utm||"",duration:"",element:e.$element||null,eventId:e.$event_id||"",event:e.$event_code||"",groupId:"",busSegment:e.$busSegment,module:e.$module,page:{domain:t.domain||"",pageId:V(n),path:n||"",title:t.title||"",url:n||""},properties:e.$extend_param?JSON.stringify(e.$extend_param):"",traceId:"",trackId:i(),triggerTime:u(Date.now())};z(t),clearTimeout(K),K=setTimeout(()=>{var e,t=F();t.length&&(t=t,console.log("写入Event数据 ",t),e=(e=uni.getStorageSync(b))?JSON.parse(e):[],t&&t.length&&(e.concat(t),uni.setStorageSync(b,JSON.stringify(e))),q())},2e3)}let w=0,T=0,k=0,N=-1,x=null,U=null,O=0;function Z(){clearInterval(U),w=0,T=0,k=0,N=1,x=null,U=null,O=0}const G=()=>{P(s.LEAVE),Z()};function P(e,t){e===s.ENTER?(O=a(),T=Date.now(),k=T,x=function(e){var t=getCurrentPages(),n=t[t.length-1],r=c.platform;let o="",i="",a="",u="";if(r&&("web"===r||"h5"===r?(o=window.location.href,i=window.location.hostname,document.referrer&&(r=new URL(document.referrer),a=r||"",u=r.hostname||"")):(o=n.route,1<t.length&&(r=t[t.length-2],a=r.route),i=c.domain||n.route)),n)return{path:n.route,busSegment:e.busSegment||"",module:e.module||"",properties:e.extend_param?JSON.stringify(e.extend_param):"",title:e.title||"",domain:i,url:o,visitPage:t.length,sourceDomain:u,sourceUrl:a}}(t)):e===s.LOOP?(N=2,w=15,k=Date.now()):e===s.LEAVE&&(N=3,w=Math.ceil((Date.now()-k)/1e3));t={busSegment:x.busSegment,circulation:N,domain:x.domain,duration:w,module:x.module,path:x.path,properties:x.properties,sourceDomain:x.sourceDomain,sourceUrl:x.sourceUrl,title:x.title,traceId:"",trackId:i(),url:x.url,visitPage:x.visitPage,visitTime:u(T),utm:"",pageUUId:O};R(t,O)}let E=!1;function A(e){if(!c.isCompatible)if("pv"===e){var t=getCurrentPages();const n=t[t.length-1];c.signTrackArray&&c.signTrackArray.length&&(E=c.signTrackArray.find(e=>e===n.route))?E=!0:(E=!1,t=function(t,e,n){var r=l.find(e=>e.path===t),o=c.platform;let i="",a="",u="",s="";return o&&("web"===o||"h5"===o?(i=window.location.href,a=window.location.hostname,document.referrer&&(o=new URL(document.referrer),u=o||"",s=o.hostname||"")):(i=t,1<e&&(o=n[e-2],u=o.route),a=c.domain||t)),{path:r&&r.path?r.path:t,busSegment:r&&r.busSegment?r.busSegment:c.busSegment||"",module:r&&r.module?r.module:c.module||"",properties:r&&r.properties?r.properties:"",domain:a,url:i,visitPage:e,sourceDomain:s,sourceUrl:u,title:r&&r.title?r.title:""}}(n.route,t.length,t),j(t))}else"leave"!==e||E||$()}const Q="f880f051db0e276f9777a7cc4d4c947c#1.0.0-alpha.15";let B={distinctId:"",anonymousId:""},_={},D={},X=null;function L(e,t,n){var r;e?(r=t,r={...r={app:_,data:r,device:D,lsi:Q,projectId:c.token,userAgent:c.uAgent||"",anonymousId:B.anonymousId,userId:B.distinctId},dataAbstract:V(JSON.stringify(r))},uni.request({url:"event"===e?c.upEventUrl:c.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:c.token,projectId:c.token},data:r,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(n,JSON.stringify(t)):uni.setStorageSync(n,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(n,JSON.stringify(t))}})):console.error("please set upload data upType")}e.getTrackId=function(){return i()},e.init=function(e){var t;e?(t="test"!==(e.env||"")?{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"}:{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"},c.upEventUrl=t.reportUrl,c.upTrackUrl=t.reportTrackUrl,(!e.flushInterval||e.flushInterval<5)&&(e.flushInterval=15),(!e.pageInterval||e.pageInterval<5)&&(e.pageInterval=15),Object.assign(c,e),uni.getSystemInfo({success:function(e){c.uAgent=e.ua;var t,n,r,o=e.uniPlatform;o.includes("app")?(c.platform=e.osName,_=function(t){var n=plus.runtime.version,n={name:t.appName,version:n||"",carrier:"app",packageName:"",ecology:""};if("android"===t.platform){let e="Android";var r=plus.android.runtimeMainActivity().getPackageName();t.romName.includes("HarmonyOS")&&(e="Harmony OS"),n.packageName=r||"",n.ecology=e}else"ios"===t.platform?(r=plus.ios.importClass("NSBundle").mainBundle().bundleIdentifier(),n.packageName=r||"",n.ecology="iOS"):n.ecology="unknown";return n}(e)):o.includes("web")||o.includes("h5")?(c.platform=o,r=(r=e).ua.toLowerCase(),n=window.location.hostname,t=document.title,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(r),r.includes("alipay")||r.includes("unionPay")||r.includes("onbuygz")||r.includes("onetravel"),r.includes("micromessenger")&&r.includes("miniprogram"),r={name:t||"",packageName:n||"",version:"",carrier:"h5",ecology:"h5"},_={...r,version:c.version||"unknown"}):o.includes("weixin")&&(c.platform="weixin",_=(t=uni.getAccountInfoSync(),{name:uni.getAppBaseInfo().appName||"",packageName:t?t.miniProgram.appId:"",version:t?t.miniProgram.envVersion+t.miniProgram.version:"",carrier:"mini",ecology:"mini"})),D=(n=e,r=c.platform,{lang:n.osLanguage||n.hostLanguage,brand:n.deviceBrand+" "+n.deviceModel,os:n.osName,osVersion:n.osVersion,resolution:n.screenWidth+"x"+n.screenHeight,browser:n.browserName,browserVersion:n.browserVersion,color:"",deviceId:n.deviceId,deviceType:(n=n,"wx"!==(r=r)?(r=n.ua.toLowerCase(),/(windows|win32|win64|wow64)/.test(r)?1:(/(linux|android)/.test(r)||/(macintosh|mac os x|iphone|ipad|ipod)/.test(r),2)):"pc"===n.deviceType?1:2),network:""})},fail:function(e){D={lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}},complete:function(){uni.getNetworkType({success(e){D.network=e.networkType}})}}),B.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",B.anonymousId=uni.getStorageSync("v_anonId"),B.anonymousId||(B.anonymousId=a(),uni.setStorageSync("v_anonId",B.anonymousId)),i()):console.log("init config error, please check config!"),clearInterval(X),X=setInterval(()=>{var e,t,n;e=uni.getStorageSync(b),uni.setStorageSync(b,""),e=e?JSON.parse(e):[],n=[],t=(t=uni.getStorageSync(W))?JSON.parse(t):[],e.length&&n.push(...e),t.length&&n.push(...t),n&&n.length&&L("event",n,W),e=uni.getStorageSync(g),uni.setStorageSync(g,""),e=e?JSON.parse(e):[],t=[],n=(n=uni.getStorageSync(J))?JSON.parse(n):[],e.length&&t.push(...e),n.length&&t.push(...n),t&&t.length&&(t.forEach(e=>{delete e.pageUUId}),L("track",t,J))},c.flushInterval||15e3),uni.addInterceptor("navigateTo",{invoke(e){A("leave")},success(e){A("pv")}}),uni.addInterceptor("switchTab",{invoke(e){A("leave")},success(e){A("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){A("leave")},success(e){A("pv")}})},e.onDestroyTrack=function(){G()},e.onStartTrack=function(e){e=e,U?G():e&&(Z(),P(s.ENTER,e),U=setInterval(()=>{P(s.LOOP,null)},c.pageInterval))},e.reportTrackEventServer=L,e.setCustomEvent=function(e){Y(e)},e.setPageExtraObj=function(e){{var n=getCurrentPages();let t=n[n.length-1];n=l.findIndex(e=>e.path===t.route),e={path:t.route,properties:e.properties?JSON.stringify(e.properties):"",busSegment:e.busSegment||"",module:e.module||"",title:e.title||""},-1!==n?l[n]=e:l.push(e)}},e.setUserId=function(e){e?(B.distinctId=e,uni.setStorageSync("v_userId",e)):(B.distinctId="",uni.setStorageSync("v_userId",""))},Object.defineProperty(e,"__esModule",{value:!0})});