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

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,8 +1,9 @@
1
1
  ## Uni版自定义埋点SDK集成文档
2
2
 
3
3
  ### SDK更新日志
4
- - 1.0.0-alpha.07 最新uni、终端通用埋点sdk;
5
- - 1.0.0-alpha.08 自定义上报数据结构删除path字段;
4
+ - v1.0.0-alpha.07 最新uni、终端通用埋点sdk;
5
+ - v1.0.0-alpha.08 自定义上报数据结构删除path字段;
6
+ - v2.0.0 调整SDK内部PVUV采集模式,分原有start方法采集及自动采集,支持获取埋点sdk内的跟踪id;
6
7
 
7
8
  ### 1、引入方式
8
9
 
@@ -20,7 +21,9 @@ onLaunch: function() {
20
21
  init({
21
22
  env: 'test', //环境变量 test production
22
23
  token: '3212414516342554624', //热果平台-可视化埋点管理端-创建对应的项目生成.
23
- sourceDomain: 'com.gzdzswy.onetravel', // 非必填,访问来源域名,取优先级:单次调用上报值 > 全局初始化值
24
+ domain: 'com.gzdzswy.onetravel', // 非必填,访问来源域名,取优先级:单次调用上报值 > 全局初始化值
25
+ isCompatible: true, // 是否兼容老方案埋点,默认兼容true,自动采集则改为false
26
+ signTrackArray: [], // 自动采集但需要单独埋点的页面path
24
27
  })
25
28
  }
26
29
  });
@@ -47,12 +50,18 @@ setUserId(123456);
47
50
  ```js
48
51
  setUserId("");
49
52
  ```
53
+ ## 4.获取埋点SDK内跟踪ID
50
54
 
51
- ### 4、自定义事件上报
55
+ ```js
56
+ import { getTrackId } from 'visual-buried-point-platform-uni'
57
+ buriedPoint.getTrackId()
58
+ ```
59
+
60
+ ## 5、自定义事件上报
52
61
 
53
62
  - sdk初始化后,可通过 ***setCustomEvent()*** 方法上报自定义埋点事件,并为事件添加属性值:
54
63
 
55
- #### 4.1 事件类型:
64
+ #### 5.1 事件类型:
56
65
 
57
66
  - 仅能选择埋点提供的事件类型,各事件类型的触发、上报由各业务平台埋点自行确认。事件类型如下:
58
67
  - **搜索事件【 search 】**
