visual-buried-point-platform-uni 1.0.0-alpha.16 → 1.0.0-alpha.18
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.
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see buried-point-uni.js.LICENSE.txt */
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{var e={151:e=>{var t={utf8:{stringToBytes:function(e){return t.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(t.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}};e.exports=t},206:e=>{function t(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}e.exports=function(e){return null!=e&&(t(e)||function(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&t(e.slice(0,0))}(e)||!!e._isBuffer)}},503:(e,t,n)=>{var r,o,i,a,u;r=n(939),o=n(151).utf8,i=n(206),a=n(151).bin,(u=function(e,t){e.constructor==String?e=t&&"binary"===t.encoding?a.stringToBytes(e):o.stringToBytes(e):i(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var n=r.bytesToWords(e),s=8*e.length,c=1732584193,l=-271733879,g=-1732584194,p=271733878,d=0;d<n.length;d++)n[d]=16711935&(n[d]<<8|n[d]>>>24)|4278255360&(n[d]<<24|n[d]>>>8);n[s>>>5]|=128<<s%32,n[14+(s+64>>>9<<4)]=s;var f=u._ff,m=u._gg,y=u._hh,h=u._ii;for(d=0;d<n.length;d+=16){var v=c,S=l,b=g,I=p;c=f(c,l,g,p,n[d+0],7,-680876936),p=f(p,c,l,g,n[d+1],12,-389564586),g=f(g,p,c,l,n[d+2],17,606105819),l=f(l,g,p,c,n[d+3],22,-1044525330),c=f(c,l,g,p,n[d+4],7,-176418897),p=f(p,c,l,g,n[d+5],12,1200080426),g=f(g,p,c,l,n[d+6],17,-1473231341),l=f(l,g,p,c,n[d+7],22,-45705983),c=f(c,l,g,p,n[d+8],7,1770035416),p=f(p,c,l,g,n[d+9],12,-1958414417),g=f(g,p,c,l,n[d+10],17,-42063),l=f(l,g,p,c,n[d+11],22,-1990404162),c=f(c,l,g,p,n[d+12],7,1804603682),p=f(p,c,l,g,n[d+13],12,-40341101),g=f(g,p,c,l,n[d+14],17,-1502002290),c=m(c,l=f(l,g,p,c,n[d+15],22,1236535329),g,p,n[d+1],5,-165796510),p=m(p,c,l,g,n[d+6],9,-1069501632),g=m(g,p,c,l,n[d+11],14,643717713),l=m(l,g,p,c,n[d+0],20,-373897302),c=m(c,l,g,p,n[d+5],5,-701558691),p=m(p,c,l,g,n[d+10],9,38016083),g=m(g,p,c,l,n[d+15],14,-660478335),l=m(l,g,p,c,n[d+4],20,-405537848),c=m(c,l,g,p,n[d+9],5,568446438),p=m(p,c,l,g,n[d+14],9,-1019803690),g=m(g,p,c,l,n[d+3],14,-187363961),l=m(l,g,p,c,n[d+8],20,1163531501),c=m(c,l,g,p,n[d+13],5,-1444681467),p=m(p,c,l,g,n[d+2],9,-51403784),g=m(g,p,c,l,n[d+7],14,1735328473),c=y(c,l=m(l,g,p,c,n[d+12],20,-1926607734),g,p,n[d+5],4,-378558),p=y(p,c,l,g,n[d+8],11,-2022574463),g=y(g,p,c,l,n[d+11],16,1839030562),l=y(l,g,p,c,n[d+14],23,-35309556),c=y(c,l,g,p,n[d+1],4,-1530992060),p=y(p,c,l,g,n[d+4],11,1272893353),g=y(g,p,c,l,n[d+7],16,-155497632),l=y(l,g,p,c,n[d+10],23,-1094730640),c=y(c,l,g,p,n[d+13],4,681279174),p=y(p,c,l,g,n[d+0],11,-358537222),g=y(g,p,c,l,n[d+3],16,-722521979),l=y(l,g,p,c,n[d+6],23,76029189),c=y(c,l,g,p,n[d+9],4,-640364487),p=y(p,c,l,g,n[d+12],11,-421815835),g=y(g,p,c,l,n[d+15],16,530742520),c=h(c,l=y(l,g,p,c,n[d+2],23,-995338651),g,p,n[d+0],6,-198630844),p=h(p,c,l,g,n[d+7],10,1126891415),g=h(g,p,c,l,n[d+14],15,-1416354905),l=h(l,g,p,c,n[d+5],21,-57434055),c=h(c,l,g,p,n[d+12],6,1700485571),p=h(p,c,l,g,n[d+3],10,-1894986606),g=h(g,p,c,l,n[d+10],15,-1051523),l=h(l,g,p,c,n[d+1],21,-2054922799),c=h(c,l,g,p,n[d+8],6,1873313359),p=h(p,c,l,g,n[d+15],10,-30611744),g=h(g,p,c,l,n[d+6],15,-1560198380),l=h(l,g,p,c,n[d+13],21,1309151649),c=h(c,l,g,p,n[d+4],6,-145523070),p=h(p,c,l,g,n[d+11],10,-1120210379),g=h(g,p,c,l,n[d+2],15,718787259),l=h(l,g,p,c,n[d+9],21,-343485551),c=c+v>>>0,l=l+S>>>0,g=g+b>>>0,p=p+I>>>0}return r.endian([c,l,g,p])})._ff=function(e,t,n,r,o,i,a){var u=e+(t&n|~t&r)+(o>>>0)+a;return(u<<i|u>>>32-i)+t},u._gg=function(e,t,n,r,o,i,a){var u=e+(t&r|n&~r)+(o>>>0)+a;return(u<<i|u>>>32-i)+t},u._hh=function(e,t,n,r,o,i,a){var u=e+(t^n^r)+(o>>>0)+a;return(u<<i|u>>>32-i)+t},u._ii=function(e,t,n,r,o,i,a){var u=e+(n^(t|~r))+(o>>>0)+a;return(u<<i|u>>>32-i)+t},u._blocksize=16,u._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);var n=r.wordsToBytes(u(e,t));return t&&t.asBytes?n:t&&t.asString?a.bytesToString(n):r.bytesToHex(n)}},939:e=>{var t,n;t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];e>0;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var n=[],r=0;r<e.length;r+=3)for(var o=e[r]<<16|e[r+1]<<8|e[r+2],i=0;i<4;i++)8*r+6*i<=8*e.length?n.push(t.charAt(o>>>6*(3-i)&63)):n.push("=");return n.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var n=[],r=0,o=0;r<e.length;o=++r%4)0!=o&&n.push((t.indexOf(e.charAt(r-1))&Math.pow(2,-2*o+8)-1)<<2*o|t.indexOf(e.charAt(r))>>>6-2*o);return n}},e.exports=n}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{getTrackId:()=>ee,init:()=>Q,onDestroyTrack:()=>re,onStartTrack:()=>ne,reportTrackEventServer:()=>ie,setCustomEvent:()=>te,setPageExtraObj:()=>oe,setUserId:()=>X});var e=n(503);let t={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},o=[];const i=()=>{if(t.trackId)return t.trackId;const e=Date.now().toString();return t.trackId=e,e};function a(){return"xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g,(function(e){let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function u(e){const t=new Date(e);return`${t.getFullYear()}-${t.getMonth()+1<10?"0"+(t.getMonth()+1):t.getMonth()+1}-${t.getDate()<10?"0"+t.getDate():t.getDate()} ${t.getHours()<10?"0"+t.getHours():t.getHours()}:${t.getMinutes()<10?"0"+t.getMinutes():t.getMinutes()}:${t.getSeconds()<10?"0"+t.getSeconds():t.getSeconds()}`}function s(e){if("web"===t.platform||"h5"===platform){const t=e.ua.toLowerCase();return/(windows|win32|win64|wow64)/.test(t)?1:(/(linux|android)/.test(t)||/(macintosh|mac os x|iphone|ipad|ipod)/.test(t),2)}return"pc"===e.deviceType?1:2}function c(){if("web"===t.platform||"h5"===t.platform){let e={utmSource:"",utmCampaign:"",utmTerm:"",utmContent:"",ctk:""};if(window.location.href){const t=window.location.href.split("?")[1]||"";if(t){const n=new URLSearchParams(t);e.utmSource=n.get("utmSource")||"",e.utmCampaign=n.get("utmCampaign")||"",e.utmTerm=n.get("utmTerm")||"",e.utmContent=n.get("utmContent")||"",e.ctk=n.get("ctk")||""}}return e}return null}const l="enter",g="loop",p="leave",d="UNIBPNPVUVSrcData",f="UNIBPNPVUVFailData";let m,y,h,v,S,b=null,I=null;const w=e=>{b?k():(clearInterval(b),m=0,y=0,h=0,v=1,S=null,b=null,I=0,S=e,T(l),b=setInterval((()=>{T(g)}),15e3))},k=()=>{T(p),clearInterval(b)};function T(e){if(e===l?(v=1,m=0,y=Date.now(),h=y,I=a()):e===g?(v=2,m=15,h=Date.now()):e===p&&(v=3,m=Math.ceil((Date.now()-h)/1e3)),S){const e={busSegment:S.busSegment||"",circulation:v,domain:S.domain,duration:m,module:S.module||"",path:S.path,url:S.url,sourceDomain:S.sourceDomain,sourceUrl:S.sourceUrl,properties:S.properties,title:S.title,traceId:"",trackId:i(),visitPage:S.visitPage,visitTime:u(y),pageUUId:I};e&&x(e,I)}}function x(e,t){let n=uni.getStorageSync(d),r=n?JSON.parse(n):[];if(r.length>0){const n=r.findIndex((e=>e.pageUUId===t));-1!==n?r[n]={...r[n],...e}:r.push(e)}else r.push(e);uni.setStorageSync(d,JSON.stringify(r))}const U=e=>{if("object"==typeof e){const t=Array.isArray(e)?[]:{};for(const n in e)"object"==typeof e[n]?t[n]=U(e[n]):t[n]=e[n];return t}return e},N=[],P=e=>{N.push(e)},O=()=>U(N),B=()=>{N.length=0},_="UNIBPNEventSrcData",A="UNIBPNEventFailData";let D;let C=0,$=0,M=0,j=-1,J=null,L=null,E=0;function V(){clearInterval(L),C=0,$=0,M=0,j=1,J=null,L=null,E=0}const H=e=>{L?z():e&&(V(),R(l,e),L=setInterval((()=>{R(g,null)}),15e3))},z=()=>{R(p),V()};function R(e,n){e===l?(E=a(),$=Date.now(),M=$,J=function(e){const n=getCurrentPages(),r=n[n.length-1];let o=t.platform,i="",a="",u="",s="";if(o)if("web"===o||"h5"===o){if(i=window.location.href,a=window.location.hostname,document.referrer){let e=new URL(document.referrer);u=e||"",s=e.hostname||""}}else i=r.route,n.length>1&&(u=n[n.length-2].route),a=t.domain?t.domain:r.route;if(r)return{path:r.route,busSegment:e.busSegment?e.busSegment:"",module:e.module?e.module:"",properties:e.extend_param?JSON.stringify(e.extend_param):"",title:e.title?e.title:"",domain:a,url:i,visitPage:n.length,sourceDomain:s,sourceUrl:u}}(n)):e===g?(j=2,C=15,M=Date.now()):e===p&&(j=3,C=Math.ceil((Date.now()-M)/1e3));const r={busSegment:J.busSegment,circulation:j,domain:J.domain,duration:C,module:J.module,path:J.path,properties:J.properties,sourceDomain:J.sourceDomain,sourceUrl:J.sourceUrl,title:J.title,traceId:"",trackId:i(),url:J.url,visitPage:J.visitPage,visitTime:u($),utm:c(),pageUUId:E};r&&x(r,E)}let F=!1;function q(e){if(t.isCompatible);else if("pv"===e){const e=getCurrentPages(),n=e[e.length-1];if(t.signTrackArray&&t.signTrackArray.length&&(F=t.signTrackArray.find((e=>e===n.route)),F))return void(F=!0);F=!1;const r=function(e,n,r){let i=o.find((t=>t.path===e)),a=t.platform,u="",s="",c="",l="";if(a)if("web"===a||"h5"===a){if(u=window.location.href,s=window.location.hostname,document.referrer){let e=new URL(document.referrer);c=e||"",l=e.hostname||""}}else u=e,n>1&&(c=r[n-2].route),s=t.domain?t.domain:e;return{path:i&&i.path?i.path:e,busSegment:i&&i.busSegment?i.busSegment:t.busSegment||"",module:i&&i.module?i.module:t.module||"",properties:i&&i.properties?i.properties:"",domain:s,url:u,visitPage:n,sourceDomain:l,sourceUrl:c,title:i&&i.title?i.title:""}}(n.route,e.length,e);w(r)}else"leave"===e&&(F||k())}const W=JSON.parse('{"dr":"2df7d9fee02691e293eb3e32b4593ade#1.0.0-alpha.17"}').dr;let K={distinctId:"",anonymousId:""},Y={},Z={},G=null;function Q(e){if(e){let n="test"===(e.env?e.env:"")?{reportUrl:"https://buryingpoint.gcongo.com.cn/client/api/event",reportTrackUrl:"https://buryingpoint.gcongo.com.cn/client/api/track",eventListUrl:"https://buryingpoint.gcongo.com.cn/api/event/query/eventList"}:{reportUrl:"https://buryingpoint.onebuygz.com/client/api/event",reportTrackUrl:"https://buryingpoint.onebuygz.com/client/api/track",eventListUrl:"https://buryingpoint.onebuygz.com/api/event/query/eventList"};t.upEventUrl=n.reportUrl,t.upTrackUrl=n.reportTrackUrl,Object.assign(t,e),uni.getSystemInfo({success:function(e){t.uAgent=e.ua;let n=e.uniPlatform;if(n.includes("app"))t.platform=e.osName,Y=function(e){let t=plus.runtime.version,n={name:e.appName,version:t||"",carrier:"app",packageName:"",ecology:""};if("android"===e.platform){let t="Android",r=plus.android.runtimeMainActivity().getPackageName();e.romName.includes("HarmonyOS")&&(t="Harmony OS"),n.packageName=r||"",n.ecology=t}else if("ios"===e.platform){let e=plus.ios.importClass("NSBundle").mainBundle().bundleIdentifier();n.packageName=e||"",n.ecology="iOS"}else n.ecology="unknown";return n}(e);else if(n.includes("web")||n.includes("h5")){t.platform=n;let r=function(e){let t="unknown",n=e.ua.toLowerCase(),r=window.location.hostname,o=document.title;return t=/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(n)?"app":"brower",n.includes("alipay")?t="alipay":n.includes("unionPay")?t="unionPay":n.includes("onbuygz")?t="onbuygz":n.includes("onetravel")&&(t="onetravel"),n.includes("micromessenger")&&(t=n.includes("miniprogram")?"wechat":"brower"),{name:o||"",packageName:r||"",version:"",carrier:"h5",ecology:"h5"}}(e);Y={...r,version:t.version?t.version:"unknown"}}else n.includes("weixin")&&(t.platform="weixin",Y=function(){const e=uni.getAccountInfoSync(),t=uni.getAppBaseInfo();return{name:t.appName?t.appName:"",packageName:e?e.miniProgram.appId:"",version:e?e.miniProgram.envVersion+e.miniProgram.version:"",carrier:"mini",ecology:"mini"}}());Z=function(e){return{lang:e.osLanguage?e.osLanguage:e.hostLanguage,brand:e.deviceBrand+" "+e.deviceModel,os:e.osName,osVersion:e.osVersion,resolution:e.screenWidth+"x"+e.screenHeight,browser:e.browserName,browserVersion:e.browserVersion,color:"",deviceId:e.deviceId,deviceType:s(e),network:""}}(e)},fail:function(e){Z={lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}},complete:function(){uni.getNetworkType({success(e){Z.network=e.networkType}})}}),K.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",K.anonymousId=uni.getStorageSync("v_anonId"),K.anonymousId||(K.anonymousId=a(),uni.setStorageSync("v_anonId",K.anonymousId)),i()}else console.log("init config error, please check config!");console.log("global:: ",t),clearInterval(G),G=setInterval((()=>{!function(){let e=uni.getStorageSync(_);uni.setStorageSync(_,"");const t=e?JSON.parse(e):[];let n=[],r=uni.getStorageSync(A);const o=r?JSON.parse(r):[];t.length&&n.push(...t),o.length&&n.push(...o),n&&n.length&&ie("event",n,A)}(),function(){let e=uni.getStorageSync(d);uni.setStorageSync(d,"");const t=e?JSON.parse(e):[];let n=[],r=uni.getStorageSync(f);const o=r?JSON.parse(r):[];t.length&&n.push(...t),o.length&&n.push(...o),n&&n.length&&(n.forEach((e=>{delete e.pageUUId})),ie("track",n,f))}()}),15e3),uni.addInterceptor("navigateTo",{invoke(e){q("leave")},success(e){q("pv")}}),uni.addInterceptor("switchTab",{invoke(e){q("leave")},success(e){q("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){q("leave")},success(e){q("pv")}})}function X(e){e?(K.distinctId=e,uni.setStorageSync("v_userId",e)):(K.distinctId="",uni.setStorageSync("v_userId",""))}function ee(){return i()}function te(t){!function(t){if(!t)return;const n=t.$page?t.$page:"",r=n.path?n.path:function(){const e=getCurrentPages(),t=e[e.length-1];return t?t.route:"/"}();let o={utm:t.$utm?t.$utm:c(),duration:"",element:t.$element?t.$element:null,eventId:t.$event_id?t.$event_id:"",event:t.$event_code?t.$event_code:"",groupId:"",busSegment:t.$busSegment?t.$busSegment:"",module:t.$module?t.$module:"",page:{domain:n.domain?n.domain:"",pageId:e(r),path:r||"",title:n.title||"",url:r||""},properties:t.$extend_param?JSON.stringify(t.$extend_param):"",traceId:"",trackId:i(),triggerTime:u(Date.now())};o&&(P(o),clearTimeout(D),D=setTimeout((()=>{const e=O();e.length&&(function(e){const t=uni.getStorageSync(_);let n=t?JSON.parse(t):[];e&&e.length&&(n.concat(e),uni.setStorageSync(_,JSON.stringify(n)))}(e),B())}),2e3))}(t)}function ne(e){H(e)}function re(){z()}function oe(e){!function(e){const t=getCurrentPages();let n=t[t.length-1];const r=o.findIndex((e=>e.path===n.route));let i={path:n.route,properties:e.properties?JSON.stringify(e.properties):"",busSegment:e.busSegment?e.busSegment:"",module:e.module?e.module:"",title:e.title?e.title:""};-1!==r?o[r]=i:o.push(i)}(e)}function ie(n,r,o){if(!n)return void console.error("please set upload data upType");const i={app:Y,data:r,device:Z,lsi:W,projectId:t.token,userAgent:t.uAgent||"",anonymousId:K.anonymousId,userId:K.distinctId},a={...i,dataAbstract:e(JSON.stringify(i))};uni.request({url:"event"===n?t.upEventUrl:t.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:t.token,projectId:t.token},data:a,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(o,JSON.stringify(r)):uni.setStorageSync(o,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(o,JSON.stringify(r))}})}})(),r})()));
|
package/index.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import MD5 from "md5";
|
|
2
|
+
import { queryTrackDataUpload } from "./autoutils.js";
|
|
3
|
+
import { setReportUrl } from "./config.js";
|
|
4
|
+
import { eventCommonStore, queryEventDataUpload } from "./eventutils.js";
|
|
5
|
+
import { uStopTrackPVData, uStartTrackPVData } from "./manualutils.js";
|
|
6
|
+
import pk from "./package.json";
|
|
7
|
+
import { uniInterceptorListener } from "./pageListener.js";
|
|
8
|
+
import {
|
|
9
|
+
getAppInfo,
|
|
10
|
+
getDeviceInfo,
|
|
11
|
+
getDeviceInfoError,
|
|
12
|
+
getWebH5Info,
|
|
13
|
+
getWXInfo,
|
|
14
|
+
Global,
|
|
15
|
+
randomUUID,
|
|
16
|
+
sdkTrackIdVal,
|
|
17
|
+
uUpdatePageExtraArray,
|
|
18
|
+
} from "./tools.js";
|
|
19
|
+
|
|
20
|
+
const localLsi = pk.lsi;
|
|
21
|
+
let _comInfo = { distinctId: "", anonymousId: "" };
|
|
22
|
+
let appData = {};
|
|
23
|
+
let deviceData = {};
|
|
24
|
+
//common global upload interval
|
|
25
|
+
let uglInterval = null;
|
|
26
|
+
export function init(config) {
|
|
27
|
+
if (config) {
|
|
28
|
+
let _cf = setReportUrl(config.env ? config.env : "");
|
|
29
|
+
Global.upEventUrl = _cf.reportUrl;
|
|
30
|
+
Global.upTrackUrl = _cf.reportTrackUrl;
|
|
31
|
+
Object.assign(Global, config);
|
|
32
|
+
getBaseicInfo();
|
|
33
|
+
_comInfo.distinctId = uni.getStorageSync("v_userId")
|
|
34
|
+
? uni.getStorageSync("v_userId")
|
|
35
|
+
: "";
|
|
36
|
+
_comInfo.anonymousId = uni.getStorageSync("v_anonId");
|
|
37
|
+
if (!_comInfo.anonymousId) {
|
|
38
|
+
_comInfo.anonymousId = randomUUID();
|
|
39
|
+
uni.setStorageSync("v_anonId", _comInfo.anonymousId);
|
|
40
|
+
}
|
|
41
|
+
sdkTrackIdVal();
|
|
42
|
+
} else {
|
|
43
|
+
console.log("init config error, please check config!");
|
|
44
|
+
}
|
|
45
|
+
console.log("global:: ", Global);
|
|
46
|
+
// 开启全局定时器
|
|
47
|
+
startGlobalTime();
|
|
48
|
+
// 监听页面的加载、卸载
|
|
49
|
+
uniInterceptorListener();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//the general custom reportCustom interval is enabled
|
|
53
|
+
function startGlobalTime() {
|
|
54
|
+
clearInterval(uglInterval);
|
|
55
|
+
uglInterval = setInterval(() => {
|
|
56
|
+
queryEventDataUpload();
|
|
57
|
+
queryTrackDataUpload();
|
|
58
|
+
}, 15000);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
//bind userID
|
|
62
|
+
export function setUserId(userId) {
|
|
63
|
+
if (userId) {
|
|
64
|
+
_comInfo.distinctId = userId;
|
|
65
|
+
uni.setStorageSync("v_userId", userId);
|
|
66
|
+
} else {
|
|
67
|
+
_comInfo.distinctId = "";
|
|
68
|
+
uni.setStorageSync("v_userId", "");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
//对外开放,获取跟踪Id
|
|
73
|
+
export function getTrackId() {
|
|
74
|
+
return sdkTrackIdVal();
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// set custom event
|
|
78
|
+
export function setCustomEvent(data) {
|
|
79
|
+
eventCommonStore(data);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
//track upload-registry
|
|
83
|
+
export function onStartTrack(tData) {
|
|
84
|
+
uStartTrackPVData(tData);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
//track upload-Destroy
|
|
88
|
+
export function onDestroyTrack() {
|
|
89
|
+
uStopTrackPVData();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
// auto track 预置的属性
|
|
93
|
+
export function setPageExtraObj(tData) {
|
|
94
|
+
uUpdatePageExtraArray(tData);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// 数据上报
|
|
98
|
+
export function reportTrackEventServer(upType, data, sFailKey) {
|
|
99
|
+
if (!upType) {
|
|
100
|
+
console.error("please set upload data upType");
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
const comData = commonData(data);
|
|
104
|
+
const reportData = {
|
|
105
|
+
...comData,
|
|
106
|
+
dataAbstract: MD5(JSON.stringify(comData)),
|
|
107
|
+
};
|
|
108
|
+
uni.request({
|
|
109
|
+
url: upType === "event" ? Global.upEventUrl : Global.upTrackUrl,
|
|
110
|
+
method: "POST",
|
|
111
|
+
header: {
|
|
112
|
+
"Content-Type": "application/json",
|
|
113
|
+
appKey: Global.token,
|
|
114
|
+
projectId: Global.token,
|
|
115
|
+
},
|
|
116
|
+
data: reportData,
|
|
117
|
+
success: function (res) {
|
|
118
|
+
console.log("res: ", JSON.stringify(res));
|
|
119
|
+
if (res && res.data) {
|
|
120
|
+
uni.setStorageSync(sFailKey, JSON.stringify(data));
|
|
121
|
+
} else {
|
|
122
|
+
uni.setStorageSync(sFailKey, "");
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
fail: function (error) {
|
|
126
|
+
console.log("error: ", error);
|
|
127
|
+
uni.setStorageSync(sFailKey, JSON.stringify(data));
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function commonData(allData) {
|
|
133
|
+
return {
|
|
134
|
+
app: appData,
|
|
135
|
+
data: allData,
|
|
136
|
+
device: deviceData,
|
|
137
|
+
lsi: localLsi,
|
|
138
|
+
projectId: Global.token,
|
|
139
|
+
userAgent: Global.uAgent || "",
|
|
140
|
+
anonymousId: _comInfo.anonymousId,
|
|
141
|
+
userId: _comInfo.distinctId,
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
//获取基本信息
|
|
146
|
+
function getBaseicInfo() {
|
|
147
|
+
uni.getSystemInfo({
|
|
148
|
+
success: function (res) {
|
|
149
|
+
Global.uAgent = res.ua;
|
|
150
|
+
let uniPlatform = res.uniPlatform;
|
|
151
|
+
if (uniPlatform.includes("app")) {
|
|
152
|
+
Global.platform = res.osName;
|
|
153
|
+
appData = getAppInfo(res);
|
|
154
|
+
} else if (uniPlatform.includes("web") || uniPlatform.includes("h5")) {
|
|
155
|
+
Global.platform = uniPlatform;
|
|
156
|
+
let wh5Info = getWebH5Info(res);
|
|
157
|
+
appData = {
|
|
158
|
+
...wh5Info,
|
|
159
|
+
version: Global.version ? Global.version : "unknown",
|
|
160
|
+
};
|
|
161
|
+
} else if (uniPlatform.includes("weixin")) {
|
|
162
|
+
Global.platform = "weixin";
|
|
163
|
+
appData = getWXInfo();
|
|
164
|
+
}
|
|
165
|
+
deviceData = getDeviceInfo(res);
|
|
166
|
+
},
|
|
167
|
+
fail: function (error) {
|
|
168
|
+
deviceData = getDeviceInfoError();
|
|
169
|
+
},
|
|
170
|
+
complete: function () {
|
|
171
|
+
uni.getNetworkType({
|
|
172
|
+
success(res) {
|
|
173
|
+
deviceData.network = res.networkType;
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
},
|
|
177
|
+
});
|
|
178
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visual-buried-point-platform-uni",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"lsi": "
|
|
3
|
+
"version": "1.0.0-alpha.18",
|
|
4
|
+
"lsi": "b3ba62bdaef575807f3faebc845b7339#1.0.0-alpha.18",
|
|
5
5
|
"description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.",
|
|
6
|
-
"main": "
|
|
7
|
-
"module": "dist/esm/buried-point-uni.js",
|
|
6
|
+
"main": "index.js",
|
|
8
7
|
"scripts": {
|
|
9
|
-
"
|
|
10
|
-
"build": "
|
|
8
|
+
"test": "echo \"Error: no test specified\" && exit 1",
|
|
9
|
+
"build": "webpack --mode production && npm run lsi-md5",
|
|
10
|
+
"lsi-md5": "node lsi-md5.js"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
+
"type": "module",
|
|
19
20
|
"keywords": [],
|
|
20
21
|
"author": "",
|
|
21
22
|
"license": "MIT",
|
|
@@ -23,15 +24,7 @@
|
|
|
23
24
|
"md5": "^2.3.0"
|
|
24
25
|
},
|
|
25
26
|
"devDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
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
|
+
"webpack": "^5.72.1",
|
|
28
|
+
"webpack-cli": "4.9.2"
|
|
36
29
|
}
|
|
37
30
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}Object.defineProperty(exports,"__esModule",{value:!0});var crypt=createCommonjsModule(function(e){var a,r;a="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],o=0;o<4;o++)8*r+6*o<=8*e.length?t.push(a.charAt(n>>>6*(3-o)&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((a.indexOf(e.charAt(r-1))&Math.pow(2,-2*n+8)-1)<<2*n|a.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,o=-271733879,a=-1732584194,i=271733878,u=0;u<r.length;u++)r[u]=16711935&(r[u]<<8|r[u]>>>24)|4278255360&(r[u]<<24|r[u]>>>8);r[t>>>5]|=128<<t%32,r[14+(64+t>>>9<<4)]=t;for(var s=v._ff,c=v._gg,l=v._hh,p=v._ii,u=0;u<r.length;u+=16){var g=n,d=o,m=a,f=i,n=s(n,o,a,i,r[u+0],7,-680876936),i=s(i,n,o,a,r[u+1],12,-389564586),a=s(a,i,n,o,r[u+2],17,606105819),o=s(o,a,i,n,r[u+3],22,-1044525330);n=s(n,o,a,i,r[u+4],7,-176418897),i=s(i,n,o,a,r[u+5],12,1200080426),a=s(a,i,n,o,r[u+6],17,-1473231341),o=s(o,a,i,n,r[u+7],22,-45705983),n=s(n,o,a,i,r[u+8],7,1770035416),i=s(i,n,o,a,r[u+9],12,-1958414417),a=s(a,i,n,o,r[u+10],17,-42063),o=s(o,a,i,n,r[u+11],22,-1990404162),n=s(n,o,a,i,r[u+12],7,1804603682),i=s(i,n,o,a,r[u+13],12,-40341101),a=s(a,i,n,o,r[u+14],17,-1502002290),n=c(n,o=s(o,a,i,n,r[u+15],22,1236535329),a,i,r[u+1],5,-165796510),i=c(i,n,o,a,r[u+6],9,-1069501632),a=c(a,i,n,o,r[u+11],14,643717713),o=c(o,a,i,n,r[u+0],20,-373897302),n=c(n,o,a,i,r[u+5],5,-701558691),i=c(i,n,o,a,r[u+10],9,38016083),a=c(a,i,n,o,r[u+15],14,-660478335),o=c(o,a,i,n,r[u+4],20,-405537848),n=c(n,o,a,i,r[u+9],5,568446438),i=c(i,n,o,a,r[u+14],9,-1019803690),a=c(a,i,n,o,r[u+3],14,-187363961),o=c(o,a,i,n,r[u+8],20,1163531501),n=c(n,o,a,i,r[u+13],5,-1444681467),i=c(i,n,o,a,r[u+2],9,-51403784),a=c(a,i,n,o,r[u+7],14,1735328473),n=l(n,o=c(o,a,i,n,r[u+12],20,-1926607734),a,i,r[u+5],4,-378558),i=l(i,n,o,a,r[u+8],11,-2022574463),a=l(a,i,n,o,r[u+11],16,1839030562),o=l(o,a,i,n,r[u+14],23,-35309556),n=l(n,o,a,i,r[u+1],4,-1530992060),i=l(i,n,o,a,r[u+4],11,1272893353),a=l(a,i,n,o,r[u+7],16,-155497632),o=l(o,a,i,n,r[u+10],23,-1094730640),n=l(n,o,a,i,r[u+13],4,681279174),i=l(i,n,o,a,r[u+0],11,-358537222),a=l(a,i,n,o,r[u+3],16,-722521979),o=l(o,a,i,n,r[u+6],23,76029189),n=l(n,o,a,i,r[u+9],4,-640364487),i=l(i,n,o,a,r[u+12],11,-421815835),a=l(a,i,n,o,r[u+15],16,530742520),n=p(n,o=l(o,a,i,n,r[u+2],23,-995338651),a,i,r[u+0],6,-198630844),i=p(i,n,o,a,r[u+7],10,1126891415),a=p(a,i,n,o,r[u+14],15,-1416354905),o=p(o,a,i,n,r[u+5],21,-57434055),n=p(n,o,a,i,r[u+12],6,1700485571),i=p(i,n,o,a,r[u+3],10,-1894986606),a=p(a,i,n,o,r[u+10],15,-1051523),o=p(o,a,i,n,r[u+1],21,-2054922799),n=p(n,o,a,i,r[u+8],6,1873313359),i=p(i,n,o,a,r[u+15],10,-30611744),a=p(a,i,n,o,r[u+6],15,-1560198380),o=p(o,a,i,n,r[u+13],21,1309151649),n=p(n,o,a,i,r[u+4],6,-145523070),i=p(i,n,o,a,r[u+11],10,-1120210379),a=p(a,i,n,o,r[u+2],15,718787259),o=p(o,a,i,n,r[u+9],21,-343485551),n=n+g>>>0,o=o+d>>>0,a=a+m>>>0,i=i+f>>>0}return T.endian([n,o,a,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,o,a,i){e=e+(t&r|~t&n)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._gg=function(e,t,r,n,o,a,i){e=e+(t&n|r&~n)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._hh=function(e,t,r,n,o,a,i){e=e+(t^r^n)+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._ii=function(e,t,r,n,o,a,i){e=e+(r^(t|~n))+(o>>>0)+i;return(e<<a|e>>>32-a)+t},v._blocksize=16,v._digestsize=16,e.exports=function(e,t){if(null==e)throw new Error("Illegal argument "+e);e=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 o="",a="",i="",u="";if(n&&("web"===n||"h5"===n?(o=window.location.href,a=window.location.hostname,document.referrer&&(n=new URL(document.referrer),i=n||"",u=n.hostname||"")):(o=r.route,1<t.length&&(n=t[t.length-2],i=n.route),a=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:a,url:o,visitPage:t.length,sourceDomain:u,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),o=Global.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=r[e-2],u=o.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:a,visitPage:e,sourceDomain:s,sourceUrl:u,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||{utmSource:"",utmCampaign:"",utmTerm:"",utmContent:"",ctk:""},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.16",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),console.log("global:: ",Global),getBaseicInfo(),_comInfo.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",_comInfo.anonymousId=uni.getStorageSync("v_anonId"),_comInfo.anonymousId||(_comInfo.anonymousId=randomUUID(),uni.setStorageSync("v_anonId",_comInfo.anonymousId)),sdkTrackIdVal()):console.log("init config error, please check config!"),startGlobalTime(),uniInterceptorListener()}function startGlobalTime(){clearInterval(uglInterval),uglInterval=setInterval(()=>{queryEventDataUpload(),queryTrackDataUpload()},Global.flushInterval||15e3)}function setUserId(e){e?(_comInfo.distinctId=e,uni.setStorageSync("v_userId",e)):(_comInfo.distinctId="",uni.setStorageSync("v_userId",""))}function getTrackId(){return sdkTrackIdVal()}function setCustomEvent(e){eventCommonStore(e)}function onStartTrack(e){uStartTrackPVData(e)}function onDestroyTrack(){uStopTrackPVData()}function setPageExtraObj(e){uUpdatePageExtraArray(e)}function reportTrackEventServer(e,t,r){var n;e?(n={...n=commonData(t),dataAbstract:md5(JSON.stringify(n))},uni.request({url:"event"===e?Global.upEventUrl:Global.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:Global.token,projectId:Global.token},data:n,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(r,JSON.stringify(t)):uni.setStorageSync(r,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(r,JSON.stringify(t))}})):console.error("please set upload data upType")}function commonData(e){return{app:appData,data:e,device:deviceData,lsi:localLsi,projectId:Global.token,userAgent:Global.uAgent||"",anonymousId:_comInfo.anonymousId,userId:_comInfo.distinctId}}function getBaseicInfo(){uni.getSystemInfo({success:function(e){Global.uAgent=e.ua;var t,r=e.uniPlatform;r.includes("app")?(Global.platform=e.osName,appData=getAppInfo(e)):r.includes("web")||r.includes("h5")?(Global.platform=r,t=getWebH5Info(e),appData={...t,version:Global.version||"unknown"}):r.includes("weixin")&&(Global.platform="weixin",appData=getWXInfo()),deviceData=getDeviceInfo(e,Global.platform)},fail:function(e){deviceData=getDeviceInfoError()},complete:function(){uni.getNetworkType({success(e){deviceData.network=e.networkType}})}})}exports.getTrackId=getTrackId,exports.init=init,exports.onDestroyTrack=onDestroyTrack,exports.onStartTrack=onStartTrack,exports.reportTrackEventServer=reportTrackEventServer,exports.setCustomEvent=setCustomEvent,exports.setPageExtraObj=setPageExtraObj,exports.setUserId=setUserId;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function createCommonjsModule(e,t){return e(t={exports:{}},t.exports),t.exports}var crypt=createCommonjsModule(function(e){var o,n;o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n={rotl:function(e,t){return e<<t|e>>>32-t},rotr:function(e,t){return e<<32-t|e>>>t},endian:function(e){if(e.constructor==Number)return 16711935&n.rotl(e,8)|4278255360&n.rotl(e,24);for(var t=0;t<e.length;t++)e[t]=n.endian(e[t]);return e},randomBytes:function(e){for(var t=[];0<e;e--)t.push(Math.floor(256*Math.random()));return t},bytesToWords:function(e){for(var t=[],n=0,r=0;n<e.length;n++,r+=8)t[r>>>5]|=e[n]<<24-r%32;return t},wordsToBytes:function(e){for(var t=[],n=0;n<32*e.length;n+=8)t.push(e[n>>>5]>>>24-n%32&255);return t},bytesToHex:function(e){for(var t=[],n=0;n<e.length;n++)t.push((e[n]>>>4).toString(16)),t.push((15&e[n]).toString(16));return t.join("")},hexToBytes:function(e){for(var t=[],n=0;n<e.length;n+=2)t.push(parseInt(e.substr(n,2),16));return t},bytesToBase64:function(e){for(var t=[],n=0;n<e.length;n+=3)for(var r=e[n]<<16|e[n+1]<<8|e[n+2],a=0;a<4;a++)8*n+6*a<=8*e.length?t.push(o.charAt(r>>>6*(3-a)&63)):t.push("=");return t.join("")},base64ToBytes:function(e){e=e.replace(/[^A-Z0-9+\/]/gi,"");for(var t=[],n=0,r=0;n<e.length;r=++n%4)0!=r&&t.push((o.indexOf(e.charAt(n-1))&Math.pow(2,-2*r+8)-1)<<2*r|o.indexOf(e.charAt(n))>>>6-2*r);return t}},e.exports=n}),charenc={utf8:{stringToBytes:function(e){return charenc.bin.stringToBytes(unescape(encodeURIComponent(e)))},bytesToString:function(e){return decodeURIComponent(escape(charenc.bin.bytesToString(e)))}},bin:{stringToBytes:function(e){for(var t=[],n=0;n<e.length;n++)t.push(255&e.charCodeAt(n));return t},bytesToString:function(e){for(var t=[],n=0;n<e.length;n++)t.push(String.fromCharCode(e[n]));return t.join("")}}},charenc_1=charenc,isBuffer_1=function(e){return null!=e&&(isBuffer(e)||isSlowBuffer(e)||!!e._isBuffer)};function isBuffer(e){return!!e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}function isSlowBuffer(e){return"function"==typeof e.readFloatLE&&"function"==typeof e.slice&&isBuffer(e.slice(0,0))}var md5=createCommonjsModule(function(e){function v(e,t){e.constructor==String?e=(t&&"binary"===t.encoding?I:b).stringToBytes(e):h(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,b,h,I;T=crypt,b=charenc_1.utf8,h=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||{utmSource:"",utmCampaign:"",utmTerm:"",utmContent:"",ctk:""},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.16",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),console.log("global:: ",Global),getBaseicInfo(),_comInfo.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",_comInfo.anonymousId=uni.getStorageSync("v_anonId"),_comInfo.anonymousId||(_comInfo.anonymousId=randomUUID(),uni.setStorageSync("v_anonId",_comInfo.anonymousId)),sdkTrackIdVal()):console.log("init config error, please check config!"),startGlobalTime(),uniInterceptorListener()}function startGlobalTime(){clearInterval(uglInterval),uglInterval=setInterval(()=>{queryEventDataUpload(),queryTrackDataUpload()},Global.flushInterval||15e3)}function setUserId(e){e?(_comInfo.distinctId=e,uni.setStorageSync("v_userId",e)):(_comInfo.distinctId="",uni.setStorageSync("v_userId",""))}function getTrackId(){return sdkTrackIdVal()}function setCustomEvent(e){eventCommonStore(e)}function onStartTrack(e){uStartTrackPVData(e)}function onDestroyTrack(){uStopTrackPVData()}function setPageExtraObj(e){uUpdatePageExtraArray(e)}function reportTrackEventServer(e,t,n){var r;e?(r={...r=commonData(t),dataAbstract:md5(JSON.stringify(r))},uni.request({url:"event"===e?Global.upEventUrl:Global.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:Global.token,projectId:Global.token},data:r,success:function(e){console.log("res: ",JSON.stringify(e)),e&&e.data?uni.setStorageSync(n,JSON.stringify(t)):uni.setStorageSync(n,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(n,JSON.stringify(t))}})):console.error("please set upload data upType")}function commonData(e){return{app:appData,data:e,device:deviceData,lsi:localLsi,projectId:Global.token,userAgent:Global.uAgent||"",anonymousId:_comInfo.anonymousId,userId:_comInfo.distinctId}}function getBaseicInfo(){uni.getSystemInfo({success:function(e){Global.uAgent=e.ua;var t,n=e.uniPlatform;n.includes("app")?(Global.platform=e.osName,appData=getAppInfo(e)):n.includes("web")||n.includes("h5")?(Global.platform=n,t=getWebH5Info(e),appData={...t,version:Global.version||"unknown"}):n.includes("weixin")&&(Global.platform="weixin",appData=getWXInfo()),deviceData=getDeviceInfo(e,Global.platform)},fail:function(e){deviceData=getDeviceInfoError()},complete:function(){uni.getNetworkType({success(e){deviceData.network=e.networkType}})}})}export{getTrackId,init,onDestroyTrack,onStartTrack,reportTrackEventServer,setCustomEvent,setPageExtraObj,setUserId};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e=e||self).BuriedPointUni={})}(this,function(e){"use strict";function t(e,t){return e(t={exports:{}},t.exports),t.exports}function C(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 M=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=M,y=r.utf8,S=C,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||{utmSource:"",utmCampaign:"",utmTerm:"",utmContent:"",ctk:""},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),console.log("global:: ",c),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})});
|