visual-buried-point-platform-uni 1.0.0-alpha.3 → 1.0.0-alpha.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,25 +1,29 @@
1
1
  ## Uni版自定义埋点SDK集成文档
2
2
 
3
+ ### SDK更新日志
4
+ - v1.0.0-alpha.07 最新uni、终端通用埋点sdk;
5
+ - v1.0.0-alpha.08 自定义上报数据结构删除path字段;
6
+ - v1.0.0-alpha.29 调整SDK内部PVUV采集模式,分原有start方法采集及自动采集,支持获取埋点sdk内的跟踪id;
7
+
3
8
  ### 1、引入方式
4
9
 
5
10
  ```js
6
- npm install visual-buried-point-platform-uni -S --registry=http://verdaccio.gogdev.cn/
7
- 工具-构建npm
11
+ //内网npm链接:http://verdaccio.gogdev.cn/
12
+ npm install visual-buried-point-platform-uni
8
13
  ```
9
14
 
10
15
  ### 2、初始化方式
11
16
 
12
- **app.js**
13
-
14
17
  ```js
15
- //require引入
16
- import { init } from 'visual-buried-point-platform-uni'
18
+ import { BuriedPointUni } from 'visual-buried-point-platform-uni'
17
19
  onLaunch: function() {
18
20
  //初始化sdk
19
- init({
21
+ BuriedPointUni.init({
20
22
  env: 'test', //环境变量 test production
21
23
  token: '3212414516342554624', //热果平台-可视化埋点管理端-创建对应的项目生成.
22
- sourceDomain: 'com.gzdzswy.onetravel', // 非必填,访问来源域名,取优先级:单次调用上报值 > 全局初始化值
24
+ domain: 'com.gzdzswy.onetravel', // 非必填,访问来源域名,取优先级:单次调用上报值 > 全局初始化值
25
+ isCompatible: true, // 是否兼容老方案埋点,默认兼容true,自动采集则改为false
26
+ signTrackArray: [], // 自动采集但需要单独埋点的页面path
23
27
  })
24
28
  }
25
29
  });
@@ -31,29 +35,34 @@ onLaunch: function() {
31
35
 
32
36
  ```js
33
37
  // 应用在注册或登录成功后,可调用下面API设置用户ID,后续产生的统计事件将会与该用户关联起来
34
- setUserId("登录成功-用户ID")
38
+ import { BuriedPointUni } from 'visual-buried-point-platform-uni'
39
+ BuriedPointUni.setUserId("登录成功-用户ID")
35
40
  ```
36
41
 
37
42
  **示例:**
38
43
 
39
44
  ```js
40
- import { setUserId } from 'visual-buried-point-platform-uni'
41
- setUserId(123456);
45
+ import { BuriedPointUni } from 'visual-buried-point-platform-uni'
46
+ BuriedPointUni.setUserId(123456);
42
47
  ```
43
48
 
44
49
  **注:为保持数据统计精确,在退出登录的时候建议调用一次清空:**
45
50
 
46
51
  ```js
47
- setUserId("");
52
+ BuriedPointUni.BuriedPointUni.setUserId("");
48
53
  ```
54
+ ## 4.获取埋点SDK内跟踪ID
49
55
 
56
+ ```js
57
+ import { BuriedPointUni } from 'visual-buried-point-platform-uni'
58
+ BuriedPointUni.getTrackId()
59
+ ```
50
60
 
51
-
52
- ### 4、自定义事件上报
61
+ ## 5、自定义事件上报
53
62
 
54
63
  - sdk初始化后,可通过 ***setCustomEvent()*** 方法上报自定义埋点事件,并为事件添加属性值:
55
64
 
56
- #### 4.1 事件类型:
65
+ #### 5.1 事件类型:
57
66
 
58
67
  - 仅能选择埋点提供的事件类型,各事件类型的触发、上报由各业务平台埋点自行确认。事件类型如下:
59
68
  - **搜索事件【 search 】**
@@ -63,7 +72,7 @@ setUserId("");
63
72
 
64
73
  ```js
65
74
  // 调用自定义上报
66
- setCustomEvent(data)
75
+ BuriedPointUni.setCustomEvent(data)
67
76
  ```
68
77
 
69
78
  **配置:**
@@ -74,6 +83,7 @@ setCustomEvent(data)
74
83
  | $extend_param | 否 | 扩展字段,建议根据业务需求填上 |
75
84
  | $busSegment | 否 | 业务板块 【表1】各自业务板块 |
76
85
  | $module | 否 | 业务模块【表1】各自业务模块 |
86
+ | $event_code | 是 | 对应创建的事件标识符 |
77
87
 
78
88
  表1
79
89
 
@@ -96,36 +106,34 @@ data: JSON字符串
96
106
  $extend_param: 扩展参数(JSON字符串) 【非必填字段,建议根据业务需求填上】
97
107
  $busSegment: 业务板块 【非必填字段,建议业务填上, 否则数据统计可能出现缺失】
98
108
  $module: 业务模块 【非必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
99
- $ctk: 渠道推广编码 【非必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
109
+ $event_code: 渠道推广编码 【非必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
100
110
  $duration: 停留时长 【非必填字段】
101
111
  $event_code: 事件标识符 【必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
102
112
  $page: 当前页对象 【非必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
103
- $path: 埋点组件的路径 【必填字段,建议根据业务填上, 否则数据统计可能出现缺失】
104
113
  }
114
+ import { BuriedPointUni } from 'visual-buried-point-platform-uni'
105
115
  // 参考:【点击事件】
106
116
  const params = {
107
117
  $event_id: "3213106620739878912",
118
+ $event_code: "2139oNf0te6kf0DvltL",
108
119
  $busSegment: 1,
109
120
  $module: 1,
110
- $ctk: "",
111
121
  $extend_param: {
112
122
  title: "自定义[点击事件]上报-点击_密码登录按钮",
113
123
  clickContent: "密码登录",
114
124
  ....
115
125
  ....
116
126
  },
117
- $event_code: "",
118
127
  $page: {
119
128
  domain: "",
120
129
  path: "",
121
130
  title: "",
122
131
  },
123
- $path: "",
124
132
  }
125
- setCustomEvent(params)
133
+ BuriedPointUni.setCustomEvent(params)
126
134
  ```
127
135
 
128
- ### 5、流量上报
136
+ ## 6、流量上报
129
137
 
130
138
  - sdk初始化后,可通过**onStartTrack(params)** 方法注册上报流量,并为上报添加属性值:
131
139
 
@@ -133,26 +141,20 @@ setCustomEvent(params)
133
141
 
134
142
  **配置:**【以下配置参数建议上报】
135
143
 
136
- | 参数 | 必填 | 类型 | 描述 |
137
- | ------------ | ---- | ------------------- | ---------------- |
138
- | domain | | string | 域名 |
139
- | path | | string | 路径 |
140
- | circulation | 否 | number | 页面访问类型 |
141
- | ctk | 否 | string | 渠道推广编码 |
142
- | duration | 否 | number | 停留时长 |
143
- | busSegment | 否 | string | 业务板块 【表1】 |
144
- | module | 否 | string | 业务模块 【表1】 |
145
- | extend_param | 否 | JSON对象 {} | 扩展参数 |
146
- | sourceDomain | 否 | string | 访问来源域名 |
147
- | sourceUrl | 否 | string | 访问来源url |
148
- | title | 否 | string | 页面名称 |
149
- | traceId | 否 | string | 追踪id |
150
- | visitPage | 否 | number | 访问深度 |
151
- | visitTime | 否 | yyyy-MM-dd HH:mm:ss | 访问时间 |
144
+ | 参数 | 必填 | 类型 | 描述 |
145
+ | ------------ | ---- | ----------- | ---------------- |
146
+ | domain | | string | 域名 |
147
+ | busSegment | | string | 业务板块 【表1】 |
148
+ | module | 否 | string | 业务模块 【表1】 |
149
+ | extend_param | 否 | JSON对象 {} | 扩展参数 |
150
+ | sourceDomain | 否 | string | 访问来源域名 |
151
+ | sourceUrl | 否 | string | 访问来源url |
152
+ | title | 否 | string | 页面名称 |
152
153
 
153
154
  **示例:**
154
155
 
155
156
  ```js
157
+ import { BuriedPointUni } from 'visual-buried-point-platform-uni'
156
158
  // 注:
157
159
  data: JSON对象
158
160
  const params = {
@@ -167,26 +169,27 @@ const params = {
167
169
  business_id: 222, //商户id 【...】
168
170
  }
169
171
  };
170
- onStartTrack(params)
172
+ BuriedPointUni.onStartTrack(params)
171
173
  ```
172
174
 
173
- **销毁上报流量:调用onDestroyTrack()进行销毁**
175
+ **销毁流量上报:调用onDestroyTrack()进行销毁**
174
176
 
175
177
  **示例:**
176
178
 
177
179
  ```js
178
- onDestroyTrack()
180
+ import { BuriedPointUni } from 'visual-buried-point-platform-uni'
181
+ BuriedPointUni.onDestroyTrack()
179
182
  ```
180
183
 
181
184
  注: 上报数据是否成功可查看NetWork栏,调用流量上报 **track 接口** 和 自定义上报 **event 接口**的 response
182
185
 
183
- #### 6、埋点后台管理系统
186
+ ## 7、埋点后台管理系统
184
187
 
185
188
  ##### 云测管理端地址
186
189
 
187
190
  - chameleon.gcongo.com.cn
188
191
 
189
- #### 7、SDK 文档
192
+ ## 8、SDK 文档
190
193
 
191
194
  http://verdaccio.gogdev.cn/-/web/detail/visual-buried-point-platform-uni