@@ -124,7 +133,7 @@ const params = {
124
133
  setCustomEvent(params)
125
134
  ```
126
135
 
127
- ### 5、流量上报
136
+ ## 6、流量上报
128
137
 
129
138
  - sdk初始化后,可通过**onStartTrack(params)** 方法注册上报流量,并为上报添加属性值:
130
139
 
@@ -179,13 +188,13 @@ onDestroyTrack()
179
188
 
180
189
  注: 上报数据是否成功可查看NetWork栏,调用流量上报 **track 接口** 和 自定义上报 **event 接口**的 response
181
190
 
182
- #### 6、埋点后台管理系统
191
+ ## 7、埋点后台管理系统
183
192
 
184
193
  ##### 云测管理端地址
185
194
 
186
195
  - chameleon.gcongo.com.cn
187
196
 
188
- #### 7、SDK 文档
197
+ ## 8、SDK 文档
189
198
 
190
199
  http://verdaccio.gogdev.cn/-/web/detail/visual-buried-point-platform-uni
191
200
 
@@ -0,0 +1 @@
1
+ "use strict";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}Object.defineProperty(exports,"__esModule",{value:!0});var crypt=createCommonjsModule(function(e){var o,r;o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",r={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&r.rotl(e,8)|4278255360&r.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=r.endian(e[t]);return e},randomBytes:function(e){for(var t=[];0<e;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],r=0,n=0;r<e.length;r++,n+=8)t[n>>>5]|=e[r]<<24-n%32;return t},wordsToBytes:function(e){for(var t=[],r=0;r<32*e.length;r+=8)t.push(e[r>>>5]>>>24-r%32&255);return t},bytesToHex:function(e){for(var t=[],r=0;r<e.length;r++)t.push((e[r]>>>4).toString(16)),t.push((15&e[r]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],r=0;r<e.length;r+=2)t.push(parseInt(e.substr(r,2),16));return t},bytesToBase64:function(e){for(var t=[],r=0;r<e.length;r+=3)for(var n=e[r]<<16|e[r+1]<<8|e[r+2],a=0;a<4;a++)8*r+6*a<=8*e.length?t.push(o.charAt(n>>>6*(3-a)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],r=0,n=0;r<e.length;n=++r%4)0!=n&&t.push((o.indexOf(e.charAt(r-1))&Math.pow(2,-2*n+8)-1)<<2*n|o.indexOf(e.charAt(r))>>>6-2*n);return t}},e.exports=r}),charenc={utf8:{stringToBytes:function(e){return charenc.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(charenc.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],r=0;r<e.length;r++)t.push(255&e.charCodeAt(r));return t},bytesToString:function(e){for(var t=[],r=0;r<e.length;r++)t.push(String.fromCharCode(e[r]));return t.join("")}}},charenc_1=charenc,isBuffer_1=function(e){return null!=e&&(isBuffer(e)||isSlowBuffer(e)||!!e._isBuffer)};function isBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isBuffer(e.slice(0,0))}var md5=createCommonjsModule(function(e){function v(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?I:b).stringToBytes(e):h(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var r=T.bytesToWords(e),t=8*e.length,n=1732584193,a=-271733879,o=-1732584194,i=271733878,s=0;s<r.length;s++)r[s]=16711935&(r[s]<<8|r[s]>>>24)|4278255360&(r[s]<<24|r[s]>>>8);r[t>>>5]|=128<<t%32,r[14+(64+t>>>9<<4)]=t;for(var u=v._ff,c=v._gg,l=v._hh,p=v._ii,s=0;s<r.length;s+=16){var g=n,d=a,m=o,f=i,n=u(n,a,o,i,r[s+0],7,-680876936),i=u(i,n,a,o,r[s+1],12,-389564586),o=u(o,i,n,a,r[s+2],17,606105819),a=u(a,o,i,n,r[s+3],22,-1044525330);n=u(n,a,o,i,r[s+4],7,-176418897),i=u(i,n,a,o,r[s+5],12,1200080426),o=u(o,i,n,a,r[s+6],17,-1473231341),a=u(a,o,i,n,r[s+7],22,-45705983),n=u(n,a,o,i,r[s+8],7,1770035416),i=u(i,n,a,o,r[s+9],12,-1958414417),o=u(o,i,n,a,r[s+10],17,-42063),a=u(a,o,i,n,r[s+11],22,-1990404162),n=u(n,a,o,i,r[s+12],7,1804603682),i=u(i,n,a,o,r[s+13],12,-40341101),o=u(o,i,n,a,r[s+14],17,-1502002290),n=c(n,a=u(a,o,i,n,r[s+15],22,1236535329),o,i,r[s+1],5,-165796510),i=c(i,n,a,o,r[s+6],9,-1069501632),o=c(o,i,n,a,r[s+11],14,643717713),a=c(a,o,i,n,r[s+0],20,-373897302),n=c(n,a,o,i,r[s+5],5,-701558691),i=c(i,n,a,o,r[s+10],9,38016083),o=c(o,i,n,a,r[s+15],14,-660478335),a=c(a,o,i,n,r[s+4],20,-405537848),n=c(n,a,o,i,r[s+9],5,568446438),i=c(i,n,a,o,r[s+14],9,-1019803690),o=c(o,i,n,a,r[s+3],14,-187363961),a=c(a,o,i,n,r[s+8],20,1163531501),n=c(n,a,o,i,r[s+13],5,-1444681467),i=c(i,n,a,o,r[s+2],9,-51403784),o=c(o,i,n,a,r[s+7],14,1735328473),n=l(n,a=c(a,o,i,n,r[s+12],20,-1926607734),o,i,r[s+5],4,-378558),i=l(i,n,a,o,r[s+8],11,-2022574463),o=l(o,i,n,a,r[s+11],16,1839030562),a=l(a,o,i,n,r[s+14],23,-35309556),n=l(n,a,o,i,r[s+1],4,-1530992060),i=l(i,n,a,o,r[s+4],11,1272893353),o=l(o,i,n,a,r[s+7],16,-155497632),a=l(a,o,i,n,r[s+10],23,-1094730640),n=l(n,a,o,i,r[s+13],4,681279174),i=l(i,n,a,o,r[s+0],11,-358537222),o=l(o,i,n,a,r[s+3],16,-722521979),a=l(a,o,i,n,r[s+6],23,76029189),n=l(n,a,o,i,r[s+9],4,-640364487),i=l(i,n,a,o,r[s+12],11,-421815835),o=l(o,i,n,a,r[s+15],16,530742520),n=p(n,a=l(a,o,i,n,r[s+2],23,-995338651),o,i,r[s+0],6,-198630844),i=p(i,n,a,o,r[s+7],10,1126891415),o=p(o,i,n,a,r[s+14],15,-1416354905),a=p(a,o,i,n,r[s+5],21,-57434055),n=p(n,a,o,i,r[s+12],6,1700485571),i=p(i,n,a,o,r[s+3],10,-1894986606),o=p(o,i,n,a,r[s+10],15,-1051523),a=p(a,o,i,n,r[s+1],21,-2054922799),n=p(n,a,o,i,r[s+8],6,1873313359),i=p(i,n,a,o,r[s+15],10,-30611744),o=p(o,i,n,a,r[s+6],15,-1560198380),a=p(a,o,i,n,r[s+13],21,1309151649),n=p(n,a,o,i,r[s+4],6,-145523070),i=p(i,n,a,o,r[s+11],10,-1120210379),o=p(o,i,n,a,r[s+2],15,718787259),a=p(a,o,i,n,r[s+9],21,-343485551),n=n+g>>>0,a=a+d>>>0,o=o+m>>>0,i=i+f>>>0}return T.endian([n,a,o,i])}var T,b,h,I;T=crypt,b=charenc_1.utf8,h=isBuffer_1,I=charenc_1.bin,v._ff=function(e,t,r,n,a,o,i){e=e+(t&r|~t&n)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._gg=function(e,t,r,n,a,o,i){e=e+(t&n|r&~n)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._hh=function(e,t,r,n,a,o,i){e=e+(t^r^n)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._ii=function(e,t,r,n,a,o,i){e=e+(r^(t|~n))+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=T.wordsToBytes(v(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):T.bytesToHex(e)}});let Global={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},pagesArray=[];const sdkTrackIdVal=()=>{var e;return Global.trackId||(e=Date.now().toString(),Global.trackId=e)};function randomUUID(){return"xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function timeToStr(e){e=new Date(e);return e.getFullYear()+`-${e.getMonth()+1<10?"0"+(e.getMonth()+1):e.getMonth()+1}-${e.getDate()<10?"0"+e.getDate():e.getDate()} ${e.getHours()<10?"0"+e.getHours():e.getHours()}:${e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes()}:`+(e.getSeconds()<10?"0"+e.getSeconds():e.getSeconds())}function getWebH5Info(e){var e=e.ua.toLowerCase(),t=window.location.hostname,r=document.title;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e);return e.includes("alipay")||e.includes("unionPay")||e.includes("onbuygz")||e.includes("onetravel"),e.includes("micromessenger")&&e.includes("miniprogram"),{name:r||"",packageName:t||"",version:"",carrier:"h5",ecology:"h5"}}function getWXInfo(){var e=uni.getAccountInfoSync(),t=uni.getAppBaseInfo();return{name:t.appName||"",packageName:e?e.miniProgram.appId:"",version:e?e.miniProgram.envVersion+e.miniProgram.version:"",carrier:"mini",ecology:"mini"}}function getAppInfo(t){var r=plus.runtime.version,r={name:t.appName,version:r||"",carrier:"app",packageName:"",ecology:""};if("android"===t.platform){let e="Android";var n=plus.android.runtimeMainActivity().getPackageName();t.romName.includes("HarmonyOS")&&(e="Harmony OS"),r.packageName=n||"",r.ecology=e}else"ios"===t.platform?(n=plus.ios.importClass("NSBundle").mainBundle().bundleIdentifier(),r.packageName=n||"",r.ecology="iOS"):r.ecology="unknown";return r}function getCurDeviceType(e,t){return"wx"!==t?(t=e.ua.toLowerCase(),/(windows|win32|win64|wow64)/.test(t)?1:(/(linux|android)/.test(t)||/(macintosh|mac os x|iphone|ipad|ipod)/.test(t),2)):"pc"===e.deviceType?1:2}function getDeviceInfo(e,t){return{lang:e.osLanguage||e.hostLanguage,brand:e.deviceBrand+" "+e.deviceModel,os:e.osName,osVersion:e.osVersion,resolution:e.screenWidth+"x"+e.screenHeight,browser:e.browserName,browserVersion:e.browserVersion,color:"",deviceId:e.deviceId,deviceType:getCurDeviceType(e,t),network:""}}function getDeviceInfoError(){return{lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}}function getTrackObj(e){var t=getCurrentPages(),r=t[t.length-1],n=Global.platform;let a="",o="",i="",s="";if(n&&("web"===n||"h5"===n?(a=window.location.href,o=window.location.hostname,document.referrer&&(n=new URL(document.referrer),i=n||"",s=n.hostname||"")):(a=r.route,1<t.length&&(n=t[t.length-2],i=n.route),o=Global.domain||r.route)),r)return{path:r.route,busSegment:e.busSegment||"",module:e.module||"",properties:e.extend_param?JSON.stringify(e.extend_param):"",title:e.title||"",domain:o,url:a,visitPage:t.length,sourceDomain:s,sourceUrl:i}}function uUpdatePageExtraArray(e){var t=getCurrentPages();let r=t[t.length-1];t=pagesArray.findIndex(e=>e.path===r.route),e={path:r.route,properties:e.properties?JSON.stringify(e.properties):"",busSegment:e.busSegment||"",module:e.module||"",title:e.title||""};-1!==t?pagesArray[t]=e:pagesArray.push(e)}const AUTOTRACKTYPE={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},BPNPVUV="UNIBPNPVUVSrcData",BPNPVUVFail="UNIBPNPVUVFailData";let atDuration,atEnterTimeLong,atLoopTimeLong,cirtemp,atObj,atInterval=null,cUUId=null;function clearUAData(){clearInterval(atInterval),atDuration=0,atEnterTimeLong=0,atLoopTimeLong=0,cirtemp=1,atObj=null,atInterval=null,cUUId=0}const uAutoStartTrackPVData=e=>{atInterval?autoStopTrackPVUV():(clearUAData(),atObj=e,autoTrackData(AUTOTRACKTYPE.ENTER),atInterval=setInterval(()=>{autoTrackData(AUTOTRACKTYPE.LOOP)},Global.pageInterval))},autoStopTrackPVUV=()=>{autoTrackData(AUTOTRACKTYPE.LEAVE),clearInterval(atInterval)};function autoTrackData(e){e===AUTOTRACKTYPE.ENTER?(cirtemp=1,atDuration=0,atEnterTimeLong=Date.now(),atLoopTimeLong=atEnterTimeLong,cUUId=randomUUID()):e===AUTOTRACKTYPE.LOOP?(cirtemp=2,atDuration=15,atLoopTimeLong=Date.now()):e===AUTOTRACKTYPE.LEAVE&&(cirtemp=3,atDuration=Math.ceil((Date.now()-atLoopTimeLong)/1e3)),atObj&&insertPVUVData({busSegment:atObj.busSegment||"",circulation:cirtemp,ctk:"",domain:atObj.domain,duration:atDuration,module:atObj.module||"",path:atObj.path,url:atObj.url,sourceDomain:atObj.sourceDomain,sourceUrl:atObj.sourceUrl,properties:atObj.properties,title:atObj.title,traceId:"",trackId:sdkTrackIdVal(),visitPage:atObj.visitPage,visitTime:timeToStr(atEnterTimeLong),pageUUId:cUUId},cUUId)}function insertPVUVData(e,t){var r,n=uni.getStorageSync(BPNPVUV),n=n?JSON.parse(n):[];0<n.length&&-1!==(r=n.findIndex(e=>e.pageUUId===t))?n[r]={...n[r],...e}:n.push(e),uni.setStorageSync(BPNPVUV,JSON.stringify(n))}function autoPageObj(t,e,r){var n=pagesArray.find(e=>e.path===t),a=Global.platform;let o="",i="",s="",u="";return a&&("web"===a||"h5"===a?(o=window.location.href,i=window.location.hostname,document.referrer&&(a=new URL(document.referrer),s=a||"",u=a.hostname||"")):(o=t,1<e&&(a=r[e-2],s=a.route),i=Global.domain||t)),{path:n&&n.path?n.path:t,busSegment:n&&n.busSegment?n.busSegment:Global.busSegment||"",module:n&&n.module?n.module:Global.module||"",properties:n&&n.properties?n.properties:"",domain:i,url:o,visitPage:e,sourceDomain:u,sourceUrl:s,title:n&&n.title?n.title:""}}function queryTrackDataUpload(){var e=uni.getStorageSync(BPNPVUV),e=(uni.setStorageSync(BPNPVUV,""),e?JSON.parse(e):[]),t=[],r=uni.getStorageSync(BPNPVUVFail),r=r?JSON.parse(r):[];e.length&&t.push(...e),r.length&&t.push(...r),t&&t.length&&(t.forEach(e=>{delete e.pageUUId}),reportTrackEventServer("track",t,BPNPVUVFail))}function setReportUrl(e){return"test"!==e?{reportUrl:"https://buryingpoint.onebuygz.com/client/api/event",reportTrackUrl:"https://buryingpoint.onebuygz.com/client/api/track",eventListUrl:"https://buryingpoint.onebuygz.com/api/event/query/eventList"}:{reportUrl:"https://buryingpoint.gcongo.com.cn/client/api/event",reportTrackUrl:"https://buryingpoint.gcongo.com.cn/client/api/track",eventListUrl:"https://buryingpoint.gcongo.com.cn/api/event/query/eventList"}}const deepCopy=e=>{if("object"!=typeof e)return e;var t=Array.isArray(e)?[]:{};for(const r in e)"object"==typeof e[r]?t[r]=deepCopy(e[r]):t[r]=e[r];return t},cacheData=[],addCache=e=>{cacheData.push(e)},getCache=()=>deepCopy(cacheData),clearCache=()=>{cacheData.length=0},BPNEvent="UNIBPNEventSrcData",BPNEventFail="UNIBPNEventFailData";let timerCustom;function getCurPath(){var e=getCurrentPages(),e=e[e.length-1];return e?e.route:"/"}function eventCommonStore(e){var t=e.$page||"",r=t.path||getCurPath(),t={utm:e.$utm||"",duration:"",element:e.$element||null,eventId:e.$event_id||"",event:e.$event_code||"",groupId:"",busSegment:e.$busSegment,module:e.$module,page:{domain:t.domain||"",pageId:md5(r),path:r||"",title:t.title||"",url:r||""},properties:e.$extend_param?JSON.stringify(e.$extend_param):"",traceId:"",trackId:sdkTrackIdVal(),triggerTime:timeToStr(Date.now())};addCache(t),clearTimeout(timerCustom),timerCustom=setTimeout(()=>{var e=getCache();e.length&&(insertEventData(e),clearCache())},2e3)}function insertEventData(e){console.log("写入Event数据 ",e);var t=uni.getStorageSync(BPNEvent),t=t?JSON.parse(t):[];e&&e.length&&(t.concat(e),uni.setStorageSync(BPNEvent,JSON.stringify(t)))}function queryEventDataUpload(){var e=uni.getStorageSync(BPNEvent),e=(uni.setStorageSync(BPNEvent,""),e?JSON.parse(e):[]),t=[],r=uni.getStorageSync(BPNEventFail),r=r?JSON.parse(r):[];e.length&&t.push(...e),r.length&&t.push(...r),t&&t.length&&reportTrackEventServer("event",t,BPNEventFail)}let startTime=0,enterTimeLong=0,loopTimeLong=0,cirtemp$1=-1,mObj=null,umlInterval=null,cUUId$1=0;function clearUMlData(){clearInterval(umlInterval),startTime=0,enterTimeLong=0,loopTimeLong=0,cirtemp$1=1,mObj=null,umlInterval=null,cUUId$1=0}const uStartTrackPVData=e=>{umlInterval?uStopTrackPVData():e&&(clearUMlData(),uTrackPVData(AUTOTRACKTYPE.ENTER,e),umlInterval=setInterval(()=>{uTrackPVData(AUTOTRACKTYPE.LOOP,null)},Global.pageInterval))},uStopTrackPVData=()=>{uTrackPVData(AUTOTRACKTYPE.LEAVE),clearUMlData()};function uTrackPVData(e,t){e===AUTOTRACKTYPE.ENTER?(cUUId$1=randomUUID(),enterTimeLong=Date.now(),loopTimeLong=enterTimeLong,mObj=getTrackObj(t)):e===AUTOTRACKTYPE.LOOP?(cirtemp$1=2,startTime=15,loopTimeLong=Date.now()):e===AUTOTRACKTYPE.LEAVE&&(cirtemp$1=3,startTime=Math.ceil((Date.now()-loopTimeLong)/1e3));t={busSegment:mObj.busSegment,circulation:cirtemp$1,domain:mObj.domain,duration:startTime,module:mObj.module,path:mObj.path,properties:mObj.properties,sourceDomain:mObj.sourceDomain,sourceUrl:mObj.sourceUrl,title:mObj.title,traceId:"",trackId:sdkTrackIdVal(),url:mObj.url,visitPage:mObj.visitPage,visitTime:timeToStr(enterTimeLong),utm:"",pageUUId:cUUId$1};insertPVUVData(t,cUUId$1)}var name="visual-buried-point-platform-uni",version="1.0.0-alpha.15",lsi="f880f051db0e276f9777a7cc4d4c947c#1.0.0-alpha.15",description="To make it easy for you to get started with GitLab, here's a list of recommended next steps.",main="dist/cjs/buried-point-uni.js",module$1="dist/esm/buried-point-uni.js",scripts={dev:"rollup -c -w",build:"rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.js"},repository={type:"git",url:""},files=["dist"],keywords=[],author="",license="MIT",dependencies={md5:"^2.3.0"},devDependencies={"@babel/core":"^7.5.5","@rollup/plugin-json":"^6.0.1","babel-preset-es2015":"^6.24.1",rollup:"^1.20.2","rollup-plugin-babel":"^4.3.3","rollup-plugin-commonjs":"^10.0.2","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-replace":"^2.2.0","rollup-plugin-uglify":"^6.0.2",webpack:"^4.39.2"},pk={name:name,version:version,lsi:lsi,description:description,main:main,module:module$1,scripts:scripts,repository:repository,files:files,keywords:keywords,author:author,license:license,dependencies:dependencies,devDependencies:devDependencies};function uniInterceptorListener(){uni.addInterceptor("navigateTo",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}}),uni.addInterceptor("switchTab",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}})}let pathExist=!1;function routerMsgHandler(e){if(!Global.isCompatible)if("pv"===e){var t=getCurrentPages();const r=t[t.length-1];Global.signTrackArray&&Global.signTrackArray.length&&(pathExist=Global.signTrackArray.find(e=>e===r.route))?pathExist=!0:(pathExist=!1,t=autoPageObj(r.route,t.length,t),uAutoStartTrackPVData(t))}else"leave"!==e||pathExist||autoStopTrackPVUV()}const localLsi=pk.lsi;let _comInfo={distinctId:"",anonymousId:""},appData={},deviceData={},uglInterval=null;function init(e){var t;e?(t=setReportUrl(e.env||""),Global.upEventUrl=t.reportUrl,Global.upTrackUrl=t.reportTrackUrl,(!e.flushInterval||e.flushInterval<5)&&(e.flushInterval=15),(!e.pageInterval||e.pageInterval<5)&&(e.pageInterval=15),Object.assign(Global,e),getBaseicInfo(),_comInfo.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",_comInfo.anonymousId=uni.getStorageSync("v_anonId"),_comInfo.anonymousId||(_comInfo.anonymousId=randomUUID(),uni.setStorageSync("v_anonId",_comInfo.anonymousId)),sdkTrackIdVal()):console.log("init config error, please check config!"),startGlobalTime(),uniInterceptorListener()}function startGlobalTime(){clearInterval(uglInterval),uglInterval=setInterval(()=>{queryEventDataUpload(),queryTrackDataUpload()},Global.flushInterval||15e3)}function setUserId(e){e?(_comInfo.distinctId=e,uni.setStorageSync("v_userId",e)):(_comInfo.distinctId="",uni.setStorageSync("v_userId",""))}function getTrackId(){return sdkTrackIdVal()}function setCustomEvent(e){eventCommonStore(e)}function onStartTrack(e){uStartTrackPVData(e)}function onDestroyTrack(){uStopTrackPVData()}function setPageExtraObj(e){uUpdatePageExtraArray(e)}function reportTrackEventServer(e,t,r){var n;e?(n={...n=commonData(t),dataAbstract:md5(JSON.stringify(n))},uni.request({url:"event"===e?Global.upEventUrl:Global.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:Global.token,projectId:Global.token},data:n,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(r,JSON.stringify(t)):uni.setStorageSync(r,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(r,JSON.stringify(t))}})):console.error("please set upload data upType")}function commonData(e){return{app:appData,data:e,device:deviceData,lsi:localLsi,projectId:Global.token,userAgent:Global.uAgent||"",anonymousId:_comInfo.anonymousId,userId:_comInfo.distinctId}}function getBaseicInfo(){uni.getSystemInfo({success:function(e){Global.uAgent=e.ua;var t,r=e.uniPlatform;r.includes("app")?(Global.platform=e.osName,appData=getAppInfo(e)):r.includes("web")||r.includes("h5")?(Global.platform=r,t=getWebH5Info(e),appData={...t,version:Global.version||"unknown"}):r.includes("weixin")&&(Global.platform="weixin",appData=getWXInfo()),deviceData=getDeviceInfo(e,Global.platform)},fail:function(e){deviceData=getDeviceInfoError()},complete:function(){uni.getNetworkType({success(e){deviceData.network=e.networkType}})}})}exports.getTrackId=getTrackId,exports.init=init,exports.onDestroyTrack=onDestroyTrack,exports.onStartTrack=onStartTrack,exports.reportTrackEventServer=reportTrackEventServer,exports.setCustomEvent=setCustomEvent,exports.setPageExtraObj=setPageExtraObj,exports.setUserId=setUserId;
@@ -0,0 +1 @@
1
+ function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var crypt=createCommonjsModule(function(e){var o,n;o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];0<e;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var t=[],n=0;n<e.length;n+=3)for(var r=e[n]<<16|e[n+1]<<8|e[n+2],a=0;a<4;a++)8*n+6*a<=8*e.length?t.push(o.charAt(r>>>6*(3-a)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,r=0;n<e.length;r=++n%4)0!=r&&t.push((o.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|o.indexOf(e.charAt(n))>>>6-2*r);return t}},e.exports=n}),charenc={utf8:{stringToBytes:function(e){return charenc.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(charenc.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}},charenc_1=charenc,isBuffer_1=function(e){return null!=e&&(isBuffer(e)||isSlowBuffer(e)||!!e._isBuffer)};function isBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isBuffer(e.slice(0,0))}var md5=createCommonjsModule(function(e){function v(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?I:h).stringToBytes(e):b(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=T.bytesToWords(e),t=8*e.length,r=1732584193,a=-271733879,o=-1732584194,i=271733878,u=0;u<n.length;u++)n[u]=16711935&(n[u]<<8|n[u]>>>24)|4278255360&(n[u]<<24|n[u]>>>8);n[t>>>5]|=128<<t%32,n[14+(64+t>>>9<<4)]=t;for(var l=v._ff,c=v._gg,s=v._hh,p=v._ii,u=0;u<n.length;u+=16){var g=r,d=a,m=o,f=i,r=l(r,a,o,i,n[u+0],7,-680876936),i=l(i,r,a,o,n[u+1],12,-389564586),o=l(o,i,r,a,n[u+2],17,606105819),a=l(a,o,i,r,n[u+3],22,-1044525330);r=l(r,a,o,i,n[u+4],7,-176418897),i=l(i,r,a,o,n[u+5],12,1200080426),o=l(o,i,r,a,n[u+6],17,-1473231341),a=l(a,o,i,r,n[u+7],22,-45705983),r=l(r,a,o,i,n[u+8],7,1770035416),i=l(i,r,a,o,n[u+9],12,-1958414417),o=l(o,i,r,a,n[u+10],17,-42063),a=l(a,o,i,r,n[u+11],22,-1990404162),r=l(r,a,o,i,n[u+12],7,1804603682),i=l(i,r,a,o,n[u+13],12,-40341101),o=l(o,i,r,a,n[u+14],17,-1502002290),r=c(r,a=l(a,o,i,r,n[u+15],22,1236535329),o,i,n[u+1],5,-165796510),i=c(i,r,a,o,n[u+6],9,-1069501632),o=c(o,i,r,a,n[u+11],14,643717713),a=c(a,o,i,r,n[u+0],20,-373897302),r=c(r,a,o,i,n[u+5],5,-701558691),i=c(i,r,a,o,n[u+10],9,38016083),o=c(o,i,r,a,n[u+15],14,-660478335),a=c(a,o,i,r,n[u+4],20,-405537848),r=c(r,a,o,i,n[u+9],5,568446438),i=c(i,r,a,o,n[u+14],9,-1019803690),o=c(o,i,r,a,n[u+3],14,-187363961),a=c(a,o,i,r,n[u+8],20,1163531501),r=c(r,a,o,i,n[u+13],5,-1444681467),i=c(i,r,a,o,n[u+2],9,-51403784),o=c(o,i,r,a,n[u+7],14,1735328473),r=s(r,a=c(a,o,i,r,n[u+12],20,-1926607734),o,i,n[u+5],4,-378558),i=s(i,r,a,o,n[u+8],11,-2022574463),o=s(o,i,r,a,n[u+11],16,1839030562),a=s(a,o,i,r,n[u+14],23,-35309556),r=s(r,a,o,i,n[u+1],4,-1530992060),i=s(i,r,a,o,n[u+4],11,1272893353),o=s(o,i,r,a,n[u+7],16,-155497632),a=s(a,o,i,r,n[u+10],23,-1094730640),r=s(r,a,o,i,n[u+13],4,681279174),i=s(i,r,a,o,n[u+0],11,-358537222),o=s(o,i,r,a,n[u+3],16,-722521979),a=s(a,o,i,r,n[u+6],23,76029189),r=s(r,a,o,i,n[u+9],4,-640364487),i=s(i,r,a,o,n[u+12],11,-421815835),o=s(o,i,r,a,n[u+15],16,530742520),r=p(r,a=s(a,o,i,r,n[u+2],23,-995338651),o,i,n[u+0],6,-198630844),i=p(i,r,a,o,n[u+7],10,1126891415),o=p(o,i,r,a,n[u+14],15,-1416354905),a=p(a,o,i,r,n[u+5],21,-57434055),r=p(r,a,o,i,n[u+12],6,1700485571),i=p(i,r,a,o,n[u+3],10,-1894986606),o=p(o,i,r,a,n[u+10],15,-1051523),a=p(a,o,i,r,n[u+1],21,-2054922799),r=p(r,a,o,i,n[u+8],6,1873313359),i=p(i,r,a,o,n[u+15],10,-30611744),o=p(o,i,r,a,n[u+6],15,-1560198380),a=p(a,o,i,r,n[u+13],21,1309151649),r=p(r,a,o,i,n[u+4],6,-145523070),i=p(i,r,a,o,n[u+11],10,-1120210379),o=p(o,i,r,a,n[u+2],15,718787259),a=p(a,o,i,r,n[u+9],21,-343485551),r=r+g>>>0,a=a+d>>>0,o=o+m>>>0,i=i+f>>>0}return T.endian([r,a,o,i])}var T,h,b,I;T=crypt,h=charenc_1.utf8,b=isBuffer_1,I=charenc_1.bin,v._ff=function(e,t,n,r,a,o,i){e=e+(t&n|~t&r)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._gg=function(e,t,n,r,a,o,i){e=e+(t&r|n&~r)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._hh=function(e,t,n,r,a,o,i){e=e+(t^n^r)+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._ii=function(e,t,n,r,a,o,i){e=e+(n^(t|~r))+(a>>>0)+i;return(e<<o|e>>>32-o)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=T.wordsToBytes(v(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):T.bytesToHex(e)}});let Global={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},pagesArray=[];const sdkTrackIdVal=()=>{var e;return Global.trackId||(e=Date.now().toString(),Global.trackId=e)};function randomUUID(){return"xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function timeToStr(e){e=new Date(e);return e.getFullYear()+`-${e.getMonth()+1<10?"0"+(e.getMonth()+1):e.getMonth()+1}-${e.getDate()<10?"0"+e.getDate():e.getDate()} ${e.getHours()<10?"0"+e.getHours():e.getHours()}:${e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes()}:`+(e.getSeconds()<10?"0"+e.getSeconds():e.getSeconds())}function getWebH5Info(e){var e=e.ua.toLowerCase(),t=window.location.hostname,n=document.title;/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(e);return e.includes("alipay")||e.includes("unionPay")||e.includes("onbuygz")||e.includes("onetravel"),e.includes("micromessenger")&&e.includes("miniprogram"),{name:n||"",packageName:t||"",version:"",carrier:"h5",ecology:"h5"}}function getWXInfo(){var e=uni.getAccountInfoSync(),t=uni.getAppBaseInfo();return{name:t.appName||"",packageName:e?e.miniProgram.appId:"",version:e?e.miniProgram.envVersion+e.miniProgram.version:"",carrier:"mini",ecology:"mini"}}function getAppInfo(t){var n=plus.runtime.version,n={name:t.appName,version:n||"",carrier:"app",packageName:"",ecology:""};if("android"===t.platform){let e="Android";var r=plus.android.runtimeMainActivity().getPackageName();t.romName.includes("HarmonyOS")&&(e="Harmony OS"),n.packageName=r||"",n.ecology=e}else"ios"===t.platform?(r=plus.ios.importClass("NSBundle").mainBundle().bundleIdentifier(),n.packageName=r||"",n.ecology="iOS"):n.ecology="unknown";return n}function getCurDeviceType(e,t){return"wx"!==t?(t=e.ua.toLowerCase(),/(windows|win32|win64|wow64)/.test(t)?1:(/(linux|android)/.test(t)||/(macintosh|mac os x|iphone|ipad|ipod)/.test(t),2)):"pc"===e.deviceType?1:2}function getDeviceInfo(e,t){return{lang:e.osLanguage||e.hostLanguage,brand:e.deviceBrand+" "+e.deviceModel,os:e.osName,osVersion:e.osVersion,resolution:e.screenWidth+"x"+e.screenHeight,browser:e.browserName,browserVersion:e.browserVersion,color:"",deviceId:e.deviceId,deviceType:getCurDeviceType(e,t),network:""}}function getDeviceInfoError(){return{lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}}function getTrackObj(e){var t=getCurrentPages(),n=t[t.length-1],r=Global.platform;let a="",o="",i="",u="";if(r&&("web"===r||"h5"===r?(a=window.location.href,o=window.location.hostname,document.referrer&&(r=new URL(document.referrer),i=r||"",u=r.hostname||"")):(a=n.route,1<t.length&&(r=t[t.length-2],i=r.route),o=Global.domain||n.route)),n)return{path:n.route,busSegment:e.busSegment||"",module:e.module||"",properties:e.extend_param?JSON.stringify(e.extend_param):"",title:e.title||"",domain:o,url:a,visitPage:t.length,sourceDomain:u,sourceUrl:i}}function uUpdatePageExtraArray(e){var t=getCurrentPages();let n=t[t.length-1];t=pagesArray.findIndex(e=>e.path===n.route),e={path:n.route,properties:e.properties?JSON.stringify(e.properties):"",busSegment:e.busSegment||"",module:e.module||"",title:e.title||""};-1!==t?pagesArray[t]=e:pagesArray.push(e)}const AUTOTRACKTYPE={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},BPNPVUV="UNIBPNPVUVSrcData",BPNPVUVFail="UNIBPNPVUVFailData";let atDuration,atEnterTimeLong,atLoopTimeLong,cirtemp,atObj,atInterval=null,cUUId=null;function clearUAData(){clearInterval(atInterval),atDuration=0,atEnterTimeLong=0,atLoopTimeLong=0,cirtemp=1,atObj=null,atInterval=null,cUUId=0}const uAutoStartTrackPVData=e=>{atInterval?autoStopTrackPVUV():(clearUAData(),atObj=e,autoTrackData(AUTOTRACKTYPE.ENTER),atInterval=setInterval(()=>{autoTrackData(AUTOTRACKTYPE.LOOP)},Global.pageInterval))},autoStopTrackPVUV=()=>{autoTrackData(AUTOTRACKTYPE.LEAVE),clearInterval(atInterval)};function autoTrackData(e){e===AUTOTRACKTYPE.ENTER?(cirtemp=1,atDuration=0,atEnterTimeLong=Date.now(),atLoopTimeLong=atEnterTimeLong,cUUId=randomUUID()):e===AUTOTRACKTYPE.LOOP?(cirtemp=2,atDuration=15,atLoopTimeLong=Date.now()):e===AUTOTRACKTYPE.LEAVE&&(cirtemp=3,atDuration=Math.ceil((Date.now()-atLoopTimeLong)/1e3)),atObj&&insertPVUVData({busSegment:atObj.busSegment||"",circulation:cirtemp,ctk:"",domain:atObj.domain,duration:atDuration,module:atObj.module||"",path:atObj.path,url:atObj.url,sourceDomain:atObj.sourceDomain,sourceUrl:atObj.sourceUrl,properties:atObj.properties,title:atObj.title,traceId:"",trackId:sdkTrackIdVal(),visitPage:atObj.visitPage,visitTime:timeToStr(atEnterTimeLong),pageUUId:cUUId},cUUId)}function insertPVUVData(e,t){var n,r=uni.getStorageSync(BPNPVUV),r=r?JSON.parse(r):[];0<r.length&&-1!==(n=r.findIndex(e=>e.pageUUId===t))?r[n]={...r[n],...e}:r.push(e),uni.setStorageSync(BPNPVUV,JSON.stringify(r))}function autoPageObj(t,e,n){var r=pagesArray.find(e=>e.path===t),a=Global.platform;let o="",i="",u="",l="";return a&&("web"===a||"h5"===a?(o=window.location.href,i=window.location.hostname,document.referrer&&(a=new URL(document.referrer),u=a||"",l=a.hostname||"")):(o=t,1<e&&(a=n[e-2],u=a.route),i=Global.domain||t)),{path:r&&r.path?r.path:t,busSegment:r&&r.busSegment?r.busSegment:Global.busSegment||"",module:r&&r.module?r.module:Global.module||"",properties:r&&r.properties?r.properties:"",domain:i,url:o,visitPage:e,sourceDomain:l,sourceUrl:u,title:r&&r.title?r.title:""}}function queryTrackDataUpload(){var e=uni.getStorageSync(BPNPVUV),e=(uni.setStorageSync(BPNPVUV,""),e?JSON.parse(e):[]),t=[],n=uni.getStorageSync(BPNPVUVFail),n=n?JSON.parse(n):[];e.length&&t.push(...e),n.length&&t.push(...n),t&&t.length&&(t.forEach(e=>{delete e.pageUUId}),reportTrackEventServer("track",t,BPNPVUVFail))}function setReportUrl(e){return"test"!==e?{reportUrl:"https://buryingpoint.onebuygz.com/client/api/event",reportTrackUrl:"https://buryingpoint.onebuygz.com/client/api/track",eventListUrl:"https://buryingpoint.onebuygz.com/api/event/query/eventList"}:{reportUrl:"https://buryingpoint.gcongo.com.cn/client/api/event",reportTrackUrl:"https://buryingpoint.gcongo.com.cn/client/api/track",eventListUrl:"https://buryingpoint.gcongo.com.cn/api/event/query/eventList"}}const deepCopy=e=>{if("object"!=typeof e)return e;var t=Array.isArray(e)?[]:{};for(const n in e)"object"==typeof e[n]?t[n]=deepCopy(e[n]):t[n]=e[n];return t},cacheData=[],addCache=e=>{cacheData.push(e)},getCache=()=>deepCopy(cacheData),clearCache=()=>{cacheData.length=0},BPNEvent="UNIBPNEventSrcData",BPNEventFail="UNIBPNEventFailData";let timerCustom;function getCurPath(){var e=getCurrentPages(),e=e[e.length-1];return e?e.route:"/"}function eventCommonStore(e){var t=e.$page||"",n=t.path||getCurPath(),t={utm:e.$utm||"",duration:"",element:e.$element||null,eventId:e.$event_id||"",event:e.$event_code||"",groupId:"",busSegment:e.$busSegment,module:e.$module,page:{domain:t.domain||"",pageId:md5(n),path:n||"",title:t.title||"",url:n||""},properties:e.$extend_param?JSON.stringify(e.$extend_param):"",traceId:"",trackId:sdkTrackIdVal(),triggerTime:timeToStr(Date.now())};addCache(t),clearTimeout(timerCustom),timerCustom=setTimeout(()=>{var e=getCache();e.length&&(insertEventData(e),clearCache())},2e3)}function insertEventData(e){console.log("写入Event数据 ",e);var t=uni.getStorageSync(BPNEvent),t=t?JSON.parse(t):[];e&&e.length&&(t.concat(e),uni.setStorageSync(BPNEvent,JSON.stringify(t)))}function queryEventDataUpload(){var e=uni.getStorageSync(BPNEvent),e=(uni.setStorageSync(BPNEvent,""),e?JSON.parse(e):[]),t=[],n=uni.getStorageSync(BPNEventFail),n=n?JSON.parse(n):[];e.length&&t.push(...e),n.length&&t.push(...n),t&&t.length&&reportTrackEventServer("event",t,BPNEventFail)}let startTime=0,enterTimeLong=0,loopTimeLong=0,cirtemp$1=-1,mObj=null,umlInterval=null,cUUId$1=0;function clearUMlData(){clearInterval(umlInterval),startTime=0,enterTimeLong=0,loopTimeLong=0,cirtemp$1=1,mObj=null,umlInterval=null,cUUId$1=0}const uStartTrackPVData=e=>{umlInterval?uStopTrackPVData():e&&(clearUMlData(),uTrackPVData(AUTOTRACKTYPE.ENTER,e),umlInterval=setInterval(()=>{uTrackPVData(AUTOTRACKTYPE.LOOP,null)},Global.pageInterval))},uStopTrackPVData=()=>{uTrackPVData(AUTOTRACKTYPE.LEAVE),clearUMlData()};function uTrackPVData(e,t){e===AUTOTRACKTYPE.ENTER?(cUUId$1=randomUUID(),enterTimeLong=Date.now(),loopTimeLong=enterTimeLong,mObj=getTrackObj(t)):e===AUTOTRACKTYPE.LOOP?(cirtemp$1=2,startTime=15,loopTimeLong=Date.now()):e===AUTOTRACKTYPE.LEAVE&&(cirtemp$1=3,startTime=Math.ceil((Date.now()-loopTimeLong)/1e3));t={busSegment:mObj.busSegment,circulation:cirtemp$1,domain:mObj.domain,duration:startTime,module:mObj.module,path:mObj.path,properties:mObj.properties,sourceDomain:mObj.sourceDomain,sourceUrl:mObj.sourceUrl,title:mObj.title,traceId:"",trackId:sdkTrackIdVal(),url:mObj.url,visitPage:mObj.visitPage,visitTime:timeToStr(enterTimeLong),utm:"",pageUUId:cUUId$1};insertPVUVData(t,cUUId$1)}var name="visual-buried-point-platform-uni",version="1.0.0-alpha.15",lsi="f880f051db0e276f9777a7cc4d4c947c#1.0.0-alpha.15",description="To make it easy for you to get started with GitLab, here's a list of recommended next steps.",main="dist/cjs/buried-point-uni.js",module="dist/esm/buried-point-uni.js",scripts={dev:"rollup -c -w",build:"rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.js"},repository={type:"git",url:""},files=["dist"],keywords=[],author="",license="MIT",dependencies={md5:"^2.3.0"},devDependencies={"@babel/core":"^7.5.5","@rollup/plugin-json":"^6.0.1","babel-preset-es2015":"^6.24.1",rollup:"^1.20.2","rollup-plugin-babel":"^4.3.3","rollup-plugin-commonjs":"^10.0.2","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-replace":"^2.2.0","rollup-plugin-uglify":"^6.0.2",webpack:"^4.39.2"},pk={name:name,version:version,lsi:lsi,description:description,main:main,module:module,scripts:scripts,repository:repository,files:files,keywords:keywords,author:author,license:license,dependencies:dependencies,devDependencies:devDependencies};function uniInterceptorListener(){uni.addInterceptor("navigateTo",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}}),uni.addInterceptor("switchTab",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){routerMsgHandler("leave")},success(e){routerMsgHandler("pv")}})}let pathExist=!1;function routerMsgHandler(e){if(!Global.isCompatible)if("pv"===e){var t=getCurrentPages();const n=t[t.length-1];Global.signTrackArray&&Global.signTrackArray.length&&(pathExist=Global.signTrackArray.find(e=>e===n.route))?pathExist=!0:(pathExist=!1,t=autoPageObj(n.route,t.length,t),uAutoStartTrackPVData(t))}else"leave"!==e||pathExist||autoStopTrackPVUV()}const localLsi=pk.lsi;let _comInfo={distinctId:"",anonymousId:""},appData={},deviceData={},uglInterval=null;function init(e){var t;e?(t=setReportUrl(e.env||""),Global.upEventUrl=t.reportUrl,Global.upTrackUrl=t.reportTrackUrl,(!e.flushInterval||e.flushInterval<5)&&(e.flushInterval=15),(!e.pageInterval||e.pageInterval<5)&&(e.pageInterval=15),Object.assign(Global,e),getBaseicInfo(),_comInfo.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",_comInfo.anonymousId=uni.getStorageSync("v_anonId"),_comInfo.anonymousId||(_comInfo.anonymousId=randomUUID(),uni.setStorageSync("v_anonId",_comInfo.anonymousId)),sdkTrackIdVal()):console.log("init config error, please check config!"),startGlobalTime(),uniInterceptorListener()}function startGlobalTime(){clearInterval(uglInterval),uglInterval=setInterval(()=>{queryEventDataUpload(),queryTrackDataUpload()},Global.flushInterval||15e3)}function setUserId(e){e?(_comInfo.distinctId=e,uni.setStorageSync("v_userId",e)):(_comInfo.distinctId="",uni.setStorageSync("v_userId",""))}function getTrackId(){return sdkTrackIdVal()}function setCustomEvent(e){eventCommonStore(e)}function onStartTrack(e){uStartTrackPVData(e)}function onDestroyTrack(){uStopTrackPVData()}function setPageExtraObj(e){uUpdatePageExtraArray(e)}function reportTrackEventServer(e,t,n){var r;e?(r={...r=commonData(t),dataAbstract:md5(JSON.stringify(r))},uni.request({url:"event"===e?Global.upEventUrl:Global.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:Global.token,projectId:Global.token},data:r,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(n,JSON.stringify(t)):uni.setStorageSync(n,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(n,JSON.stringify(t))}})):console.error("please set upload data upType")}function commonData(e){return{app:appData,data:e,device:deviceData,lsi:localLsi,projectId:Global.token,userAgent:Global.uAgent||"",anonymousId:_comInfo.anonymousId,userId:_comInfo.distinctId}}function getBaseicInfo(){uni.getSystemInfo({success:function(e){Global.uAgent=e.ua;var t,n=e.uniPlatform;n.includes("app")?(Global.platform=e.osName,appData=getAppInfo(e)):n.includes("web")||n.includes("h5")?(Global.platform=n,t=getWebH5Info(e),appData={...t,version:Global.version||"unknown"}):n.includes("weixin")&&(Global.platform="weixin",appData=getWXInfo()),deviceData=getDeviceInfo(e,Global.platform)},fail:function(e){deviceData=getDeviceInfoError()},complete:function(){uni.getNetworkType({success(e){deviceData.network=e.networkType}})}})}export{getTrackId,init,onDestroyTrack,onStartTrack,reportTrackEventServer,setCustomEvent,setPageExtraObj,setUserId};
@@ -0,0 +1 @@
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).BuriedPointUni={})}(this,function(e){"use strict";function t(e,t){return e(t={exports:{}},t.exports),t.exports}function M(e){return null!=e&&(o(e)||"function"==typeof(t=e).readFloatLE&&"function"==typeof t.slice&&o(t.slice(0,0))||!!e._isBuffer);var t}var C=t(function(e){var i,n;i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];0<e;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var t=[],n=0;n<e.length;n+=3)for(var r=e[n]<<16|e[n+1]<<8|e[n+2],o=0;o<4;o++)8*n+6*o<=8*e.length?t.push(i.charAt(r>>>6*(3-o)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,r=0;n<e.length;r=++n%4)0!=r&&t.push((i.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|i.indexOf(e.charAt(n))>>>6-2*r);return t}},e.exports=n}),n={utf8:{stringToBytes:function(e){return n.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(n.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}},r=n;function o(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}var V=t(function(e){function v(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?I:y).stringToBytes(e):S(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=h.bytesToWords(e),t=8*e.length,r=1732584193,o=-271733879,i=-1732584194,a=271733878,u=0;u<n.length;u++)n[u]=16711935&(n[u]<<8|n[u]>>>24)|4278255360&(n[u]<<24|n[u]>>>8);n[t>>>5]|=128<<t%32,n[14+(64+t>>>9<<4)]=t;for(var s=v._ff,c=v._gg,l=v._hh,g=v._ii,u=0;u<n.length;u+=16){var p=r,d=o,f=i,m=a,r=s(r,o,i,a,n[u+0],7,-680876936),a=s(a,r,o,i,n[u+1],12,-389564586),i=s(i,a,r,o,n[u+2],17,606105819),o=s(o,i,a,r,n[u+3],22,-1044525330);r=s(r,o,i,a,n[u+4],7,-176418897),a=s(a,r,o,i,n[u+5],12,1200080426),i=s(i,a,r,o,n[u+6],17,-1473231341),o=s(o,i,a,r,n[u+7],22,-45705983),r=s(r,o,i,a,n[u+8],7,1770035416),a=s(a,r,o,i,n[u+9],12,-1958414417),i=s(i,a,r,o,n[u+10],17,-42063),o=s(o,i,a,r,n[u+11],22,-1990404162),r=s(r,o,i,a,n[u+12],7,1804603682),a=s(a,r,o,i,n[u+13],12,-40341101),i=s(i,a,r,o,n[u+14],17,-1502002290),r=c(r,o=s(o,i,a,r,n[u+15],22,1236535329),i,a,n[u+1],5,-165796510),a=c(a,r,o,i,n[u+6],9,-1069501632),i=c(i,a,r,o,n[u+11],14,643717713),o=c(o,i,a,r,n[u+0],20,-373897302),r=c(r,o,i,a,n[u+5],5,-701558691),a=c(a,r,o,i,n[u+10],9,38016083),i=c(i,a,r,o,n[u+15],14,-660478335),o=c(o,i,a,r,n[u+4],20,-405537848),r=c(r,o,i,a,n[u+9],5,568446438),a=c(a,r,o,i,n[u+14],9,-1019803690),i=c(i,a,r,o,n[u+3],14,-187363961),o=c(o,i,a,r,n[u+8],20,1163531501),r=c(r,o,i,a,n[u+13],5,-1444681467),a=c(a,r,o,i,n[u+2],9,-51403784),i=c(i,a,r,o,n[u+7],14,1735328473),r=l(r,o=c(o,i,a,r,n[u+12],20,-1926607734),i,a,n[u+5],4,-378558),a=l(a,r,o,i,n[u+8],11,-2022574463),i=l(i,a,r,o,n[u+11],16,1839030562),o=l(o,i,a,r,n[u+14],23,-35309556),r=l(r,o,i,a,n[u+1],4,-1530992060),a=l(a,r,o,i,n[u+4],11,1272893353),i=l(i,a,r,o,n[u+7],16,-155497632),o=l(o,i,a,r,n[u+10],23,-1094730640),r=l(r,o,i,a,n[u+13],4,681279174),a=l(a,r,o,i,n[u+0],11,-358537222),i=l(i,a,r,o,n[u+3],16,-722521979),o=l(o,i,a,r,n[u+6],23,76029189),r=l(r,o,i,a,n[u+9],4,-640364487),a=l(a,r,o,i,n[u+12],11,-421815835),i=l(i,a,r,o,n[u+15],16,530742520),r=g(r,o=l(o,i,a,r,n[u+2],23,-995338651),i,a,n[u+0],6,-198630844),a=g(a,r,o,i,n[u+7],10,1126891415),i=g(i,a,r,o,n[u+14],15,-1416354905),o=g(o,i,a,r,n[u+5],21,-57434055),r=g(r,o,i,a,n[u+12],6,1700485571),a=g(a,r,o,i,n[u+3],10,-1894986606),i=g(i,a,r,o,n[u+10],15,-1051523),o=g(o,i,a,r,n[u+1],21,-2054922799),r=g(r,o,i,a,n[u+8],6,1873313359),a=g(a,r,o,i,n[u+15],10,-30611744),i=g(i,a,r,o,n[u+6],15,-1560198380),o=g(o,i,a,r,n[u+13],21,1309151649),r=g(r,o,i,a,n[u+4],6,-145523070),a=g(a,r,o,i,n[u+11],10,-1120210379),i=g(i,a,r,o,n[u+2],15,718787259),o=g(o,i,a,r,n[u+9],21,-343485551),r=r+p>>>0,o=o+d>>>0,i=i+f>>>0,a=a+m>>>0}return h.endian([r,o,i,a])}var h,y,S,I;h=C,y=r.utf8,S=M,I=r.bin,v._ff=function(e,t,n,r,o,i,a){e=e+(t&n|~t&r)+(o>>>0)+a;return(e<<i|e>>>32-i)+t},v._gg=function(e,t,n,r,o,i,a){e=e+(t&r|n&~r)+(o>>>0)+a;return(e<<i|e>>>32-i)+t},v._hh=function(e,t,n,r,o,i,a){e=e+(t^n^r)+(o>>>0)+a;return(e<<i|e>>>32-i)+t},v._ii=function(e,t,n,r,o,i,a){e=e+(n^(t|~r))+(o>>>0)+a;return(e<<i|e>>>32-i)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=h.wordsToBytes(v(e,t));return t&&t.asBytes?e:t&&t.asString?I.bytesToString(e):h.bytesToHex(e)}});let c={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},l=[];const i=()=>{var e;return c.trackId||(e=Date.now().toString(),c.trackId=e)};function a(){return"xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g,function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function u(e){e=new Date(e);return e.getFullYear()+`-${e.getMonth()+1<10?"0"+(e.getMonth()+1):e.getMonth()+1}-${e.getDate()<10?"0"+e.getDate():e.getDate()} ${e.getHours()<10?"0"+e.getHours():e.getHours()}:${e.getMinutes()<10?"0"+e.getMinutes():e.getMinutes()}:`+(e.getSeconds()<10?"0"+e.getSeconds():e.getSeconds())}const s={ENTER:"enter",LOOP:"loop",LEAVE:"leave"},g="UNIBPNPVUVSrcData",J="UNIBPNPVUVFailData";let p,d,f,m,v,h=null,y=null;const j=e=>{h?$():(clearInterval(h),p=0,d=0,f=0,m=1,v=null,h=null,y=0,v=e,S(s.ENTER),h=setInterval(()=>{S(s.LOOP)},c.pageInterval))},$=()=>{S(s.LEAVE),clearInterval(h)};function S(e){e===s.ENTER?(m=1,p=0,d=Date.now(),f=d,y=a()):e===s.LOOP?(m=2,p=15,f=Date.now()):e===s.LEAVE&&(m=3,p=Math.ceil((Date.now()-f)/1e3)),v&&R({busSegment:v.busSegment||"",circulation:m,ctk:"",domain:v.domain,duration:p,module:v.module||"",path:v.path,url:v.url,sourceDomain:v.sourceDomain,sourceUrl:v.sourceUrl,properties:v.properties,title:v.title,traceId:"",trackId:i(),visitPage:v.visitPage,visitTime:u(d),pageUUId:y},y)}function R(e,t){var n,r=uni.getStorageSync(g),r=r?JSON.parse(r):[];0<r.length&&-1!==(n=r.findIndex(e=>e.pageUUId===t))?r[n]={...r[n],...e}:r.push(e),uni.setStorageSync(g,JSON.stringify(r))}const H=e=>{if("object"!=typeof e)return e;var t=Array.isArray(e)?[]:{};for(const n in e)"object"==typeof e[n]?t[n]=H(e[n]):t[n]=e[n];return t},I=[],z=e=>{I.push(e)},F=()=>H(I),q=()=>{I.length=0},b="UNIBPNEventSrcData",W="UNIBPNEventFailData";let K;function Y(e){var t=e.$page||"",n=t.path||((n=(n=getCurrentPages())[n.length-1])?n.route:"/"),t={utm:e.$utm||"",duration:"",element:e.$element||null,eventId:e.$event_id||"",event:e.$event_code||"",groupId:"",busSegment:e.$busSegment,module:e.$module,page:{domain:t.domain||"",pageId:V(n),path:n||"",title:t.title||"",url:n||""},properties:e.$extend_param?JSON.stringify(e.$extend_param):"",traceId:"",trackId:i(),triggerTime:u(Date.now())};z(t),clearTimeout(K),K=setTimeout(()=>{var e,t=F();t.length&&(t=t,console.log("写入Event数据 ",t),e=(e=uni.getStorageSync(b))?JSON.parse(e):[],t&&t.length&&(e.concat(t),uni.setStorageSync(b,JSON.stringify(e))),q())},2e3)}let w=0,T=0,k=0,N=-1,x=null,U=null,O=0;function Z(){clearInterval(U),w=0,T=0,k=0,N=1,x=null,U=null,O=0}const G=()=>{P(s.LEAVE),Z()};function P(e,t){e===s.ENTER?(O=a(),T=Date.now(),k=T,x=function(e){var t=getCurrentPages(),n=t[t.length-1],r=c.platform;let o="",i="",a="",u="";if(r&&("web"===r||"h5"===r?(o=window.location.href,i=window.location.hostname,document.referrer&&(r=new URL(document.referrer),a=r||"",u=r.hostname||"")):(o=n.route,1<t.length&&(r=t[t.length-2],a=r.route),i=c.domain||n.route)),n)return{path:n.route,busSegment:e.busSegment||"",module:e.module||"",properties:e.extend_param?JSON.stringify(e.extend_param):"",title:e.title||"",domain:i,url:o,visitPage:t.length,sourceDomain:u,sourceUrl:a}}(t)):e===s.LOOP?(N=2,w=15,k=Date.now()):e===s.LEAVE&&(N=3,w=Math.ceil((Date.now()-k)/1e3));t={busSegment:x.busSegment,circulation:N,domain:x.domain,duration:w,module:x.module,path:x.path,properties:x.properties,sourceDomain:x.sourceDomain,sourceUrl:x.sourceUrl,title:x.title,traceId:"",trackId:i(),url:x.url,visitPage:x.visitPage,visitTime:u(T),utm:"",pageUUId:O};R(t,O)}let E=!1;function A(e){if(!c.isCompatible)if("pv"===e){var t=getCurrentPages();const n=t[t.length-1];c.signTrackArray&&c.signTrackArray.length&&(E=c.signTrackArray.find(e=>e===n.route))?E=!0:(E=!1,t=function(t,e,n){var r=l.find(e=>e.path===t),o=c.platform;let i="",a="",u="",s="";return o&&("web"===o||"h5"===o?(i=window.location.href,a=window.location.hostname,document.referrer&&(o=new URL(document.referrer),u=o||"",s=o.hostname||"")):(i=t,1<e&&(o=n[e-2],u=o.route),a=c.domain||t)),{path:r&&r.path?r.path:t,busSegment:r&&r.busSegment?r.busSegment:c.busSegment||"",module:r&&r.module?r.module:c.module||"",properties:r&&r.properties?r.properties:"",domain:a,url:i,visitPage:e,sourceDomain:s,sourceUrl:u,title:r&&r.title?r.title:""}}(n.route,t.length,t),j(t))}else"leave"!==e||E||$()}const Q="f880f051db0e276f9777a7cc4d4c947c#1.0.0-alpha.15";let B={distinctId:"",anonymousId:""},_={},D={},X=null;function L(e,t,n){var r;e?(r=t,r={...r={app:_,data:r,device:D,lsi:Q,projectId:c.token,userAgent:c.uAgent||"",anonymousId:B.anonymousId,userId:B.distinctId},dataAbstract:V(JSON.stringify(r))},uni.request({url:"event"===e?c.upEventUrl:c.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:c.token,projectId:c.token},data:r,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(n,JSON.stringify(t)):uni.setStorageSync(n,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(n,JSON.stringify(t))}})):console.error("please set upload data upType")}e.getTrackId=function(){return i()},e.init=function(e){var t;e?(t="test"!==(e.env||"")?{reportUrl:"https://buryingpoint.onebuygz.com/client/api/event",reportTrackUrl:"https://buryingpoint.onebuygz.com/client/api/track",eventListUrl:"https://buryingpoint.onebuygz.com/api/event/query/eventList"}:{reportUrl:"https://buryingpoint.gcongo.com.cn/client/api/event",reportTrackUrl:"https://buryingpoint.gcongo.com.cn/client/api/track",eventListUrl:"https://buryingpoint.gcongo.com.cn/api/event/query/eventList"},c.upEventUrl=t.reportUrl,c.upTrackUrl=t.reportTrackUrl,(!e.flushInterval||e.flushInterval<5)&&(e.flushInterval=15),(!e.pageInterval||e.pageInterval<5)&&(e.pageInterval=15),Object.assign(c,e),uni.getSystemInfo({success:function(e){c.uAgent=e.ua;var t,n,r,o=e.uniPlatform;o.includes("app")?(c.platform=e.osName,_=function(t){var n=plus.runtime.version,n={name:t.appName,version:n||"",carrier:"app",packageName:"",ecology:""};if("android"===t.platform){let e="Android";var r=plus.android.runtimeMainActivity().getPackageName();t.romName.includes("HarmonyOS")&&(e="Harmony OS"),n.packageName=r||"",n.ecology=e}else"ios"===t.platform?(r=plus.ios.importClass("NSBundle").mainBundle().bundleIdentifier(),n.packageName=r||"",n.ecology="iOS"):n.ecology="unknown";return n}(e)):o.includes("web")||o.includes("h5")?(c.platform=o,r=(r=e).ua.toLowerCase(),n=window.location.hostname,t=document.title,/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(r),r.includes("alipay")||r.includes("unionPay")||r.includes("onbuygz")||r.includes("onetravel"),r.includes("micromessenger")&&r.includes("miniprogram"),r={name:t||"",packageName:n||"",version:"",carrier:"h5",ecology:"h5"},_={...r,version:c.version||"unknown"}):o.includes("weixin")&&(c.platform="weixin",_=(t=uni.getAccountInfoSync(),{name:uni.getAppBaseInfo().appName||"",packageName:t?t.miniProgram.appId:"",version:t?t.miniProgram.envVersion+t.miniProgram.version:"",carrier:"mini",ecology:"mini"})),D=(n=e,r=c.platform,{lang:n.osLanguage||n.hostLanguage,brand:n.deviceBrand+" "+n.deviceModel,os:n.osName,osVersion:n.osVersion,resolution:n.screenWidth+"x"+n.screenHeight,browser:n.browserName,browserVersion:n.browserVersion,color:"",deviceId:n.deviceId,deviceType:(n=n,"wx"!==(r=r)?(r=n.ua.toLowerCase(),/(windows|win32|win64|wow64)/.test(r)?1:(/(linux|android)/.test(r)||/(macintosh|mac os x|iphone|ipad|ipod)/.test(r),2)):"pc"===n.deviceType?1:2),network:""})},fail:function(e){D={lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}},complete:function(){uni.getNetworkType({success(e){D.network=e.networkType}})}}),B.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",B.anonymousId=uni.getStorageSync("v_anonId"),B.anonymousId||(B.anonymousId=a(),uni.setStorageSync("v_anonId",B.anonymousId)),i()):console.log("init config error, please check config!"),clearInterval(X),X=setInterval(()=>{var e,t,n;e=uni.getStorageSync(b),uni.setStorageSync(b,""),e=e?JSON.parse(e):[],n=[],t=(t=uni.getStorageSync(W))?JSON.parse(t):[],e.length&&n.push(...e),t.length&&n.push(...t),n&&n.length&&L("event",n,W),e=uni.getStorageSync(g),uni.setStorageSync(g,""),e=e?JSON.parse(e):[],t=[],n=(n=uni.getStorageSync(J))?JSON.parse(n):[],e.length&&t.push(...e),n.length&&t.push(...n),t&&t.length&&(t.forEach(e=>{delete e.pageUUId}),L("track",t,J))},c.flushInterval||15e3),uni.addInterceptor("navigateTo",{invoke(e){A("leave")},success(e){A("pv")}}),uni.addInterceptor("switchTab",{invoke(e){A("leave")},success(e){A("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){A("leave")},success(e){A("pv")}})},e.onDestroyTrack=function(){G()},e.onStartTrack=function(e){e=e,U?G():e&&(Z(),P(s.ENTER,e),U=setInterval(()=>{P(s.LOOP,null)},c.pageInterval))},e.reportTrackEventServer=L,e.setCustomEvent=function(e){Y(e)},e.setPageExtraObj=function(e){{var n=getCurrentPages();let t=n[n.length-1];n=l.findIndex(e=>e.path===t.route),e={path:t.route,properties:e.properties?JSON.stringify(e.properties):"",busSegment:e.busSegment||"",module:e.module||"",title:e.title||""},-1!==n?l[n]=e:l.push(e)}},e.setUserId=function(e){e?(B.distinctId=e,uni.setStorageSync("v_userId",e)):(B.distinctId="",uni.setStorageSync("v_userId",""))},Object.defineProperty(e,"__esModule",{value:!0})});
package/package.json CHANGED
@@ -1,19 +1,21 @@
1
1
  {
2
2
  "name": "visual-buried-point-platform-uni",
3
- "version": "1.0.0-alpha.13",
4
- "lsi": "0b09c324cb7f1b33318b864c3384acb6#1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.15",
4
+ "lsi": "f880f051db0e276f9777a7cc4d4c947c#1.0.0-alpha.15",
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",
7
8
  "scripts": {
8
- "test": "echo \"Error: no test specified\" && exit 1",
9
- "build": "rimraf dist && webpack --mode production && npm run lsi-md5",
10
- "lsi-md5": "node lsi-md5.js"
9
+ "dev": "rollup -c -w",
10
+ "build": "rimraf dist && rollup -c --environment INCLUDE_DEPS,BUILD:production && node lsi-md5.js"
11
11
  },
12
- "type": "module",
13
12
  "repository": {
14
13
  "type": "git",
15
14
  "url": ""
16
15
  },
16
+ "files": [
17
+ "dist"
18
+ ],
17
19
  "keywords": [],
18
20
  "author": "",
19
21
  "license": "MIT",
@@ -21,8 +23,15 @@
21
23
  "md5": "^2.3.0"
22
24
  },
23
25
  "devDependencies": {
24
- "webpack": "^5.72.1",
25
- "webpack-cli": "4.9.2",
26
- "rimraf": "^5.0.5"
26
+ "@babel/core": "^7.5.5",
27
+ "@rollup/plugin-json": "^6.0.1",
28
+ "babel-preset-es2015": "^6.24.1",
29
+ "rollup": "^1.20.2",
30
+ "rollup-plugin-babel": "^4.3.3",
31
+ "rollup-plugin-commonjs": "^10.0.2",
32
+ "rollup-plugin-node-resolve": "^5.2.0",
33
+ "rollup-plugin-replace": "^2.2.0",
34
+ "rollup-plugin-uglify": "^6.0.2",
35
+ "webpack": "^4.39.2"
27
36
  }
28
37
  }
package/autoutils.js DELETED
@@ -1,167 +0,0 @@
1
- import { reportTrackEventServer, _config } from "./index.js";
2
- import { sdkTrackIdVal, Global, pagesArray, timeToStr } from "./tools.js";
3
-
4
- export const AUTOTRACKTYPE = {
5
- ENTER: "enter",
6
- LOOP: "loop",
7
- LEAVE: "leave",
8
- };
9
- // PVUV存储的key值
10
- const BPNPVUV = "UNIBPNPVUVSrcData";
11
- const BPNPVUVFail = "UNIBPNPVUVFailData";
12
- // 采集数据
13
- let atDuration;
14
- let atEnterTimeLong;
15
- let atLoopTimeLong;
16
- let cirtemp;
17
- let _pageObj;
18
- let atInterval = null;
19
-
20
- export const autoStartTrackPVUV = (objParams) => {
21
- clearInterval(atInterval);
22
- _pageObj = null;
23
- _pageObj = objParams;
24
- autoTrackData(AUTOTRACKTYPE.ENTER);
25
- atInterval = setInterval(() => {
26
- autoTrackData(AUTOTRACKTYPE.LOOP);
27
- }, 15000);
28
- };
29
-
30
- export const autoStopTrackPVUV = () => {
31
- autoTrackData(AUTOTRACKTYPE.LEAVE);
32
- clearInterval(atInterval);
33
- };
34
-
35
- function autoTrackData(type) {
36
- if (type === AUTOTRACKTYPE.ENTER) {
37
- cirtemp = 1;
38
- atDuration = 0;
39
- atEnterTimeLong = Date.now();
40
- atLoopTimeLong = Date.now();
41
- } else if (type === AUTOTRACKTYPE.LOOP) {
42
- cirtemp = 2;
43
- atDuration = 15;
44
- atLoopTimeLong = Date.now();
45
- } else if (type === AUTOTRACKTYPE.LEAVE) {
46
- cirtemp = 3;
47
- atDuration = Math.ceil((Date.now() - atLoopTimeLong) / 1000);
48
- }
49
- if (_pageObj) {
50
- const puvData = {
51
- busSegment: _pageObj.busSegment || "",
52
- circulation: cirtemp,
53
- ctk: "",
54
- domain: _pageObj.domain,
55
- duration: atDuration,
56
- module: _pageObj.module || "",
57
- path: _pageObj.path,
58
- url: _pageObj.url,
59
- sourceDomain: _pageObj.sourceDomain,
60
- sourceUrl: _pageObj.sourceUrl,
61
- properties: _pageObj.properties,
62
- title: _pageObj.title,
63
- traceId: "",
64
- trackId: sdkTrackIdVal(),
65
- visitPage: _pageObj.visitPage,
66
- visitTime: timeToStr(atEnterTimeLong),
67
- };
68
- if (puvData) {
69
- insertPVUVData(puvData);
70
- }
71
- }
72
- }
73
-
74
- // 插入数据
75
- export function insertPVUVData(pData) {
76
- let td = uni.getStorageSync(BPNPVUV);
77
- let allPvuvData = td ? JSON.parse(td) : [];
78
- if (pData) {
79
- allPvuvData.push({ ...pData, status: 0 });
80
- uni.setStorageSync(BPNPVUV, JSON.stringify(allPvuvData));
81
- }
82
- }
83
-
84
- // 自动采集对象
85
- export function autoPageObj(cpath, clength, cpages) {
86
- let _pObj = pagesArray.find((obj) => obj.path === cpath);
87
- let pf = Global.platform;
88
- let url = "";
89
- let domain = "";
90
- let srcUrl = "";
91
- let srcDomain = "";
92
- if (pf) {
93
- if (pf === "web" || pf === "h5") {
94
- url = window.location.href;
95
- domain = window.location.hostname;
96
- if (document.referrer) {
97
- let parsedUrl = new URL(document.referrer);
98
- srcUrl = parsedUrl || "";
99
- srcDomain = parsedUrl.hostname || "";
100
- }
101
- } else {
102
- url = cpath;
103
- if (clength > 1) {
104
- let beforePage = cpages[clength - 2];
105
- srcUrl = beforePage.route;
106
- }
107
- domain = _config.domain ? _config.domain : cpath;
108
- }
109
- }
110
- return {
111
- path: _pObj && _pObj.path ? _pObj.path : cpath,
112
- busSegment:
113
- _pObj && _pObj.busSegment ? _pObj.busSegment : _config.busSegment || "",
114
- module: _pObj && _pObj.module ? _pObj.module : _config.module || "",
115
- properties: _pObj && _pObj.properties ? _pObj.properties : "",
116
- domain: domain,
117
- url: url,
118
- visitPage: clength,
119
- sourceDomain: srcDomain,
120
- sourceUrl: srcUrl,
121
- title: _pObj && _pObj.title ? _pObj.title : "",
122
- };
123
- }
124
-
125
- /**
126
- * 查询数据
127
- * 0 未上报 2上报失败
128
- */
129
- export function queryTrackDataUpload() {
130
- let td = uni.getStorageSync(BPNPVUV);
131
- uni.setStorageSync(BPNPVUV, "");
132
- const arr = td ? JSON.parse(td) : [];
133
- let uploadArray = [];
134
- let ftd = uni.getStorageSync(BPNPVUVFail);
135
- const failArr = ftd ? JSON.parse(ftd) : [];
136
- if (arr.length) {
137
- uploadArray.push(...arr);
138
- }
139
- if (failArr.length) {
140
- uploadArray.push(...failArr);
141
- }
142
- if (uploadArray && uploadArray.length) {
143
- uploadArray.forEach((item) => {
144
- delete item.status;
145
- });
146
- reportTrackEventServer("track", uploadArray, BPNPVUVFail);
147
- }
148
- }
149
-
150
- // 更新当前页的业务方设置的对象
151
- export function uUpdatePageExtraArray(d) {
152
- const pages = getCurrentPages();
153
- let page = pages[pages.length - 1];
154
- const index = pagesArray.findIndex((item) => item.path === page.route);
155
- let temp = {
156
- path: page.route,
157
- properties: d.properties ? JSON.stringify(d.properties) : "",
158
- busSegment: d.busSegment ? d.busSegment : "",
159
- module: d.module ? d.module : "",
160
- title: d.title ? d.title : "",
161
- };
162
- if (index !== -1) {
163
- pagesArray[index] = temp;
164
- } else {
165
- pagesArray.push(temp);
166
- }
167
- }
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/eventutils.js DELETED
@@ -1,95 +0,0 @@
1
- import MD5 from "md5";
2
- import { addCache, clearCache, getCache } from "./cache.js";
3
- import { reportTrackEventServer } from "./index.js";
4
- import { sdkTrackIdVal, timeToStr } from "./tools.js";
5
-
6
- //Event存储的key值
7
- const BPNEvent = "UNIBPNEventSrcData";
8
- const BPNEventFail = "UNIBPNEventFailData";
9
- let timerCustom;
10
-
11
- function getCurPath() {
12
- const pages = getCurrentPages();
13
- const gcp = pages[pages.length - 1];
14
- return gcp ? gcp.route : "/";
15
- }
16
-
17
- // 自定义部分 type=>custom event=>到四种具体事件类型 extend_param 扩展字段
18
- export function eventCommonStore(data) {
19
- const _page = data.$page ? data.$page : "";
20
- const _path = _page.path ? _page.path : getCurPath();
21
- const reportEventData = {
22
- ctk: data.$ctk ? data.$ctk : "",
23
- duration: "",
24
- element: data.$element ? data.$element : null,
25
- eventId: data.$event_id ? data.$event_id : "",
26
- event: data.$event_code ? data.$event_code : "",
27
- groupId: "",
28
- busSegment: data.$busSegment,
29
- module: data.$module,
30
- page: {
31
- domain: _page.domain ? _page.domain : "",
32
- pageId: MD5(_path),
33
- path: _path || "",
34
- title: _page.title || "",
35
- url: _path || "",
36
- },
37
- properties: data.$extend_param ? JSON.stringify(data.$extend_param) : "",
38
- traceId: "",
39
- trackId: sdkTrackIdVal(),
40
- triggerTime: timeToStr(Date.now()),
41
- };
42
-
43
- if (reportEventData) {
44
- addCache(reportEventData);
45
- clearTimeout(timerCustom);
46
- timerCustom = setTimeout(() => {
47
- const data = getCache();
48
- if (data.length) {
49
- insertEventData(data);
50
- clearCache();
51
- }
52
- }, 2000);
53
- }
54
- }
55
-
56
- /**
57
- * 插入可视化和Event数据合并
58
- */
59
- export function insertEventData(cData) {
60
- console.log("写入Event数据 ", cData);
61
- let cd = uni.getStorageSync(BPNEvent);
62
- let allEventData = cd ? JSON.parse(cd) : [];
63
- if (cData && cData.length) {
64
- cData.forEach((item) => {
65
- item.status = 0;
66
- allEventData.push(item);
67
- });
68
- uni.setStorageSync(BPNEvent, JSON.stringify(allEventData));
69
- }
70
- }
71
-
72
- /**
73
- * 查询自定义数据
74
- * 0 未上报/上报失败
75
- */
76
- export function queryEventDataUpload() {
77
- let cd = uni.getStorageSync(BPNEvent);
78
- uni.setStorageSync(BPNEvent, "");
79
- const arr = cd ? JSON.parse(cd) : [];
80
- let uploadArray = [];
81
- let fcd = uni.getStorageSync(BPNEventFail);
82
- const failArr = fcd ? JSON.parse(fcd) : [];
83
- if (arr.length) {
84
- uploadArray.push(...arr);
85
- }
86
- if (failArr.length) {
87
- uploadArray.push(...failArr);
88
- }
89
- if (uploadArray && uploadArray.length) {
90
- uploadArray.forEach((item) => {
91
- delete item.status;
92
- });
93
- reportTrackEventServer("event", uploadArray, BPNEventFail);
94
- }
95
- }
package/index.js DELETED
@@ -1,200 +0,0 @@
1
- import MD5 from "md5";
2
- import { queryTrackDataUpload, uUpdatePageExtraArray } from "./autoutils.js";
3
- import { setReportUrl } from "./config.js";
4
- import { eventCommonStore, queryEventDataUpload } from "./eventutils.js";
5
- import { destroyTrackReport, startTrackReport } from "./manualutils.js";
6
- import pk from "./package.json";
7
- import { uniInterceptorListener } from "./pageListener.js";
8
- import {
9
- getAppInfo,
10
- getDeviceInfo,
11
- getDeviceInfoError,
12
- getWebH5Info,
13
- randomUUID,
14
- getWXInfo,
15
- Global,
16
- sdkTrackIdVal,
17
- } from "./tools.js";
18
-
19
- const localLsi = pk.lsi;
20
- let _comInfo = { distinctId: "", anonymousId: "" };
21
- let appData = {};
22
- let deviceData = {};
23
- export let _config = {
24
- env: "production",
25
- token: "",
26
- srcDomain: "",
27
- flushInterval: 15,
28
- isCompatible: "",
29
- signTrackArray: [],
30
- };
31
-
32
- //common global upload interval
33
- let uglInterval = null;
34
- export function init(config) {
35
- if (config) {
36
- let _cf = setReportUrl(config.env ? config.env : "");
37
- Global.upEventUrl = _cf.reportUrl;
38
- Global.upTrackUrl = _cf.reportTrackUrl;
39
- if (config.flushInterval) {
40
- if (config.flushInterval < 5) {
41
- config.flushInterval = 15;
42
- }
43
- } else {
44
- config.flushInterval = 15;
45
- }
46
- _config = {
47
- env: config.env,
48
- token: config.token ? config.token : "",
49
- domain: config.domain ? config.domain : "",
50
- flushInterval: config.flushInterval,
51
- isCompatible:
52
- config.isCompatible != undefined ? config.isCompatible : true,
53
- signTrackArray: config.signTrackArray || [],
54
- };
55
- getBaseicInfo();
56
- _comInfo.distinctId = uni.getStorageSync("v_userId")
57
- ? uni.getStorageSync("v_userId")
58
- : "";
59
- _comInfo.anonymousId = uni.getStorageSync("v_anonId");
60
- if (!_comInfo.anonymousId) {
61
- _comInfo.anonymousId = randomUUID();
62
- uni.setStorageSync("v_anonId", _comInfo.anonymousId);
63
- }
64
- sdkTrackIdVal();
65
- } else {
66
- console.log("init config error, please check config!");
67
- }
68
- // 开启全局定时器
69
- startGlobalTime();
70
- // 监听页面的加载、卸载
71
- uniInterceptorListener();
72
- }
73
-
74
- //the general custom reportCustom interval is enabled
75
- function startGlobalTime() {
76
- clearInterval(uglInterval);
77
- uglInterval = setInterval(() => {
78
- queryEventDataUpload();
79
- queryTrackDataUpload();
80
- }, 15000);
81
- }
82
-
83
- //bind userID
84
- export function setUserId(userId) {
85
- if (userId) {
86
- _comInfo.distinctId = userId;
87
- uni.setStorageSync("v_userId", userId);
88
- } else {
89
- _comInfo.distinctId = "";
90
- uni.setStorageSync("v_userId", "");
91
- }
92
- }
93
-
94
- //对外开放,获取跟踪Id
95
- export function getTrackId() {
96
- return sdkTrackIdVal();
97
- }
98
-
99
- // set custom event
100
- export function setCustomEvent(data) {
101
- eventCommonStore(data);
102
- }
103
-
104
- //track upload-registry
105
- export function onStartTrack(tData) {
106
- startTrackReport(tData);
107
- }
108
-
109
- //track upload-Destroy
110
- export function onDestroyTrack() {
111
- destroyTrackReport();
112
- }
113
-
114
- // auto track 预置的属性
115
- export function setPageExtraObj(tData) {
116
- uUpdatePageExtraArray(tData);
117
- }
118
-
119
- // 数据上报
120
- export function reportTrackEventServer(upType, data, sFailKey) {
121
- if (!upType) {
122
- console.error("please set upload data upType");
123
- return;
124
- }
125
- const comData = commonData(data);
126
- const reportData = {
127
- ...comData,
128
- dataAbstract: MD5(JSON.stringify(comData)),
129
- };
130
- uni.request({
131
- url: upType === "event" ? Global.upEventUrl : Global.upTrackUrl,
132
- method: "POST",
133
- header: {
134
- "Content-Type": "application/json",
135
- appKey: _config.token,
136
- projectId: _config.token,
137
- },
138
- data: reportData,
139
- success: function (res) {
140
- console.log("res: ", JSON.stringify(res));
141
- if (res && res.data) {
142
- uni.setStorageSync(sFailKey, JSON.stringify(data));
143
- } else {
144
- uni.setStorageSync(sFailKey, "");
145
- }
146
- },
147
- fail: function (error) {
148
- console.log("error: ", error);
149
- uni.setStorageSync(sFailKey, JSON.stringify(data));
150
- },
151
- });
152
- }
153
-
154
- function commonData(allData) {
155
- return {
156
- app: appData,
157
- data: allData,
158
- device: deviceData,
159
- lsi: localLsi,
160
- projectId: _config.token,
161
- userAgent: Global.uAgent || "",
162
- anonymousId: _comInfo.anonymousId,
163
- userId: _comInfo.distinctId,
164
- };
165
- }
166
-
167
- //获取基本信息
168
- function getBaseicInfo() {
169
- uni.getSystemInfo({
170
- success: function (res) {
171
- Global.uAgent = res.ua;
172
- let uniPlatform = res.uniPlatform;
173
- if (uniPlatform.includes("app")) {
174
- Global.platform = res.osName;
175
- appData = getAppInfo(res);
176
- } else if (uniPlatform.includes("web") || uniPlatform.includes("h5")) {
177
- Global.platform = uniPlatform;
178
- let wh5Info = getWebH5Info(res);
179
- appData = {
180
- ...wh5Info,
181
- version: _config.version ? _config.version : "unknown",
182
- };
183
- } else if (uniPlatform.includes("weixin")) {
184
- Global.platform = "weixin";
185
- appData = getWXInfo();
186
- }
187
- deviceData = getDeviceInfo(res, Global.platform);
188
- },
189
- fail: function (error) {
190
- deviceData = getDeviceInfoError();
191
- },
192
- complete: function () {
193
- uni.getNetworkType({
194
- success(res) {
195
- deviceData.network = res.networkType;
196
- },
197
- });
198
- },
199
- });
200
- }
package/lsi-md5.js DELETED
@@ -1,20 +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
- const { name, version } = packageJson;
8
- // MD5
9
- const combinedString = name + "-" + version;
10
- const md5Str = MD5(combinedString);
11
- packageJson.lsi = md5Str + "#" + version;
12
- //base64
13
- // const combinedString = name.substring(0, 16) + "v" + version;
14
- // const base64Str = btoa(combinedString);
15
- // packageJson.lsi = base64Str;
16
-
17
- const updatedPackageJson = JSON.stringify(packageJson, null, 2);
18
- fs.writeFileSync("./package.json", updatedPackageJson, "utf8");
19
-
20
- console.log('write package.json "lsi" value success ');
package/manualutils.js DELETED
@@ -1,68 +0,0 @@
1
- import { AUTOTRACKTYPE, insertPVUVData } from "./autoutils.js";
2
- import { sdkTrackIdVal, getTrackObj, timeToStr } from "./tools.js";
3
-
4
- // 流量上报采集
5
- let startTime = 0;
6
- let enterTimeLong = 0;
7
- let loopTimeLong = 0;
8
- let obj = null;
9
- let cirtemp = -1;
10
- let umanInterval = null;
11
- /**
12
- * 注册
13
- */
14
- export const startTrackReport = (tData) => {
15
- clearInterval(umanInterval);
16
- if (tData) {
17
- assemblyTrackData(AUTOTRACKTYPE.ENTER, tData);
18
- umanInterval = setInterval(() => {
19
- assemblyTrackData(AUTOTRACKTYPE.LOOP, null);
20
- }, 15000);
21
- }
22
- };
23
-
24
- /**
25
- * 销毁
26
- */
27
- export const destroyTrackReport = () => {
28
- onTrackReport(AUTOTRACKTYPE.LEAVE);
29
- clearInterval(umanInterval);
30
- };
31
-
32
- function assemblyTrackData(type, tData) {
33
- if (type === AUTOTRACKTYPE.ENTER) {
34
- cirtemp = 1;
35
- startTime = 0;
36
- enterTimeLong = Date.now();
37
- loopTimeLong = Date.now();
38
- obj = getTrackObj(tData);
39
- } else if (type === AUTOTRACKTYPE.LOOP) {
40
- cirtemp = 2;
41
- startTime = 15;
42
- loopTimeLong = Date.now();
43
- } else if (type === AUTOTRACKTYPE.LEAVE) {
44
- cirtemp = 3;
45
- startTime = Math.ceil((Date.now() - loopTimeLong) / 1000);
46
- }
47
- const puvData = {
48
- busSegment: obj.busSegment,
49
- circulation: cirtemp,
50
- ctk: "",
51
- domain: obj.domain,
52
- duration: startTime,
53
- module: obj.module,
54
- path: obj.path,
55
- properties: obj.properties,
56
- sourceDomain: obj.sourceDomain,
57
- sourceUrl: obj.sourceUrl,
58
- title: obj.title,
59
- traceId: "",
60
- trackId: sdkTrackIdVal(),
61
- url: obj.url,
62
- visitPage: obj.visitPage,
63
- visitTime: timeToStr(enterTimeLong),
64
- };
65
- if (puvData) {
66
- insertPVUVData(puvData);
67
- }
68
- }
package/pageListener.js DELETED
@@ -1,71 +0,0 @@
1
- import {
2
- autoPageObj,
3
- autoStartTrackPVUV,
4
- autoStopTrackPVUV
5
- } from "./autoutils.js";
6
- import { _config } from "./index.js";
7
-
8
- export function uniInterceptorListener() {
9
- uni.addInterceptor("navigateTo", {
10
- invoke(args) {
11
- // {"url":"/pages/Home/Home/Home"}
12
- routerMsgHandler("leave");
13
- },
14
- success(args) {
15
- // {"errMsg":"switchTab:ok"}
16
- routerMsgHandler("pv");
17
- },
18
- });
19
- uni.addInterceptor("switchTab", {
20
- invoke(args) {
21
- routerMsgHandler("leave");
22
- },
23
- success(args) {
24
- routerMsgHandler("pv");
25
- },
26
- });
27
- uni.addInterceptor("navigateBack", {
28
- invoke(args) {
29
- routerMsgHandler("leave");
30
- },
31
- success(args) {
32
- routerMsgHandler("pv");
33
- },
34
- });
35
- // 切换到前台
36
- // uni.onAppShow((res) => {
37
- // console.log("-----onAppShow--");
38
- // //routerMsgHandler("pv");
39
- // });
40
- // // 切换到后台
41
- // uni.onAppHide(() => {
42
- // console.log("-----onAppHide--");
43
- // //routerMsgHandler("leave");
44
- // });
45
- }
46
-
47
- // 路由消息统一处理
48
- let pathExist = false;
49
- function routerMsgHandler(msg) {
50
- if (_config.isCompatible) {
51
- } else {
52
- if (msg === "pv") {
53
- const pages = getCurrentPages();
54
- const page = pages[pages.length - 1];
55
- if (_config.signTrackArray && _config.signTrackArray.length) {
56
- pathExist = _config.signTrackArray.find((obj) => obj === page.route);
57
- if (pathExist) {
58
- pathExist = true;
59
- return;
60
- }
61
- }
62
- pathExist = false;
63
- const pageObj = autoPageObj(page.route, pages.length, pages);
64
- autoStartTrackPVUV(pageObj);
65
- } else if (msg === "leave") {
66
- if (!pathExist) {
67
- autoStopTrackPVUV();
68
- }
69
- }
70
- }
71
- }
package/tools.js DELETED
@@ -1,236 +0,0 @@
1
- export const AUTOTRACKTYPE = {
2
- ENTER: "enter",
3
- LOOP: "loop",
4
- LEAVE: "leave",
5
- };
6
-
7
- export let Global = {
8
- trackId: "",
9
- platform: "",
10
- uAgent: "",
11
- upEventUrl: "",
12
- upTrackUrl: "",
13
- };
14
-
15
- // 本地记录每个页面设置的属性值例如:module...
16
- export let pagesArray = [];
17
-
18
- export const sdkTrackIdVal = () => {
19
- if (Global.trackId) {
20
- return Global.trackId;
21
- }
22
- const tId = Date.now().toString();
23
- Global.trackId = tId;
24
- return tId;
25
- };
26
-
27
- export function randomUUID() {
28
- let uuid = "xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function (c) {
29
- let r = (Math.random() * 16) | 0,
30
- v = c === "x" ? r : (r & 0x3) | 0x8;
31
- return v.toString(16);
32
- });
33
- return uuid;
34
- }
35
-
36
- export function timeToStr(timestamp) {
37
- const date = new Date(timestamp);
38
- const year = date.getFullYear();
39
- const month =
40
- date.getMonth() + 1 < 10
41
- ? "0" + (date.getMonth() + 1)
42
- : date.getMonth() + 1;
43
- const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
44
- const hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
45
- const minute =
46
- date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
47
- const second =
48
- date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
49
- const formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
50
- return formattedDate;
51
- }
52
-
53
- //web或者h5的appInfo
54
- export function getWebH5Info(result) {
55
- let ecology = "unknown";
56
- let ua = result.ua.toLowerCase();
57
- let hostname = window.location.hostname;
58
- let titleName = document.title;
59
- let isMobile =
60
- /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua);
61
- if (isMobile) {
62
- ecology = "app";
63
- } else {
64
- ecology = "brower";
65
- }
66
- if (ua.includes("alipay")) {
67
- ecology = "alipay";
68
- } else if (ua.includes("unionPay")) {
69
- ecology = "unionPay";
70
- } else if (ua.includes("onbuygz")) {
71
- ecology = "onbuygz";
72
- } else if (ua.includes("onetravel")) {
73
- ecology = "onetravel";
74
- }
75
- if (ua.includes("micromessenger")) {
76
- if (ua.includes("miniprogram")) {
77
- ecology = "wechat";
78
- } else {
79
- ecology = "brower";
80
- }
81
- }
82
- return {
83
- name: titleName ? titleName : "",
84
- packageName: hostname ? hostname : "",
85
- version: "",
86
- carrier: "h5",
87
- //ecology: ecology,
88
- ecology: "h5",
89
- };
90
- }
91
-
92
- //微信的appInfo
93
- export function getWXInfo() {
94
- const accInfo = uni.getAccountInfoSync();
95
- const bInfo = uni.getAppBaseInfo();
96
- return {
97
- name: bInfo.appName ? bInfo.appName : "",
98
- packageName: accInfo ? accInfo.miniProgram.appId : "",
99
- version: accInfo
100
- ? accInfo.miniProgram.envVersion + accInfo.miniProgram.version
101
- : "",
102
- carrier: "mini",
103
- // ecology: "wechat",
104
- ecology: "mini",
105
- };
106
- }
107
-
108
- //app的appInfo
109
- export function getAppInfo(result) {
110
- let version = plus.runtime.version;
111
- let app = {
112
- name: result.appName,
113
- version: version ? version : "",
114
- carrier: "app",
115
- packageName: "",
116
- ecology: "",
117
- };
118
- if (result.platform === "android") {
119
- let osName = "Android";
120
- let pkName = plus.android.runtimeMainActivity().getPackageName();
121
- if (result.romName.includes("HarmonyOS")) {
122
- osName = "Harmony OS";
123
- }
124
- app.packageName = pkName ? pkName : "";
125
- app.ecology = osName;
126
- } else if (result.platform === "ios") {
127
- let pkName = plus.ios
128
- .importClass("NSBundle")
129
- .mainBundle()
130
- .bundleIdentifier();
131
- app.packageName = pkName ? pkName : "";
132
- app.ecology = "iOS";
133
- } else {
134
- app.ecology = "unknown";
135
- }
136
- return app;
137
- }
138
-
139
- function getCurDeviceType(res, platform) {
140
- if (platform !== "wx") {
141
- const userAgent = res.ua.toLowerCase();
142
- if (/(windows|win32|win64|wow64)/.test(userAgent)) {
143
- return 1;
144
- } else if (/(linux|android)/.test(userAgent)) {
145
- return 2;
146
- } else if (/(macintosh|mac os x|iphone|ipad|ipod)/.test(userAgent)) {
147
- return 2;
148
- } else {
149
- return 2;
150
- }
151
- } else {
152
- if (res.deviceType === "pc") {
153
- return 1;
154
- } else {
155
- return 2;
156
- }
157
- }
158
- }
159
-
160
- //获取设备信息
161
- export function getDeviceInfo(res, platform) {
162
- let device = {
163
- lang: res.osLanguage ? res.osLanguage : res.hostLanguage,
164
- brand: res.deviceBrand + " " + res.deviceModel,
165
- os: res.osName,
166
- osVersion: res.osVersion,
167
- resolution: res.screenWidth + "x" + res.screenHeight,
168
- browser: res.browserName,
169
- browserVersion: res.browserVersion,
170
- color: "",
171
- deviceId: res.deviceId,
172
- deviceType: getCurDeviceType(res, platform),
173
- network: "",
174
- };
175
- return device;
176
- }
177
-
178
- //error默认获取设备信息
179
- export function getDeviceInfoError() {
180
- return {
181
- lang: "",
182
- brand: "",
183
- os: "",
184
- osVersion: "",
185
- resolution: "",
186
- browser: "",
187
- browserVersion: "",
188
- color: "",
189
- deviceId: "",
190
- deviceType: "",
191
- network: "",
192
- };
193
- }
194
-
195
- //uni 通用h5、app、wx拿到当前路由栈
196
- export function getTrackObj(tData) {
197
- const pages = getCurrentPages();
198
- const gcp = pages[pages.length - 1];
199
- let pf = Global.platform;
200
- let url = "";
201
- let domain = "";
202
- let srcUrl = "";
203
- let srcDomain = "";
204
- if (pf) {
205
- if (pf === "web" || pf === "h5") {
206
- url = window.location.href;
207
- domain = window.location.hostname;
208
- if (document.referrer) {
209
- let parsedUrl = new URL(document.referrer);
210
- srcUrl = parsedUrl || "";
211
- srcDomain = parsedUrl.hostname || "";
212
- }
213
- } else {
214
- url = gcp.route;
215
- if (pages.length > 1) {
216
- let beforePage = pages[pages.length - 2];
217
- srcUrl = beforePage.route;
218
- }
219
- domain = _config.domain ? _config.domain : gcp.route;
220
- }
221
- }
222
- if (gcp) {
223
- return {
224
- path: gcp.route,
225
- busSegment: tData.busSegment ? tData.busSegment : "",
226
- module: tData.module ? tData.module : "",
227
- properties: tData.extend_param ? JSON.stringify(tData.extend_param) : "",
228
- title: tData.title ? tData.title : "",
229
- domain: domain,
230
- url: url,
231
- visitPage: pages.length,
232
- sourceDomain: srcDomain,
233
- sourceUrl: srcUrl,
234
- };
235
- }
236
- }
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
- };