visual-buried-point-platform-uni 1.0.0-alpha.8 → 2.0.0

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