visual-buried-point-platform-uni 1.0.0-alpha.21 → 1.0.0-alpha.23
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/dist/buried-point-uni.js +2 -0
- package/dist/buried-point-uni.js.LICENSE.txt +6 -0
- package/index.js +4 -4
- package/package.json +5 -2
- package/autoutils.js +0 -177
- package/bpstorage.js +0 -29
- package/cache.js +0 -28
- package/config.js +0 -25
- package/eventutils.js +0 -91
- package/lsi-md5.js +0 -22
- package/manualutils.js +0 -87
- package/pageListener.js +0 -71
- package/tools.js +0 -308
- package/webpack.config.js +0 -17
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/*! For license information please see buried-point-uni.js.LICENSE.txt */
|
|
2
|
+
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)=>{!function(){var t=n(939),r=n(151).utf8,o=n(206),i=n(151).bin,a=function(e,n){e.constructor==String?e=n&&"binary"===n.encoding?i.stringToBytes(e):r.stringToBytes(e):o(e)?e=Array.prototype.slice.call(e,0):Array.isArray(e)||e.constructor===Uint8Array||(e=e.toString());for(var u=t.bytesToWords(e),s=8*e.length,c=1732584193,l=-271733879,g=-1732584194,p=271733878,d=0;d<u.length;d++)u[d]=16711935&(u[d]<<8|u[d]>>>24)|4278255360&(u[d]<<24|u[d]>>>8);u[s>>>5]|=128<<s%32,u[14+(s+64>>>9<<4)]=s;var m=a._ff,f=a._gg,h=a._hh,v=a._ii;for(d=0;d<u.length;d+=16){var y=c,S=l,b=g,I=p;c=m(c,l,g,p,u[d+0],7,-680876936),p=m(p,c,l,g,u[d+1],12,-389564586),g=m(g,p,c,l,u[d+2],17,606105819),l=m(l,g,p,c,u[d+3],22,-1044525330),c=m(c,l,g,p,u[d+4],7,-176418897),p=m(p,c,l,g,u[d+5],12,1200080426),g=m(g,p,c,l,u[d+6],17,-1473231341),l=m(l,g,p,c,u[d+7],22,-45705983),c=m(c,l,g,p,u[d+8],7,1770035416),p=m(p,c,l,g,u[d+9],12,-1958414417),g=m(g,p,c,l,u[d+10],17,-42063),l=m(l,g,p,c,u[d+11],22,-1990404162),c=m(c,l,g,p,u[d+12],7,1804603682),p=m(p,c,l,g,u[d+13],12,-40341101),g=m(g,p,c,l,u[d+14],17,-1502002290),c=f(c,l=m(l,g,p,c,u[d+15],22,1236535329),g,p,u[d+1],5,-165796510),p=f(p,c,l,g,u[d+6],9,-1069501632),g=f(g,p,c,l,u[d+11],14,643717713),l=f(l,g,p,c,u[d+0],20,-373897302),c=f(c,l,g,p,u[d+5],5,-701558691),p=f(p,c,l,g,u[d+10],9,38016083),g=f(g,p,c,l,u[d+15],14,-660478335),l=f(l,g,p,c,u[d+4],20,-405537848),c=f(c,l,g,p,u[d+9],5,568446438),p=f(p,c,l,g,u[d+14],9,-1019803690),g=f(g,p,c,l,u[d+3],14,-187363961),l=f(l,g,p,c,u[d+8],20,1163531501),c=f(c,l,g,p,u[d+13],5,-1444681467),p=f(p,c,l,g,u[d+2],9,-51403784),g=f(g,p,c,l,u[d+7],14,1735328473),c=h(c,l=f(l,g,p,c,u[d+12],20,-1926607734),g,p,u[d+5],4,-378558),p=h(p,c,l,g,u[d+8],11,-2022574463),g=h(g,p,c,l,u[d+11],16,1839030562),l=h(l,g,p,c,u[d+14],23,-35309556),c=h(c,l,g,p,u[d+1],4,-1530992060),p=h(p,c,l,g,u[d+4],11,1272893353),g=h(g,p,c,l,u[d+7],16,-155497632),l=h(l,g,p,c,u[d+10],23,-1094730640),c=h(c,l,g,p,u[d+13],4,681279174),p=h(p,c,l,g,u[d+0],11,-358537222),g=h(g,p,c,l,u[d+3],16,-722521979),l=h(l,g,p,c,u[d+6],23,76029189),c=h(c,l,g,p,u[d+9],4,-640364487),p=h(p,c,l,g,u[d+12],11,-421815835),g=h(g,p,c,l,u[d+15],16,530742520),c=v(c,l=h(l,g,p,c,u[d+2],23,-995338651),g,p,u[d+0],6,-198630844),p=v(p,c,l,g,u[d+7],10,1126891415),g=v(g,p,c,l,u[d+14],15,-1416354905),l=v(l,g,p,c,u[d+5],21,-57434055),c=v(c,l,g,p,u[d+12],6,1700485571),p=v(p,c,l,g,u[d+3],10,-1894986606),g=v(g,p,c,l,u[d+10],15,-1051523),l=v(l,g,p,c,u[d+1],21,-2054922799),c=v(c,l,g,p,u[d+8],6,1873313359),p=v(p,c,l,g,u[d+15],10,-30611744),g=v(g,p,c,l,u[d+6],15,-1560198380),l=v(l,g,p,c,u[d+13],21,1309151649),c=v(c,l,g,p,u[d+4],6,-145523070),p=v(p,c,l,g,u[d+11],10,-1120210379),g=v(g,p,c,l,u[d+2],15,718787259),l=v(l,g,p,c,u[d+9],21,-343485551),c=c+y>>>0,l=l+S>>>0,g=g+b>>>0,p=p+I>>>0}return t.endian([c,l,g,p])};a._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},a._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},a._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},a._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},a._blocksize=16,a._digestsize=16,e.exports=function(e,n){if(null==e)throw new Error("Illegal argument "+e);var r=t.wordsToBytes(a(e,n));return n&&n.asBytes?r:n&&n.asString?i.bytesToString(r):t.bytesToHex(r)}}()},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);var r={};n.d(r,{DU:()=>te,Ts:()=>X,p6:()=>oe,Pq:()=>re,Bm:()=>ae,Ex:()=>ne,dL:()=>ie,do:()=>ee});var o=n(503);let i={domain:"",busSegment:"",module:"",flushInterval:"",pageInterval:"",token:"",version:"",trackId:"",platform:"",uAgent:"",upEventUrl:"",upTrackUrl:"",isCompatible:!0,signTrackArray:[]},a=[];const u=()=>{if(i.trackId)return i.trackId;const e=Date.now().toString();return i.trackId=e,e};function s(){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 c(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 l(e){if("web"===i.platform||"h5"===i.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 g(){if("web"===i.platform||"h5"===i.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 p="enter",d="loop",m="leave",f="UNIBPNPVUVSrcData",h="UNIBPNPVUVFailData";let v,y,S,b,I,w=null,k=null;const T=e=>{w?U():(clearInterval(w),v=0,y=0,S=0,b=1,I=null,w=null,k=0,I=e,x(p),w=setInterval((()=>{x(d)}),15e3))},U=()=>{x(m),clearInterval(w)};function x(e){if(e===p?(b=1,v=0,y=Date.now(),S=y,k=s()):e===d?(b=2,v=15,S=Date.now()):e===m&&(b=3,v=Math.ceil((Date.now()-S)/1e3)),I){const e={busSegment:I.busSegment||"",circulation:b,domain:I.domain,duration:v,module:I.module||"",path:I.path,url:I.url,sourceDomain:I.sourceDomain,sourceUrl:I.sourceUrl,properties:I.properties,title:I.title,traceId:"",trackId:u(),visitPage:I.visitPage,visitTime:c(y),pageUUId:k};e&&N(e,k)}}function N(e,t){let n=uni.getStorageSync(f),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(f,JSON.stringify(r))}const P=e=>{if("object"==typeof e){const t=Array.isArray(e)?[]:{};for(const n in e)"object"==typeof e[n]?t[n]=P(e[n]):t[n]=e[n];return t}return e},B=[],O=e=>{B.push(e)},D=()=>P(B),A=()=>{B.length=0},_="UNIBPNEventSrcData",C="UNIBPNEventFailData";let $;let E=0,M=0,J=0,L=-1,j=null,V=null,H=0;const q=e=>{V?z():e&&(clearInterval(V),E=0,M=0,J=0,L=1,j=null,V=null,H=0,R(p,e),V=setInterval((()=>{R(d,null)}),15e3))},z=()=>{R(m,null),clearInterval(V)};function R(e,t){e===p?(H=s(),M=Date.now(),J=M,j=function(e){const t=getCurrentPages(),n=t[t.length-1];let r=i.platform,o="",a="",u="",s="";if(r)if("web"===r||"h5"===r){if(o=window.location.href,a=window.location.hostname,document.referrer){let e=new URL(document.referrer);u=e||"",s=e.hostname||""}}else o=n.route,t.length>1&&(u=t[t.length-2].route),a=i.domain?i.domain:n.route;if(n)return{path:n.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:o,visitPage:t.length,sourceDomain:s,sourceUrl:u}}(t)):e===d?(L=2,E=15,J=Date.now()):e===m&&(L=3,E=Math.ceil((Date.now()-J)/1e3));const n={busSegment:j.busSegment,circulation:L,domain:j.domain,duration:E,module:j.module,path:j.path,properties:j.properties,sourceDomain:j.sourceDomain,sourceUrl:j.sourceUrl,title:j.title,traceId:"",trackId:u(),url:j.url,visitPage:j.visitPage,visitTime:c(M),utm:g(),pageUUId:H};n&&(console.log("写入ml数据:",n),N(n,H))}let F=!1;function W(e){if(i.isCompatible);else if("pv"===e){const e=getCurrentPages(),t=e[e.length-1];if(i.signTrackArray&&i.signTrackArray.length&&(F=i.signTrackArray.find((e=>e===t.route)),F))return void(F=!0);F=!1;const n=function(e,t,n){let r=a.find((t=>t.path===e)),o=i.platform,u="",s="",c="",l="";if(o)if("web"===o||"h5"===o){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,t>1&&(c=n[t-2].route),s=i.domain?i.domain:e;return{path:r&&r.path?r.path:e,busSegment:r&&r.busSegment?r.busSegment:i.busSegment||"",module:r&&r.module?r.module:i.module||"",properties:r&&r.properties?r.properties:"",domain:s,url:u,visitPage:t,sourceDomain:l,sourceUrl:c,title:r&&r.title?r.title:""}}(t.route,e.length,e);T(n)}else"leave"===e&&(F||U())}const K=JSON.parse('{"dr":"c3a3572a7a0facff92ab2afbbcd94dd6#1.0.0-alpha.22"}').dr;let Y={distinctId:"",anonymousId:""},Z={},G={},Q=null;function X(e){if(e){let t="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"};i.upEventUrl=t.reportUrl,i.upTrackUrl=t.reportTrackUrl,Object.assign(i,e),uni.getSystemInfo({success:function(e){i.uAgent=e.ua;let t=e.uniPlatform;if(t.includes("app"))i.platform=e.osName,Z=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(t.includes("web")||t.includes("h5")){i.platform=t;let n=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);Z={...n,version:i.version?i.version:"unknown"}}else t.includes("weixin")&&(i.platform="weixin",Z=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"}}());G=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:l(e),network:""}}(e)},fail:function(e){G={lang:"",brand:"",os:"",osVersion:"",resolution:"",browser:"",browserVersion:"",color:"",deviceId:"",deviceType:"",network:""}},complete:function(){uni.getNetworkType({success(e){G.network=e.networkType}})}}),Y.distinctId=uni.getStorageSync("v_userId")?uni.getStorageSync("v_userId"):"",Y.anonymousId=uni.getStorageSync("v_anonId"),Y.anonymousId||(Y.anonymousId=s(),uni.setStorageSync("v_anonId",Y.anonymousId)),u()}else console.log("init config error, please check config!");clearInterval(Q),Q=setInterval((()=>{!function(){let e=uni.getStorageSync(_);uni.setStorageSync(_,"");const t=e?JSON.parse(e):[];let n=[],r=uni.getStorageSync(C);const o=r?JSON.parse(r):[];t.length&&n.push(...t),o.length&&n.push(...o),n&&n.length&&(console.log("queryEventUpload:"),ae("event",n,C))}(),function(){let e=uni.getStorageSync(f);uni.setStorageSync(f,"");const t=e?JSON.parse(e):[];let n=[],r=uni.getStorageSync(h);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})),console.log("queryTrackDataUpload"),ae("track",n,h))}()}),15e3),uni.addInterceptor("navigateTo",{invoke(e){W("leave")},success(e){W("pv")}}),uni.addInterceptor("switchTab",{invoke(e){W("leave")},success(e){W("pv")}}),uni.addInterceptor("navigateBack",{invoke(e){W("leave")},success(e){W("pv")}})}function ee(e){e?(Y.distinctId=e,uni.setStorageSync("v_userId",e)):(Y.distinctId="",uni.setStorageSync("v_userId",""))}function te(){return u()}function ne(e){!function(e){const t=e.$page?e.$page:"",n=t.path?t.path:function(){const e=getCurrentPages(),t=e[e.length-1];return t?t.route:"/"}(),r={utm:e.$utm?e.$utm:g(),duration:"",element:e.$element?e.$element:null,eventId:e.$event_id?e.$event_id:"",event:e.$event_code?e.$event_code:"",groupId:"",busSegment:e.$busSegment?e.$busSegment:"",module:e.$module?e.$module:"",page:{domain:t.domain?t.domain:"",pageId:o(n),path:n||"",title:t.title||"",url:n||""},properties:e.$extend_param?JSON.stringify(e.$extend_param):"",traceId:"",trackId:u(),triggerTime:c(Date.now())};r&&(O(r),clearTimeout($),$=setTimeout((()=>{const e=D();e.length&&(function(e){const t=uni.getStorageSync(_);let n=t?JSON.parse(t):[];e&&e.length&&(e.forEach((e=>{n.push(e)})),uni.setStorageSync(_,JSON.stringify(n)))}(e),A())}),2e3))}(e)}function re(e){q(e)}function oe(){z()}function ie(e){!function(e){const t=getCurrentPages();let n=t[t.length-1];const r=a.findIndex((e=>e.path===n.route));let o={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?a[r]=o:a.push(o)}(e)}function ae(e,t,n){if(!e)return void console.error("please set upload data upType");const r={app:Z,data:t,device:G,lsi:K,projectId:i.token,userAgent:i.uAgent||"",anonymousId:Y.anonymousId,userId:Y.distinctId},a={...r,dataAbstract:o(JSON.stringify(r))};uni.request({url:"event"===e?i.upEventUrl:i.upTrackUrl,method:"POST",header:{"Content-Type":"application/json",appKey:i.token,projectId:i.token},data:a,success:function(e){e&&e.data?uni.setStorageSync(n,JSON.stringify(t)):uni.setStorageSync(n,"")},fail:function(e){console.log("error: ",e),uni.setStorageSync(n,JSON.stringify(t))}})}var ue=r.DU,se=r.Ts,ce=r.p6,le=r.Pq,ge=r.Bm,pe=r.Ex,de=r.dL,me=r.do;export{ue as getTrackId,se as init,ce as onDestroyTrack,le as onStartTrack,ge as reportTrackEventServer,pe as setCustomEvent,de as setPageExtraObj,me as setUserId};
|
package/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import MD5 from "md5";
|
|
|
2
2
|
import { queryTrackDataUpload } from "./autoutils.js";
|
|
3
3
|
import { setReportUrl } from "./config.js";
|
|
4
4
|
import { eventCommonStore, queryEventDataUpload } from "./eventutils.js";
|
|
5
|
-
import {
|
|
5
|
+
import { uDestoryTrackPVData, uStartTrackPVData } from "./manualutils.js";
|
|
6
6
|
import pk from "./package.json";
|
|
7
7
|
import { uniInterceptorListener } from "./pageListener.js";
|
|
8
8
|
import {
|
|
@@ -74,8 +74,8 @@ export function getTrackId() {
|
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
// set custom event
|
|
77
|
-
export function setCustomEvent(
|
|
78
|
-
eventCommonStore(
|
|
77
|
+
export function setCustomEvent(tData) {
|
|
78
|
+
eventCommonStore(tData);
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
//track upload-registry
|
|
@@ -85,7 +85,7 @@ export function onStartTrack(tData) {
|
|
|
85
85
|
|
|
86
86
|
//track upload-Destroy
|
|
87
87
|
export function onDestroyTrack() {
|
|
88
|
-
|
|
88
|
+
uDestoryTrackPVData();
|
|
89
89
|
}
|
|
90
90
|
|
|
91
91
|
// auto track Preset attribute
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "visual-buried-point-platform-uni",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
4
|
-
"lsi": "
|
|
3
|
+
"version": "1.0.0-alpha.23",
|
|
4
|
+
"lsi": "e36456e47889d6ad105b32f40620ebb7#1.0.0-alpha.23",
|
|
5
5
|
"description": "To make it easy for you to get started with GitLab, here's a list of recommended next steps.",
|
|
6
6
|
"main": "index.js",
|
|
7
7
|
"scripts": {
|
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"type": "git",
|
|
14
14
|
"url": ""
|
|
15
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist"
|
|
18
|
+
],
|
|
16
19
|
"type": "module",
|
|
17
20
|
"keywords": [],
|
|
18
21
|
"author": "",
|
package/autoutils.js
DELETED
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { reportTrackEventServer } from "./index.js";
|
|
2
|
-
import {
|
|
3
|
-
sdkTrackIdVal,
|
|
4
|
-
Global,
|
|
5
|
-
pagesArray,
|
|
6
|
-
timeToStr,
|
|
7
|
-
randomUUID,
|
|
8
|
-
} from "./tools.js";
|
|
9
|
-
|
|
10
|
-
export const AUTOTRACKTYPE = {
|
|
11
|
-
ENTER: "enter",
|
|
12
|
-
LOOP: "loop",
|
|
13
|
-
LEAVE: "leave",
|
|
14
|
-
};
|
|
15
|
-
// PVUV存储的key值
|
|
16
|
-
const BPNPVUV = "UNIBPNPVUVSrcData";
|
|
17
|
-
const BPNPVUVFail = "UNIBPNPVUVFailData";
|
|
18
|
-
// 采集数据
|
|
19
|
-
let atDuration;
|
|
20
|
-
let atEnterTimeLong;
|
|
21
|
-
let atLoopTimeLong;
|
|
22
|
-
let cirtemp;
|
|
23
|
-
let atObj;
|
|
24
|
-
let atInterval = null;
|
|
25
|
-
let cUUId = null;
|
|
26
|
-
|
|
27
|
-
function clearUAData() {
|
|
28
|
-
clearInterval(atInterval);
|
|
29
|
-
atDuration = 0;
|
|
30
|
-
atEnterTimeLong = 0;
|
|
31
|
-
atLoopTimeLong = 0;
|
|
32
|
-
cirtemp = 1;
|
|
33
|
-
atObj = null;
|
|
34
|
-
atInterval = null;
|
|
35
|
-
cUUId = 0;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const uAutoStartTrackPVData = (objParams) => {
|
|
39
|
-
if (atInterval) {
|
|
40
|
-
autoStopTrackPVUV();
|
|
41
|
-
} else {
|
|
42
|
-
clearUAData();
|
|
43
|
-
atObj = objParams;
|
|
44
|
-
autoTrackData(AUTOTRACKTYPE.ENTER);
|
|
45
|
-
atInterval = setInterval(() => {
|
|
46
|
-
autoTrackData(AUTOTRACKTYPE.LOOP);
|
|
47
|
-
}, 15000);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export const autoStopTrackPVUV = () => {
|
|
52
|
-
autoTrackData(AUTOTRACKTYPE.LEAVE);
|
|
53
|
-
clearInterval(atInterval);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
function autoTrackData(type) {
|
|
57
|
-
if (type === AUTOTRACKTYPE.ENTER) {
|
|
58
|
-
cirtemp = 1;
|
|
59
|
-
atDuration = 0;
|
|
60
|
-
atEnterTimeLong = Date.now();
|
|
61
|
-
atLoopTimeLong = atEnterTimeLong;
|
|
62
|
-
cUUId = randomUUID();
|
|
63
|
-
} else if (type === AUTOTRACKTYPE.LOOP) {
|
|
64
|
-
cirtemp = 2;
|
|
65
|
-
atDuration = 15;
|
|
66
|
-
atLoopTimeLong = Date.now();
|
|
67
|
-
} else if (type === AUTOTRACKTYPE.LEAVE) {
|
|
68
|
-
cirtemp = 3;
|
|
69
|
-
atDuration = Math.ceil((Date.now() - atLoopTimeLong) / 1000);
|
|
70
|
-
}
|
|
71
|
-
if (atObj) {
|
|
72
|
-
const puvData = {
|
|
73
|
-
busSegment: atObj.busSegment || "",
|
|
74
|
-
circulation: cirtemp,
|
|
75
|
-
domain: atObj.domain,
|
|
76
|
-
duration: atDuration,
|
|
77
|
-
module: atObj.module || "",
|
|
78
|
-
path: atObj.path,
|
|
79
|
-
url: atObj.url,
|
|
80
|
-
sourceDomain: atObj.sourceDomain,
|
|
81
|
-
sourceUrl: atObj.sourceUrl,
|
|
82
|
-
properties: atObj.properties,
|
|
83
|
-
title: atObj.title,
|
|
84
|
-
traceId: "",
|
|
85
|
-
trackId: sdkTrackIdVal(),
|
|
86
|
-
visitPage: atObj.visitPage,
|
|
87
|
-
visitTime: timeToStr(atEnterTimeLong),
|
|
88
|
-
pageUUId: cUUId,
|
|
89
|
-
};
|
|
90
|
-
if (puvData) {
|
|
91
|
-
insertPVUVData(puvData, cUUId);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// 插入数据
|
|
97
|
-
export function insertPVUVData(pData, pUUId) {
|
|
98
|
-
let td = uni.getStorageSync(BPNPVUV);
|
|
99
|
-
let mPVData = td ? JSON.parse(td) : [];
|
|
100
|
-
if (mPVData.length > 0) {
|
|
101
|
-
const index = mPVData.findIndex((obj) => obj.pageUUId === pUUId);
|
|
102
|
-
if (index !== -1) {
|
|
103
|
-
mPVData[index] = { ...mPVData[index], ...pData };
|
|
104
|
-
} else {
|
|
105
|
-
mPVData.push(pData);
|
|
106
|
-
}
|
|
107
|
-
} else {
|
|
108
|
-
mPVData.push(pData);
|
|
109
|
-
}
|
|
110
|
-
uni.setStorageSync(BPNPVUV, JSON.stringify(mPVData));
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// 自动采集对象
|
|
114
|
-
export function autoPageObj(cpath, clength, cpages) {
|
|
115
|
-
let _pObj = pagesArray.find((obj) => obj.path === cpath);
|
|
116
|
-
let pf = Global.platform;
|
|
117
|
-
let url = "";
|
|
118
|
-
let domain = "";
|
|
119
|
-
let srcUrl = "";
|
|
120
|
-
let srcDomain = "";
|
|
121
|
-
if (pf) {
|
|
122
|
-
if (pf === "web" || pf === "h5") {
|
|
123
|
-
url = window.location.href;
|
|
124
|
-
domain = window.location.hostname;
|
|
125
|
-
if (document.referrer) {
|
|
126
|
-
let parsedUrl = new URL(document.referrer);
|
|
127
|
-
srcUrl = parsedUrl || "";
|
|
128
|
-
srcDomain = parsedUrl.hostname || "";
|
|
129
|
-
}
|
|
130
|
-
} else {
|
|
131
|
-
url = cpath;
|
|
132
|
-
if (clength > 1) {
|
|
133
|
-
let beforePage = cpages[clength - 2];
|
|
134
|
-
srcUrl = beforePage.route;
|
|
135
|
-
}
|
|
136
|
-
domain = Global.domain ? Global.domain : cpath;
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
return {
|
|
140
|
-
path: _pObj && _pObj.path ? _pObj.path : cpath,
|
|
141
|
-
busSegment:
|
|
142
|
-
_pObj && _pObj.busSegment ? _pObj.busSegment : Global.busSegment || "",
|
|
143
|
-
module: _pObj && _pObj.module ? _pObj.module : Global.module || "",
|
|
144
|
-
properties: _pObj && _pObj.properties ? _pObj.properties : "",
|
|
145
|
-
domain: domain,
|
|
146
|
-
url: url,
|
|
147
|
-
visitPage: clength,
|
|
148
|
-
sourceDomain: srcDomain,
|
|
149
|
-
sourceUrl: srcUrl,
|
|
150
|
-
title: _pObj && _pObj.title ? _pObj.title : "",
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* 查询数据
|
|
156
|
-
* 0 未上报 2上报失败
|
|
157
|
-
*/
|
|
158
|
-
export function queryTrackDataUpload() {
|
|
159
|
-
let td = uni.getStorageSync(BPNPVUV);
|
|
160
|
-
uni.setStorageSync(BPNPVUV, "");
|
|
161
|
-
const arr = td ? JSON.parse(td) : [];
|
|
162
|
-
let uploadArray = [];
|
|
163
|
-
let ftd = uni.getStorageSync(BPNPVUVFail);
|
|
164
|
-
const failArr = ftd ? JSON.parse(ftd) : [];
|
|
165
|
-
if (arr.length) {
|
|
166
|
-
uploadArray.push(...arr);
|
|
167
|
-
}
|
|
168
|
-
if (failArr.length) {
|
|
169
|
-
uploadArray.push(...failArr);
|
|
170
|
-
}
|
|
171
|
-
if (uploadArray && uploadArray.length) {
|
|
172
|
-
uploadArray.forEach((item) => {
|
|
173
|
-
delete item.pageUUId;
|
|
174
|
-
});
|
|
175
|
-
reportTrackEventServer("track", uploadArray, BPNPVUVFail);
|
|
176
|
-
}
|
|
177
|
-
}
|
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,91 +0,0 @@
|
|
|
1
|
-
import MD5 from "md5";
|
|
2
|
-
import { addCache, clearCache, getCache } from "./cache.js";
|
|
3
|
-
import { reportTrackEventServer } from "./index.js";
|
|
4
|
-
import { getUtmObj, sdkTrackIdVal, timeToStr } from "./tools.js";
|
|
5
|
-
|
|
6
|
-
//Event存储的key值
|
|
7
|
-
const BPNEvent = "UNIBPNEventSrcData";
|
|
8
|
-
const BPNEventFail = "UNIBPNEventFailData";
|
|
9
|
-
let timerCustom;
|
|
10
|
-
|
|
11
|
-
function getCurPath() {
|
|
12
|
-
const pages = getCurrentPages();
|
|
13
|
-
const gcp = pages[pages.length - 1];
|
|
14
|
-
return gcp ? gcp.route : "/";
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// 自定义部分 type=>custom event=>到四种具体事件类型 extend_param 扩展字段
|
|
18
|
-
export function eventCommonStore(data) {
|
|
19
|
-
if (!data) return;
|
|
20
|
-
const _page = data.$page ? data.$page : "";
|
|
21
|
-
const _path = _page.path ? _page.path : getCurPath();
|
|
22
|
-
let reportEventData = {
|
|
23
|
-
utm: data.$utm ? data.$utm : getUtmObj(),
|
|
24
|
-
duration: "",
|
|
25
|
-
element: data.$element ? data.$element : null,
|
|
26
|
-
eventId: data.$event_id ? data.$event_id : "",
|
|
27
|
-
event: data.$event_code ? data.$event_code : "",
|
|
28
|
-
groupId: "",
|
|
29
|
-
busSegment: data.$busSegment ? data.$busSegment : "",
|
|
30
|
-
module: data.$module ? data.$module : "",
|
|
31
|
-
page: {
|
|
32
|
-
domain: _page.domain ? _page.domain : "",
|
|
33
|
-
pageId: MD5(_path),
|
|
34
|
-
path: _path || "",
|
|
35
|
-
title: _page.title || "",
|
|
36
|
-
url: _path || "",
|
|
37
|
-
},
|
|
38
|
-
properties: data.$extend_param ? JSON.stringify(data.$extend_param) : "",
|
|
39
|
-
traceId: "",
|
|
40
|
-
trackId: sdkTrackIdVal(),
|
|
41
|
-
triggerTime: timeToStr(Date.now()),
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
if (reportEventData) {
|
|
45
|
-
addCache(reportEventData);
|
|
46
|
-
clearTimeout(timerCustom);
|
|
47
|
-
timerCustom = setTimeout(() => {
|
|
48
|
-
const data = getCache();
|
|
49
|
-
if (data.length) {
|
|
50
|
-
insertEventData(data);
|
|
51
|
-
clearCache();
|
|
52
|
-
}
|
|
53
|
-
}, 2000);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* 插入Event数据合并
|
|
59
|
-
*/
|
|
60
|
-
export function insertEventData(cData) {
|
|
61
|
-
const cd = uni.getStorageSync(BPNEvent);
|
|
62
|
-
let allEventData = cd ? JSON.parse(cd) : [];
|
|
63
|
-
if (cData && cData.length) {
|
|
64
|
-
// concat方法
|
|
65
|
-
allEventData.concat(cData);
|
|
66
|
-
uni.setStorageSync(BPNEvent, JSON.stringify(allEventData));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* 查询自定义数据
|
|
72
|
-
* 0 未上报/上报失败
|
|
73
|
-
*/
|
|
74
|
-
export function queryEventDataUpload() {
|
|
75
|
-
let cd = uni.getStorageSync(BPNEvent);
|
|
76
|
-
uni.setStorageSync(BPNEvent, "");
|
|
77
|
-
const arr = cd ? JSON.parse(cd) : [];
|
|
78
|
-
let uploadArray = [];
|
|
79
|
-
let fcd = uni.getStorageSync(BPNEventFail);
|
|
80
|
-
const failArr = fcd ? JSON.parse(fcd) : [];
|
|
81
|
-
if (arr.length) {
|
|
82
|
-
uploadArray.push(...arr);
|
|
83
|
-
}
|
|
84
|
-
if (failArr.length) {
|
|
85
|
-
uploadArray.push(...failArr);
|
|
86
|
-
}
|
|
87
|
-
if (uploadArray && uploadArray.length) {
|
|
88
|
-
console.log("queryEventDataUpload");
|
|
89
|
-
reportTrackEventServer("event", uploadArray, BPNEventFail);
|
|
90
|
-
}
|
|
91
|
-
}
|
package/lsi-md5.js
DELETED
|
@@ -1,22 +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 fs = require("fs");
|
|
6
|
-
// const MD5 = require("md5");
|
|
7
|
-
const packageJson = JSON.parse(fs.readFileSync("./package.json", "utf-8"));
|
|
8
|
-
|
|
9
|
-
const { name, version } = packageJson;
|
|
10
|
-
// MD5
|
|
11
|
-
const combinedString = name + "-" + version;
|
|
12
|
-
const md5Str = MD5(combinedString);
|
|
13
|
-
packageJson.lsi = md5Str + "#" + version;
|
|
14
|
-
//base64
|
|
15
|
-
// const combinedString = name.substring(0, 16) + "v" + version;
|
|
16
|
-
// const base64Str = btoa(combinedString);
|
|
17
|
-
// packageJson.lsi = base64Str;
|
|
18
|
-
|
|
19
|
-
const updatedPackageJson = JSON.stringify(packageJson, null, 2);
|
|
20
|
-
fs.writeFileSync("./package.json", updatedPackageJson, "utf8");
|
|
21
|
-
|
|
22
|
-
console.log('write package.json "lsi" value success ');
|
package/manualutils.js
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { AUTOTRACKTYPE, insertPVUVData } from "./autoutils.js";
|
|
2
|
-
import {
|
|
3
|
-
getTrackObj,
|
|
4
|
-
getUtmObj,
|
|
5
|
-
randomUUID,
|
|
6
|
-
sdkTrackIdVal,
|
|
7
|
-
timeToStr,
|
|
8
|
-
} from "./tools.js";
|
|
9
|
-
|
|
10
|
-
// 流量上报采集
|
|
11
|
-
let startTime = 0;
|
|
12
|
-
let enterTimeLong = 0;
|
|
13
|
-
let loopTimeLong = 0;
|
|
14
|
-
let cirtemp = -1;
|
|
15
|
-
let mObj = null;
|
|
16
|
-
let umlInterval = null;
|
|
17
|
-
let cUUId = 0;
|
|
18
|
-
|
|
19
|
-
function clearUMlData() {
|
|
20
|
-
clearInterval(umlInterval);
|
|
21
|
-
startTime = 0;
|
|
22
|
-
enterTimeLong = 0;
|
|
23
|
-
loopTimeLong = 0;
|
|
24
|
-
cirtemp = 1;
|
|
25
|
-
mObj = null;
|
|
26
|
-
umlInterval = null;
|
|
27
|
-
cUUId = 0;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// start pv
|
|
31
|
-
export const uStartTrackPVData = (tData) => {
|
|
32
|
-
if (umlInterval) {
|
|
33
|
-
uStopTrackPVData();
|
|
34
|
-
} else {
|
|
35
|
-
if (tData) {
|
|
36
|
-
clearUMlData();
|
|
37
|
-
uTrackPVData(AUTOTRACKTYPE.ENTER, tData);
|
|
38
|
-
umlInterval = setInterval(() => {
|
|
39
|
-
uTrackPVData(AUTOTRACKTYPE.LOOP, null);
|
|
40
|
-
}, 15000);
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
// stop pv
|
|
46
|
-
export const uStopTrackPVData = () => {
|
|
47
|
-
uTrackPVData(AUTOTRACKTYPE.LEAVE);
|
|
48
|
-
clearUMlData();
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
function uTrackPVData(type, tData) {
|
|
52
|
-
if (type === AUTOTRACKTYPE.ENTER) {
|
|
53
|
-
cUUId = randomUUID();
|
|
54
|
-
enterTimeLong = Date.now();
|
|
55
|
-
loopTimeLong = enterTimeLong;
|
|
56
|
-
mObj = getTrackObj(tData);
|
|
57
|
-
} else if (type === AUTOTRACKTYPE.LOOP) {
|
|
58
|
-
cirtemp = 2;
|
|
59
|
-
startTime = 15;
|
|
60
|
-
loopTimeLong = Date.now();
|
|
61
|
-
} else if (type === AUTOTRACKTYPE.LEAVE) {
|
|
62
|
-
cirtemp = 3;
|
|
63
|
-
startTime = Math.ceil((Date.now() - loopTimeLong) / 1000);
|
|
64
|
-
}
|
|
65
|
-
const puvData = {
|
|
66
|
-
busSegment: mObj.busSegment,
|
|
67
|
-
circulation: cirtemp,
|
|
68
|
-
domain: mObj.domain,
|
|
69
|
-
duration: startTime,
|
|
70
|
-
module: mObj.module,
|
|
71
|
-
path: mObj.path,
|
|
72
|
-
properties: mObj.properties,
|
|
73
|
-
sourceDomain: mObj.sourceDomain,
|
|
74
|
-
sourceUrl: mObj.sourceUrl,
|
|
75
|
-
title: mObj.title,
|
|
76
|
-
traceId: "",
|
|
77
|
-
trackId: sdkTrackIdVal(),
|
|
78
|
-
url: mObj.url,
|
|
79
|
-
visitPage: mObj.visitPage,
|
|
80
|
-
visitTime: timeToStr(enterTimeLong),
|
|
81
|
-
utm: getUtmObj(),
|
|
82
|
-
pageUUId: cUUId,
|
|
83
|
-
};
|
|
84
|
-
if (puvData) {
|
|
85
|
-
insertPVUVData(puvData, cUUId);
|
|
86
|
-
}
|
|
87
|
-
}
|
package/pageListener.js
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
autoPageObj,
|
|
3
|
-
uAutoStartTrackPVData,
|
|
4
|
-
autoStopTrackPVUV
|
|
5
|
-
} from "./autoutils.js";
|
|
6
|
-
import { Global } from "./tools.js";
|
|
7
|
-
|
|
8
|
-
export function uniInterceptorListener() {
|
|
9
|
-
uni.addInterceptor("navigateTo", {
|
|
10
|
-
invoke(args) {
|
|
11
|
-
// {"url":"/pages/Home/Home/Home"}
|
|
12
|
-
routerMsgHandler("leave");
|
|
13
|
-
},
|
|
14
|
-
success(args) {
|
|
15
|
-
// {"errMsg":"switchTab:ok"}
|
|
16
|
-
routerMsgHandler("pv");
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
uni.addInterceptor("switchTab", {
|
|
20
|
-
invoke(args) {
|
|
21
|
-
routerMsgHandler("leave");
|
|
22
|
-
},
|
|
23
|
-
success(args) {
|
|
24
|
-
routerMsgHandler("pv");
|
|
25
|
-
},
|
|
26
|
-
});
|
|
27
|
-
uni.addInterceptor("navigateBack", {
|
|
28
|
-
invoke(args) {
|
|
29
|
-
routerMsgHandler("leave");
|
|
30
|
-
},
|
|
31
|
-
success(args) {
|
|
32
|
-
routerMsgHandler("pv");
|
|
33
|
-
},
|
|
34
|
-
});
|
|
35
|
-
// 切换到前台
|
|
36
|
-
// uni.onAppShow((res) => {
|
|
37
|
-
// console.log("-----onAppShow--");
|
|
38
|
-
// //routerMsgHandler("pv");
|
|
39
|
-
// });
|
|
40
|
-
// // 切换到后台
|
|
41
|
-
// uni.onAppHide(() => {
|
|
42
|
-
// console.log("-----onAppHide--");
|
|
43
|
-
// //routerMsgHandler("leave");
|
|
44
|
-
// });
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// 路由消息统一处理
|
|
48
|
-
let pathExist = false;
|
|
49
|
-
function routerMsgHandler(msg) {
|
|
50
|
-
if (Global.isCompatible) {
|
|
51
|
-
} else {
|
|
52
|
-
if (msg === "pv") {
|
|
53
|
-
const pages = getCurrentPages();
|
|
54
|
-
const page = pages[pages.length - 1];
|
|
55
|
-
if (Global.signTrackArray && Global.signTrackArray.length) {
|
|
56
|
-
pathExist = Global.signTrackArray.find((obj) => obj === page.route);
|
|
57
|
-
if (pathExist) {
|
|
58
|
-
pathExist = true;
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
pathExist = false;
|
|
63
|
-
const pageObj = autoPageObj(page.route, pages.length, pages);
|
|
64
|
-
uAutoStartTrackPVData(pageObj);
|
|
65
|
-
} else if (msg === "leave") {
|
|
66
|
-
if (!pathExist) {
|
|
67
|
-
autoStopTrackPVUV();
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
package/tools.js
DELETED
|
@@ -1,308 +0,0 @@
|
|
|
1
|
-
export const AUTOTRACKTYPE = {
|
|
2
|
-
ENTER: "enter",
|
|
3
|
-
LOOP: "loop",
|
|
4
|
-
LEAVE: "leave",
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
export let Global = {
|
|
8
|
-
// 项目的域名
|
|
9
|
-
domain: "",
|
|
10
|
-
// 全局业务类型
|
|
11
|
-
busSegment: "",
|
|
12
|
-
// 全局业务版本
|
|
13
|
-
module: "",
|
|
14
|
-
// 定时上报周期
|
|
15
|
-
flushInterval: "",
|
|
16
|
-
// 每个页面PV采集的周期
|
|
17
|
-
pageInterval: "",
|
|
18
|
-
// 项目id
|
|
19
|
-
token: "",
|
|
20
|
-
// 版本号(如果在H5使用,建议传)
|
|
21
|
-
version: "",
|
|
22
|
-
// 全局单次访问链路id
|
|
23
|
-
trackId: "",
|
|
24
|
-
// 当前平台
|
|
25
|
-
platform: "",
|
|
26
|
-
// 全局uAgent
|
|
27
|
-
uAgent: "",
|
|
28
|
-
// 上报的事件url
|
|
29
|
-
upEventUrl: "",
|
|
30
|
-
// 上报的流量url
|
|
31
|
-
upTrackUrl: "",
|
|
32
|
-
// 是否兼容老方案 默认true兼容
|
|
33
|
-
isCompatible: true,
|
|
34
|
-
// 需要单个采集的页面path
|
|
35
|
-
signTrackArray: [],
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
// 本地记录每个页面设置的属性值例如:module...
|
|
39
|
-
export let pagesArray = [];
|
|
40
|
-
|
|
41
|
-
export const sdkTrackIdVal = () => {
|
|
42
|
-
if (Global.trackId) {
|
|
43
|
-
return Global.trackId;
|
|
44
|
-
}
|
|
45
|
-
const tId = Date.now().toString();
|
|
46
|
-
Global.trackId = tId;
|
|
47
|
-
return tId;
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export function randomUUID() {
|
|
51
|
-
let uuid = "xxxx-4xxx-yxxx-xxxx".replace(/[xy]/g, function (c) {
|
|
52
|
-
let r = (Math.random() * 16) | 0,
|
|
53
|
-
v = c === "x" ? r : (r & 0x3) | 0x8;
|
|
54
|
-
return v.toString(16);
|
|
55
|
-
});
|
|
56
|
-
return uuid;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
export function timeToStr(timestamp) {
|
|
60
|
-
const date = new Date(timestamp);
|
|
61
|
-
const year = date.getFullYear();
|
|
62
|
-
const month =
|
|
63
|
-
date.getMonth() + 1 < 10
|
|
64
|
-
? "0" + (date.getMonth() + 1)
|
|
65
|
-
: date.getMonth() + 1;
|
|
66
|
-
const day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
|
|
67
|
-
const hour = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
|
|
68
|
-
const minute =
|
|
69
|
-
date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
|
|
70
|
-
const second =
|
|
71
|
-
date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
|
|
72
|
-
const formattedDate = `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
|
73
|
-
return formattedDate;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
//web或者h5的appInfo
|
|
77
|
-
export function getWebH5Info(result) {
|
|
78
|
-
let ecology = "unknown";
|
|
79
|
-
let ua = result.ua.toLowerCase();
|
|
80
|
-
let hostname = window.location.hostname;
|
|
81
|
-
let titleName = document.title;
|
|
82
|
-
let isMobile =
|
|
83
|
-
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(ua);
|
|
84
|
-
if (isMobile) {
|
|
85
|
-
ecology = "app";
|
|
86
|
-
} else {
|
|
87
|
-
ecology = "brower";
|
|
88
|
-
}
|
|
89
|
-
if (ua.includes("alipay")) {
|
|
90
|
-
ecology = "alipay";
|
|
91
|
-
} else if (ua.includes("unionPay")) {
|
|
92
|
-
ecology = "unionPay";
|
|
93
|
-
} else if (ua.includes("onbuygz")) {
|
|
94
|
-
ecology = "onbuygz";
|
|
95
|
-
} else if (ua.includes("onetravel")) {
|
|
96
|
-
ecology = "onetravel";
|
|
97
|
-
}
|
|
98
|
-
if (ua.includes("micromessenger")) {
|
|
99
|
-
if (ua.includes("miniprogram")) {
|
|
100
|
-
ecology = "wechat";
|
|
101
|
-
} else {
|
|
102
|
-
ecology = "brower";
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
name: titleName ? titleName : "",
|
|
107
|
-
packageName: hostname ? hostname : "",
|
|
108
|
-
version: "",
|
|
109
|
-
carrier: "h5",
|
|
110
|
-
ecology: "h5",
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
//微信的appInfo
|
|
115
|
-
export function getWXInfo() {
|
|
116
|
-
const accInfo = uni.getAccountInfoSync();
|
|
117
|
-
const bInfo = uni.getAppBaseInfo();
|
|
118
|
-
return {
|
|
119
|
-
name: bInfo.appName ? bInfo.appName : "",
|
|
120
|
-
packageName: accInfo ? accInfo.miniProgram.appId : "",
|
|
121
|
-
version: accInfo
|
|
122
|
-
? accInfo.miniProgram.envVersion + accInfo.miniProgram.version
|
|
123
|
-
: "",
|
|
124
|
-
carrier: "mini",
|
|
125
|
-
ecology: "mini",
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
//app的appInfo
|
|
130
|
-
export function getAppInfo(result) {
|
|
131
|
-
let version = plus.runtime.version;
|
|
132
|
-
let app = {
|
|
133
|
-
name: result.appName,
|
|
134
|
-
version: version ? version : "",
|
|
135
|
-
carrier: "app",
|
|
136
|
-
packageName: "",
|
|
137
|
-
ecology: "",
|
|
138
|
-
};
|
|
139
|
-
if (result.platform === "android") {
|
|
140
|
-
let osName = "Android";
|
|
141
|
-
let pkName = plus.android.runtimeMainActivity().getPackageName();
|
|
142
|
-
if (result.romName.includes("HarmonyOS")) {
|
|
143
|
-
osName = "Harmony OS";
|
|
144
|
-
}
|
|
145
|
-
app.packageName = pkName ? pkName : "";
|
|
146
|
-
app.ecology = osName;
|
|
147
|
-
} else if (result.platform === "ios") {
|
|
148
|
-
let pkName = plus.ios
|
|
149
|
-
.importClass("NSBundle")
|
|
150
|
-
.mainBundle()
|
|
151
|
-
.bundleIdentifier();
|
|
152
|
-
app.packageName = pkName ? pkName : "";
|
|
153
|
-
app.ecology = "iOS";
|
|
154
|
-
} else {
|
|
155
|
-
app.ecology = "unknown";
|
|
156
|
-
}
|
|
157
|
-
return app;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function getCurDeviceType(res) {
|
|
161
|
-
if (Global.platform === "web" || Global.platform === "h5") {
|
|
162
|
-
const userAgent = res.ua.toLowerCase();
|
|
163
|
-
if (/(windows|win32|win64|wow64)/.test(userAgent)) {
|
|
164
|
-
return 1;
|
|
165
|
-
} else if (/(linux|android)/.test(userAgent)) {
|
|
166
|
-
return 2;
|
|
167
|
-
} else if (/(macintosh|mac os x|iphone|ipad|ipod)/.test(userAgent)) {
|
|
168
|
-
return 2;
|
|
169
|
-
} else {
|
|
170
|
-
return 2;
|
|
171
|
-
}
|
|
172
|
-
} else {
|
|
173
|
-
if (res.deviceType === "pc") {
|
|
174
|
-
return 1;
|
|
175
|
-
} else {
|
|
176
|
-
return 2;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
//获取设备信息
|
|
182
|
-
export function getDeviceInfo(res) {
|
|
183
|
-
let device = {
|
|
184
|
-
lang: res.osLanguage ? res.osLanguage : res.hostLanguage,
|
|
185
|
-
brand: res.deviceBrand + " " + res.deviceModel,
|
|
186
|
-
os: res.osName,
|
|
187
|
-
osVersion: res.osVersion,
|
|
188
|
-
resolution: res.screenWidth + "x" + res.screenHeight,
|
|
189
|
-
browser: res.browserName,
|
|
190
|
-
browserVersion: res.browserVersion,
|
|
191
|
-
color: "",
|
|
192
|
-
deviceId: res.deviceId,
|
|
193
|
-
deviceType: getCurDeviceType(res),
|
|
194
|
-
network: "",
|
|
195
|
-
};
|
|
196
|
-
return device;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
//error默认获取设备信息
|
|
200
|
-
export function getDeviceInfoError() {
|
|
201
|
-
return {
|
|
202
|
-
lang: "",
|
|
203
|
-
brand: "",
|
|
204
|
-
os: "",
|
|
205
|
-
osVersion: "",
|
|
206
|
-
resolution: "",
|
|
207
|
-
browser: "",
|
|
208
|
-
browserVersion: "",
|
|
209
|
-
color: "",
|
|
210
|
-
deviceId: "",
|
|
211
|
-
deviceType: "",
|
|
212
|
-
network: "",
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
//uni 通用h5、app、wx拿到当前路由栈
|
|
217
|
-
export function getTrackObj(tData) {
|
|
218
|
-
const pages = getCurrentPages();
|
|
219
|
-
const gcp = pages[pages.length - 1];
|
|
220
|
-
let pf = Global.platform;
|
|
221
|
-
let url = "";
|
|
222
|
-
let domain = "";
|
|
223
|
-
let srcUrl = "";
|
|
224
|
-
let srcDomain = "";
|
|
225
|
-
if (pf) {
|
|
226
|
-
if (pf === "web" || pf === "h5") {
|
|
227
|
-
url = window.location.href;
|
|
228
|
-
domain = window.location.hostname;
|
|
229
|
-
if (document.referrer) {
|
|
230
|
-
let parsedUrl = new URL(document.referrer);
|
|
231
|
-
srcUrl = parsedUrl || "";
|
|
232
|
-
srcDomain = parsedUrl.hostname || "";
|
|
233
|
-
}
|
|
234
|
-
} else {
|
|
235
|
-
url = gcp.route;
|
|
236
|
-
if (pages.length > 1) {
|
|
237
|
-
let beforePage = pages[pages.length - 2];
|
|
238
|
-
srcUrl = beforePage.route;
|
|
239
|
-
}
|
|
240
|
-
domain = Global.domain ? Global.domain : gcp.route;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
if (gcp) {
|
|
244
|
-
return {
|
|
245
|
-
path: gcp.route,
|
|
246
|
-
busSegment: tData.busSegment ? tData.busSegment : "",
|
|
247
|
-
module: tData.module ? tData.module : "",
|
|
248
|
-
properties: tData.extend_param ? JSON.stringify(tData.extend_param) : "",
|
|
249
|
-
title: tData.title ? tData.title : "",
|
|
250
|
-
domain: domain,
|
|
251
|
-
url: url,
|
|
252
|
-
visitPage: pages.length,
|
|
253
|
-
sourceDomain: srcDomain,
|
|
254
|
-
sourceUrl: srcUrl,
|
|
255
|
-
};
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
// 更新当前页的业务方设置的对象
|
|
260
|
-
export function uUpdatePageExtraArray(d) {
|
|
261
|
-
const pages = getCurrentPages();
|
|
262
|
-
let page = pages[pages.length - 1];
|
|
263
|
-
const index = pagesArray.findIndex((item) => item.path === page.route);
|
|
264
|
-
let temp = {
|
|
265
|
-
path: page.route,
|
|
266
|
-
properties: d.properties ? JSON.stringify(d.properties) : "",
|
|
267
|
-
busSegment: d.busSegment ? d.busSegment : "",
|
|
268
|
-
module: d.module ? d.module : "",
|
|
269
|
-
title: d.title ? d.title : "",
|
|
270
|
-
};
|
|
271
|
-
if (index !== -1) {
|
|
272
|
-
pagesArray[index] = temp;
|
|
273
|
-
} else {
|
|
274
|
-
pagesArray.push(temp);
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
// 得到utm
|
|
279
|
-
export function getUtmObj() {
|
|
280
|
-
if (Global.platform === "web" || Global.platform === "h5") {
|
|
281
|
-
let utm = {
|
|
282
|
-
utmSource: "",
|
|
283
|
-
utmCampaign: "",
|
|
284
|
-
utmTerm: "",
|
|
285
|
-
utmContent: "",
|
|
286
|
-
ctk: "",
|
|
287
|
-
};
|
|
288
|
-
if (window.location.href) {
|
|
289
|
-
const paramsUrl = window.location.href.split("?")[1] || "";
|
|
290
|
-
if (paramsUrl) {
|
|
291
|
-
const urlParams = new URLSearchParams(paramsUrl);
|
|
292
|
-
// 渠道来源
|
|
293
|
-
utm.utmSource = urlParams.get("utmSource") || "";
|
|
294
|
-
// 活动名称
|
|
295
|
-
utm.utmCampaign = urlParams.get("utmCampaign") || "";
|
|
296
|
-
// 渠道媒介
|
|
297
|
-
utm.utmTerm = urlParams.get("utmTerm") || "";
|
|
298
|
-
// 内容
|
|
299
|
-
utm.utmContent = urlParams.get("utmContent") || "";
|
|
300
|
-
// 关键词
|
|
301
|
-
utm.ctk = urlParams.get("ctk") || "";
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
return utm;
|
|
305
|
-
} else {
|
|
306
|
-
return null;
|
|
307
|
-
}
|
|
308
|
-
}
|
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
|
-
};
|