192
195
 
@@ -0,0 +1 @@
1
+ function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}Object.defineProperty(exports,"__esModule",{value:!0});var crypt=createCommonjsModule(function(e){var a,n;a="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(a.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((a.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|a.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:b).stringToBytes(e):T(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=y.bytesToWords(e),t=8*e.length,r=1732584193,o=-271733879,a=-1732584194,i=271733878,l=0;l<n.length;l++)n[l]=16711935&(n[l]<<8|n[l]>>>24)|4278255360&(n[l]<<24|n[l]>>>8);n[t>>>5]|=128<<t%32,n[14+(64+t>>>9<<4)]=t;for(var u=v._ff,s=v._gg,c=v._hh,p=v._ii,l=0;l<n.length;l+=16){var g=r,d=o,m=a,f=i,r=u(r,o,a,i,n[l+0],7,-680876936),i=u(i,r,o,a,n[l+1],12,-389564586),a=u(a,i,r,o,n[l+2],17,606105819),o=u(o,a,i,r,n[l+3],22,-1044525330);r=u(r,o,a,i,n[l+4],7,-176418897),i=u(i,r,o,a,n[l+5],12,1200080426),a=u(a,i,r,o,n[l+6],17,-1473231341),o=u(o,a,i,r,n[l+7],22,-45705983),r=u(r,o,a,i,n[l+8],7,1770035416),i=u(i,r,o,a,n[l+9],12,-1958414417),a=u(a,i,r,o,n[l+10],17,-42063),o=u(o,a,i,r,n[l+11],22,-1990404162),r=u(r,o,a,i,n[l+12],7,1804603682),i=u(i,r,o,a,n[l+13],12,-40341101),a=u(a,i,r,o,n[l+14],17,-1502002290),r=s(r,o=u(o,a,i,r,n[l+15],22,1236535329),a,i,n[l+1],5,-165796510),i=s(i,r,o,a,n[l+6],9,-1069501632),a=s(a,i,r,o,n[l+11],14,643717713),o=s(o,a,i,r,n[l+0],20,-373897302),r=s(r,o,a,i,n[l+5],5,-701558691),i=s(i,r,o,a,n[l+10],9,38016083),a=s(a,i,r,o,n[l+15],14,-660478335),o=s(o,a,i,r,n[l+4],20,-405537848),r=s(r,o,a,i,n[l+9],5,568446438),i=s(i,r,o,a,n[l+14],9,-1019803690),a=s(a,i,r,o,n[l+3],14,-187363961),o=s(o,a,i,r,n[l+8],20,1163531501),r=s(r,o,a,i,n[l+13],5,-1444681467),i=s(i,r,o,a,n[l+2],9,-51403784),a=s(a,i,r,o,n[l+7],14,1735328473),r=c(r,o=s(o,a,i,r,n[l+12],20,-1926607734),a,i,n[l+5],4,-378558),i=c(i,r,o,a,n[l+8],11,-2022574463),a=c(a,i,r,o,n[l+11],16,1839030562),o=c(o,a,i,r,n[l+14],23,-35309556),r=c(r,o,a,i,n[l+1],4,-1530992060),i=c(i,r,o,a,n[l+4],11,1272893353),a=c(a,i,r,o,n[l+7],16,-155497632),o=c(o,a,i,r,n[l+10],23,-1094730640),r=c(r,o,a,i,n[l+13],4,681279174),i=c(i,r,o,a,n[l+0],11,-358537222),a=c(a,i,r,o,n[l+3],16,-722521979),o=c(o,a,i,r,n[l+6],23,76029189),r=c(r,o,a,i,n[l+9],4,-640364487),i=c(i,r,o,a,n[l+12],11,-421815835),a=c(a,i,r,o,n[l+15],16,530742520),r=p(r,o=c(o,a,i,r,n[l+2],23,-995338651),a,i,n[l+0],6,-198630844),i=p(i,r,o,a,n[l+7],10,1126891415),a=p(a,i,r,o,n[l+14],15,-1416354905),o=p(o,a,i,r,n[l+5],21,-57434055),r=p(r,o,a,i,n[l+12],6,1700485571),i=p(i,r,o,a,n[l+3],10,-1894986606),a=p(a,i,r,o,n[l+10],15,-1051523),o=p(o,a,i,r,n[l+1],21,-2054922799),r=p(r,o,a,i,n[l+8],6,1873313359),i=p(i,r,o,a,n[l+15],10,-30611744),a=p(a,i,r,o,n[l+6],15,-1560198380),o=p(o,a,i,r,n[l+13],21,1309151649),r=p(r,o,a,i,n[l+4],6,-145523070),i=p(i,r,o,a,n[l+11],10,-1120210379),a=p(a,i,r,o,n[l+2],15,718787259),o=p(o,a,i,r,n[l+9],21,-343485551),r=r+g>>>0,o=o+d>>>0,a=a+m>>>0,i=i+f>>>0}return y.endian([r,o,a,i])}var y,b,T,I;y=crypt,b=charenc_1.utf8,T=isBuffer_1,I=charenc_1.bin,v._ff=function(e,t,n,r,o,a,i){e=e+(t&n|~t&r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._gg=function(e,t,n,r,o,a,i){e=e+(t&r|n&~r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._hh=function(e,t,n,r,o,a,i){e=e+(t^n^r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._ii=function(e,t,n,r,o,a,i){e=e+(n^(t|~r))+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=y.wordsToBytes(v(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):y.bytesToHex(e)}});let wxMini="wxMini",usrIdKey="v_userId",anonIdKey="v_anonId";function getWxMiniInfo(){var e=wx.getAccountInfoSync().miniProgram;return{name:"",packageName:e?e.appId:"",version:e?e.envVersion+e.version:"",carrier:"mini",ecology:"mini"}}function getWxMiniDeviceInfo(){var e=wx.getSystemInfoSync();let t={lang:e.language,brand:e.brand+" "+e.model,os:e.platform,osVersion:e.system,resolution:e.screenWidth+"x"+e.screenHeight,browser:"",browserVersion:"",color:"",deviceId:"",deviceType:getWxMiniDeviceType(e.system),network:""};return wx.getNetworkType({success(e){t.network=e.networkType}}),t}function getWxMiniDeviceType(t){return["Windows","Linux","macOS"].every(e=>t.includes(e))?1:2}function getWxMiniUserId(){return wx.getStorageSync(usrIdKey)?wx.getStorageSync(usrIdKey):""}function getWxMiniAnonyMousIdId(){let e=wx.getStorageSync(anonIdKey);return e&&(e=randomUUID$1(),wx.setStorageSync(anonIdKey,e)),e}let AUTOTRACKTYPE={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},BPNPVUV="UNIBPNPVUVSrcData",BPNPVUVFail="UNIBPNPVUVFailData",Global={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},pagesArray=[];function isWXMiniProgram(){return"undefined"!=typeof wx&&wx.getSystemInfoSync}let sdkTrackIdVal=()=>{var e;return Global.trackId||(e=Date.now().toString(),Global.trackId=e)};function randomUUID$1(){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){var t;return"web"===Global.platform||"h5"===Global.platform?(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){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),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 o="",a="",i="",l="";if(r&&("web"===r||"h5"===r?(o=window.location.href,a=window.location.hostname,document.referrer&&(r=new URL(document.referrer),i=r||"",l=r.hostname||"")):(o=n.route,1<t.length&&(r=t[t.length-2],i=r.route),a=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:a,url:o,visitPage:t.length,sourceDomain:l,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)}function getUtmObj(){var e,t;return"web"===Global.platform||"h5"===Global.platform?(e={utmSource:"",utmCampaign:"",utmTerm:"",utmContent:"",ctk:""},window.location.href&&(t=window.location.href.split("?")[1]||"")&&(t=new URLSearchParams(t),e.utmSource=t.get("utmSource")||"",e.utmCampaign=t.get("utmCampaign")||"",e.utmTerm=t.get("utmTerm")||"",e.utmContent=t.get("utmContent")||"",e.ctk=t.get("ctk")||""),e):null}function insertPVUVData(e,t){let n=null;var r,o=(n=(Global.platform===wxMini?wx:uni).getStorageSync(BPNPVUV))?JSON.parse(n):[];0<o.length&&-1!==(r=o.findIndex(e=>e.uid===t))?o[r]={...o[r],...e}:o.push(e),(Global.platform===wxMini?wx:uni).setStorageSync(BPNPVUV,JSON.stringify(o))}let atDuration,atEnterTimeLong,atLoopTimeLong,cirtemp,atObj,atInterval,uid;function clearUAData(){clearInterval(atInterval),atInterval=null,atEnterTimeLong=0,atLoopTimeLong=0,atObj=null,uid=0,cirtemp=1,atDuration=0,uid=randomUUID(),atEnterTimeLong=Date.now(),atLoopTimeLong=atEnterTimeLong}let uAutoStartTrackPVData=e=>{atInterval&&autoStopTrackPVUV(),autoTrackData(AUTOTRACKTYPE.ENTER),atInterval=setInterval(()=>{autoTrackData(AUTOTRACKTYPE.LOOP)},15e3)},autoStopTrackPVUV=()=>{autoTrackData(AUTOTRACKTYPE.LEAVE),clearInterval(atInterval),atInterval=null};function autoTrackData(e){e===AUTOTRACKTYPE.ENTER?(clearUAData(),atObj=objParams):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,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),uid:uid},uid)}function autoPageObj(t,e,n){var r=pagesArray.find(e=>e.path===t),o=Global.platform;let a="",i="",l="",u="";return o&&("web"===o||"h5"===o?(a=window.location.href,i=window.location.hostname,document.referrer&&(o=new URL(document.referrer),l=o||"",u=o.hostname||"")):(a=t,1<e&&(o=n[e-2],l=o.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:a,visitPage:e,sourceDomain:u,sourceUrl:l,title:r&&r.title?r.title:""}}function queryTrackDataUpload(){let e=null,t=null;var n=[],r=(t=(Global.platform===wxMini?(e=wx.getStorageSync(BPNPVUV),wx.setStorageSync(BPNPVUV,""),wx):(e=uni.getStorageSync(BPNPVUV),uni.setStorageSync(BPNPVUV,""),uni)).getStorageSync(BPNPVUVFail),e?JSON.parse(e):[]),o=t?JSON.parse(t):[];r.length&&n.push(...r),o.length&&(n.push(...o),n.forEach(e=>{delete e.pageUUId})),n&&n.length&&BuriedPointUni.reportTrackEventServer("track",n,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"}}let deepCopy=e=>{if("object"!=typeof e)return e;var t,n=Array.isArray(e)?[]:{};for(t in e)"object"==typeof e[t]?n[t]=deepCopy(e[t]):n[t]=e[t];return n},cacheData=[],addCache=e=>{cacheData.push(e)},getCache=()=>deepCopy(cacheData),clearCache=()=>{cacheData.length=0},BPNEvent="UNIBPNEventSrcData",BPNEventFail="UNIBPNEventFailData",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||getUtmObj(),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){let t,n=(t=(Global.platform===wxMini?wx:uni).getStorageSync(BPNEvent))?JSON.parse(t):[];e&&e.length&&(e.forEach(e=>{n.push(e)}),(Global.platform===wxMini?wx:uni).setStorageSync(BPNEvent,JSON.stringify(n)))}function queryEventDataUpload(){let e=null,t=null;var n=[],r=(t=(Global.platform===wxMini?(e=wx.getStorageSync(BPNEvent),wx.setStorageSync(BPNEvent,""),wx):(e=uni.getStorageSync(BPNEvent),uni.setStorageSync(BPNEvent,""),uni)).getStorageSync(BPNEventFail),e?JSON.parse(e):[]),o=t?JSON.parse(t):[];r.length&&n.push(...r),o.length&&n.push(...o),n&&n.length&&BuriedPointUni.reportTrackEventServer("event",n,BPNEventFail)}let startTime,enterTimeLong,loopTimeLong,umlInterval,cirtemp$1,mObj,cPUUId;function uStartTrackPVData(e){umlInterval&&uDestoryTrackPVData(),e&&(clearInterval(umlInterval),uTrackPVData(AUTOTRACKTYPE.ENTER,e),umlInterval=setInterval(()=>{uTrackPVData(AUTOTRACKTYPE.LOOP,null)},15e3))}function uDestoryTrackPVData(){uTrackPVData(AUTOTRACKTYPE.LEAVE,null),clearInterval(umlInterval),umlInterval=null}function uTrackPVData(e,t){e===AUTOTRACKTYPE.ENTER?(mObj=null,cPUUId=0,cirtemp$1=1,startTime=0,enterTimeLong=-1,loopTimeLong=-1,enterTimeLong=Date.now(),loopTimeLong=enterTimeLong,cPUUId=randomUUID$1(),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:getUtmObj(),uid:cPUUId};insertPVUVData(t,cPUUId)}var name="visual-buried-point-platform-uni",version="1.0.0-alpha.31",lsi="2e7b05624b068c071618750728921cd8#1.0.0-alpha.30",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={build:"rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.cjs"},type="module",files=["dist"],repository={type:"git",url:""},keywords=[],author="",license="MIT",dependencies={md5:"^2.3.0"},devDependencies={rimraf:"^6.0.1",webpack:"^5.72.1","webpack-cli":"^6.0.1","@babel/core":"^7.26.10","@babel/preset-env":"^7.26.9","@rollup/plugin-json":"^6.0.1","babel-loader":"^10.0.0","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"},pk={name:name,version:version,lsi:lsi,description:description,main:main,module:module$1,"umd:main":"dist/umd/buried-point-uni.js",scripts:scripts,type:type,files:files,repository:repository,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(console.log("----msg--",e),"pv"===e){var n=getCurrentPages();let t=n[n.length-1];Global.signTrackArray&&Global.signTrackArray.length&&(pathExist=Global.signTrackArray.find(e=>e===t.route))?pathExist=!0:(pathExist=!1,autoPageObj(t.route,n.length,n),uAutoStartTrackPVData())}else"leave"===e&&(console.log("--msg leave----",e),pathExist||autoStopTrackPVUV())}let usrIdKey$1="v_userId",anonIdKey$1="v_anonId",localLsi=pk.lsi,_comInfo={distinctId:"",anonymousId:""},appData={},deviceData={},uglInterval=null;class BuriedPointUni{init(e){var t;e?(t=setReportUrl(e.env||""),Global.upEventUrl=t.reportUrl,Global.upTrackUrl=t.reportTrackUrl,Object.assign(Global,e),this.getBaseicInfo(),Global.platform===wxMini?(_comInfo.distinctId=getWxMiniUserId(),_comInfo.anonymousId=getWxMiniAnonyMousIdId()):(_comInfo.distinctId=uni.getStorageSync(usrIdKey$1)||"",_comInfo.anonymousId=uni.getStorageSync(anonIdKey$1),_comInfo.anonymousId||(_comInfo.anonymousId=randomUUID$1(),uni.setStorageSync(anonIdKey$1,_comInfo.anonymousId))),sdkTrackIdVal(),this.startGlobalTime(),Global.platform!==wxMini&&uniInterceptorListener()):console.log("init config error, please check config!")}startGlobalTime(){clearInterval(uglInterval),uglInterval=setInterval(()=>{queryEventDataUpload(),queryTrackDataUpload()},15e3)}setUserId(e){e?(_comInfo.distinctId=e,(Global.platform===wxMini?wx:uni).setStorageSync(usrIdKey$1,e)):(_comInfo.distinctId="",Global.platform===wxMini?wx.setStorageSync(usrIdKey$1,e):uni.setStorageSync(usrIdKey$1,""))}getTrackId(){return sdkTrackIdVal()}setCustomEvent(e){eventCommonStore(e)}onStartTrack(e){uStartTrackPVData(e)}onDestroyTrack(){uDestoryTrackPVData()}setPageExtraObj(e){uUpdatePageExtraArray(e)}reportTrackEventServer(e,t,n){var r;e?(r={...r=this.commonData(t),dataAbstract:md5(JSON.stringify(r))},Global.platform===wxMini?wx.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){e&&e.data?wx.setStorageSync(n,JSON.stringify(t)):wx.setStorageSync(n,"")},fail:function(e){console.error(e),wx.setStorageSync(n,JSON.stringify(t))}}):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){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")}commonData(e){return{app:appData,data:e,device:deviceData,lsi:localLsi,projectId:Global.token,userAgent:Global.uAgent||"",anonymousId:_comInfo.anonymousId,userId:_comInfo.distinctId}}getBaseicInfo(){isWXMiniProgram?(Global.platform=wxMini,appData=getWxMiniInfo(),deviceData=getWxMiniDeviceInfo()):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)},fail:function(e){deviceData=getDeviceInfoError()},complete:function(){uni.getNetworkType({success(e){deviceData.network=e.networkType}})}})}}exports.BuriedPointUni=BuriedPointUni;
@@ -0,0 +1 @@
1
+ function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var crypt=createCommonjsModule(function(e){var a,n;a="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(a.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((a.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|a.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:b).stringToBytes(e):T(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=y.bytesToWords(e),t=8*e.length,r=1732584193,o=-271733879,a=-1732584194,i=271733878,l=0;l<n.length;l++)n[l]=16711935&(n[l]<<8|n[l]>>>24)|4278255360&(n[l]<<24|n[l]>>>8);n[t>>>5]|=128<<t%32,n[14+(64+t>>>9<<4)]=t;for(var u=v._ff,s=v._gg,c=v._hh,p=v._ii,l=0;l<n.length;l+=16){var g=r,d=o,m=a,f=i,r=u(r,o,a,i,n[l+0],7,-680876936),i=u(i,r,o,a,n[l+1],12,-389564586),a=u(a,i,r,o,n[l+2],17,606105819),o=u(o,a,i,r,n[l+3],22,-1044525330);r=u(r,o,a,i,n[l+4],7,-176418897),i=u(i,r,o,a,n[l+5],12,1200080426),a=u(a,i,r,o,n[l+6],17,-1473231341),o=u(o,a,i,r,n[l+7],22,-45705983),r=u(r,o,a,i,n[l+8],7,1770035416),i=u(i,r,o,a,n[l+9],12,-1958414417),a=u(a,i,r,o,n[l+10],17,-42063),o=u(o,a,i,r,n[l+11],22,-1990404162),r=u(r,o,a,i,n[l+12],7,1804603682),i=u(i,r,o,a,n[l+13],12,-40341101),a=u(a,i,r,o,n[l+14],17,-1502002290),r=s(r,o=u(o,a,i,r,n[l+15],22,1236535329),a,i,n[l+1],5,-165796510),i=s(i,r,o,a,n[l+6],9,-1069501632),a=s(a,i,r,o,n[l+11],14,643717713),o=s(o,a,i,r,n[l+0],20,-373897302),r=s(r,o,a,i,n[l+5],5,-701558691),i=s(i,r,o,a,n[l+10],9,38016083),a=s(a,i,r,o,n[l+15],14,-660478335),o=s(o,a,i,r,n[l+4],20,-405537848),r=s(r,o,a,i,n[l+9],5,568446438),i=s(i,r,o,a,n[l+14],9,-1019803690),a=s(a,i,r,o,n[l+3],14,-187363961),o=s(o,a,i,r,n[l+8],20,1163531501),r=s(r,o,a,i,n[l+13],5,-1444681467),i=s(i,r,o,a,n[l+2],9,-51403784),a=s(a,i,r,o,n[l+7],14,1735328473),r=c(r,o=s(o,a,i,r,n[l+12],20,-1926607734),a,i,n[l+5],4,-378558),i=c(i,r,o,a,n[l+8],11,-2022574463),a=c(a,i,r,o,n[l+11],16,1839030562),o=c(o,a,i,r,n[l+14],23,-35309556),r=c(r,o,a,i,n[l+1],4,-1530992060),i=c(i,r,o,a,n[l+4],11,1272893353),a=c(a,i,r,o,n[l+7],16,-155497632),o=c(o,a,i,r,n[l+10],23,-1094730640),r=c(r,o,a,i,n[l+13],4,681279174),i=c(i,r,o,a,n[l+0],11,-358537222),a=c(a,i,r,o,n[l+3],16,-722521979),o=c(o,a,i,r,n[l+6],23,76029189),r=c(r,o,a,i,n[l+9],4,-640364487),i=c(i,r,o,a,n[l+12],11,-421815835),a=c(a,i,r,o,n[l+15],16,530742520),r=p(r,o=c(o,a,i,r,n[l+2],23,-995338651),a,i,n[l+0],6,-198630844),i=p(i,r,o,a,n[l+7],10,1126891415),a=p(a,i,r,o,n[l+14],15,-1416354905),o=p(o,a,i,r,n[l+5],21,-57434055),r=p(r,o,a,i,n[l+12],6,1700485571),i=p(i,r,o,a,n[l+3],10,-1894986606),a=p(a,i,r,o,n[l+10],15,-1051523),o=p(o,a,i,r,n[l+1],21,-2054922799),r=p(r,o,a,i,n[l+8],6,1873313359),i=p(i,r,o,a,n[l+15],10,-30611744),a=p(a,i,r,o,n[l+6],15,-1560198380),o=p(o,a,i,r,n[l+13],21,1309151649),r=p(r,o,a,i,n[l+4],6,-145523070),i=p(i,r,o,a,n[l+11],10,-1120210379),a=p(a,i,r,o,n[l+2],15,718787259),o=p(o,a,i,r,n[l+9],21,-343485551),r=r+g>>>0,o=o+d>>>0,a=a+m>>>0,i=i+f>>>0}return y.endian([r,o,a,i])}var y,b,T,I;y=crypt,b=charenc_1.utf8,T=isBuffer_1,I=charenc_1.bin,v._ff=function(e,t,n,r,o,a,i){e=e+(t&n|~t&r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._gg=function(e,t,n,r,o,a,i){e=e+(t&r|n&~r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._hh=function(e,t,n,r,o,a,i){e=e+(t^n^r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._ii=function(e,t,n,r,o,a,i){e=e+(n^(t|~r))+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=y.wordsToBytes(v(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):y.bytesToHex(e)}});let wxMini="wxMini",usrIdKey="v_userId",anonIdKey="v_anonId";function getWxMiniInfo(){var e=wx.getAccountInfoSync().miniProgram;return{name:"",packageName:e?e.appId:"",version:e?e.envVersion+e.version:"",carrier:"mini",ecology:"mini"}}function getWxMiniDeviceInfo(){var e=wx.getSystemInfoSync();let t={lang:e.language,brand:e.brand+" "+e.model,os:e.platform,osVersion:e.system,resolution:e.screenWidth+"x"+e.screenHeight,browser:"",browserVersion:"",color:"",deviceId:"",deviceType:getWxMiniDeviceType(e.system),network:""};return wx.getNetworkType({success(e){t.network=e.networkType}}),t}function getWxMiniDeviceType(t){return["Windows","Linux","macOS"].every(e=>t.includes(e))?1:2}function getWxMiniUserId(){return wx.getStorageSync(usrIdKey)?wx.getStorageSync(usrIdKey):""}function getWxMiniAnonyMousIdId(){let e=wx.getStorageSync(anonIdKey);return e&&(e=randomUUID$1(),wx.setStorageSync(anonIdKey,e)),e}let AUTOTRACKTYPE={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},BPNPVUV="UNIBPNPVUVSrcData",BPNPVUVFail="UNIBPNPVUVFailData",Global={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},pagesArray=[];function isWXMiniProgram(){return"undefined"!=typeof wx&&wx.getSystemInfoSync}let sdkTrackIdVal=()=>{var e;return Global.trackId||(e=Date.now().toString(),Global.trackId=e)};function randomUUID$1(){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){var t;return"web"===Global.platform||"h5"===Global.platform?(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){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),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 o="",a="",i="",l="";if(r&&("web"===r||"h5"===r?(o=window.location.href,a=window.location.hostname,document.referrer&&(r=new URL(document.referrer),i=r||"",l=r.hostname||"")):(o=n.route,1<t.length&&(r=t[t.length-2],i=r.route),a=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:a,url:o,visitPage:t.length,sourceDomain:l,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)}function getUtmObj(){var e,t;return"web"===Global.platform||"h5"===Global.platform?(e={utmSource:"",utmCampaign:"",utmTerm:"",utmContent:"",ctk:""},window.location.href&&(t=window.location.href.split("?")[1]||"")&&(t=new URLSearchParams(t),e.utmSource=t.get("utmSource")||"",e.utmCampaign=t.get("utmCampaign")||"",e.utmTerm=t.get("utmTerm")||"",e.utmContent=t.get("utmContent")||"",e.ctk=t.get("ctk")||""),e):null}function insertPVUVData(e,t){let n=null;var r,o=(n=(Global.platform===wxMini?wx:uni).getStorageSync(BPNPVUV))?JSON.parse(n):[];0<o.length&&-1!==(r=o.findIndex(e=>e.uid===t))?o[r]={...o[r],...e}:o.push(e),(Global.platform===wxMini?wx:uni).setStorageSync(BPNPVUV,JSON.stringify(o))}let atDuration,atEnterTimeLong,atLoopTimeLong,cirtemp,atObj,atInterval,uid;function clearUAData(){clearInterval(atInterval),atInterval=null,atEnterTimeLong=0,atLoopTimeLong=0,atObj=null,uid=0,cirtemp=1,atDuration=0,uid=randomUUID(),atEnterTimeLong=Date.now(),atLoopTimeLong=atEnterTimeLong}let uAutoStartTrackPVData=e=>{atInterval&&autoStopTrackPVUV(),autoTrackData(AUTOTRACKTYPE.ENTER),atInterval=setInterval(()=>{autoTrackData(AUTOTRACKTYPE.LOOP)},15e3)},autoStopTrackPVUV=()=>{autoTrackData(AUTOTRACKTYPE.LEAVE),clearInterval(atInterval),atInterval=null};function autoTrackData(e){e===AUTOTRACKTYPE.ENTER?(clearUAData(),atObj=objParams):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,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),uid:uid},uid)}function autoPageObj(t,e,n){var r=pagesArray.find(e=>e.path===t),o=Global.platform;let a="",i="",l="",u="";return o&&("web"===o||"h5"===o?(a=window.location.href,i=window.location.hostname,document.referrer&&(o=new URL(document.referrer),l=o||"",u=o.hostname||"")):(a=t,1<e&&(o=n[e-2],l=o.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:a,visitPage:e,sourceDomain:u,sourceUrl:l,title:r&&r.title?r.title:""}}function queryTrackDataUpload(){let e=null,t=null;var n=[],r=(t=(Global.platform===wxMini?(e=wx.getStorageSync(BPNPVUV),wx.setStorageSync(BPNPVUV,""),wx):(e=uni.getStorageSync(BPNPVUV),uni.setStorageSync(BPNPVUV,""),uni)).getStorageSync(BPNPVUVFail),e?JSON.parse(e):[]),o=t?JSON.parse(t):[];r.length&&n.push(...r),o.length&&(n.push(...o),n.forEach(e=>{delete e.pageUUId})),n&&n.length&&BuriedPointUni.reportTrackEventServer("track",n,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"}}let deepCopy=e=>{if("object"!=typeof e)return e;var t,n=Array.isArray(e)?[]:{};for(t in e)"object"==typeof e[t]?n[t]=deepCopy(e[t]):n[t]=e[t];return n},cacheData=[],addCache=e=>{cacheData.push(e)},getCache=()=>deepCopy(cacheData),clearCache=()=>{cacheData.length=0},BPNEvent="UNIBPNEventSrcData",BPNEventFail="UNIBPNEventFailData",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||getUtmObj(),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){let t,n=(t=(Global.platform===wxMini?wx:uni).getStorageSync(BPNEvent))?JSON.parse(t):[];e&&e.length&&(e.forEach(e=>{n.push(e)}),(Global.platform===wxMini?wx:uni).setStorageSync(BPNEvent,JSON.stringify(n)))}function queryEventDataUpload(){let e=null,t=null;var n=[],r=(t=(Global.platform===wxMini?(e=wx.getStorageSync(BPNEvent),wx.setStorageSync(BPNEvent,""),wx):(e=uni.getStorageSync(BPNEvent),uni.setStorageSync(BPNEvent,""),uni)).getStorageSync(BPNEventFail),e?JSON.parse(e):[]),o=t?JSON.parse(t):[];r.length&&n.push(...r),o.length&&n.push(...o),n&&n.length&&BuriedPointUni.reportTrackEventServer("event",n,BPNEventFail)}let startTime,enterTimeLong,loopTimeLong,umlInterval,cirtemp$1,mObj,cPUUId;function uStartTrackPVData(e){umlInterval&&uDestoryTrackPVData(),e&&(clearInterval(umlInterval),uTrackPVData(AUTOTRACKTYPE.ENTER,e),umlInterval=setInterval(()=>{uTrackPVData(AUTOTRACKTYPE.LOOP,null)},15e3))}function uDestoryTrackPVData(){uTrackPVData(AUTOTRACKTYPE.LEAVE,null),clearInterval(umlInterval),umlInterval=null}function uTrackPVData(e,t){e===AUTOTRACKTYPE.ENTER?(mObj=null,cPUUId=0,cirtemp$1=1,startTime=0,enterTimeLong=-1,loopTimeLong=-1,enterTimeLong=Date.now(),loopTimeLong=enterTimeLong,cPUUId=randomUUID$1(),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:getUtmObj(),uid:cPUUId};insertPVUVData(t,cPUUId)}var name="visual-buried-point-platform-uni",version="1.0.0-alpha.31",lsi="2e7b05624b068c071618750728921cd8#1.0.0-alpha.30",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={build:"rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.cjs"},type="module",files=["dist"],repository={type:"git",url:""},keywords=[],author="",license="MIT",dependencies={md5:"^2.3.0"},devDependencies={rimraf:"^6.0.1",webpack:"^5.72.1","webpack-cli":"^6.0.1","@babel/core":"^7.26.10","@babel/preset-env":"^7.26.9","@rollup/plugin-json":"^6.0.1","babel-loader":"^10.0.0","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"},pk={name:name,version:version,lsi:lsi,description:description,main:main,module:module,"umd:main":"dist/umd/buried-point-uni.js",scripts:scripts,type:type,files:files,repository:repository,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(console.log("----msg--",e),"pv"===e){var n=getCurrentPages();let t=n[n.length-1];Global.signTrackArray&&Global.signTrackArray.length&&(pathExist=Global.signTrackArray.find(e=>e===t.route))?pathExist=!0:(pathExist=!1,autoPageObj(t.route,n.length,n),uAutoStartTrackPVData())}else"leave"===e&&(console.log("--msg leave----",e),pathExist||autoStopTrackPVUV())}let usrIdKey$1="v_userId",anonIdKey$1="v_anonId",localLsi=pk.lsi,_comInfo={distinctId:"",anonymousId:""},appData={},deviceData={},uglInterval=null;class BuriedPointUni{init(e){var t;e?(t=setReportUrl(e.env||""),Global.upEventUrl=t.reportUrl,Global.upTrackUrl=t.reportTrackUrl,Object.assign(Global,e),this.getBaseicInfo(),Global.platform===wxMini?(_comInfo.distinctId=getWxMiniUserId(),_comInfo.anonymousId=getWxMiniAnonyMousIdId()):(_comInfo.distinctId=uni.getStorageSync(usrIdKey$1)||"",_comInfo.anonymousId=uni.getStorageSync(anonIdKey$1),_comInfo.anonymousId||(_comInfo.anonymousId=randomUUID$1(),uni.setStorageSync(anonIdKey$1,_comInfo.anonymousId))),sdkTrackIdVal(),this.startGlobalTime(),Global.platform!==wxMini&&uniInterceptorListener()):console.log("init config error, please check config!")}startGlobalTime(){clearInterval(uglInterval),uglInterval=setInterval(()=>{queryEventDataUpload(),queryTrackDataUpload()},15e3)}setUserId(e){e?(_comInfo.distinctId=e,(Global.platform===wxMini?wx:uni).setStorageSync(usrIdKey$1,e)):(_comInfo.distinctId="",Global.platform===wxMini?wx.setStorageSync(usrIdKey$1,e):uni.setStorageSync(usrIdKey$1,""))}getTrackId(){return sdkTrackIdVal()}setCustomEvent(e){eventCommonStore(e)}onStartTrack(e){uStartTrackPVData(e)}onDestroyTrack(){uDestoryTrackPVData()}setPageExtraObj(e){uUpdatePageExtraArray(e)}reportTrackEventServer(e,t,n){var r;e?(r={...r=this.commonData(t),dataAbstract:md5(JSON.stringify(r))},Global.platform===wxMini?wx.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){e&&e.data?wx.setStorageSync(n,JSON.stringify(t)):wx.setStorageSync(n,"")},fail:function(e){console.error(e),wx.setStorageSync(n,JSON.stringify(t))}}):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){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")}commonData(e){return{app:appData,data:e,device:deviceData,lsi:localLsi,projectId:Global.token,userAgent:Global.uAgent||"",anonymousId:_comInfo.anonymousId,userId:_comInfo.distinctId}}getBaseicInfo(){isWXMiniProgram?(Global.platform=wxMini,appData=getWxMiniInfo(),deviceData=getWxMiniDeviceInfo()):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)},fail:function(e){deviceData=getDeviceInfoError()},complete:function(){uni.getNetworkType({success(e){deviceData.network=e.networkType}})}})}}export{BuriedPointUni};
@@ -0,0 +1 @@
1
+ ((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){function t(e,t){return e(t={exports:{}},t.exports),t.exports}function L(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 J=t(function(e){var a,n;a="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(a.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((a.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|a.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 j=t(function(e){function S(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?I:h).stringToBytes(e):v(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=y.bytesToWords(e),t=8*e.length,r=1732584193,o=-271733879,a=-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 s=S._ff,c=S._gg,l=S._hh,g=S._ii,u=0;u<n.length;u+=16){var p=r,d=o,m=a,f=i,r=s(r,o,a,i,n[u+0],7,-680876936),i=s(i,r,o,a,n[u+1],12,-389564586),a=s(a,i,r,o,n[u+2],17,606105819),o=s(o,a,i,r,n[u+3],22,-1044525330);r=s(r,o,a,i,n[u+4],7,-176418897),i=s(i,r,o,a,n[u+5],12,1200080426),a=s(a,i,r,o,n[u+6],17,-1473231341),o=s(o,a,i,r,n[u+7],22,-45705983),r=s(r,o,a,i,n[u+8],7,1770035416),i=s(i,r,o,a,n[u+9],12,-1958414417),a=s(a,i,r,o,n[u+10],17,-42063),o=s(o,a,i,r,n[u+11],22,-1990404162),r=s(r,o,a,i,n[u+12],7,1804603682),i=s(i,r,o,a,n[u+13],12,-40341101),a=s(a,i,r,o,n[u+14],17,-1502002290),r=c(r,o=s(o,a,i,r,n[u+15],22,1236535329),a,i,n[u+1],5,-165796510),i=c(i,r,o,a,n[u+6],9,-1069501632),a=c(a,i,r,o,n[u+11],14,643717713),o=c(o,a,i,r,n[u+0],20,-373897302),r=c(r,o,a,i,n[u+5],5,-701558691),i=c(i,r,o,a,n[u+10],9,38016083),a=c(a,i,r,o,n[u+15],14,-660478335),o=c(o,a,i,r,n[u+4],20,-405537848),r=c(r,o,a,i,n[u+9],5,568446438),i=c(i,r,o,a,n[u+14],9,-1019803690),a=c(a,i,r,o,n[u+3],14,-187363961),o=c(o,a,i,r,n[u+8],20,1163531501),r=c(r,o,a,i,n[u+13],5,-1444681467),i=c(i,r,o,a,n[u+2],9,-51403784),a=c(a,i,r,o,n[u+7],14,1735328473),r=l(r,o=c(o,a,i,r,n[u+12],20,-1926607734),a,i,n[u+5],4,-378558),i=l(i,r,o,a,n[u+8],11,-2022574463),a=l(a,i,r,o,n[u+11],16,1839030562),o=l(o,a,i,r,n[u+14],23,-35309556),r=l(r,o,a,i,n[u+1],4,-1530992060),i=l(i,r,o,a,n[u+4],11,1272893353),a=l(a,i,r,o,n[u+7],16,-155497632),o=l(o,a,i,r,n[u+10],23,-1094730640),r=l(r,o,a,i,n[u+13],4,681279174),i=l(i,r,o,a,n[u+0],11,-358537222),a=l(a,i,r,o,n[u+3],16,-722521979),o=l(o,a,i,r,n[u+6],23,76029189),r=l(r,o,a,i,n[u+9],4,-640364487),i=l(i,r,o,a,n[u+12],11,-421815835),a=l(a,i,r,o,n[u+15],16,530742520),r=g(r,o=l(o,a,i,r,n[u+2],23,-995338651),a,i,n[u+0],6,-198630844),i=g(i,r,o,a,n[u+7],10,1126891415),a=g(a,i,r,o,n[u+14],15,-1416354905),o=g(o,a,i,r,n[u+5],21,-57434055),r=g(r,o,a,i,n[u+12],6,1700485571),i=g(i,r,o,a,n[u+3],10,-1894986606),a=g(a,i,r,o,n[u+10],15,-1051523),o=g(o,a,i,r,n[u+1],21,-2054922799),r=g(r,o,a,i,n[u+8],6,1873313359),i=g(i,r,o,a,n[u+15],10,-30611744),a=g(a,i,r,o,n[u+6],15,-1560198380),o=g(o,a,i,r,n[u+13],21,1309151649),r=g(r,o,a,i,n[u+4],6,-145523070),i=g(i,r,o,a,n[u+11],10,-1120210379),a=g(a,i,r,o,n[u+2],15,718787259),o=g(o,a,i,r,n[u+9],21,-343485551),r=r+p>>>0,o=o+d>>>0,a=a+m>>>0,i=i+f>>>0}return y.endian([r,o,a,i])}var y,h,v,I;y=J,h=r.utf8,v=L,I=r.bin,S._ff=function(e,t,n,r,o,a,i){e=e+(t&n|~t&r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},S._gg=function(e,t,n,r,o,a,i){e=e+(t&r|n&~r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},S._hh=function(e,t,n,r,o,a,i){e=e+(t^n^r)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},S._ii=function(e,t,n,r,o,a,i){e=e+(n^(t|~r))+(o>>>0)+i;return(e<<a|e>>>32-a)+t},S._blocksize=16,S._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=y.wordsToBytes(S(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):y.bytesToHex(e)}});let a="wxMini",M="v_userId",V="v_anonId";let i={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},u="UNIBPNPVUVSrcData",$="UNIBPNPVUVFailData",c={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},l=[];let s=()=>{var e;return c.trackId||(e=Date.now().toString(),c.trackId=e)};function g(){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 p(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 R(){var e,t;return"web"===c.platform||"h5"===c.platform?(e={utmSource:"",utmCampaign:"",utmTerm:"",utmContent:"",ctk:""},window.location.href&&(t=window.location.href.split("?")[1]||"")&&(t=new URLSearchParams(t),e.utmSource=t.get("utmSource")||"",e.utmCampaign=t.get("utmCampaign")||"",e.utmTerm=t.get("utmTerm")||"",e.utmContent=t.get("utmContent")||"",e.ctk=t.get("ctk")||""),e):null}function H(e,t){let n=null;var r,o=(n=(c.platform===a?wx:uni).getStorageSync(u))?JSON.parse(n):[];0<o.length&&-1!==(r=o.findIndex(e=>e.uid===t))?o[r]={...o[r],...e}:o.push(e),(c.platform===a?wx:uni).setStorageSync(u,JSON.stringify(o))}let d,m,f,S,y,h,v;let z=e=>{h&&q(),I(i.ENTER),h=setInterval(()=>{I(i.LOOP)},15e3)},q=()=>{I(i.LEAVE),clearInterval(h),h=null};function I(e){e===i.ENTER?(clearInterval(h),h=null,m=0,f=0,y=null,v=0,S=1,d=0,v=randomUUID(),m=Date.now(),f=m,y=objParams):e===i.LOOP?(S=2,d=15,f=Date.now()):e===i.LEAVE&&(S=3,d=Math.ceil((Date.now()-f)/1e3)),y&&H({busSegment:y.busSegment||"",circulation:S,domain:y.domain,duration:d,module:y.module||"",path:y.path,url:y.url,sourceDomain:y.sourceDomain,sourceUrl:y.sourceUrl,properties:y.properties,title:y.title,traceId:"",trackId:s(),visitPage:y.visitPage,visitTime:p(m),uid:v},v)}let F=e=>{if("object"!=typeof e)return e;var t,n=Array.isArray(e)?[]:{};for(t in e)"object"==typeof e[t]?n[t]=F(e[t]):n[t]=e[t];return n},w=[],b="UNIBPNEventSrcData",W="UNIBPNEventFailData",G;function K(e){var t=e.$page||"",n=t.path||((n=(n=getCurrentPages())[n.length-1])?n.route:"/"),t={utm:e.$utm||R(),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:j(n),path:n||"",title:t.title||"",url:n||""},properties:e.$extend_param?JSON.stringify(e.$extend_param):"",traceId:"",trackId:s(),triggerTime:p(Date.now())};e=t,w.push(e),clearTimeout(G),G=setTimeout(()=>{var n=F(w);if(n.length){{let e,t=(e=(c.platform===a?wx:uni).getStorageSync(b))?JSON.parse(e):[];n&&n.length&&(n.forEach(e=>{t.push(e)}),(c.platform===a?wx:uni).setStorageSync(b,JSON.stringify(t)))}w.length=0}},2e3)}let x,T,k,U,E,O,N;function Y(){P(i.LEAVE,null),clearInterval(U),U=null}function P(e,t){e===i.ENTER?(O=null,N=0,E=1,x=0,T=-1,k=-1,T=Date.now(),k=T,N=g(),O=(e=>{var t=getCurrentPages(),n=t[t.length-1],r=c.platform;let o="",a="",i="",u="";if(r&&("web"===r||"h5"===r?(o=window.location.href,a=window.location.hostname,document.referrer&&(r=new URL(document.referrer),i=r||"",u=r.hostname||"")):(o=n.route,1<t.length&&(r=t[t.length-2],i=r.route),a=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:a,url:o,visitPage:t.length,sourceDomain:u,sourceUrl:i}})(t)):e===i.LOOP?(E=2,x=15,k=Date.now()):e===i.LEAVE&&(E=3,x=Math.ceil((Date.now()-k)/1e3));t={busSegment:O.busSegment,circulation:E,domain:O.domain,duration:x,module:O.module,path:O.path,properties:O.properties,sourceDomain:O.sourceDomain,sourceUrl:O.sourceUrl,title:O.title,traceId:"",trackId:s(),url:O.url,visitPage:O.visitPage,visitTime:p(T),utm:R(),uid:N};H(t,N)}let A=!1;function D(e){if(!c.isCompatible)if(console.log("----msg--",e),"pv"===e){var n=getCurrentPages();let t=n[n.length-1];c.signTrackArray&&c.signTrackArray.length&&(A=c.signTrackArray.find(e=>e===t.route))?A=!0:(A=!1,((t,e,n)=>{var r=l.find(e=>e.path===t),o=c.platform;let a="",i="",u="",s="";o&&("web"===o||"h5"===o?(a=window.location.href,i=window.location.hostname,document.referrer&&(o=new URL(document.referrer),u=o||"",s=o.hostname||"")):(a=t,1<e&&(o=n[e-2],u=o.route),i=c.domain||t)),r&&r.path&&r.path,r&&r.busSegment?r.busSegment:c.busSegment,r&&r.module?r.module:c.module,r&&r.properties&&r.properties,i,a,s,u,r&&r.title&&r.title})(t.route,n.length,n),z())}else"leave"===e&&(console.log("--msg leave----",e),A||q())}let B="v_userId",Z="v_anonId",Q="2e7b05624b068c071618750728921cd8#1.0.0-alpha.30",_={distinctId:"",anonymousId:""},X={},ee={},te=null;class C{init(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,Object.assign(c,e),this.getBaseicInfo(),c.platform===a?(_.distinctId=wx.getStorageSync(M)?wx.getStorageSync(M):"",_.anonymousId=(()=>{let e=wx.getStorageSync(V);return e&&(e=g(),wx.setStorageSync(V,e)),e})()):(_.distinctId=uni.getStorageSync(B)||"",_.anonymousId=uni.getStorageSync(Z),_.anonymousId||(_.anonymousId=g(),uni.setStorageSync(Z,_.anonymousId))),s(),this.startGlobalTime(),c.platform!==a&&(uni.addInterceptor("navigateTo",{invoke(e){D("leave")},success(e){D("pv")}}),uni.addInterceptor("switchTab",{invoke(e){D("leave")},success(e){D("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){D("leave")},success(e){D("pv")}}))):console.log("init config error, please check config!")}startGlobalTime(){clearInterval(te),te=setInterval(()=>{{let e=null,t=null;var n=[],r=(t=(c.platform===a?(e=wx.getStorageSync(b),wx.setStorageSync(b,""),wx):(e=uni.getStorageSync(b),uni.setStorageSync(b,""),uni)).getStorageSync(W),e?JSON.parse(e):[]),o=t?JSON.parse(t):[];r.length&&n.push(...r),o.length&&n.push(...o),n&&n.length&&C.reportTrackEventServer("event",n,W)}{let e=null,t=null;r=[],t=(c.platform===a?(e=wx.getStorageSync(u),wx.setStorageSync(u,""),wx):(e=uni.getStorageSync(u),uni.setStorageSync(u,""),uni)).getStorageSync($),o=e?JSON.parse(e):[],n=t?JSON.parse(t):[],o.length&&r.push(...o),n.length&&(r.push(...n),r.forEach(e=>{delete e.pageUUId})),r&&r.length&&C.reportTrackEventServer("track",r,$)}},15e3)}setUserId(e){e?(_.distinctId=e,(c.platform===a?wx:uni).setStorageSync(B,e)):(_.distinctId="",c.platform===a?wx.setStorageSync(B,e):uni.setStorageSync(B,""))}getTrackId(){return s()}setCustomEvent(e){K(e)}onStartTrack(e){e=e,U&&Y(),e&&(clearInterval(U),P(i.ENTER,e),U=setInterval(()=>{P(i.LOOP,null)},15e3))}onDestroyTrack(){Y()}setPageExtraObj(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)}}reportTrackEventServer(e,t,n){var r;e?(r={...r=this.commonData(t),dataAbstract:j(JSON.stringify(r))},c.platform===a?wx.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){e&&e.data?wx.setStorageSync(n,JSON.stringify(t)):wx.setStorageSync(n,"")},fail:function(e){console.error(e),wx.setStorageSync(n,JSON.stringify(t))}}):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){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")}commonData(e){return{app:X,data:e,device:ee,lsi:Q,projectId:c.token,userAgent:c.uAgent||"",anonymousId:_.anonymousId,userId:_.distinctId}}getBaseicInfo(){var e;c.platform=a,X={name:"",packageName:(e=wx.getAccountInfoSync().miniProgram)?e.appId:"",version:e?e.envVersion+e.version:"",carrier:"mini",ecology:"mini"},ee=(()=>{var t,e=wx.getSystemInfoSync();let n={lang:e.language,brand:e.brand+" "+e.model,os:e.platform,osVersion:e.system,resolution:e.screenWidth+"x"+e.screenHeight,browser:"",browserVersion:"",color:"",deviceId:"",deviceType:(t=e.system,["Windows","Linux","macOS"].every(e=>t.includes(e))?1:2),network:""};return wx.getNetworkType({success(e){n.network=e.networkType}}),n})()}}e.BuriedPointUni=C,Object.defineProperty(e,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,15 +1,18 @@
1
1
  {
2
2
  "name": "visual-buried-point-platform-uni",
3
- "version": "1.0.0-alpha.03",
4
- "lsi": "9b6bb5e44edfe8d4f2b9bfaad5c392fb",
3
+ "version": "1.0.0-alpha.31",
4
+ "lsi": "c0b9508734e8698708cada65f19d0214#1.0.0-alpha.31",
5
5
  "description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.",
6
- "main": "index.js",
6
+ "main": "dist/cjs/buried-point-uni.js",
7
+ "module": "dist/esm/buried-point-uni.js",
8
+ "umd:main": "dist/umd/buried-point-uni.js",
7
9
  "scripts": {
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"
10
+ "build": "rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.cjs"
11
11
  },
12
12
  "type": "module",
13
+ "files": [
14
+ "dist"
15
+ ],
13
16
  "repository": {
14
17
  "type": "git",
15
18
  "url": ""
@@ -21,7 +24,19 @@
21
24
  "md5": "^2.3.0"
22
25
  },
23
26
  "devDependencies": {
27
+ "rimraf": "^6.0.1",
24
28
  "webpack": "^5.72.1",
25
- "webpack-cli": "4.9.2"
29
+ "webpack-cli": "^6.0.1",
30
+ "@babel/core": "^7.26.10",
31
+ "@babel/preset-env": "^7.26.9",
32
+ "@rollup/plugin-json": "^6.0.1",
33
+ "babel-loader": "^10.0.0",
34
+ "babel-preset-es2015": "^6.24.1",
35
+ "rollup": "^1.20.2",
36
+ "rollup-plugin-babel": "^4.3.3",
37
+ "rollup-plugin-commonjs": "^10.0.2",
38
+ "rollup-plugin-node-resolve": "^5.2.0",
39
+ "rollup-plugin-replace": "^2.2.0",
40
+ "rollup-plugin-uglify": "^6.0.2"
26
41
  }
27
42
  }
package/bpstorage.js DELETED
@@ -1,29 +0,0 @@
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 DELETED
@@ -1,28 +0,0 @@
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 DELETED
@@ -1,25 +0,0 @@
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/index.js DELETED
@@ -1,307 +0,0 @@
1
- import MD5 from "md5";
2
- import pk from "./package.json";
3
- import { addCache, getCache, clearCache } from "./cache.js";
4
- import { addSData, getSData, delSData } from "./bpstorage.js";
5
- import {
6
- randomUUID,
7
- webH5Info,
8
- wxInfo,
9
- getAppInfo,
10
- getDeviceInfo,
11
- getDeviceInfoError,
12
- timeToStr,
13
- getTrackObj,
14
- } from "./tools.js";
15
- import { setReportUrl } from "./config.js";
16
-
17
- const localLsi = pk.lsi;
18
- let platform = "";
19
- let uAgent = "";
20
- let reportUrl = "";
21
- let reportTrackUrl = "";
22
- let trackId = "";
23
- let _comInfo = { distinctId: "", anonymousId: "" };
24
- let appData = {};
25
- let deviceData = {};
26
- let _config = {
27
- env: "production",
28
- token: "",
29
- srcDomain: "",
30
- flushInterval: 15,
31
- };
32
- //track upload interval
33
- let tInterval = null;
34
- let busObj = null;
35
- let startTime = 0;
36
- let startTimeLong = 0;
37
-
38
- //common global upload interval
39
- let cInterval = null;
40
-
41
- export function init(config) {
42
- if (config) {
43
- let _cf = setReportUrl(config.env ? config.env : "");
44
- reportUrl = _cf.reportUrl;
45
- reportTrackUrl = _cf.reportTrackUrl;
46
- if (config.flushInterval) {
47
- if (config.flushInterval < 5) {
48
- config.flushInterval = 15;
49
- }
50
- } else {
51
- config.flushInterval = 15;
52
- }
53
- _config = {
54
- env: config.env,
55
- token: config.token ? config.token : "",
56
- srcDomain: config.sourceDomain ? config.sourceDomain : "",
57
- flushInterval: config.flushInterval,
58
- };
59
- getBaseicInfo();
60
- _comInfo.distinctId = uni.getStorageSync("v_userId")
61
- ? uni.getStorageSync("v_userId")
62
- : "";
63
- _comInfo.anonymousId = uni.getStorageSync("v_anonId");
64
- if (!_comInfo.anonymousId) {
65
- _comInfo.anonymousId = randomUUID();
66
- uni.setStorageSync("v_anonId", _comInfo.anonymousId);
67
- }
68
- if (!trackId) {
69
- trackId = Date.now().toString();
70
- }
71
- } else {
72
- console.log("init config error, please check config!");
73
- }
74
- startGlobalTime();
75
- }
76
-
77
- //the general custom reportCustom interval is enabled
78
- function startGlobalTime() {
79
- clearInterval(cInterval);
80
- cInterval = setInterval(() => {
81
- let cData = getSData();
82
- console.log("storage data " + JSON.stringify(cData));
83
- if (cData) {
84
- reportCustom(cData);
85
- delSData();
86
- }
87
- }, _config.flushInterval * 1000);
88
- }
89
-
90
- //bind userID
91
- export function setUserId(userId) {
92
- if (userId) {
93
- _comInfo.distinctId = userId;
94
- uni.setStorageSync("v_userId", userId);
95
- } else {
96
- _comInfo.distinctId = "";
97
- uni.setStorageSync("v_userId", "");
98
- }
99
- }
100
-
101
- //set custom event
102
- export function setCustomEvent(data) {
103
- let reportData = null;
104
- const _page = data.$page ? data.$page : "";
105
- const _path = _page.path ? _page.path : getCurPath();
106
- reportData = {
107
- ctk: data.$ctk ? data.$ctk : "",
108
- duration: "",
109
- element: null,
110
- eventId: data.$event_id ? data.$event_id : "",
111
- event: data.$event_code ? data.$event_code : "",
112
- groupId: "",
113
- busSegment: data.$busSegment,
114
- module: data.$module,
115
- page: {
116
- domain: _page.domain ? _page.domain : "",
117
- pageId: MD5(_path),
118
- path: _path,
119
- title: _page.title ? _page.title : "",
120
- },
121
- path: data.$path ? data.$path : "",
122
- properties: data.$extend_param ? JSON.stringify(data.$extend_param) : "",
123
- traceId: "",
124
- trackId: trackId,
125
- triggerTime: timeToStr(Date.now()),
126
- url: "",
127
- };
128
- if (reportData) {
129
- addCache(reportData);
130
- const data = getCache();
131
- if (data.length) {
132
- console.log("customData: ", JSON.stringify(data));
133
- addSData(data);
134
- clearCache();
135
- }
136
- }
137
- }
138
-
139
- function reportCustom(data) {
140
- if (!reportUrl) {
141
- //console.error("please set upload data url");
142
- return;
143
- }
144
- const comData = commonData(data);
145
- const reportData = {
146
- ...comData,
147
- dataAbstract: MD5(JSON.stringify(comData)),
148
- };
149
- uni.request({
150
- url: reportUrl,
151
- method: "POST",
152
- header: {
153
- "Content-Type": "application/json",
154
- appKey: _config.token,
155
- projectId: _config.token,
156
- },
157
- data: reportData,
158
- success: function (res) {},
159
- fail: function (error) {
160
- console.error(error);
161
- },
162
- });
163
- }
164
-
165
- //track upload-注册
166
- export function onStartTrack(tData) {
167
- busObj = null;
168
- startTime = 0;
169
- startTimeLong = Date.now();
170
- busObj = tData;
171
- clearInterval(tInterval);
172
- assemblyTrackData("start");
173
- tInterval = setInterval(() => {
174
- startTime += 15;
175
- startTimeLong = Date.now();
176
- assemblyTrackData("start");
177
- }, 15 * 1000);
178
- }
179
-
180
- //track upload-销毁
181
- export function onDestroyTrack() {
182
- assemblyTrackData("destroy");
183
- clearInterval(tInterval);
184
- }
185
-
186
- function assemblyTrackData(type) {
187
- if (busObj) {
188
- let obj = getTrackObj(busObj);
189
- let trackData = null;
190
- if (type === "destroy") {
191
- startTime = (Date.now() - startTimeLong) / 1000;
192
- }
193
- trackData = {
194
- busSegment: busObj.busSegment,
195
- circulation: obj.circulation,
196
- ctk: busObj.ctk ? busObj.ctk : "",
197
- domain: obj.domain,
198
- duration: startTime === 0 ? 0 : startTime,
199
- module: busObj.module,
200
- path: obj.path,
201
- properties: busObj.extend_param
202
- ? JSON.stringify(busObj.extend_param)
203
- : "",
204
- sourceDomain: obj.sourceDomain ? obj.sourceDomain : _config.srcDomain,
205
- sourceUrl: obj.sourceUrl,
206
- title: obj.title,
207
- traceId: busObj.traceId ? busObj.traceId : "",
208
- trackId: trackId,
209
- url: obj.url,
210
- visitPage: obj.visitPage,
211
- visitTime: busObj.visitTime ? busObj.visitTime : timeToStr(Date.now()),
212
- };
213
- if (trackData) {
214
- reportTrack([trackData]);
215
- }
216
- }
217
- }
218
-
219
- // track upload data
220
- function reportTrack(data) {
221
- if (!reportTrackUrl) {
222
- return;
223
- }
224
- const comData = commonData(data);
225
- const reportTrackData = {
226
- ...comData,
227
- dataAbstract: MD5(JSON.stringify(comData)),
228
- };
229
- uni.request({
230
- url: reportTrackUrl,
231
- method: "POST",
232
- header: {
233
- "Content-Type": "application/json",
234
- appKey: _config.token,
235
- projectId: _config.token,
236
- },
237
- data: reportTrackData,
238
- success: function (res) {},
239
- fail: function (error) {
240
- console.error(error);
241
- },
242
- });
243
- }
244
-
245
- function getCurPath() {
246
- if (platform) {
247
- if (platform == "wx") {
248
- let gcp = getCurrentPages();
249
- return gcp ? gcp[gcp.length - 1].route : "/";
250
- } else if (platform == "web") {
251
- return window.location.hostname;
252
- } else if (platform == "android" || platform === "ios") {
253
- return "";
254
- }
255
- }
256
- }
257
-
258
- function commonData(allData) {
259
- return {
260
- app: appData,
261
- data: allData,
262
- deviceData: deviceData,
263
- lsi: localLsi,
264
- projectId: _config.token,
265
- userAgent: uAgent ? uAgent : "",
266
- anonymousId: _comInfo.anonymousId,
267
- userId: _comInfo.distinctId,
268
- };
269
- }
270
-
271
- //获取基本信息
272
- function getBaseicInfo() {
273
- uni.getSystemInfo({
274
- success: function (res) {
275
- uAgent = res.ua;
276
- let uniPlatform = res.uniPlatform;
277
- if (uniPlatform.includes("app")) {
278
- platform = res.osName;
279
- appData = getAppInfo(res);
280
- } else if (uniPlatform.includes("web") || uniPlatform.includes("h5")) {
281
- platform = uniPlatform;
282
- let wh5Info = webH5Info(res);
283
- appData = {
284
- ...wh5Info,
285
- version: _config.version ? _config.version : "unknown",
286
- };
287
- } else if (uniPlatform.includes("weixin")) {
288
- platform = "wx";
289
- appData = wxInfo();
290
- }
291
- deviceData = getDeviceInfo(res);
292
- },
293
- fail: function (error) {
294
- deviceData = getDeviceInfoError();
295
- },
296
- complete: function () {
297
- uni.getNetworkType({
298
- success(res) {
299
- deviceData = {
300
- ...deviceData,
301
- network: res.networkType,
302
- };
303
- },
304
- });
305
- },
306
- });
307
- }
package/lsi-md5.js DELETED
@@ -1,21 +0,0 @@
1
- // 此js在npm build,根据name + version + md5后会自动修改package.json中的lsi
2
- // 注:发给后端,作为标识依据和上报字段lsi值
3
- import fs from 'fs' ;
4
- import MD5 from 'md5' ;
5
- const packageJson = JSON.parse(fs.readFileSync('./package.json', 'utf-8'));
6
-
7
-
8
- const { name, version } = packageJson;
9
- // MD5
10
- const combinedString = name + "-" + version;
11
- const md5Str = MD5(combinedString);
12
- packageJson.lsi = md5Str;
13
- //base64
14
- // const combinedString = name.substring(0, 16) + "v" + version;
15
- // const base64Str = btoa(combinedString);
16
- // packageJson.lsi = base64Str;
17
-
18
- const updatedPackageJson = JSON.stringify(packageJson, null, 2);
19
- fs.writeFileSync("./package.json", updatedPackageJson, "utf8");
20
-
21
- console.log('write package.json "lsi" value success ');
package/tools.js DELETED
@@ -1,182 +0,0 @@
1
- export function randomUUID() {
2
- let uuid = "xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function (c) {
3
- let r = (Math.random() * 16) | 0,
4
- v = c === "x" ? r : (r & 0x3) | 0x8;
5
- return v.toString(16);
6
- });
7
- return uuid;
8
- }
9
-
10
- export function timeToStr(timestamp) {
11
- const date = new Date(timestamp);
12
- const year = date.getFullYear();
13
- const month =
14
- date.getMonth() + 1 < 10
15
- ? "0" + (date.getMonth() + 1)
16
- : date.getMonth() + 1;
17
- const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
18
- const hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
19
- const minute =
20
- date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
21
- const second =
22
- date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
23
- const formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
24
- return formattedDate;
25
- }
26
-
27
- //web或者h5的appInfo
28
- export function webH5Info(result) {
29
- let ecology = "unknown";
30
- let ua = result.ua.toLowerCase();
31
- let hostname = window.location.hostname;
32
- let titleName = document.title;
33
- let isMobile =
34
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua);
35
- if (isMobile) {
36
- ecology = "app";
37
- } else {
38
- ecology = "brower";
39
- }
40
- if (ua.includes("alipay")) {
41
- ecology = "alipay";
42
- } else if (ua.includes("unionPay")) {
43
- ecology = "unionPay";
44
- } else if (ua.includes("onbuygz")) {
45
- ecology = "onbuygz";
46
- } else if (ua.includes("onetravel")) {
47
- ecology = "onetravel";
48
- }
49
- if (ua.includes("micromessenger")) {
50
- if (ua.includes("miniprogram")) {
51
- ecology = "wechat";
52
- } else {
53
- ecology = "brower";
54
- }
55
- }
56
- return {
57
- name: titleName ? titleName : "",
58
- packageName: hostname ? hostname : "",
59
- version: "",
60
- carrier: "h5",
61
- ecology: ecology,
62
- };
63
- }
64
-
65
- //微信的appInfo
66
- export function wxInfo() {
67
- let accInfo = uni.getAccountInfoSync();
68
- return {
69
- name: "",
70
- packageName: accInfo ? accInfo.appId : "",
71
- version: accInfo ? accInfo.envVersion + accInfo.version : "",
72
- carrier: "mini",
73
- ecology: "wechat",
74
- };
75
- }
76
-
77
- //app的appInfo
78
- export function getAppInfo(result) {
79
- let version = plus.runtime.version;
80
- let app = {
81
- name: result.appName,
82
- version: version ? version : "",
83
- carrier: "app",
84
- };
85
- if (result.platform === "android") {
86
- let osName = "android";
87
- let pkName = plus.android.runtimeMainActivity().getPackageName();
88
- if (result.romName.includes("HarmonyOS")) {
89
- osName = "harmonyOS";
90
- }
91
- app = {
92
- ...app,
93
- packageName: pkName ? pkName : "",
94
- ecology: osName,
95
- };
96
- } else if (result.platform === "ios") {
97
- let pkName = plus.ios
98
- .importClass("NSBundle")
99
- .mainBundle()
100
- .bundleIdentifier();
101
- app = {
102
- ...app,
103
- packageName: pkName ? pkName : "",
104
- ecology: "ios",
105
- };
106
- } else {
107
- app = {
108
- ...app,
109
- packageName: "",
110
- version: "",
111
- ecology: "unknown",
112
- };
113
- }
114
- return app;
115
- }
116
-
117
- function getCurDeviceType(ua) {
118
- const userAgent = ua.toLowerCase();
119
- if (/(windows|win32|win64|wow64)/.test(userAgent)) {
120
- return 1;
121
- } else if (/(linux|android)/.test(userAgent)) {
122
- return 2;
123
- } else if (/(macintosh|mac os x|iphone|ipad|ipod)/.test(userAgent)) {
124
- return 2;
125
- } else {
126
- return 2;
127
- }
128
- }
129
-
130
- //获取设备信息
131
- export function getDeviceInfo(res) {
132
- let device = {
133
- lang: res.osLanguage ? res.osLanguage : res.hostLanguage,
134
- brand: res.deviceBrand + " " + res.deviceModel,
135
- os: res.os,
136
- osVersion: res.osVersion,
137
- resolution: res.screenWidth + "x" + res.screenHeight,
138
- browser: res.browserName,
139
- browserVersion: res.browserVersion,
140
- color: "",
141
- deviceId: res.deviceId,
142
- deviceType: getCurDeviceType(res.ua),
143
- network: "",
144
- };
145
- return device;
146
- }
147
-
148
- //error默认获取设备信息
149
- export function getDeviceInfoError() {
150
- return {
151
- lang: "",
152
- brand: "",
153
- os: "",
154
- osVersion: "",
155
- resolution: "",
156
- browser: "",
157
- browserVersion: "",
158
- color: "",
159
- deviceId: "",
160
- deviceType: "",
161
- network: "",
162
- };
163
- }
164
-
165
- //流量上报H5环境
166
- export function getTrackObj(busObj) {
167
- //uni 通用h5、app、wx拿到当前路由栈
168
- const pages = getCurrentPages();
169
- const gcp = pages[pages.length - 1];
170
- if (gcp) {
171
- return {
172
- path: gcp.route,
173
- domain: busObj.domain ? busObj.domain : "",
174
- url: busObj.url ? busObj.url : "",
175
- circulation: gcp.length > 1 ? 2 : 1,
176
- visitPage: gcp.length,
177
- sourceDomain: busObj.sourceDomain? busObj.sourceDomain : "",
178
- sourceUrl: busObj.sourceUrl? busObj.sourceUrl : "",
179
- title: busObj.title ? busObj.title : "",
180
- };
181
- }
182
- }
package/webpack.config.js DELETED
@@ -1,17 +0,0 @@
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
- };