gio-miniprogram-sdk 4.1.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/alipay.js +1 -1
  2. package/dist/baidu.js +1 -1
  3. package/dist/bytedance.js +1 -1
  4. package/dist/jingdong.js +1 -1
  5. package/dist/kuaishou.js +1 -1
  6. package/dist/plugins/gioABTest.js +1 -1
  7. package/dist/plugins/gioCompress.js +1 -1
  8. package/dist/plugins/gioEventAutoTracking.js +1 -1
  9. package/dist/plugins/gioImpressionTracking.js +1 -1
  10. package/dist/plugins/gioMultipleInstances.js +1 -1
  11. package/dist/qq.js +1 -1
  12. package/dist/quickapp.js +1 -1
  13. package/dist/taobao.js +1 -1
  14. package/dist/taro.js +1 -1
  15. package/dist/uniapp.js +1 -1
  16. package/dist/wechat.js +1 -1
  17. package/package.json +1 -1
  18. package/rollup.plugins.config.js +5 -0
  19. package/src/adapters/gioTaobaoAdapter.ts +2 -0
  20. package/src/adapters/gioTaroAdapter.ts +2 -0
  21. package/src/adapters/gioUniAppAdapter.ts +2 -0
  22. package/src/constants/config.ts +1 -0
  23. package/src/core/dataStore/eventContextBuilder.ts +28 -10
  24. package/src/core/dataStore/eventHooks/index.ts +6 -1
  25. package/src/core/dataStore/eventHooks/minipPage.ts +39 -2
  26. package/src/core/dataStore/eventHooks/pageEffects.ts +2 -13
  27. package/src/core/dataStore/index.ts +24 -20
  28. package/src/core/growingIO.ts +89 -33
  29. package/src/platformConfig/base.ts +0 -1
  30. package/src/plugins/gioABTest.ts +15 -8
  31. package/src/plugins/gioCompress.ts +2 -0
  32. package/src/plugins/gioEventAutoTracking.ts +20 -3
  33. package/src/plugins/gioImpressionTracking.ts +13 -2
  34. package/src/plugins/gioMultipleInstances.ts +14 -3
  35. package/src/types/dataStore.ts +5 -1
  36. package/src/types/eventHooks.ts +3 -0
  37. package/src/types/growingIO.ts +52 -33
  38. package/src/utils/tools.ts +4 -0
package/dist/kuaishou.js CHANGED
@@ -1 +1 @@
1
- const t=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,e=t=>["undefined","null"].includes(P(t)),i=t=>"string"===P(t),n=t=>"number"===P(t),s=t=>"boolean"===P(t),r=t=>"[object Object]"==={}.toString.call(t)&&!e(t),o=t=>["function","asyncfunction"].includes(P(t)),a=t=>Array.isArray(t)&&"array"===P(t),g=t=>{try{return Array.from(t)[0]}catch(t){return}},l=t=>{try{const e=Array.from(t);return e[e.length-1]}catch(t){return}},u=(t,e=1)=>a(t)&&n(e)?t.slice(e>0?e:1,t.length):t,c=(t,e=!1)=>{if(a(t)){let i=0;const n=[];for(const s of t)s&&!k(s)&&(n[i++]=s),e&&0===s&&(n[i++]=s);return n}return t},h=(t,e)=>{if(a(t)){const i=t.findIndex(e);return 0>i?void 0:t[i]}},d=t=>e(t)?"":""+t,p=(t,e)=>"string"===P(t)?t.split(e):t,v=t=>{if(i(t)){const e=p(t,"");return`${g(e).toLowerCase()}${u(e).join("")}`}return t},m=(t,e)=>(i(t)||(t=d(t)),t.slice(0,e.length)===e),I={}.hasOwnProperty,f=(t,i)=>!e(t)&&I.call(t,i),y=t=>r(t)?Object.keys(t):[],S=(t,e)=>{y(t).forEach((i=>e(t[i],i)))},O=(t,e)=>{const i=y(t);return!(!r(t)||!r(e)||i.length!==y(e).length||i.map(((i,n)=>r(t[i])?O(t[i],e[i]):t[i]===e[i])).includes(!1))},w=(t,e,i)=>{let n=t;return r(t)?(e.split(".").forEach((t=>{n=n?n[t]:i})),n):i},b=(t,e)=>{if(!r(t))return!1;try{if("string"===P(e))return delete t[e];if("array"===P(e))return e.map((e=>delete t[e]));"object"===P(e)&&e.constructor===RegExp&&y(t).forEach((i=>{e.test(i)&&b(t,i)}))}catch(t){return!1}},_=(t,e=250,i,n)=>{let s,r=0;return"boolean"!==P(i)&&(n=t,t=i,i=void 0),function(...o){let a=this,g=Date.now()-r;function l(){r=Date.now(),t.apply(a,o)}n&&!s&&l(),s&&clearTimeout(s),void 0===n&&g>e?l():!0!==i&&(s=setTimeout(n?function(){s=void 0}:l,void 0===n?e-g:e))}},k=t=>a(t)?0===t.length:r(t)?0===y(t).length:!t,P=t=>({}.toString.call(t).slice(8,-1).toLowerCase());var T=Object.freeze({__proto__:null,isNil:e,isString:i,isNaN:t=>"NaN"===d(Number(t)),isNumber:n,isBoolean:s,isObject:r,isRegExp:t=>"[object RegExp]"==={}.toString.call(t),isFunction:o,isArray:a,isDate:t=>"date"===P(t),fixed:(t,e)=>n(t)?Number(t.toFixed(n(e)?e:2)):i(t)&&"NaN"!==d(Number(t))?Number(Number(t).toFixed(n(e)?e:2)):t,head:g,last:l,drop:u,dropWhile:(t,e)=>a(t)?t.filter((t=>!e(t))):t,compact:c,find:h,isEqualArray:(t,e)=>!(!a(t)||!a(e)||t.length!==e.length)&&t.every(((t,i)=>t===e[i])),toString:d,split:p,lowerFirst:v,upperFirst:t=>{if(i(t)){const e=p(t,"");return`${g(e).toUpperCase()}${u(e).join("")}`}return t},startsWith:m,endsWith:(t,e)=>{const{length:i}=t;let n=i;n>i&&(n=i);const s=n;return n-=e.length,n>=0&&t.slice(n,s)===e},hasOwnProperty:I,has:f,keys:y,forEach:S,isEqual:O,get:w,unset:b,throttle:_,isEmpty:k,typeOf:P,formatDate:t=>{function e(t){return 10>t?"0"+t:t}return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+" "+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+"."+e(t.getMilliseconds())}});const E=(t,e)=>{console.log("%c[GrowingIO]:"+t,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[e]||"")},C=(t,e=!0,i="参数不合法")=>E(`${e?"调用":"设置"} ${t} 失败,${i}!`,"warn"),A=t=>{try{return t()}catch(t){return}},q=(t,e)=>{if(o(t))try{t(e)}catch(t){E("回调执行失败!"+t,"error")}},x=t=>i(t)?t.trim().substring(0,100):t,j=(e,n)=>i(e)&&!k(e)&&e.match(t)?n():(E("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),N=t=>(e(t)||y(t).forEach((e=>{o(t[e])?t[e]=A((()=>t[e]())):r(t[e])?b(t,e):a(t[e])||(t[e]=d(t[e]))})),t),U=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})),K=t=>t.pixelRatio?Math.round(t.screenHeight*t.pixelRatio):t.screenHeight,D=t=>t.pixelRatio?Math.round(t.screenWidth*t.pixelRatio):t.screenWidth,$=(t,e)=>{if(t){const i=t.toLowerCase();return-1!==i.indexOf("android")?e+"-Android":-1!==i.indexOf("ios")?e+"-iOS":t}},H=t=>{if(i(t)){const e=t.indexOf("?");return-1!==e?[t.substring(0,e),t.substring(e+1)]:[t,""]}return["",""]},L=t=>i(t)?t.startsWith("/")?t:"/"+t:"",R=t=>A((()=>{switch(t){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let t;return t||(t=A((()=>swan))),t||(t=A((()=>my))),t||(t=A((()=>tt))),t||(t=A((()=>qq))),t||(t=A((()=>ks))),t||(t=A((()=>jd))),t||(t=A((()=>wx))),t}}})),F=t=>A((()=>{switch(t){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return __ttConfig;case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),G=()=>{let t;return!t&&A((()=>swan))&&(t="swan"),!t&&A((()=>tt))&&(t="tt"),!t&&A((()=>qq))&&(t="qq"),!t&&A((()=>my.tb))&&(t="tb"),!t&&A((()=>my))&&(t="my"),!t&&A((()=>ks))&&(t="ks"),!t&&A((()=>jd))&&(t="jd"),!t&&A((()=>wx))&&(t="wx"),t||h(y(global),(t=>d(t).toLowerCase().includes("quickapp")))&&(t="quickapp"),t},V=()=>{var t;return null!==(t=A((()=>$global)))&&void 0!==t?t:global},B=t=>{const i={};return r(t)&&(b(t,"&&sendTo"),S(t,((t,n)=>{const s=d(n).slice(0,100);r(t)?i[s]=B(t):a(t)?(i[s]=c(t.slice(0,100),!0),i[s]=i[s].join("||").slice(0,1e3)):i[s]=e(t)?"":d(t).slice(0,1e3)}))),i},M=(t,e)=>{const i=()=>e.map((e=>t.getStorageSync(e)));try{return t.minip.canIUse("batchGetStorageSync")?t.minip.batchGetStorageSync(e):i()}catch(t){return i()}},Q=(t,e)=>{const i=()=>e.map((({key:e,value:i})=>t.setStorageSync(e,i)));try{return t.minip.canIUse("batchSetStorageSync")?t.minip.batchSetStorageSync(e):i()}catch(t){return i()}},z=t=>y(t||{}).map((i=>i?`${i}=${e(t[i])?"":t[i]}`:"")).join("&"),W=t=>{(m(t,"?")||m(t,"&"))&&(t=t.slice(1,t.length));const e={};return t.split("&").forEach((t=>{const i=t.split("=");i[0]&&(e[i[0]]=i[1])})),e};var Y=Object.freeze({__proto__:null,consoleText:E,callError:C,niceTry:A,niceCallback:q,limitString:x,eventNameValidate:j,getDynamicAttributes:N,guid:U,getScreenHeight:K,getScreenWidth:D,getOS:$,compareVersion:(t="",e="")=>{const i=t=>t.replace(/\s+/g,""),n=t=>t.replace(/[vV]/g,""),s=i(n(t)),r=i(n(e)),o=s.split("."),a=r.split(".");for(let t=0;3>t;t++){let e=Number(o[t]),i=Number(a[t]);if(e>i)return 1;if(i>e)return-1;if(!isNaN(e)&&isNaN(i))return 1;if(isNaN(e)&&!isNaN(i))return-1}return 0},getVueVersion:t=>{if(t){const e=Number(g(p(t.version,".")));return Number.isNaN(e)?0:e}return 0},splitPath:H,normalPath:L,isTaro3:t=>{const{Current:e,createComponent:i}=t;return!(!t||!e||i)},getPlainMinip:R,getPlainConfig:F,getPlainPlatform:G,getSubKeys:t=>y(t).filter((t=>t.indexOf("__sub")>-1&&t.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let t=A((()=>getApp({allowDefault:!0})));return t||(t=V()),t},getGlobal:V,limitObject:B,batchGetStorageSync:M,batchSetStorageSync:Q,qsStringify:z,qsParse:W,hashCode:(t,e=!1)=>{let i=0;if(k(t)||"boolean"==typeof t)return i;let n=0;for(;n<t.length;)i=(i<<5)-i+t.charCodeAt(n),i|=0,n++;return e?Math.abs(i):i}});const J=t=>i(t)&&t.length>0||n(t)&&t>0,Z={autotrack:{type:"boolean",default:!0},compress:{type:"boolean",default:!0},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},extraParams:{type:"array",default:[]},followShare:{type:"boolean",default:!0},forceLogin:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:3e5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},requestTimeout:{type:"number",default:5e3},taro:{type:["object","module"],default:!1},taroVue:{type:["object","function"],default:!1},tbConfig:{type:"object",default:{cloud:void 0,cloudFuncSend:!1,cloudFuncName:"httpTunnel",cloudFuncHandler:"main",cloudAppId:void 0,path:void 0}},trackPage:{type:"boolean",default:!0},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},X=["clearGeneralProps","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],et=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...X],it={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},nt=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],st=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],rt=[...st,"appChannel","language","platformVersion"],ot={gsid:"_growing_gsid_",originalSource:"_gdp_original_source_",userId:"_growing_userId_",userKey:"_growing_userKey_",gioId:"_growing_gioId_",plugin_gsid:"_growing_plugin_gsid_",plugin_originalSource:"_gdp_plugin_original_source_",plugin_userId:"_growing_plugin_userId_",plugin_userKey:"_growing_plugin_userKey_",plugin_gioId:"_growing_plugin_gioId_"};var at="MINIP_LIFECYCLE",gt="ON_COMMIT_REQUEST",lt="ON_COMPOSE_AFTER",ut="ON_COMPOSE_BEFORE",ct="ON_ERROR",ht="ON_INSTALL",dt="ON_SEND_AFTER",pt="ON_SEND_BEFORE",vt="OPTION_CHANGE",mt="OPTION_INITIALIZED",It="SDK_INITIALIZED";class ft{constructor(t){this.growingIO=t,this.main=(t,e)=>{var i,n,s,r,o,a;t||(t=this.growingIO.trackingId);const{sdkVersion:g,platformConfig:l,minipInstance:u,userStore:c,dataStore:h,dataStore:{scene:d,eventHooks:p,lastVisitEvent:v,lastPageEvent:m}}=this.growingIO,{version:I,dataSourceId:f,appId:y,idMapping:S,ignoreFields:O}=h.getTrackerVds(t),w=h.locationData[t],{systemInfo:_={},network:P={}}=u,{brand:T,model:E,platform:C,language:A}=_,q={appChannel:"scn:"+(d||"NA"),appVersion:I,dataSourceId:f,deviceBrand:T,deviceId:c.getUid(),deviceModel:E,deviceType:$(C,l.name),domain:y,language:A,latitude:null==w?void 0:w.latitude,longitude:null==w?void 0:w.longitude,networkState:(null==P?void 0:P.networkType)||(null==P?void 0:P.type)||(null==P?void 0:P.subtype),operatingSystem:$(C,l.name),path:(null===(i=p.currentPage)||void 0===i?void 0:i.path)?null===(n=p.currentPage)||void 0===n?void 0:n.path:v.path,platform:l.platform,platformVersion:l.name+(_.version?" "+_.version:""),query:(null===(s=p.currentPage)||void 0===s?void 0:s.path)?null===(r=p.currentPage)||void 0===r?void 0:r.query:v.query,screenHeight:K(_),screenWidth:D(_),sdkVersion:g,sessionId:c.getSessionId(t),title:(null===(o=m[t])||void 0===o?void 0:o.title)||(null===(a=p.currentPage)||void 0===a?void 0:a.title)||u.getPageTitle(u.getCurrentPage()),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:c.getUserId(t)};return S&&(q.userKey=c.getUserKey(t)),k(O)||O.forEach((t=>{b(q,t)})),k(e)?Object.assign(Object.assign({},q),{trackingId:t}):Object.assign(Object.assign(Object.assign({},q),e),{trackingId:t})}}}function yt(t,e,i,n){return new(i||(i=Promise))((function(s,r){function o(t){try{g(n.next(t))}catch(t){r(t)}}function a(t){try{g(n.throw(t))}catch(t){r(t)}}function g(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}g((n=n.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class St{constructor(t){this.growingIO=t,this.main=(t,e)=>{var i,n;const s=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:g,uploader:l,dataStore:u,dataStore:{trackersExecute:c,shareOut:h,lastCloseTime:d,eventHooks:p,saveStorageInfo:v,setOriginalSource:m}}=this.growingIO;r.emit(at,{event:"App "+t,timestamp:s,params:null!==(i=e[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",t,s);const I=g.listeners.app;switch(r.emit(ut,{event:"App "+t,params:null!==(n=e[0])&&void 0!==n?n:{}}),t){case I.appCreate:case I.appShow:{const{path:t,query:i}=this.enterParamsParse(e[0]);!h&&a.originalSource&&c((e=>{m(e,{path:t,query:i})})),d?(Date.now()-d>a.keepAlive||u.lastScene&&u.scene!==u.lastScene)&&(c((t=>{o.setSessionId(t)})),p.currentPage.time=void 0,c((e=>{this.buildVisitEvent(e,{path:t,query:i})}))):(u.lastVisitEvent={path:t,query:i},c((e=>{this.buildVisitEvent(e,{path:t,query:i})})));break}case I.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),v(),o.saveUserInfo(),c((t=>{this.buildCloseEvent(t),a.forceLogin||l.initiateRequest(t,!0)}))}},this.enterParamsParse=t=>{const{gioPlatform:e,minipInstance:i,dataStore:n}=this.growingIO;let s="",o="";const a=(t,e={})=>{s=t,o=y(e).map((t=>`${t}=${e[t]}`)).join("&")};if("quickapp"!==e&&i.minip.canIUse("getEnterOptionsSync")){const{path:e,query:s,scene:g,referrerInfo:l}=i.minip.getEnterOptionsSync()||{},u=t.query||s;if(a(t.path||e,u),n.scene=t.scene||g,!k(l)&&r(null==l?void 0:l.extraData)){let t=[];S(l.extraData,((e,i)=>{!f(u,i)&&["string","number","boolean"].includes(P(e))&&t.push(`${i}=${e}`)}));const e=t.join("&");o=o&&e?`${o}&${e}`:o||e}}else{const{path:e,query:i}=t;a(e,i),this.parseScene(t)}return{path:s,query:o}},this.parseScene=t=>{var e;const{minipInstance:i,gioPlatform:n,dataStore:s}=this.growingIO;let r;if("quickapp"===n){const{extra:t,type:e}=i.getAppSource();r=(null==t?void 0:t.scene)||e}else k(t)||((null===(e=null==t?void 0:t.query)||void 0===e?void 0:e.wxShoppingListScene)?r=t.query.wxShoppingListScene:(null==t?void 0:t.scene)?r=t.scene:s.scene="NA");s.scene=r},this.buildVisitEvent=(t,i)=>{var n;const{dataStore:{getOriginalSource:s,eventContextBuilder:r,eventInterceptor:o,eventHooks:a},minipInstance:g,vdsConfig:l}=this.growingIO,u=s(t),c=(null==i?void 0:i.query)||"";let h=Object.assign({eventType:"VISIT"},r(t,{path:(null==i?void 0:i.path)||"",query:"string"===P(c)?c:z(c),title:(null===(n=a.currentPage)||void 0===n?void 0:n.title)||g.getPageTitle(g.getCurrentPage()),timestamp:a.currentPage.time?a.currentPage.time-1:+Date.now()}));l.originalSource&&!e(u)&&(h=Object.assign(Object.assign({},h),u)),o(h)},this.buildCloseEvent=t=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},e(t)))}}}class Ot{constructor(t){this.growingIO=t,this.parsePage=(t,e)=>{var i;const n=t.route||t.uri||t.__route__||(null===(i=null==t?void 0:t.$page)||void 0===i?void 0:i.fullPath)||"";k(e)?this.query=void 0:this.query=this.getQuery(e),this.path!==n&&(this.time=Date.now()),this.path=n,this.title=this.settedTitle[this.path]||this.growingIO.minipInstance.getPageTitle(t||this.growingIO.minipInstance.getCurrentPage())},this.getQuery=t=>{const e=Object.assign({},t);return b(e,"wxShoppingListScene"),z(e)},this.getReferralPage=t=>{var e;const{minipInstance:i,dataStore:{lastPageEvent:n,scene:s}}=this.growingIO;return(null===(e=n[t])||void 0===e?void 0:e.path)||(s?`scn:${i.scnPrefix}${s}`:null)},this.updateShareResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=L(e+(i?"?"+i:"")),t.query=i,t},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=L(e+(i?"?"+i:"")),t.query=i,t},this.query=void 0,this.settedTitle={},this.pageProps={}}buildShareQuery(t){var e,i,n;const s=H(null!==(e=t.path)&&void 0!==e?e:"");let r=this.path,o={},a=f(t,"path");return a&&(r=g(s),o=W(l(s))||{}),k(o)&&(o=W(null!==(i=t.query)&&void 0!==i?i:"")||{}),!a&&k(o)&&(o=W(null!==(n=this.query)&&void 0!==n?n:"")||{}),[r,z(o)]}}class wt{constructor(t){this.growingIO=t,this.main=(t,e,i)=>{var n,s;const r=Date.now(),{emitter:a,minipInstance:g,plugins:l,vdsConfig:u,platformConfig:c,dataStore:{getTrackerVds:h,trackersExecute:d,shareOut:p,eventHooks:v,toggleShareOut:m,buildAppMessageEvent:I,buildTimelineEvent:f,buildAddFavorites:y},inPlugin:S}=this.growingIO,{currentPage:O}=v;if(this.prevEvent[e]&&50>Date.now()-Number(this.prevEvent[e]))return;t||(t=g.getCurrentPage()),t.route||(t.route=g.getCurrentPath(t));const _=t.route||t.uri||t.__route__||(null===(n=null==t?void 0:t.$page)||void 0===n?void 0:n.fullPath)||"";a.emit(at,{event:"Page "+e,timestamp:r,params:{page:t,args:i[0]}}),u.debug&&console.log("Page:",_,"#",e,r),this.prevEvent[e]=Date.now();const k=c.listeners.page;switch(a.emit(ut,{page:t,event:"Page "+e,params:{page:t,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=e,e){case k.pageLoad:this.argQuery[_]=w(t,"options")||w(t,"__displayReporter.query")||w(t,"$page.query")||w(t,"$wx.__displayReporter.query")||i[0]||{},b(this.argQuery[_],"$taroTimestamp"),O.parsePage(t,this.argQuery[_]);break;case k.pageShow:S?(O.parsePage(t,this.argQuery[_]),O.path||(O.path=`/插件${u.appId}}`,O.title=`/插件${u.appId}}`),d((t=>{const{trackPage:e}=h(t);e&&this.buildPageEvent(t)}))):p&&v.currentPage.time||(O.parsePage(t,this.argQuery[_]),v.currentPage.time=Date.now(),d((t=>{const{trackPage:e}=h(t);e&&this.buildPageEvent(t)}))),m(!1);break;case k.pageHide:case k.pageUnload:break;case k.shareApp:m(!0),d((t=>{const{followShare:e}=h(t);e&&I(t,i)}));break;case k.shareTime:d((t=>{const{followShare:e}=h(t);e&&f(t,i)}));break;case k.addFavorites:d((t=>{const{followShare:e}=h(t);e&&y(t,i)}));break;case k.tabTap:{const t=null===(s=null==l?void 0:l.gioEventAutoTracking)||void 0===s?void 0:s.buildTabClickEvent;u.autotrack&&t&&o(t)&&t(this.growingIO.trackingId,i[0]);break}}e===k.pageUnload&&d((t=>{O.pageProps[t]=void 0}))},this.buildPageEvent=(t,e)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:n,eventHooks:{currentPage:s}},minipInstance:r}=this.growingIO,o=Object.assign(Object.assign({eventType:"PAGE",referralPage:s.getReferralPage(t)},i(t)),{title:(null==s?void 0:s.title)||r.getPageTitle(r.getCurrentPage()),timestamp:s.time});!k(e)&&e.title&&(o.title=e.title);const a=A((()=>s.pageProps[t]));k(a)||(o.attributes=a,s.pageProps[t]=void 0),n(o)},this.prevEvent={},this.argQuery={}}}class bt{constructor(t){var e;this.growingIO=t,this.isNormalFc=(t,e)=>o(e)&&"constructor"!==t,this.objectTraverse=(t,e)=>{Object.getOwnPropertyNames(t).forEach((i=>e(i,t))),f(t,"methods")&&Object.getOwnPropertyNames(t.methods).forEach((i=>{t[i]||e(i,t.methods)})),f(t,"lifetimes")&&Object.getOwnPropertyNames(t.lifetimes).forEach((i=>{t[i]||e(i,t.lifetimes)})),f(t,"pageLifetimes")&&Object.getOwnPropertyNames(t.pageLifetimes).forEach((i=>{t[i]||e(i,t.pageLifetimes)}))},this.supLifeFcs=(t,e)=>{a(this[e+"Handlers"])&&this[e+"Handlers"].forEach((e=>{o(t[e])||["onShareAppMessage","onShareTimeline"].includes(e)||(t[e]=()=>{})}))},this.lifeFcEffects=(t,e,i)=>{const n=this;return["onShareTimeline","onAddToFavorites"].includes(t)?function(...s){let r=e.apply(this,s);"onShareTimeline"===t&&n.growingIO.vdsConfig.followShare&&(r=n.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===t&&(r=n.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(s);return r&&o.push(r),n[`def${i}Cbs`][t].apply(this,o),r}:function(...s){var r;return yt(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===t){if(o=null!==(r=yield e.apply(this,s))&&void 0!==r?r:{},"promise"===P(o.promise)){const t=function(){return yt(this,void 0,void 0,(function*(){let t=o;return new Promise((e=>{let i=setTimeout((()=>{e(Object.assign({},t)),clearTimeout(i),i=void 0}),3e3);o.promise.then((n=>{t=n,e(Object.assign({},t)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield t()),b(o,"promise")}n.growingIO.vdsConfig.followShare&&(o=n.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(s);o&&a.push(o),n[`def${i}Cbs`][t].apply(this,a)}catch(t){E(t,"error")}return"onShareAppMessage"!==t&&(o=e.apply(this,s)),n.growingIO.emitter.emit(at,{event:`${i} ${t}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(s)}}),o}))}},this.customFcEffects=(t,e)=>{const i=this;return function(...n){var s,r;let a;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let e=n[0]||{};f(e,"type")&&((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))||(e=n[n.length-1]),((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))&&i.actionEventTypes.includes(e.type)&&(o(i.actionEffects)||(i.actionEffects=(null===(r=null===(s=i.growingIO.plugins)||void 0===s?void 0:s.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(e,t))}catch(t){E(t,"error")}return a=e.apply(this,n),a}},this.appApplyProxy=(t,e)=>this.appHandlers.includes(t)?this.lifeFcEffects(t,e,"App"):this.customFcEffects(t,e),this.pageApplyProxy=(t,e)=>this.pageHandlers.includes(t)?this.lifeFcEffects(t,e,"Page"):this.customFcEffects(t,e),this.appOverriding=t=>(this.setAppEffectCbs(),this.supLifeFcs(t,"app"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.appApplyProxy(t,e[t]))})),t),this.pageOverriding=t=>(this.setPageEffectCbs(),this.supLifeFcs(t,"page"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.componentOverriding=t=>(this.setPageEffectCbs(),t.methods||(t.methods={}),this.supLifeFcs(this.growingIO.inPlugin?t:t.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?t:t.methods,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.setAppEffectCbs=()=>{const t=this;this.appHandlers.forEach((e=>{this.defAppCbs[e]=function(...i){t.appEffects.main(e,i)}}))},this.setPageEffectCbs=()=>{const t=this;this.pageHandlers.forEach((e=>{this.defPageCbs[e]=function(...i){t.pageEffects.main(this,e,i)}}))},this.growingApp=t=>this.originalApp(this.appOverriding(t)),this.growingPage=t=>this.originalPage(this.pageOverriding(t)),this.growingComponent=t=>this.originalComponent(this.componentOverriding(t)),this.growingBehavior=t=>this.originalBehavior(this.componentOverriding(t)),this.nativeGrowing=(t=["App","Page","Component","Behavior"])=>{const e=this,{platformConfig:i}=this.growingIO,n=i.hooks;if(this.setAppEffectCbs(),this.setPageEffectCbs(),t.includes("App"))try{n.App&&!this.appHooked&&(this.originalApp=App||global.App||function(){},App=function(...t){return e.growingApp(t[0])},this.appHooked=!0)}catch(t){}if(t.includes("Page"))try{n.Page&&!this.pageHooked&&(this.originalPage=Page||global.Page||function(){},Page=function(...t){return e.growingPage(t[0])},this.pageHooked=!0)}catch(t){}if(t.includes("Component"))try{n.Component&&!this.componentHooked&&(this.originalComponent=Component||global.Component||function(){},Component=function(...t){return e.growingComponent(t[0])},this.componentHooked=!0)}catch(t){}if(t.includes("Behavior"))try{n.Behavior&&!this.behaviorHooked&&(this.originalBehavior=Behavior||global.Behavior||function(){},Behavior=function(...t){return e.growingBehavior(t[0])},this.behaviorHooked=!0)}catch(t){}},this.initEventHooks=()=>{const t=this,{platformConfig:e,gioPlatform:i}=this.growingIO;e.canHook?(this.nativeGrowing(),V().GioApp=A((()=>null!==App&&void 0!==App?App:window.GioApp)),V().GioPage=A((()=>null!==Page&&void 0!==Page?Page:window.GioPage)),V().GioComponent=A((()=>null!==Component&&void 0!==Component?Component:window.GioComponent)),V().GioBehavior=A((()=>Behavior))):"quickapp"===i&&(window.GioApp=function(...e){return t.appOverriding(e[0])},window.GioPage=function(...e){return t.pageOverriding(e[0])},window.GioComponent=function(...e){return t.pageOverriding(e[0])})};const i=null===(e=this.growingIO)||void 0===e?void 0:e.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new St(this.growingIO),this.pageEffects=new wt(this.growingIO),this.currentPage=new Ot(this.growingIO)}}class _t{constructor(t){var n,r;this.growingIO=t,this.ALLOW_SETTING_KEYS=y(Z),this.getStorageKey=(t,e)=>{const{inPlugin:i}=this.growingIO;return`${t===this.growingIO.trackingId?"":t}${ot[i?"plugin_"+e:e]}`},this.getGsid=t=>{let e=Number(this._gsid[t]);return Number.isNaN(e)||e>=1e9||1>e?(this.setGsid(t,1),1):e},this.setGsid=(t,e)=>{let i=Number(e);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[t]=i,10>this._gsid[t]-this._stid[t]||this.saveStorageInfo()},this.initStorageInfo=t=>{const{minipInstance:e}=this.growingIO,i=e.getStorageSync(this.getStorageKey(t,"gsid"));let n=Number(i);(Number.isNaN(n)||n>=1e9||1>n)&&(n=1),this._gsid[t]=n,this._stid[t]=n,n!==i&&e.setStorageSync(this.getStorageKey(t,"gsid"),n)},this.saveStorageInfo=()=>{const{minipInstance:t}=this.growingIO;this._stid=Object.assign({},this._gsid),Q(t,this.initializedTrackingIds.map((t=>({key:this.getStorageKey(t,"gsid"),value:this._gsid[t]}))))},this.setOriginalSource=(t,{path:i,query:n})=>{const{minipInstance:s}=this.growingIO;if(e(this.getOriginalSource(t))){const e={path:i,query:n,title:""};s.setStorageSync(this.getStorageKey(t,"originalSource"),JSON.stringify(e))}},this.getOriginalSource=t=>{const{minipInstance:e}=this.growingIO;return A((()=>JSON.parse(e.getStorageSync(this.getStorageKey(t,"originalSource")))))},this.getTrackerVds=t=>this.growingIO.trackingId===t?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=t=>{const e=this.initOptions(t);return e.trackingId=t.trackingId,this.growingIO.trackingId=t.trackingId,this.growingIO.vdsConfig=e,e},this.initTrackerHooker=t=>{var e,i;const{platformConfig:n,inPlugin:s,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:g}=t;a||g||(n.canHook=!0),s&&!["tbp","jdp"].includes(r.platform)||this.eventHooks.initEventHooks(),a&&(null===(e=null==o?void 0:o.gioUniAppAdapter)||void 0===e||e.main()),g&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=t=>{var e,i,n,s,r,o;const{projectId:g,dataSourceId:l,appId:u,trackingId:c}=t,h={};return this.ALLOW_SETTING_KEYS.forEach((e=>{const i=Z[e].type;(a(i)?i.includes(P(t[e])):P(t[e])===Z[e].type)?"ignoreFields"===e?h.ignoreFields=t.ignoreFields.filter((t=>st.includes(t))):"extraParams"===e?h.extraParams=t.extraParams.filter((t=>rt.includes(t))):(h[e]=t[e],["dataCollect","autotrack"].includes(e)&&!h[e]&&E("已关闭"+it[e],"info")):h[e]=Z[e].default})),h.uploadInterval=Math.round(h.uploadInterval),(Number.isNaN(h.uploadInterval)||0>h.uploadInterval||h.uploadInterval>3e3)&&(h.uploadInterval=1e3),h.enableIdMapping&&!h.idMapping&&(h.idMapping=!0,h.idMapping||this.growingIO.userStore.setUserKey(c,"")),b(h,"enableIdMapping"),h.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(h.requestTimeout))&&h.requestTimeout>0||(h.requestTimeout=5e3),Object.assign(Object.assign({},h),{projectId:g,dataSourceId:l,appId:u,trackingId:c,performance:{monitor:null===(i=null===(e=h.performance)||void 0===e?void 0:e.monitor)||void 0===i||i,exception:null===(s=null===(n=h.performance)||void 0===n?void 0:n.exception)||void 0===s||s,network:null!==(o=null===(r=h.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(t,e,n)=>{var s;const{userStore:r,emitter:o}=this.growingIO,a=this.getTrackerVds(t),g=i(e)&&this.ALLOW_SETTING_KEYS.includes(e),l=g&&typeof n===(null===(s=Z[e])||void 0===s?void 0:s.type);if(g&&l){const i=Object.assign({},a);if(this.updateVdsConfig(t,Object.assign(Object.assign({},a),{[e]:n})),"dataCollect"===e&&i.dataCollect!==n&&n){r.setSessionId(t);const{path:e,query:i,settedTitle:n}=this.eventHooks.currentPage;this.eventHooks.currentPage.title=n[e]||this.growingIO.minipInstance.getPageTitle(this.growingIO.minipInstance.getCurrentPage()),this.sendVisit(t,{path:e,query:i}),this.eventHooks.currentPage.time=Date.now(),this.sendPage(t,{path:e,query:i})}return o.emit(vt,{optionName:e,optionValue:n}),!0}return C("setOption > "+e),!1},this.getOption=(t,e)=>{const i=this.getTrackerVds(t);return e&&f(this.growingIO.vdsConfig,e)?f(i,e)?i[e]:this.growingIO.vdsConfig[e]:k(e)?i:void C("getOption > "+e)},this.updateVdsConfig=(t,e)=>{t===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),e),V().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[t]=Object.assign(Object.assign({},this.growingIO.subInstance[t]),e),V().vdsConfig.subInstance[t]=this.growingIO.subInstance[t])},this.toggleShareOut=t=>{s(t)?this.shareOut=t:this.shareOut=!this.shareOut},this.sendVisit=(t,e)=>{this.eventHooks.appEffects.buildVisitEvent(t,null!=e?e:this.lastVisitEvent)},this.sendPage=(t,e)=>{this.eventHooks.pageEffects.buildPageEvent(t,e)},this.eventConverter=t=>{const{dataStore:e,uploader:i}=this.growingIO,{dataCollect:n}=this.getTrackerVds(t.trackingId);if(n){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(t.eventType)||(t.eventSequenceId=e.getGsid(t.trackingId),e.setGsid(t.trackingId,t.eventSequenceId+1));const n={};S(t,((t,e)=>{var i;if("element"===e){const e=null!==(i=g(t))&&void 0!==i?i:{};S(e,((t,e)=>{k(t)&&0!==t||(n[e]=t)}))}else k(t)&&0!==t||(n[e]=t)})),this.growingIO.emitter.emit(lt,{composedEvent:n}),i.commitRequest(Object.assign(Object.assign({},n),{requestId:U()}))}},this.eventInterceptor=t=>{const{systemInfo:e,network:i}=this.growingIO.minipInstance;k(e)||k(i)?this.interceptEvents.push(t):k(this.interceptEvents)?this.eventConverter(t):([...this.interceptEvents,t].forEach((e=>{const i=Object.assign(Object.assign({},e),this.eventContextBuilder(t.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(i)})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:t,network:e}}=this.growingIO;t&&e&&!k(this.interceptEvents)&&([...this.interceptEvents].forEach((t=>{const e=Object.assign(Object.assign({},t),this.eventContextBuilder(t.trackingId,{path:t.path,query:t.query,timestamp:t.timestamp}));this.eventConverter(e)})),this.interceptEvents=[])},this.buildAppMessageEvent=(t,e)=>{var i;const n=e[0];let s;2>e.length?1===e.length&&(s=n):s=e[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==s?void 0:s.path)||"").split("?");o(Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share",attributes:Object.assign({$from:n.from,$target:null===(i=null==n?void 0:n.target)||void 0===i?void 0:i.id,$share_title:null==s?void 0:s.title,$share_path:g(a),$share_query:a[1]},null==s?void 0:s.attributes)},r(t)))},this.buildTimelineEvent=(t,e)=>{var i;const n=e[0];let s;2>e.length?1===e.length&&(s=n):s=e[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==s?void 0:s.path)||"").split("?");o(Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline",attributes:Object.assign({$target:null===(i=null==n?void 0:n.target)||void 0===i?void 0:i.id,$share_title:null==s?void 0:s.title,$share_path:g(a),$share_query:a[1]},null==s?void 0:s.attributes)},r(t)))},this.buildAddFavorites=(t,e)=>{const i=e[0];let n;2>e.length?1===e.length&&(n=i):n=e[1];const{dataStore:{eventContextBuilder:s,eventInterceptor:r}}=this.growingIO,o=((null==n?void 0:n.path)||"").split("?");r(Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites",attributes:{$share_title:null==n?void 0:n.title,$share_path:g(o),$share_query:o[1]}},s(t)))},this.trackersExecute=t=>{this.initializedTrackingIds.forEach((e=>{"function"===P(t)&&t(e)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new ft(this.growingIO).main,this.eventHooks=new bt(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:l,minipInstance:u}=this.growingIO;l.on(It,(({trackingId:t})=>{this.initializedTrackingIds.push(t),this.initStorageInfo(t)})),l.on(gt,(({eventData:t,trackingId:e})=>{"VISIT"===t.eventType&&(this.lastVisitEvent=t),"PAGE"===t.eventType&&(this.lastPageEvent[e]=t)})),o(null===(n=u.minip)||void 0===n?void 0:n.onAppHide)&&u.minip.onAppHide((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];S(e,(t=>{t.start&&(t.leng=t.leng+(+Date.now()-t.start))}))}))})),o(null===(r=u.minip)||void 0===r?void 0:r.onAppShow)&&u.minip.onAppShow((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];S(e,(t=>{t.start&&(t.start=+Date.now())}))}))})),l.on(vt,(({optionName:t,optionValue:e})=>{"dataCollect"===t&&!1===e&&this.trackersExecute((t=>{this.growingIO.clearTrackTimer(t)}))}))}get scene(){return this._scene}set scene(t){const e=this._scene;this._scene=t,e!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:t,oldScene:e})}}const kt={scnPrefix:"",appHandlers:["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange"],pageHandlers:["onLoad","onShow","onReady","onHide","onShareAppMessage","onTabItemTap","onUnload","onPullDownRefresh","onReachBottom","onResize"],actionEventTypes:["onclick","tap","onTap","longpress","longTap","blur","change","onChange","submit","confirm","getuserinfo","getphonenumber","contact","mouseup"],canHook:!0,hooks:{App:!0,Page:!0,Component:!0,Behavior:!0},listeners:{app:{appLaunch:"onLaunch",appShow:"onShow",appClose:"onHide"},page:{pageLoad:"onLoad",pageShow:"onShow",pageReady:"onReady",pageHide:"onHide",pageUnload:"onUnload",tabTap:"onTabItemTap",shareApp:"onShareAppMessage"},actions:{click:["onclick","tap","longpress","longTap","getuserinfo","getphonenumber","contact","mouseup"],change:["blur","change","confirm"],submit:["submit"]}}},Pt=Object.assign(Object.assign({},kt),{listeners:Object.assign({},kt.listeners),name:"KuaiShou",platform:"kuaishoup",scnPrefix:"ks_"});class Tt{constructor(t){this.growingIO=t,this.minip=R("ks"),this.hookSetTitle=()=>{var t;const e=null===(t=this.minip)||void 0===t?void 0:t.setNavigationBarTitle,i=this;e&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const t=i.getCurrentPath(),{title:e}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.settedTitle[t]=e}return e.apply(this,arguments)}})},this.navigateTo=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateTo(t)},this.switchTab=t=>{var e;null===(e=this.minip)||void 0===e||e.switchTab(t)},this.navigateToMiniProgram=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateToMiniProgram(t)},this.getImageInfo=({src:t,success:e,fail:i,complete:n})=>{var s;return null===(s=this.minip)||void 0===s?void 0:s.getImageInfo({src:t,success:e,fail:i,complete:n})},this.initImpression=t=>{var e,i;null===(i=null===(e=this.growingIO.plugins)||void 0===e?void 0:e.gioImpressionTracking)||void 0===i||i.main(t,"observeAll")},this.getCurrentPage=()=>A((()=>l(getCurrentPages())))||{},this.getCurrentPath=()=>{const t=this.getCurrentPage();return(null==t?void 0:t.route)||(null==t?void 0:t.uri)||(null==t?void 0:t.__route__)||""},this.getPageTitle=t=>{var e,n;let s="";const r=F(G());try{const o=(null==t?void 0:t.data)||t.$data||{};if(s=i(null==o?void 0:o.gioPageTitle)?null==o?void 0:o.gioPageTitle:"",0===s.length){const e=r.page[t.route]||r.page[t.route+".html"];s=e?e.window.navigationBarTitleText:r.global.window.navigationBarTitleText}if(0===s.length){const i=null===(n=null===(e=null==r?void 0:r.tabBar)||void 0===e?void 0:e.list)||void 0===n?void 0:n.find((e=>e.pagePath===t.route||e.pagePath===t.route+".html"));s=(null==i?void 0:i.text)||""}}catch(t){return""}return x(s)},this.getStorageSync=t=>{var e;let i=null===(e=this.minip)||void 0===e?void 0:e.getStorageSync(t);return r(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=t=>new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:t,success:({data:t})=>e(t),fail:()=>e("")})})),this.setStorageSync=(t,e,i)=>{var n;i&&(e={value:e,expiredAt:i}),null===(n=this.minip)||void 0===n||n.setStorageSync(t,e)},this.setStorage=(t,e)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:t,data:e})},this.removeStorageSync=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorageSync(t)},this.removeStorage=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorage(t)},this.getNetworkType=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{t.network=i,e(i)},fail:()=>e(null)})}))},this.request=({url:t,data:e,header:i,timeout:n,method:s,success:r,fail:a,complete:g})=>{var l;const u=null===(l=this.minip)||void 0===l?void 0:l.request({url:t,data:e,header:i,headers:i,timeout:n,method:s,success:r,fail:a,complete:g});let c=setTimeout((()=>{(null==u?void 0:u.abort)&&o(null==u?void 0:u.abort)&&(null==u||u.abort()),clearTimeout(c),c=null}),(n||1e4)+10);return u},this.getSystemInfo=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{t.systemInfo=i,e(i)},fail:()=>e(null)})}))},this.getSetting=()=>new Promise((t=>{var e;null===(e=this.minip)||void 0===e||e.getSetting({success:t,fail:t})}));const{platformConfig:{platform:e,scnPrefix:n}}=this.growingIO;this.platform=e,this.scnPrefix=n,this.growingIO.emitter.on(mt,(()=>{this.getNetworkType().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()}))}))}}class Et extends Tt{constructor(t){super(t),this.growingIO=t,this.hookSetTitle()}}const Ct=["gioPerformance"];class At{constructor(t){var e,i,n,s,r,a;this.growingIO=t,this.innerPluginInit=()=>{var t;Ct.forEach((t=>{var e;return b(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins,t)})),y(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins).forEach((t=>{var e,i;const{name:n,method:s}=null!==(i=null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins[t])&&void 0!==i?i:{};h(this.pluginItems,(t=>t.name===n))||this.pluginItems.push({name:v(n||t),method:s||(t=>{})})})),k(this.pluginItems)||this.installAll()},this.install=(t,e,i)=>{var n,s;const{emitter:r}=this.growingIO,o=e||h(this.pluginItems,(e=>e.name===t));if((null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[t])return E(`重复加载插件 ${t} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return E(`插件加载失败!不存在名为 ${t} 的插件!`,"error"),!1;try{return(null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[t]=new o.method(this.growingIO,i),e&&(r.emit(ht,t),E("加载插件 "+t,"info")),!0}catch(i){return this.lifeError(e,i),E(`插件【${t}】加载异常 ${i}`,"error"),!1}},this.installAll=t=>{(t||this.pluginItems).forEach((e=>{this.install(e.name,t?e:void 0,t?null==e?void 0:e.options:void 0)&&!h(this.pluginItems,(t=>t.name===e.name))&&this.pluginItems.push({name:v(e.name),method:e.method?e.method:()=>{}})}))},this.uninstall=t=>{var e;b(this.pluginItems,t);const i=b(null===(e=this.growingIO)||void 0===e?void 0:e.plugins,t);return i||E(`卸载插件 ${t} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((t=>this.uninstall(t.name)))},this.lifeError=(t,e)=>{this.growingIO.emitter.emit(ct,{plugin:t,error:e}),E(`插件执行错误 ${t.name} ${e}`,"error")},this.callLifeCycle=(t,e)=>{this.pluginItems.forEach((i=>{const n=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][t]:void 0;if(n&&o(n))try{n(e)}catch(t){this.lifeError(i,t)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(e=this.growingIO.emitter)||void 0===e||e.on(ht,(t=>this.callLifeCycle("onInstall",t))),null===(i=this.growingIO.emitter)||void 0===i||i.on(ct,(t=>this.callLifeCycle("onError",t))),null===(n=this.growingIO.emitter)||void 0===n||n.on(ut,(t=>this.callLifeCycle("onComposeBefore",t))),null===(s=this.growingIO.emitter)||void 0===s||s.on(lt,(t=>this.callLifeCycle("onComposeAfter",t))),null===(r=this.growingIO.emitter)||void 0===r||r.on(pt,(t=>this.callLifeCycle("onSendBefore",t))),null===(a=this.growingIO.emitter)||void 0===a||a.on(dt,(t=>this.callLifeCycle("onSendAfter",t)))}}var qt={},xt={}.hasOwnProperty;function jt(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(t){return null}}function Nt(t){try{return encodeURIComponent(t)}catch(t){return null}}qt.stringify=function(t,e){e=e||"";var i,n,s=[];for(n in"string"!=typeof e&&(e="?"),t)if(xt.call(t,n)){if((i=t[n])||null!=i&&!isNaN(i)||(i=""),n=Nt(n),i=Nt(i),null===n||null===i)continue;s.push(n+"="+i)}return s.length?e+s.join("&"):""},qt.parse=function(t){for(var e,i=/([^=?#&]+)=?([^&]*)/g,n={};e=i.exec(t);){var s=jt(e[1]),r=jt(e[2]);null===s||null===r||s in n||(n[s]=r)}return n};class Ut{constructor(t){this.growingIO=t,this.generateURL=t=>{const{serverUrl:e,projectId:i}=this.growingIO.dataStore.getTrackerVds(t);return m(e,"http")?`${e}/v3/projects/${i}/collect`:`https://${e}/v3/projects/${i}/collect`},this.getHoardingQueue=t=>{var e;return null!==(e=this.hoardingQueue[t])&&void 0!==e?e:[]},this.getRequestQueue=t=>{var e;return null!==(e=this.requestQueue[t])&&void 0!==e?e:[]},this.commitRequest=t=>{var i,n;const s=Object.assign({},t),{vdsConfig:r,emitter:o}=this.growingIO;o.emit(gt,{eventData:t,trackingId:t.trackingId}),r.forceLogin?(e(this.hoardingQueue[t.trackingId])&&(this.hoardingQueue[t.trackingId]=[]),null===(i=this.hoardingQueue[t.trackingId])||void 0===i||i.push(s)):(e(this.requestQueue[t.trackingId])&&(this.requestQueue[t.trackingId]=[]),null===(n=this.requestQueue[t.trackingId])||void 0===n||n.push(s),this.initiateRequest(t.trackingId))},this.initiateRequest=(t,e)=>{const{plugins:i,vdsConfig:n,minipInstance:s,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(t),...this.getRequestQueue(t)],a=t=>{var a,g;if(null===(a=null==n?void 0:n.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(g=null==i?void 0:i.gioTaobaoAdapter)||void 0===g||g.singleInvoke(t);else if(e)this.batchInvoke(t);else{const{uploadInterval:e}=this.growingIO.dataStore.getTrackerVds(t);_(this.batchInvoke,e,!1,!1)(t)}o.some((t=>"VISIT"===t.eventType))&&s.removeStorageSync(r.getStorageKey(t,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(t);else{let e=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(t),clearInterval(e),e=void 0)}),500)}},this.batchInvoke=t=>{const{vdsConfig:e,emitter:i}=this.growingIO,n=this.getHoardingQueue(t),s=this.getRequestQueue(t);let r=[...n,...s];r.length>50?(r=r.slice(0,50),n.length>50?this.hoardingQueue[t]=n.slice(50):(this.requestQueue[t]=s.slice(50-n.length),this.hoardingQueue[t]=[])):(this.hoardingQueue[t]=[],this.requestQueue[t]=[]);let o=r.filter((t=>(this.retryIds[t.requestId]||0)<=this.retryLimit));if(k(o))return;const a=o.map((t=>{const e=Object.assign({},t);return b(e,["requestId","trackingId"]),e}));e.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(pt,{eventsQueue:o,requestData:a,trackingId:t})},this.sendEvent=(t,e)=>{var i;const n=g(t).trackingId,{minipInstance:s,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:u}=r.getTrackerVds(n);this.requestingNum+=1;const c={"content-type":"jdp"===s.platform?"application/json":"application/json;charset=UTF-8"};let h=[...e];const d=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);d&&(h=a.gioCompress.compressToUTF16(JSON.stringify(e)),c["X-Compress-Codec"]="1");const p=this.generateURL(n);s.request({url:`${p}?stm=${Date.now()}&compress=${d?"1":"0"}`,header:c,method:"POST",data:h,timeout:u,fail:e=>{[200,204].includes(e.code)||(t.forEach((t=>{this.requestFailFn(t)})),E("请求失败!"+JSON.stringify(e),"error"))},complete:t=>{this.requestingNum-=1,o.emit(dt,{result:t,requestData:e}),this.initiateRequest(n)}})},this.requestFailFn=t=>{if(this.retryIds[t.requestId]||(this.retryIds[t.requestId]=0),this.retryIds[t.requestId]+=1,!this.requestQueue[t.trackingId].some((e=>e.requestId===t.requestId))){let e=setTimeout((()=>{k(this.requestQueue[t.trackingId])?(this.requestQueue[t.trackingId].push(t),this.initiateRequest(t.trackingId)):this.requestQueue[t.trackingId].push(t),clearTimeout(e),e=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:i,vdsConfig:n,plugins:s}=this.growingIO;i.on(pt,(({eventsQueue:t,requestData:e,trackingId:i})=>{var r,o;i===this.growingIO.trackingId&&((null===(r=null==n?void 0:n.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==s?void 0:s.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(t,e):this.sendEvent(t,e))}))}}class Kt{constructor(t){this.growingIO=t,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:t}=this.growingIO;return this._uid||(this._uid=t.getStorageSync(this._getUidKey())),this._uid||(this._uid=U(),t.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=t=>{const e=this._uid;this._uid=t,e!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:t,oldUId:e}))},this.getSessionId=t=>(this._sessionId[t]||this.setSessionId(t),this._sessionId[t]),this.setSessionId=(t,e)=>{const i=this._sessionId[t];e||(e=U()),this._sessionId[t]=e,i!==e&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:e,oldSessionId:i})},this._getUserIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"userId"),this.getUserId=t=>{const{minipInstance:e}=this.growingIO;return this._userId[t]||(this._userId[t]=e.getStorageSync(this._getUserIdKey(t))),this._userId[t]},this.setUserId=(t,i)=>{const n=this._userId[t];this._userId[t]=e(i)?"":i,n!==this._userId[t]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(t),this._userId[t]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:i,oldUserId:n})),i&&this.setGioId(t,i)},this._getUserKeyKey=t=>this.growingIO.dataStore.getStorageKey(t,"userKey"),this.getUserKey=t=>{const{minipInstance:e}=this.growingIO;return this._userKey[t]||(this._userKey[t]=e.getStorageSync(this._getUserKeyKey(t))),this._userKey[t]},this.setUserKey=(t,i)=>{const n=this._userKey[t];this._userKey[t]=e(i)?"":i,n!==this._userKey[t]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(t),this._userKey[t]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:i,oldUserKey:n}))},this._getGioIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"gioId"),this.getGioId=t=>{const{minipInstance:e}=this.growingIO;return this._gioId[t]||(this._gioId[t]=e.getStorageSync(this._getGioIdKey(t))),this._gioId[t]},this.setGioId=(t,i)=>{const n=this._gioId[t];this._gioId[t]=e(i)?"":i,n!==this._gioId[t]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(t),this._gioId[t]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:i,oldGioId:n}))},this.initUserInfo=t=>{var e;const{minipInstance:i}=this.growingIO,n=[this._getUidKey(),this._getUserIdKey(t),this._getUserKeyKey(t),this._getGioIdKey(t)],s=null!==(e=M(i,n))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,i)=>{"_uid"===e?this.getUid():this[e][t]=s[i]}))},this.saveUserInfo=()=>{const{minipInstance:t,dataStore:{trackersExecute:e}}=this.growingIO;e((e=>{Q(t,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(e),value:this._userId[e]},{key:this._getUserKeyKey(e),value:this._userKey[e]},{key:this._getGioIdKey(e),value:this._gioId[e]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={}}}const Dt=new class{constructor(){var t;this.init=t=>{var e;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:t});try{if(E("Gio小程序SDK 初始化中...","info"),t.trackingId&&this.dataStore.initializedTrackingIds.includes(t.trackingId))throw Error(`已存在实例 ${t.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(t);return null===(e=this.emitter)||void 0===e||e.emit(mt,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(t.trackingId),this.emitter.emit(It,i),this.trackingId&&this.trackingId!==t.trackingId||(V().__gio__=()=>this),E("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&E("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(t){return E(t,"error"),!1}},this.handlerDistribute=(t,e,i)=>{const{initializedTrackingIds:n,getTrackerVds:s}=this.dataStore;if(s(t)&&n.includes(t))return this[e](t,...i);E(`不存在实例:${t},请检查!`,"warn")},this.registerPlugins=t=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...t],this.plugins.installAll(t)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(t,e)=>this.dataStore.getOption(t,e),this.setOption=(t,e,i)=>{var n;return y(it).includes(e)?typeof i===(null===(n=Z[e])||void 0===n?void 0:n.type)?(this.dataStore.setOption(t,e,i),E(`已修改${it[e]}: ${i}`,"info"),!0):(E(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(E(`不存在可修改的配置项:${e},请检查后重试!`,"error"),!1)},this.setPageAttributes=(t,e)=>{const{currentPage:i}=this.dataStore.eventHooks;k(i.pageProps[t])&&(i.pageProps[t]={}),k(e)||(i.pageProps[t]=Object.assign(Object.assign({},i.pageProps[t]),B(e)))},this.sendPage=(t,e)=>{const{trackPage:i}=this.dataStore.getTrackerVds(t);i?E("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(t,e)},this.identify=(t,e)=>{if(t===this.trackingId)if(this.vdsConfig.forceLogin){if(!J(e))return void C("identify");const t=d(e).slice(0,1e3);this.userStore.setUid(t),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((e=>{const i=this.uploader.getHoardingQueue(e);i.forEach(((e,n)=>i[n].deviceId=t)),this.uploader.initiateRequest(e,!0)}))}else C("identify",!1,"forceLogin未开启");else C("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(t,e)=>{if(!k(e)&&r(e)){const{eventContextBuilder:i,eventInterceptor:n,lastVisitEvent:s}=this.dataStore,r=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES",attributes:B(e)},i(t));r.path||(r.path=s.path,r.query=s.query,r.title=s.title),n(r)}else C("setUserAttributes")},this.setUserId=(t,i,n)=>{if(J(i)){const s=this.userStore.getGioId(t);i=d(i).slice(0,1e3),n=d(n).slice(0,1e3),this.userStore.setUserId(t,i);const{idMapping:r}=this.dataStore.getTrackerVds(t);if(r&&this.userStore.setUserKey(t,e(n)?"":n),s&&s!==i){this.userStore.setSessionId(t);const{path:e,query:i,settedTitle:n}=this.dataStore.eventHooks.currentPage;this.dataStore.eventHooks.currentPage.title=n[e]||this.minipInstance.getPageTitle(this.minipInstance.getCurrentPage()),this.dataStore.sendVisit(t,{path:e,query:i})}}else C("setUserId")},this.clearUserId=t=>{this.userStore.setUserId(t,void 0),this.userStore.setUserKey(t,void 0)},this.setGeneralProps=(t,e)=>{var i;return k(e)?(C("setGeneralProps"),!1):(this.dataStore.generalProps[t]=Object.assign(Object.assign({},null!==(i=this.dataStore.generalProps[t])&&void 0!==i?i:{}),e),!0)},this.clearGeneralProps=(t,e)=>{try{k(this.dataStore.generalProps[t])||(a(e)&&!k(e)?e.forEach((e=>{b(this.dataStore.generalProps[t],e)})):this.dataStore.generalProps[t]={})}catch(t){return C("setGeneralProps"),!1}},this.track=(t,e,i)=>{j(e,(()=>{var n;const{eventContextBuilder:s,eventInterceptor:o,generalProps:a}=this.dataStore,g=Object.assign(Object.assign({},null!==(n=a[t])&&void 0!==n?n:{}),r(i)&&!k(i)?i:{}),l=Object.assign({eventType:"CUSTOM",eventName:e,attributes:B(N(g))},s(t));this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(l["&&sendTo"]=i["&&sendTo"]),o(l)}))},this.trackTimerStart=(t,e)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(t);return i?j(e,(()=>{const i=U();return this.dataStore.trackTimers[t]||(this.dataStore.trackTimers[t]={}),this.dataStore.trackTimers[t][i]={eventName:e,leng:0,start:+Date.now()},i})):(E("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(t,e,i)=>{const{dataCollect:n}=this.dataStore.getTrackerVds(t),s=this.dataStore.trackTimers[t];if(e&&s&&s[e]){if(n){const n=864e5,r=s[e];if(0!==r.start){const t=+Date.now()-r.start;r.leng=t>0?r.leng+t:0}const{eventContextBuilder:o,eventInterceptor:a}=this.dataStore,g=Object.assign({eventType:"CUSTOM",eventName:r.eventName,attributes:B(Object.assign(Object.assign({},i),{event_duration:r.leng>n?0:r.leng/1e3}))},o(t));return this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(g["&&sendTo"]=i["&&sendTo"]),a(g),!0}return E("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return E("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(t,e)=>{const i=this.dataStore.trackTimers[t];return e&&i&&i[e]?(delete i[e],!0):(E("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=t=>{this.dataStore.trackTimers[t]={}},this.setLocation=(t,e,i)=>{k(this.dataStore.locationData[t])&&(this.dataStore.locationData[t]={});const n=this.dataStore.locationData[t],s=t=>t>=-180&&180>=t;s(e)&&s(i)&&(n.latitude!==e||n.longitude!==i)&&(this.dataStore.locationData[t]={latitude:e,longitude:i})},this.updateImpression=()=>{E("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(t,e,i)=>{E("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),q(i,{})},this.getGioInfo=t=>{const{getUid:e,getUserId:i,getUserKey:n,getSessionId:s}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:g,idMapping:l,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(t),h={gioappid:o,giocs1:i(t)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:s(t),giou:e()};return h.giodatacollect=g,h.giodatasourceid=a,l&&(h.giouserkey=n(t)),k(u)||u.forEach((t=>{c.includes(t)||(h["gio"+t]=this.dataStore.lastVisitEvent[t])})),qt.stringify(h)},this.utils=Object.assign(Object.assign(Object.assign({},T),Y),{qs:qt}),this.emitter={all:t=t||new Map,on:function(e,i){var n=t.get(e);n?n.push(i):t.set(e,[i])},off:function(e,i){var n=t.get(e);n&&(i?n.splice(n.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var n=t.get(e);n&&n.slice().map((function(t){t(i)})),(n=t.get("*"))&&n.slice().map((function(t){t(e,i)}))}},this.gioPlatform="ks",this.gioFramework="native",this.sdkVersion="4.1.0";try{"quickapp"===this.gioPlatform||o(getApp)&&o(App)?this.inPlugin=!1:this.inPlugin=!0}catch(t){this.inPlugin=!0}this.inPlugin&&E("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Pt,this.minipInstance=new Et(this),this.dataStore=new _t(this),this.userStore=new Kt(this),this.uploader=new Ut(this),this.plugins=new At(this),this.plugins.innerPluginInit()}},$t=function(){var t;const e=arguments[0];let n="g0",s=e;if(e.indexOf(".")>-1&&(n=null!==(t=e.split(".")[0])&&void 0!==t?t:"g0",s=e.split(".")[1]),i(s)&&et.includes(s)&&Dt[s]){const t=u(Array.from(arguments));if("init"===s){const e=((t,e)=>{const i=d(e[0]),n=d(e[1]),s=(4===e.length?e[3]:e[2])||{};return i&&n?t.dataStore.initializedTrackingIds.some(((e,s)=>{const r=0===s?t.vdsConfig:t.subInstance[e];return r.projectId===i&&r.dataSourceId===n}))?(E("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:n,appId:d(4===e.length?e[2]:""),userOptions:s}:(E('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})(Dt,t);if(e){const{projectId:t,dataSourceId:i,appId:s,userOptions:r}=e;return Dt.init(Object.assign(Object.assign({},r),{projectId:t,dataSourceId:i,appId:s,trackingId:n}))}return!1}if("registerPlugins"===s)Dt.registerPlugins(t[0]);else{if(Dt.gioSDKInitialized&&Dt.vdsConfig)return X.includes(s)?A((()=>Dt.handlerDistribute(n,s,t))):A((()=>Dt[s](...t)));E("SDK未初始化!","error")}}else if(nt.includes(s))E(`方法 ${d(s)} 已被弃用,请移除!`,"warn");else{if("canIUse"===s)return et.includes(arguments[1])&&!!Dt[arguments[1]];E(`不存在名为 ${d(s)} 的方法调用!`,"error")}};V().gdp=$t,V().gioSDKVersion=Dt.sdkVersion;const Ht=A((()=>{var t;return null!==(t=Dt.dataStore.eventHooks.growingApp)&&void 0!==t?t:App})),Lt=A((()=>{var t;return null!==(t=Dt.dataStore.eventHooks.growingPage)&&void 0!==t?t:Page})),Rt=A((()=>{var t;return null!==(t=Dt.dataStore.eventHooks.growingComponent)&&void 0!==t?t:Component})),Ft=A((()=>{var t;return null!==(t=Dt.dataStore.eventHooks.growingBehavior)&&void 0!==t?t:Behavior}));export{Ht as GioApp,Ft as GioBehavior,Rt as GioComponent,Lt as GioPage,$t as default};
1
+ const t=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,e=t=>["undefined","null"].includes(T(t)),i=t=>"string"===T(t),s=t=>"number"===T(t),n=t=>"boolean"===T(t),r=t=>"[object Object]"==={}.toString.call(t)&&!e(t),o=t=>["function","asyncfunction"].includes(T(t)),a=t=>Array.isArray(t)&&"array"===T(t),g=t=>"date"===T(t),l=t=>{try{return Array.from(t)[0]}catch(t){return}},u=t=>{try{const e=Array.from(t);return e[e.length-1]}catch(t){return}},c=(t,e=1)=>a(t)&&s(e)?t.slice(e>0?e:1,t.length):t,h=(t,e=!1)=>{if(a(t)){let i=0;const s=[];for(const n of t)n&&!P(n)&&(s[i++]=n),e&&0===n&&(s[i++]=n);return s}return t},d=(t,e)=>{if(a(t)){const i=t.findIndex(e);return 0>i?void 0:t[i]}},p=t=>e(t)?"":""+t,v=(t,e)=>"string"===T(t)?t.split(e):t,m=t=>{if(i(t)){const e=v(t,"");return`${l(e).toLowerCase()}${c(e).join("")}`}return t},I=(t,e)=>(i(t)||(t=p(t)),t.slice(0,e.length)===e),f={}.hasOwnProperty,y=(t,i)=>!e(t)&&f.call(t,i),S=t=>r(t)?Object.keys(t):[],O=(t,e)=>{S(t).forEach((i=>e(t[i],i)))},w=(t,e)=>{const i=S(t);return!(!r(t)||!r(e)||i.length!==S(e).length||i.map(((i,s)=>r(t[i])?w(t[i],e[i]):t[i]===e[i])).includes(!1))},b=(t,e,i)=>{let s=t;return r(t)?(e.split(".").forEach((t=>{s=s?s[t]:i})),s):i},_=(t,e)=>{if(!r(t))return!1;try{if("string"===T(e))return delete t[e];if("array"===T(e))return e.map((e=>delete t[e]));"object"===T(e)&&e.constructor===RegExp&&S(t).forEach((i=>{e.test(i)&&_(t,i)}))}catch(t){return!1}},k=(t,e=250,i,s)=>{let n,r=0;return"boolean"!==T(i)&&(s=t,t=i,i=void 0),function(...o){let a=this,g=Date.now()-r;function l(){r=Date.now(),t.apply(a,o)}s&&!n&&l(),n&&clearTimeout(n),void 0===s&&g>e?l():!0!==i&&(n=setTimeout(s?function(){n=void 0}:l,void 0===s?e-g:e))}},P=t=>a(t)?0===t.length:r(t)?0===S(t).length:!t,T=t=>({}.toString.call(t).slice(8,-1).toLowerCase()),E=t=>{function e(t){return 10>t?"0"+t:t}return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+" "+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+"."+e(t.getMilliseconds())};var C=Object.freeze({__proto__:null,isNil:e,isString:i,isNaN:t=>"NaN"===p(Number(t)),isNumber:s,isBoolean:n,isObject:r,isRegExp:t=>"[object RegExp]"==={}.toString.call(t),isFunction:o,isArray:a,isDate:g,fixed:(t,e)=>s(t)?Number(t.toFixed(s(e)?e:2)):i(t)&&"NaN"!==p(Number(t))?Number(Number(t).toFixed(s(e)?e:2)):t,head:l,last:u,drop:c,dropWhile:(t,e)=>a(t)?t.filter((t=>!e(t))):t,compact:h,find:d,isEqualArray:(t,e)=>!(!a(t)||!a(e)||t.length!==e.length)&&t.every(((t,i)=>t===e[i])),toString:p,split:v,lowerFirst:m,upperFirst:t=>{if(i(t)){const e=v(t,"");return`${l(e).toUpperCase()}${c(e).join("")}`}return t},startsWith:I,endsWith:(t,e)=>{const{length:i}=t;let s=i;s>i&&(s=i);const n=s;return s-=e.length,s>=0&&t.slice(s,n)===e},hasOwnProperty:f,has:y,keys:S,forEach:O,isEqual:w,get:b,unset:_,throttle:k,isEmpty:P,typeOf:T,formatDate:E});const A=(t,e)=>{console.log("%c[GrowingIO]:"+t,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[e]||"")},j=(t,e=!0,i="参数不合法")=>A(`${e?"调用":"设置"} ${t} 失败,${i}!`,"warn"),q=t=>{try{return t()}catch(t){return}},x=(t,e)=>{if(o(t))try{t(e)}catch(t){A("回调执行失败!"+t,"error")}},N=t=>i(t)?t.trim().substring(0,100):t,U=(e,s)=>i(e)&&!P(e)&&e.match(t)?s():(A("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),K=t=>(e(t)||S(t).forEach((e=>{o(t[e])?t[e]=q((()=>t[e]())):r(t[e])?_(t,e):a(t[e])||(t[e]=p(t[e]))})),t),D=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})),H=t=>t.pixelRatio?Math.round(t.screenHeight*t.pixelRatio):t.screenHeight,$=t=>t.pixelRatio?Math.round(t.screenWidth*t.pixelRatio):t.screenWidth,L=(t,e)=>{if(t){const i=t.toLowerCase();return-1!==i.indexOf("android")?e+"-Android":-1!==i.indexOf("ios")?e+"-iOS":t}},R=t=>{if(i(t)){const e=t.indexOf("?");return-1!==e?[t.substring(0,e),t.substring(e+1)]:[t,""]}return["",""]},F=t=>i(t)?t.startsWith("/")?t:"/"+t:"",G=t=>q((()=>{switch(t){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let t;return t||(t=q((()=>swan))),t||(t=q((()=>my))),t||(t=q((()=>tt))),t||(t=q((()=>qq))),t||(t=q((()=>ks))),t||(t=q((()=>jd))),t||(t=q((()=>wx))),t}}})),V=t=>q((()=>{switch(t){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return __ttConfig;case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),B=()=>{let t;return!t&&q((()=>swan))&&(t="swan"),!t&&q((()=>tt))&&(t="tt"),!t&&q((()=>qq))&&(t="qq"),!t&&q((()=>my.tb))&&(t="tb"),!t&&q((()=>my))&&(t="my"),!t&&q((()=>ks))&&(t="ks"),!t&&q((()=>jd))&&(t="jd"),!t&&q((()=>wx))&&(t="wx"),t||d(S(global),(t=>p(t).toLowerCase().includes("quickapp")))&&(t="quickapp"),t},M=()=>{var t;return null!==(t=q((()=>$global)))&&void 0!==t?t:global},Q=t=>{const i={};return r(t)&&(_(t,"&&sendTo"),O(t,((t,s)=>{const n=p(s).slice(0,100);r(t)?i[n]=Q(t):a(t)?(i[n]=h(t.slice(0,100),!0),i[n]=i[n].join("||").slice(0,1e3)):g(t)?i[n]=E(t):i[n]=e(t)?"":p(t).slice(0,1e3)}))),i},z=(t,e)=>{const i=()=>e.map((e=>t.getStorageSync(e)));try{return t.minip.canIUse("batchGetStorageSync")?t.minip.batchGetStorageSync(e):i()}catch(t){return i()}},W=(t,e)=>{const i=()=>e.map((({key:e,value:i})=>t.setStorageSync(e,i)));try{return t.minip.canIUse("batchSetStorageSync")?t.minip.batchSetStorageSync(e):i()}catch(t){return i()}},Y=t=>S(t||{}).map((i=>i?`${i}=${e(t[i])?"":t[i]}`:"")).join("&"),J=t=>{(I(t,"?")||I(t,"&"))&&(t=t.slice(1,t.length));const e={};return t.split("&").forEach((t=>{const i=t.split("=");i[0]&&(e[i[0]]=i[1])})),e};var Z=Object.freeze({__proto__:null,consoleText:A,callError:j,niceTry:q,niceCallback:x,limitString:N,eventNameValidate:U,getDynamicAttributes:K,guid:D,getScreenHeight:H,getScreenWidth:$,getOS:L,compareVersion:(t="",e="")=>{const i=t=>t.replace(/\s+/g,""),s=t=>t.replace(/[vV]/g,""),n=i(s(t)),r=i(s(e)),o=n.split("."),a=r.split(".");for(let t=0;3>t;t++){let e=Number(o[t]),i=Number(a[t]);if(e>i)return 1;if(i>e)return-1;if(!isNaN(e)&&isNaN(i))return 1;if(isNaN(e)&&!isNaN(i))return-1}return 0},getVueVersion:t=>{if(t){const e=Number(l(v(t.version,".")));return Number.isNaN(e)?0:e}return 0},splitPath:R,normalPath:F,isTaro3:t=>{const{Current:e,createComponent:i}=t;return!(!t||!e||i)},getPlainMinip:G,getPlainConfig:V,getPlainPlatform:B,getSubKeys:t=>S(t).filter((t=>t.indexOf("__sub")>-1&&t.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let t=q((()=>getApp({allowDefault:!0})));return t||(t=M()),t},getGlobal:M,limitObject:Q,batchGetStorageSync:z,batchSetStorageSync:W,qsStringify:Y,qsParse:J,hashCode:(t,e=!1)=>{let i=0;if(P(t)||"boolean"==typeof t)return i;let s=0;for(;s<t.length;)i=(i<<5)-i+t.charCodeAt(s),i|=0,s++;return e?Math.abs(i):i}});const X=t=>i(t)&&t.length>0||s(t)&&t>0,et={autotrack:{type:"boolean",default:!0},compress:{type:"boolean",default:!0},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},extraParams:{type:"array",default:[]},followShare:{type:"boolean",default:!0},forceLogin:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:3e5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},requestTimeout:{type:"number",default:5e3},taro:{type:["object","module"],default:!1},taroVue:{type:["object","function"],default:!1},tbConfig:{type:"object",default:{cloud:void 0,cloudFuncSend:!1,cloudFuncName:"httpTunnel",cloudFuncHandler:"main",cloudAppId:void 0,path:void 0}},trackPage:{type:"boolean",default:!0},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},it=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],st=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...it],nt={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},rt=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],ot=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],at=[...ot,"appChannel","language","platformVersion"],gt={gsid:"_growing_gsid_",originalSource:"_gdp_original_source_",userId:"_growing_userId_",userKey:"_growing_userKey_",gioId:"_growing_gioId_",plugin_gsid:"_growing_plugin_gsid_",plugin_originalSource:"_gdp_plugin_original_source_",plugin_userId:"_growing_plugin_userId_",plugin_userKey:"_growing_plugin_userKey_",plugin_gioId:"_growing_plugin_gioId_"};var lt="MINIP_LIFECYCLE",ut="ON_COMMIT_REQUEST",ct="ON_COMPOSE_AFTER",ht="ON_COMPOSE_BEFORE",dt="ON_ERROR",pt="ON_INSTALL",vt="ON_SEND_AFTER",mt="ON_SEND_BEFORE",It="OPTION_CHANGE",ft="OPTION_INITIALIZED",yt="SDK_INITIALIZED";class St{constructor(t){this.growingIO=t,this.main=(t,e,i=!0)=>{var s;t||(t=this.growingIO.trackingId);const{sdkVersion:n,platformConfig:r,minipInstance:o,userStore:a,dataStore:g,dataStore:{scene:l,eventHooks:{currentPage:u},lastVisitEvent:c,lastPageEvent:h,generalProps:d}}=this.growingIO,{version:p,dataSourceId:v,appId:m,idMapping:I,ignoreFields:f}=g.getTrackerVds(t),y=g.locationData[t],{systemInfo:S={},network:O={}}=o,{brand:w,model:b,platform:k,language:T}=S,E={appChannel:"scn:"+(l||"NA"),appVersion:p,dataSourceId:v,deviceBrand:w,deviceId:a.getUid(),deviceModel:b,deviceType:L(k,r.name),domain:m,language:T,latitude:null==y?void 0:y.latitude,longitude:null==y?void 0:y.longitude,networkState:(null==O?void 0:O.networkType)||(null==O?void 0:O.type)||(null==O?void 0:O.subtype),operatingSystem:L(k,r.name),path:(null==u?void 0:u.path)?null==u?void 0:u.path:c.path,platform:r.platform,platformVersion:r.name+(S.version?" "+S.version:""),query:(null==u?void 0:u.path)?null==u?void 0:u.query:c.query,screenHeight:H(S),screenWidth:$(S),sdkVersion:n,sessionId:a.getSessionId(t),title:(null===(s=h[t])||void 0===s?void 0:s.title)||(null==u?void 0:u.title)||o.getPageTitle(o.getCurrentPage()),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:a.getUserId(t)};return I&&(E.userKey=a.getUserKey(t)),i&&!P(d[t])&&(E.attributes=Object.assign({},d[t])),P(E.attributes)||(E.attributes=Q(K(Object.assign({},E.attributes)))),P(f)||f.forEach((t=>{_(E,t)})),P(e)?Object.assign(Object.assign({},E),{trackingId:t}):Object.assign(Object.assign(Object.assign({},E),e),{trackingId:t})}}}function Ot(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{g(s.next(t))}catch(t){r(t)}}function a(t){try{g(s.throw(t))}catch(t){r(t)}}function g(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}g((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class wt{constructor(t){this.growingIO=t,this.main=(t,e)=>{var i,s;const n=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:g,uploader:l,dataStore:u,dataStore:{trackersExecute:c,shareOut:h,lastCloseTime:d,eventHooks:p,saveStorageInfo:v,setOriginalSource:m}}=this.growingIO;r.emit(lt,{event:"App "+t,timestamp:n,params:null!==(i=e[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",t,n);const I=g.listeners.app;switch(r.emit(ht,{event:"App "+t,params:null!==(s=e[0])&&void 0!==s?s:{}}),t){case I.appCreate:case I.appShow:{const{path:t,query:i}=this.enterParamsParse(e[0]);!h&&a.originalSource&&c((e=>{m(e,{path:t,query:i})})),d?(Date.now()-d>a.keepAlive||u.lastScene&&u.scene!==u.lastScene)&&(c((t=>{o.setSessionId(t)})),p.currentPage.time=void 0,c((e=>{this.buildVisitEvent(e,{path:t,query:i})}))):(u.lastVisitEvent={path:t,query:i},c((e=>{this.buildVisitEvent(e,{path:t,query:i})})));break}case I.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),v(),o.saveUserInfo(),c((t=>{this.buildCloseEvent(t),a.forceLogin||l.initiateRequest(t,!0)}))}},this.enterParamsParse=t=>{const{gioPlatform:e,minipInstance:i,dataStore:s}=this.growingIO;let n="",o="";const a=(t,e={})=>{n=t,o=S(e).map((t=>`${t}=${e[t]}`)).join("&")};if("quickapp"!==e&&i.minip.canIUse("getEnterOptionsSync")){const{path:e,query:n,scene:g,referrerInfo:l}=i.minip.getEnterOptionsSync()||{},u=t.query||n;if(a(t.path||e,u),s.scene=t.scene||g,!P(l)&&r(null==l?void 0:l.extraData)){let t=[];O(l.extraData,((e,i)=>{!y(u,i)&&["string","number","boolean"].includes(T(e))&&t.push(`${i}=${e}`)}));const e=t.join("&");o=o&&e?`${o}&${e}`:o||e}}else{const{path:e,query:i}=t;a(e,i),this.parseScene(t)}return{path:n,query:o}},this.parseScene=t=>{var e;const{minipInstance:i,gioPlatform:s,dataStore:n}=this.growingIO;let r;if("quickapp"===s){const{extra:t,type:e}=i.getAppSource();r=(null==t?void 0:t.scene)||e}else P(t)||((null===(e=null==t?void 0:t.query)||void 0===e?void 0:e.wxShoppingListScene)?r=t.query.wxShoppingListScene:(null==t?void 0:t.scene)?r=t.scene:n.scene="NA");n.scene=r},this.buildVisitEvent=(t,i)=>{var s;const{dataStore:{getOriginalSource:n,eventContextBuilder:r,eventInterceptor:o,eventHooks:a},minipInstance:g,vdsConfig:l}=this.growingIO,u=n(t),c=(null==i?void 0:i.query)||"";let h=Object.assign({eventType:"VISIT"},r(t,{path:(null==i?void 0:i.path)||"",query:"string"===T(c)?c:Y(c),title:(null===(s=a.currentPage)||void 0===s?void 0:s.title)||g.getPageTitle(g.getCurrentPage()),timestamp:a.currentPage.time?a.currentPage.time-1:+Date.now()}));l.originalSource&&!e(u)&&(h=Object.assign(Object.assign({},h),u)),o(h)},this.buildCloseEvent=t=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},e(t)))}}}class bt{constructor(t){this.growingIO=t,this.parsePage=(t,e)=>{var i;const s=t.route||t.uri||t.__route__||(null===(i=null==t?void 0:t.$page)||void 0===i?void 0:i.fullPath)||"";P(e)?this.query=void 0:this.query=this.getQuery(e),this.path!==s&&(this.time=Date.now()),this.path=s,this.title=this.settedTitle[this.path]||this.growingIO.minipInstance.getPageTitle(t||this.growingIO.minipInstance.getCurrentPage())},this.getQuery=t=>{const e=Object.assign({},t);return _(e,"wxShoppingListScene"),Y(e)},this.getReferralPage=t=>{var e;const{minipInstance:i,dataStore:{lastPageEvent:s,scene:n}}=this.growingIO;return(null===(e=s[t])||void 0===e?void 0:e.path)||(n?`scn:${i.scnPrefix}${n}`:null)},this.updateShareResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=F(e+(i?"?"+i:"")),t.query=i,t},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=F(e+(i?"?"+i:"")),t.query=i,t},this.eventSetPageProps=(t,e)=>{const i=q((()=>this.pageProps[t][this.path]));return P(i)?e.attributes:Q(K(Object.assign(Object.assign({},e.attributes),i)))},this.query=void 0,this.settedTitle={},this.pageProps={}}buildShareQuery(t){var e,i,s;const n=R(null!==(e=t.path)&&void 0!==e?e:"");let r=this.path,o={},a=y(t,"path");return a&&(r=l(n),o=J(u(n))||{}),P(o)&&(o=J(null!==(i=t.query)&&void 0!==i?i:"")||{},h(S(o)).forEach((t=>{t.toLowerCase().startsWith("utm_")&&_(o,t)}))),!a&&P(o)&&(o=J(null!==(s=this.query)&&void 0!==s?s:"")||{}),[r,Y(o)]}}class _t{constructor(t){this.growingIO=t,this.main=(t,e,i)=>{var s,n;const r=Date.now(),{emitter:a,minipInstance:g,plugins:l,vdsConfig:u,platformConfig:c,dataStore:{getTrackerVds:h,trackersExecute:d,shareOut:p,eventHooks:v,toggleShareOut:m,buildAppMessageEvent:I,buildTimelineEvent:f,buildAddFavorites:y},inPlugin:S}=this.growingIO,{currentPage:O}=v;if(this.prevEvent[e]&&50>Date.now()-Number(this.prevEvent[e]))return;t||(t=g.getCurrentPage()),t.route||(t.route=g.getCurrentPath(t));const w=t.route||t.uri||t.__route__||(null===(s=null==t?void 0:t.$page)||void 0===s?void 0:s.fullPath)||"";a.emit(lt,{event:"Page "+e,timestamp:r,params:{page:t,args:i[0]}}),u.debug&&console.log("Page:",w,"#",e,r),this.prevEvent[e]=Date.now();const k=c.listeners.page;switch(a.emit(ht,{page:t,event:"Page "+e,params:{page:t,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=e,e){case k.pageLoad:this.argQuery[w]=b(t,"options")||b(t,"__displayReporter.query")||b(t,"$page.query")||b(t,"$wx.__displayReporter.query")||i[0]||{},_(this.argQuery[w],"$taroTimestamp"),O.parsePage(t,this.argQuery[w]);break;case k.pageShow:S?(O.parsePage(t,this.argQuery[w]),O.path||(O.path=`/插件${u.appId}}`,O.title=`/插件${u.appId}}`),d((t=>{const{trackPage:e}=h(t);e&&this.buildPageEvent(t)}))):p&&v.currentPage.time||(O.parsePage(t,this.argQuery[w]),v.currentPage.time=Date.now(),d((t=>{const{trackPage:e}=h(t);e&&this.buildPageEvent(t)}))),m(!1);break;case k.pageHide:case k.pageUnload:break;case k.shareApp:m(!0),d((t=>{const{followShare:e}=h(t);e&&I(t,i)}));break;case k.shareTime:d((t=>{const{followShare:e}=h(t);e&&f(t,i)}));break;case k.addFavorites:d((t=>{const{followShare:e}=h(t);e&&y(t,i)}));break;case k.tabTap:{const t=null===(n=null==l?void 0:l.gioEventAutoTracking)||void 0===n?void 0:n.buildTabClickEvent;u.autotrack&&t&&o(t)&&t(this.growingIO.trackingId,i[0]);break}}},this.buildPageEvent=(t,e)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:s,eventHooks:{currentPage:n}},minipInstance:r}=this.growingIO,o=Object.assign(Object.assign({eventType:"PAGE",referralPage:n.getReferralPage(t)},i(t)),{title:(null==n?void 0:n.title)||r.getPageTitle(r.getCurrentPage()),timestamp:n.time});o.attributes=n.eventSetPageProps(t,o),!P(e)&&e.title&&(o.title=e.title),s(o)},this.prevEvent={},this.argQuery={}}}class kt{constructor(t){var e;this.growingIO=t,this.isNormalFc=(t,e)=>o(e)&&"constructor"!==t,this.objectTraverse=(t,e)=>{Object.getOwnPropertyNames(t).forEach((i=>e(i,t))),y(t,"methods")&&Object.getOwnPropertyNames(t.methods).forEach((i=>{t[i]||e(i,t.methods)})),y(t,"lifetimes")&&Object.getOwnPropertyNames(t.lifetimes).forEach((i=>{t[i]||e(i,t.lifetimes)})),y(t,"pageLifetimes")&&Object.getOwnPropertyNames(t.pageLifetimes).forEach((i=>{t[i]||e(i,t.pageLifetimes)}))},this.supLifeFcs=(t,e)=>{a(this[e+"Handlers"])&&this[e+"Handlers"].forEach((e=>{o(t[e])||["onShareAppMessage","onShareTimeline"].includes(e)||(t[e]=()=>{})}))},this.lifeFcEffects=(t,e,i)=>{const s=this;return["onShareTimeline","onAddToFavorites"].includes(t)?function(...n){let r=e.apply(this,n);"onShareTimeline"===t&&s.growingIO.vdsConfig.followShare&&(r=s.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===t&&(r=s.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(n);return r&&o.push(r),s[`def${i}Cbs`][t].apply(this,o),r}:function(...n){var r;return Ot(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===t){if(o=null!==(r=e.apply(this,n))&&void 0!==r?r:{},"promise"===T(o)&&(o=yield o.then((t=>t))),"promise"===T(o.promise)){const t=function(){return Ot(this,void 0,void 0,(function*(){let t=o;return new Promise((e=>{let i=setTimeout((()=>{e(Object.assign({},t)),clearTimeout(i),i=void 0}),3e3);o.promise.then((s=>{t=s,e(Object.assign({},t)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield t()),_(o,"promise")}s.growingIO.vdsConfig.followShare&&(o=s.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(n);o&&a.push(o),s[`def${i}Cbs`][t].apply(this,a)}catch(t){A(t,"error")}return"onShareAppMessage"!==t&&(o=e.apply(this,n)),s.growingIO.emitter.emit(lt,{event:`${i} ${t}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(n)}}),o}))}},this.customFcEffects=(t,e)=>{const i=this;return function(...s){var n,r;let a;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let e=s[0]||{};y(e,"type")&&((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))||(e=s[s.length-1]),((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))&&i.actionEventTypes.includes(e.type)&&(o(i.actionEffects)||(i.actionEffects=(null===(r=null===(n=i.growingIO.plugins)||void 0===n?void 0:n.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(e,t))}catch(t){A(t,"error")}return a=e.apply(this,s),a}},this.appApplyProxy=(t,e)=>this.appHandlers.includes(t)?this.lifeFcEffects(t,e,"App"):this.customFcEffects(t,e),this.pageApplyProxy=(t,e)=>this.pageHandlers.includes(t)?this.lifeFcEffects(t,e,"Page"):this.customFcEffects(t,e),this.appOverriding=t=>(this.setAppEffectCbs(),this.supLifeFcs(t,"app"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.appApplyProxy(t,e[t]))})),t),this.pageOverriding=t=>(this.setPageEffectCbs(),this.supLifeFcs(t,"page"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.componentOverriding=t=>(this.setPageEffectCbs(),t.methods||(t.methods={}),this.supLifeFcs(this.growingIO.inPlugin?t:t.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?t:t.methods,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.setAppEffectCbs=()=>{const t=this;this.appHandlers.forEach((e=>{this.defAppCbs[e]=function(...i){t.appEffects.main(e,i)}}))},this.setPageEffectCbs=()=>{const t=this;this.pageHandlers.forEach((e=>{this.defPageCbs[e]=function(...i){t.pageEffects.main(this,e,i)}}))},this.growingApp=t=>this.originalApp(this.appOverriding(t)),this.growingPage=t=>this.originalPage(this.pageOverriding(t)),this.growingComponent=t=>this.originalComponent(this.componentOverriding(t)),this.growingBehavior=t=>this.originalBehavior(this.componentOverriding(t)),this.nativeGrowing=(t=["App","Page","Component","Behavior"])=>{const e=this,{platformConfig:i}=this.growingIO,s=i.hooks;if(this.setAppEffectCbs(),this.setPageEffectCbs(),t.includes("App"))try{s.App&&!this.appHooked&&(this.originalApp=App||global.App||function(){},App=function(...t){return e.growingApp(t[0])},this.appHooked=!0)}catch(t){}if(t.includes("Page"))try{s.Page&&!this.pageHooked&&(this.originalPage=Page||global.Page||function(){},Page=function(...t){return e.growingPage(t[0])},this.pageHooked=!0)}catch(t){}if(t.includes("Component"))try{s.Component&&!this.componentHooked&&(this.originalComponent=Component||global.Component||function(){},Component=function(...t){return e.growingComponent(t[0])},this.componentHooked=!0)}catch(t){}if(t.includes("Behavior"))try{s.Behavior&&!this.behaviorHooked&&(this.originalBehavior=Behavior||global.Behavior||function(){},Behavior=function(...t){return e.growingBehavior(t[0])},this.behaviorHooked=!0)}catch(t){}},this.initEventHooks=()=>{const t=this,{platformConfig:e,gioPlatform:i}=this.growingIO;e.canHook?(this.nativeGrowing(),M().GioApp=q((()=>null!==App&&void 0!==App?App:window.GioApp)),M().GioPage=q((()=>null!==Page&&void 0!==Page?Page:window.GioPage)),M().GioComponent=q((()=>null!==Component&&void 0!==Component?Component:window.GioComponent)),M().GioBehavior=q((()=>Behavior))):"quickapp"===i&&(window.GioApp=function(...e){return t.appOverriding(e[0])},window.GioPage=function(...e){return t.pageOverriding(e[0])},window.GioComponent=function(...e){return t.pageOverriding(e[0])})};const i=null===(e=this.growingIO)||void 0===e?void 0:e.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new wt(this.growingIO),this.pageEffects=new _t(this.growingIO),this.currentPage=new bt(this.growingIO)}}class Pt{constructor(t){var s,r;this.growingIO=t,this.ALLOW_SETTING_KEYS=S(et),this.getStorageKey=(t,e)=>{const{inPlugin:i}=this.growingIO;return`${t===this.growingIO.trackingId?"":t}${gt[i?"plugin_"+e:e]}`},this.getGsid=t=>{let e=Number(this._gsid[t]);return Number.isNaN(e)||e>=1e9||1>e?(this.setGsid(t,1),1):e},this.setGsid=(t,e)=>{let i=Number(e);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[t]=i,10>this._gsid[t]-this._stid[t]||this.saveStorageInfo()},this.initStorageInfo=t=>{const{minipInstance:e}=this.growingIO,i=e.getStorageSync(this.getStorageKey(t,"gsid"));let s=Number(i);(Number.isNaN(s)||s>=1e9||1>s)&&(s=1),this._gsid[t]=s,this._stid[t]=s,s!==i&&e.setStorageSync(this.getStorageKey(t,"gsid"),s)},this.saveStorageInfo=()=>{const{minipInstance:t}=this.growingIO;this._stid=Object.assign({},this._gsid),W(t,this.initializedTrackingIds.map((t=>({key:this.getStorageKey(t,"gsid"),value:this._gsid[t]}))))},this.setOriginalSource=(t,{path:i,query:s})=>{const{minipInstance:n}=this.growingIO;if(e(this.getOriginalSource(t))){const e={path:i,query:s,title:""};n.setStorageSync(this.getStorageKey(t,"originalSource"),JSON.stringify(e))}},this.getOriginalSource=t=>{const{minipInstance:e}=this.growingIO;return q((()=>JSON.parse(e.getStorageSync(this.getStorageKey(t,"originalSource")))))},this.getTrackerVds=t=>this.growingIO.trackingId===t?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=t=>{const e=this.initOptions(t);return e.trackingId=t.trackingId,this.growingIO.trackingId=t.trackingId,this.growingIO.vdsConfig=e,e},this.initTrackerHooker=t=>{var e,i;const{platformConfig:s,inPlugin:n,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:g}=t;a||g||(s.canHook=!0),n&&!["tbp","jdp"].includes(r.platform)||this.eventHooks.initEventHooks(),a&&(null===(e=null==o?void 0:o.gioUniAppAdapter)||void 0===e||e.main()),g&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=t=>{var e,i,s,n,r,o;const{projectId:g,dataSourceId:l,appId:u,trackingId:c}=t,h={};return this.ALLOW_SETTING_KEYS.forEach((e=>{const i=et[e].type;(a(i)?i.includes(T(t[e])):T(t[e])===et[e].type)?"ignoreFields"===e?h.ignoreFields=t.ignoreFields.filter((t=>ot.includes(t))):"extraParams"===e?h.extraParams=t.extraParams.filter((t=>at.includes(t))):(h[e]=t[e],["dataCollect","autotrack"].includes(e)&&!h[e]&&A("已关闭"+nt[e],"info")):h[e]=et[e].default})),h.uploadInterval=Math.round(h.uploadInterval),(Number.isNaN(h.uploadInterval)||0>h.uploadInterval||h.uploadInterval>3e3)&&(h.uploadInterval=1e3),h.enableIdMapping&&!h.idMapping&&(h.idMapping=!0,h.idMapping||this.growingIO.userStore.setUserKey(c,"")),_(h,"enableIdMapping"),h.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(h.requestTimeout))&&h.requestTimeout>0||(h.requestTimeout=5e3),Object.assign(Object.assign({},h),{projectId:g,dataSourceId:l,appId:u,trackingId:c,performance:{monitor:null===(i=null===(e=h.performance)||void 0===e?void 0:e.monitor)||void 0===i||i,exception:null===(n=null===(s=h.performance)||void 0===s?void 0:s.exception)||void 0===n||n,network:null!==(o=null===(r=h.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(t,e,s)=>{var n;const{userStore:r,emitter:o}=this.growingIO,a=this.getTrackerVds(t),g=i(e)&&this.ALLOW_SETTING_KEYS.includes(e),l=g&&typeof s===(null===(n=et[e])||void 0===n?void 0:n.type);if(g&&l){const i=Object.assign({},a);if(this.updateVdsConfig(t,Object.assign(Object.assign({},a),{[e]:s})),"dataCollect"===e&&i.dataCollect!==s&&s){r.setSessionId(t);const{path:e,query:i,settedTitle:s}=this.eventHooks.currentPage;this.eventHooks.currentPage.title=s[e]||this.growingIO.minipInstance.getPageTitle(this.growingIO.minipInstance.getCurrentPage()),this.sendVisit(t,{path:e,query:i}),this.eventHooks.currentPage.time=Date.now(),this.sendPage(t,{path:e,query:i})}return o.emit(It,{optionName:e,optionValue:s}),!0}return j("setOption > "+e),!1},this.getOption=(t,e)=>{const i=this.getTrackerVds(t);return e&&y(this.growingIO.vdsConfig,e)?y(i,e)?i[e]:this.growingIO.vdsConfig[e]:P(e)?i:void j("getOption > "+e)},this.updateVdsConfig=(t,e)=>{t===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),e),M().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[t]=Object.assign(Object.assign({},this.growingIO.subInstance[t]),e),M().vdsConfig.subInstance[t]=this.growingIO.subInstance[t])},this.toggleShareOut=t=>{n(t)?this.shareOut=t:this.shareOut=!this.shareOut},this.sendVisit=(t,e)=>{this.eventHooks.appEffects.buildVisitEvent(t,null!=e?e:this.lastVisitEvent)},this.sendPage=(t,e)=>{this.eventHooks.pageEffects.buildPageEvent(t,e)},this.eventConverter=t=>{const{dataStore:e,uploader:i}=this.growingIO,{dataCollect:s}=this.getTrackerVds(t.trackingId);if(s){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(t.eventType)||(t.eventSequenceId=e.getGsid(t.trackingId),e.setGsid(t.trackingId,t.eventSequenceId+1));const s={};O(t,((t,e)=>{var i;if("element"===e){const e=null!==(i=l(t))&&void 0!==i?i:{};O(e,((t,e)=>{P(t)&&0!==t||(s[e]=t)}))}else P(t)&&0!==t||(s[e]=t)})),this.growingIO.emitter.emit(ct,{composedEvent:s}),i.commitRequest(Object.assign(Object.assign({},s),{requestId:D()}))}},this.eventInterceptor=t=>{const{systemInfo:e,network:i}=this.growingIO.minipInstance;P(e)||P(i)?this.interceptEvents.push(t):P(this.interceptEvents)?this.eventConverter(t):([...this.interceptEvents,t].forEach((e=>{const i=Object.assign(Object.assign({},e),this.eventContextBuilder(t.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(i)})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:t,network:e}}=this.growingIO;t&&e&&!P(this.interceptEvents)&&([...this.interceptEvents].forEach((t=>{const e=Object.assign(Object.assign({},t),this.eventContextBuilder(t.trackingId,{path:t.path,query:t.query,timestamp:t.timestamp}));this.eventConverter(e)})),this.interceptEvents=[])},this.buildAppMessageEvent=(t,e)=>{var i,s;const n=e[0];let r;2>e.length?1===e.length&&(r=n):r=e[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,g=((null==r?void 0:r.path)||"").split("?"),u=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(t));u.attributes=Q(Object.assign(Object.assign(Object.assign({},null!==(i=u.attributes)&&void 0!==i?i:{}),{$from:n.from,$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:l(g),$share_query:g[1]}),null==r?void 0:r.attributes)),a(u)},this.buildTimelineEvent=(t,e)=>{var i,s;const n=e[0];let r;2>e.length?1===e.length&&(r=n):r=e[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,g=((null==r?void 0:r.path)||"").split("?"),u=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(t));u.attributes=Q(Object.assign(Object.assign(Object.assign({},null!==(i=u.attributes)&&void 0!==i?i:{}),{$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:l(g),$share_query:g[1]}),null==r?void 0:r.attributes)),a(u)},this.buildAddFavorites=(t,e)=>{var i;const s=e[0];let n;2>e.length?1===e.length&&(n=s):n=e[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==n?void 0:n.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(t));g.attributes=Q(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$share_title:null==n?void 0:n.title,$share_path:l(a),$share_query:a[1]})),o(g)},this.trackersExecute=t=>{this.initializedTrackingIds.forEach((e=>{"function"===T(t)&&t(e)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new St(this.growingIO).main,this.eventHooks=new kt(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:g,minipInstance:u}=this.growingIO;g.on(yt,(({trackingId:t})=>{this.initializedTrackingIds.push(t),this.initStorageInfo(t)})),g.on(ut,(({eventData:t,trackingId:e})=>{"VISIT"===t.eventType&&(this.lastVisitEvent=t),"PAGE"===t.eventType&&(this.lastPageEvent[e]=t)})),o(null===(s=u.minip)||void 0===s?void 0:s.onAppHide)&&u.minip.onAppHide((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];O(e,(t=>{t.start&&(t.leng=t.leng+(+Date.now()-t.start))}))}))})),o(null===(r=u.minip)||void 0===r?void 0:r.onAppShow)&&u.minip.onAppShow((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];O(e,(t=>{t.start&&(t.start=+Date.now())}))}))})),g.on(It,(({optionName:t,optionValue:e})=>{"dataCollect"===t&&!1===e&&this.trackersExecute((t=>{this.growingIO.clearTrackTimer(t)}))}))}get scene(){return this._scene}set scene(t){const e=this._scene;this._scene=t,e!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:t,oldScene:e})}}const Tt={scnPrefix:"",appHandlers:["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange"],pageHandlers:["onLoad","onShow","onReady","onHide","onShareAppMessage","onTabItemTap","onUnload","onPullDownRefresh","onReachBottom","onResize"],actionEventTypes:["onclick","tap","onTap","longpress","longTap","blur","change","onChange","submit","confirm","getuserinfo","getphonenumber","contact","mouseup"],canHook:!0,hooks:{App:!0,Page:!0,Component:!0,Behavior:!0},listeners:{app:{appLaunch:"onLaunch",appShow:"onShow",appClose:"onHide"},page:{pageLoad:"onLoad",pageShow:"onShow",pageReady:"onReady",pageHide:"onHide",pageUnload:"onUnload",tabTap:"onTabItemTap",shareApp:"onShareAppMessage"},actions:{click:["onclick","tap","longpress","longTap","getuserinfo","getphonenumber","contact","mouseup"],change:["blur","change","confirm"],submit:["submit"]}}},Et=Object.assign(Object.assign({},Tt),{listeners:Object.assign({},Tt.listeners),name:"KuaiShou",platform:"kuaishoup",scnPrefix:"ks_"});class Ct{constructor(t){this.growingIO=t,this.minip=G("ks"),this.hookSetTitle=()=>{var t;const e=null===(t=this.minip)||void 0===t?void 0:t.setNavigationBarTitle,i=this;e&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const t=i.getCurrentPath(),{title:e}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.settedTitle[t]=e}return e.apply(this,arguments)}})},this.navigateTo=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateTo(t)},this.switchTab=t=>{var e;null===(e=this.minip)||void 0===e||e.switchTab(t)},this.navigateToMiniProgram=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateToMiniProgram(t)},this.getImageInfo=({src:t,success:e,fail:i,complete:s})=>{var n;return null===(n=this.minip)||void 0===n?void 0:n.getImageInfo({src:t,success:e,fail:i,complete:s})},this.initImpression=t=>{var e,i;null===(i=null===(e=this.growingIO.plugins)||void 0===e?void 0:e.gioImpressionTracking)||void 0===i||i.main(t,"observeAll")},this.getCurrentPage=()=>q((()=>u(getCurrentPages())))||{},this.getCurrentPath=()=>{const t=this.getCurrentPage();return(null==t?void 0:t.route)||(null==t?void 0:t.uri)||(null==t?void 0:t.__route__)||""},this.getPageTitle=t=>{var e,s;let n="";const r=V(B());try{const o=(null==t?void 0:t.data)||t.$data||{};if(n=i(null==o?void 0:o.gioPageTitle)?null==o?void 0:o.gioPageTitle:"",0===n.length){const e=r.page[t.route]||r.page[t.route+".html"];n=e?e.window.navigationBarTitleText:r.global.window.navigationBarTitleText}if(0===n.length){const i=null===(s=null===(e=null==r?void 0:r.tabBar)||void 0===e?void 0:e.list)||void 0===s?void 0:s.find((e=>e.pagePath===t.route||e.pagePath===t.route+".html"));n=(null==i?void 0:i.text)||""}}catch(t){return""}return N(n)},this.getStorageSync=t=>{var e;let i=null===(e=this.minip)||void 0===e?void 0:e.getStorageSync(t);return r(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=t=>new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:t,success:({data:t})=>e(t),fail:()=>e("")})})),this.setStorageSync=(t,e,i)=>{var s;i&&(e={value:e,expiredAt:i}),null===(s=this.minip)||void 0===s||s.setStorageSync(t,e)},this.setStorage=(t,e)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:t,data:e})},this.removeStorageSync=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorageSync(t)},this.removeStorage=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorage(t)},this.getNetworkType=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{t.network=i,e(i)},fail:()=>e(null)})}))},this.request=({url:t,data:e,header:i,timeout:s,method:n,success:r,fail:a,complete:g})=>{var l;const u=null===(l=this.minip)||void 0===l?void 0:l.request({url:t,data:e,header:i,headers:i,timeout:s,method:n,success:r,fail:a,complete:g});let c=setTimeout((()=>{(null==u?void 0:u.abort)&&o(null==u?void 0:u.abort)&&(null==u||u.abort()),clearTimeout(c),c=null}),(s||1e4)+10);return u},this.getSystemInfo=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{t.systemInfo=i,e(i)},fail:()=>e(null)})}))},this.getSetting=()=>new Promise((t=>{var e;null===(e=this.minip)||void 0===e||e.getSetting({success:t,fail:t})}));const{platformConfig:{platform:e,scnPrefix:s}}=this.growingIO;this.platform=e,this.scnPrefix=s,this.growingIO.emitter.on(ft,(()=>{this.getNetworkType().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()}))}))}}class At extends Ct{constructor(t){super(t),this.growingIO=t,this.hookSetTitle()}}const jt=["gioPerformance"];class qt{constructor(t){var e,i,s,n,r,a;this.growingIO=t,this.innerPluginInit=()=>{var t;jt.forEach((t=>{var e;return _(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins,t)})),S(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins).forEach((t=>{var e,i;const{name:s,method:n}=null!==(i=null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins[t])&&void 0!==i?i:{};d(this.pluginItems,(t=>t.name===s))||this.pluginItems.push({name:m(s||t),method:n||(t=>{})})})),P(this.pluginItems)||this.installAll()},this.install=(t,e,i)=>{var s,n;const{emitter:r}=this.growingIO,o=e||d(this.pluginItems,(e=>e.name===t));if((null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[t])return A(`重复加载插件 ${t} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return A(`插件加载失败!不存在名为 ${t} 的插件!`,"error"),!1;try{return(null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[t]=new o.method(this.growingIO,i),e&&(r.emit(pt,t),A("加载插件 "+t,"info")),!0}catch(i){return this.lifeError(e,i),A(`插件【${t}】加载异常 ${i}`,"error"),!1}},this.installAll=t=>{(t||this.pluginItems).forEach((e=>{this.install(e.name,t?e:void 0,t?null==e?void 0:e.options:void 0)&&!d(this.pluginItems,(t=>t.name===e.name))&&this.pluginItems.push({name:m(e.name),method:e.method?e.method:()=>{}})}))},this.uninstall=t=>{var e;_(this.pluginItems,t);const i=_(null===(e=this.growingIO)||void 0===e?void 0:e.plugins,t);return i||A(`卸载插件 ${t} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((t=>this.uninstall(t.name)))},this.lifeError=(t,e)=>{this.growingIO.emitter.emit(dt,{plugin:t,error:e}),A(`插件执行错误 ${t.name} ${e}`,"error")},this.callLifeCycle=(t,e)=>{this.pluginItems.forEach((i=>{const s=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][t]:void 0;if(s&&o(s))try{s(e)}catch(t){this.lifeError(i,t)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(e=this.growingIO.emitter)||void 0===e||e.on(pt,(t=>this.callLifeCycle("onInstall",t))),null===(i=this.growingIO.emitter)||void 0===i||i.on(dt,(t=>this.callLifeCycle("onError",t))),null===(s=this.growingIO.emitter)||void 0===s||s.on(ht,(t=>this.callLifeCycle("onComposeBefore",t))),null===(n=this.growingIO.emitter)||void 0===n||n.on(ct,(t=>this.callLifeCycle("onComposeAfter",t))),null===(r=this.growingIO.emitter)||void 0===r||r.on(mt,(t=>this.callLifeCycle("onSendBefore",t))),null===(a=this.growingIO.emitter)||void 0===a||a.on(vt,(t=>this.callLifeCycle("onSendAfter",t)))}}var xt={},Nt={}.hasOwnProperty;function Ut(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(t){return null}}function Kt(t){try{return encodeURIComponent(t)}catch(t){return null}}xt.stringify=function(t,e){e=e||"";var i,s,n=[];for(s in"string"!=typeof e&&(e="?"),t)if(Nt.call(t,s)){if((i=t[s])||null!=i&&!isNaN(i)||(i=""),s=Kt(s),i=Kt(i),null===s||null===i)continue;n.push(s+"="+i)}return n.length?e+n.join("&"):""},xt.parse=function(t){for(var e,i=/([^=?#&]+)=?([^&]*)/g,s={};e=i.exec(t);){var n=Ut(e[1]),r=Ut(e[2]);null===n||null===r||n in s||(s[n]=r)}return s};class Dt{constructor(t){this.growingIO=t,this.generateURL=t=>{const{serverUrl:e,projectId:i}=this.growingIO.dataStore.getTrackerVds(t);return I(e,"http")?`${e}/v3/projects/${i}/collect`:`https://${e}/v3/projects/${i}/collect`},this.getHoardingQueue=t=>{var e;return null!==(e=this.hoardingQueue[t])&&void 0!==e?e:[]},this.getRequestQueue=t=>{var e;return null!==(e=this.requestQueue[t])&&void 0!==e?e:[]},this.commitRequest=t=>{var i,s;const n=Object.assign({},t),{vdsConfig:r,emitter:o}=this.growingIO;o.emit(ut,{eventData:t,trackingId:t.trackingId}),r.forceLogin?(e(this.hoardingQueue[t.trackingId])&&(this.hoardingQueue[t.trackingId]=[]),null===(i=this.hoardingQueue[t.trackingId])||void 0===i||i.push(n)):(e(this.requestQueue[t.trackingId])&&(this.requestQueue[t.trackingId]=[]),null===(s=this.requestQueue[t.trackingId])||void 0===s||s.push(n),this.initiateRequest(t.trackingId))},this.initiateRequest=(t,e)=>{const{plugins:i,vdsConfig:s,minipInstance:n,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(t),...this.getRequestQueue(t)],a=t=>{var a,g;if(null===(a=null==s?void 0:s.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(g=null==i?void 0:i.gioTaobaoAdapter)||void 0===g||g.singleInvoke(t);else if(e)this.batchInvoke(t);else{const{uploadInterval:e}=this.growingIO.dataStore.getTrackerVds(t);k(this.batchInvoke,e,!1,!1)(t)}o.some((t=>"VISIT"===t.eventType))&&n.removeStorageSync(r.getStorageKey(t,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(t);else{let e=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(t),clearInterval(e),e=void 0)}),500)}},this.batchInvoke=t=>{const{vdsConfig:e,emitter:i}=this.growingIO,s=this.getHoardingQueue(t),n=this.getRequestQueue(t);let r=[...s,...n];r.length>50?(r=r.slice(0,50),s.length>50?this.hoardingQueue[t]=s.slice(50):(this.requestQueue[t]=n.slice(50-s.length),this.hoardingQueue[t]=[])):(this.hoardingQueue[t]=[],this.requestQueue[t]=[]);let o=r.filter((t=>(this.retryIds[t.requestId]||0)<=this.retryLimit));if(P(o))return;const a=o.map((t=>{const e=Object.assign({},t);return _(e,["requestId","trackingId"]),e}));e.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(mt,{eventsQueue:o,requestData:a,trackingId:t})},this.sendEvent=(t,e)=>{var i;const s=l(t).trackingId,{minipInstance:n,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:g,requestTimeout:u}=r.getTrackerVds(s);this.requestingNum+=1;const c={"content-type":"jdp"===n.platform?"application/json":"application/json;charset=UTF-8"};let h=[...e];const d=!!g&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);d&&(h=a.gioCompress.compressToUTF16(JSON.stringify(e)),c["X-Compress-Codec"]="1");const p=this.generateURL(s);n.request({url:`${p}?stm=${Date.now()}&compress=${d?"1":"0"}`,header:c,method:"POST",data:h,timeout:u,fail:e=>{[200,204].includes(e.code)||(t.forEach((t=>{this.requestFailFn(t)})),A("请求失败!"+JSON.stringify(e),"error"))},complete:t=>{this.requestingNum-=1,o.emit(vt,{result:t,requestData:e}),this.initiateRequest(s)}})},this.requestFailFn=t=>{if(this.retryIds[t.requestId]||(this.retryIds[t.requestId]=0),this.retryIds[t.requestId]+=1,!this.requestQueue[t.trackingId].some((e=>e.requestId===t.requestId))){let e=setTimeout((()=>{P(this.requestQueue[t.trackingId])?(this.requestQueue[t.trackingId].push(t),this.initiateRequest(t.trackingId)):this.requestQueue[t.trackingId].push(t),clearTimeout(e),e=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:i,vdsConfig:s,plugins:n}=this.growingIO;i.on(mt,(({eventsQueue:t,requestData:e,trackingId:i})=>{var r,o;i===this.growingIO.trackingId&&((null===(r=null==s?void 0:s.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==n?void 0:n.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(t,e):this.sendEvent(t,e))}))}}class Ht{constructor(t){this.growingIO=t,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:t}=this.growingIO;return this._uid||(this._uid=t.getStorageSync(this._getUidKey())),this._uid||(this._uid=D(),t.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=t=>{const e=this._uid;this._uid=t,e!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:t,oldUId:e}))},this.getSessionId=t=>(this._sessionId[t]||this.setSessionId(t),this._sessionId[t]),this.setSessionId=(t,e)=>{const i=this._sessionId[t];e||(e=D()),this._sessionId[t]=e,i!==e&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:e,oldSessionId:i})},this._getUserIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"userId"),this.getUserId=t=>{const{minipInstance:e}=this.growingIO;return this._userId[t]||(this._userId[t]=e.getStorageSync(this._getUserIdKey(t))),this._userId[t]},this.setUserId=(t,i)=>{const s=this._userId[t];this._userId[t]=e(i)?"":i,s!==this._userId[t]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(t),this._userId[t]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:i,oldUserId:s})),i&&this.setGioId(t,i)},this._getUserKeyKey=t=>this.growingIO.dataStore.getStorageKey(t,"userKey"),this.getUserKey=t=>{const{minipInstance:e}=this.growingIO;return this._userKey[t]||(this._userKey[t]=e.getStorageSync(this._getUserKeyKey(t))),this._userKey[t]},this.setUserKey=(t,i)=>{const s=this._userKey[t];this._userKey[t]=e(i)?"":i,s!==this._userKey[t]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(t),this._userKey[t]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:i,oldUserKey:s}))},this._getGioIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"gioId"),this.getGioId=t=>{const{minipInstance:e}=this.growingIO;return this._gioId[t]||(this._gioId[t]=e.getStorageSync(this._getGioIdKey(t))),this._gioId[t]},this.setGioId=(t,i)=>{const s=this._gioId[t];this._gioId[t]=e(i)?"":i,s!==this._gioId[t]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(t),this._gioId[t]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:i,oldGioId:s}))},this.initUserInfo=t=>{var e;const{minipInstance:i}=this.growingIO,s=[this._getUidKey(),this._getUserIdKey(t),this._getUserKeyKey(t),this._getGioIdKey(t)],n=null!==(e=z(i,s))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,i)=>{"_uid"===e?this.getUid():this[e][t]=n[i]}))},this.saveUserInfo=()=>{const{minipInstance:t,dataStore:{trackersExecute:e}}=this.growingIO;e((e=>{W(t,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(e),value:this._userId[e]},{key:this._getUserKeyKey(e),value:this._userKey[e]},{key:this._getGioIdKey(e),value:this._gioId[e]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={}}}const $t=new class{constructor(){var t;this.init=t=>{var e;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:t});try{if(A("Gio小程序SDK 初始化中...","info"),t.trackingId&&this.dataStore.initializedTrackingIds.includes(t.trackingId))throw Error(`已存在实例 ${t.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(t);return null===(e=this.emitter)||void 0===e||e.emit(ft,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(t.trackingId),this.emitter.emit(yt,i),this.trackingId&&this.trackingId!==t.trackingId||(M().__gio__=()=>this),A("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&A("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(t){return A(t,"error"),!1}},this.handlerDistribute=(t,e,i)=>{const{initializedTrackingIds:s,getTrackerVds:n}=this.dataStore;if(n(t)&&s.includes(t))return this[e](t,...i);A(`不存在实例:${t},请检查!`,"warn")},this.registerPlugins=t=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...t],this.plugins.installAll(t)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(t,e)=>this.dataStore.getOption(t,e),this.setOption=(t,e,i)=>{var s;return S(nt).includes(e)?typeof i===(null===(s=et[e])||void 0===s?void 0:s.type)?(this.dataStore.setOption(t,e,i),A(`已修改${nt[e]}: ${i}`,"info"),!0):(A(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(A(`不存在可修改的配置项:${e},请检查后重试!`,"error"),!1)},this.setPageAttributes=(t,e)=>{if(r(e)&&!P(e)){const{currentPage:i}=this.dataStore.eventHooks;return P(i.pageProps[t])&&(i.pageProps[t]={}),P(i.pageProps[t][i.path])&&(i.pageProps[t][i.path]={}),P(e)||O(e,((e,s)=>{o(i.pageProps[t][i.path][s])&&!o(e)||(i.pageProps[t][i.path][s]=e)})),!0}return j("setPageAttributes"),!1},this.clearPageAttributes=(t,e)=>{try{if(!P(this.dataStore.eventHooks.currentPage.pageProps[t])){const{currentPage:i}=this.dataStore.eventHooks;a(e)&&!P(e)?e.forEach((e=>{_(i.pageProps[t][i.path],e)})):i.pageProps[t][i.path]={}}}catch(t){return j("clearPageAttributes"),!1}},this.sendPage=(t,e)=>{const{trackPage:i}=this.dataStore.getTrackerVds(t);i?A("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(t,e)},this.identify=(t,e)=>{if(t===this.trackingId)if(this.vdsConfig.forceLogin){if(!X(e))return void j("identify");const t=p(e).slice(0,1e3);this.userStore.setUid(t),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((e=>{const i=this.uploader.getHoardingQueue(e);i.forEach(((e,s)=>i[s].deviceId=t)),this.uploader.initiateRequest(e,!0)}))}else j("identify",!1,"forceLogin未开启");else j("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(t,e)=>{var i;if(r(e)&&!P(e)){const{eventContextBuilder:s,eventInterceptor:n,lastVisitEvent:r}=this.dataStore,o=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},s(t));o.attributes=Q(Object.assign(Object.assign({},null!==(i=o.attributes)&&void 0!==i?i:{}),K(e))),o.path||(o.path=r.path,o.query=r.query,o.title=r.title),n(o)}else j("setUserAttributes")},this.setUserId=(t,i,s)=>{if(X(i)){const n=this.userStore.getGioId(t);i=p(i).slice(0,1e3),s=p(s).slice(0,1e3),this.userStore.setUserId(t,i);const{idMapping:r}=this.dataStore.getTrackerVds(t);if(r&&this.userStore.setUserKey(t,e(s)?"":s),n&&n!==i){this.userStore.setSessionId(t);const{path:e,query:i,settedTitle:s}=this.dataStore.eventHooks.currentPage;this.dataStore.eventHooks.currentPage.title=s[e]||this.minipInstance.getPageTitle(this.minipInstance.getCurrentPage()),this.dataStore.sendVisit(t,{path:e,query:i})}}else j("setUserId")},this.clearUserId=t=>{this.userStore.setUserId(t,void 0),this.userStore.setUserKey(t,void 0)},this.setGeneralProps=(t,e)=>r(e)&&!P(e)?(P(this.dataStore.generalProps[t])&&(this.dataStore.generalProps[t]={}),O(e,((e,i)=>{o(this.dataStore.generalProps[t][i])&&!o(e)||(this.dataStore.generalProps[t][i]=e)})),!0):(j("setGeneralProps"),!1),this.clearGeneralProps=(t,e)=>{try{P(this.dataStore.generalProps[t])||(a(e)&&!P(e)?e.forEach((e=>{_(this.dataStore.generalProps[t],e)})):this.dataStore.generalProps[t]={})}catch(t){return j("clearGeneralProps"),!1}},this.track=(t,e,i)=>{U(e,(()=>{var s;const{eventContextBuilder:n,eventInterceptor:o}=this.dataStore,a=Object.assign({eventType:"CUSTOM",eventName:e},n(t));a.attributes=Q(Object.assign(Object.assign({},null!==(s=a.attributes)&&void 0!==s?s:{}),K(Object.assign({},r(i)&&!P(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(a["&&sendTo"]=i["&&sendTo"]),o(a)}))},this.trackTimerStart=(t,e)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(t);return i?U(e,(()=>{const i=D();return this.dataStore.trackTimers[t]||(this.dataStore.trackTimers[t]={}),this.dataStore.trackTimers[t][i]={eventName:e,leng:0,start:+Date.now()},i})):(A("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(t,e,i)=>{var s;const{dataCollect:n}=this.dataStore.getTrackerVds(t),o=this.dataStore.trackTimers[t];if(e&&o&&o[e]){if(n){const n=864e5,a=o[e];if(0!==a.start){const t=+Date.now()-a.start;a.leng=t>0?a.leng+t:0}const{eventContextBuilder:g,eventInterceptor:l}=this.dataStore,u=Object.assign({eventType:"CUSTOM",eventName:a.eventName},g(t));return u.attributes=Q(Object.assign(Object.assign({},null!==(s=u.attributes)&&void 0!==s?s:{}),K(Object.assign(Object.assign({},r(i)&&!P(i)?i:{}),{event_duration:a.leng>n?0:a.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(u["&&sendTo"]=i["&&sendTo"]),l(u),!0}return A("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return A("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(t,e)=>{const i=this.dataStore.trackTimers[t];return e&&i&&i[e]?(delete i[e],!0):(A("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=t=>{this.dataStore.trackTimers[t]={}},this.setLocation=(t,e,i)=>{P(this.dataStore.locationData[t])&&(this.dataStore.locationData[t]={});const s=this.dataStore.locationData[t],n=t=>t>=-180&&180>=t;n(e)&&n(i)&&(s.latitude!==e||s.longitude!==i)&&(this.dataStore.locationData[t]={latitude:e,longitude:i})},this.updateImpression=()=>{A("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(t,e,i)=>{A("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),x(i,{})},this.getGioInfo=t=>{const{getUid:e,getUserId:i,getUserKey:s,getSessionId:n}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:g,idMapping:l,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(t),h={gioappid:o,giocs1:i(t)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:n(t),giou:e()};return h.giodatacollect=g,h.giodatasourceid=a,l&&(h.giouserkey=s(t)),P(u)||u.forEach((t=>{c.includes(t)||(h["gio"+t]=this.dataStore.lastVisitEvent[t])})),xt.stringify(h)},this.utils=Object.assign(Object.assign(Object.assign({},C),Z),{qs:xt}),this.emitter={all:t=t||new Map,on:function(e,i){var s=t.get(e);s?s.push(i):t.set(e,[i])},off:function(e,i){var s=t.get(e);s&&(i?s.splice(s.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var s=t.get(e);s&&s.slice().map((function(t){t(i)})),(s=t.get("*"))&&s.slice().map((function(t){t(e,i)}))}},this.gioPlatform="ks",this.gioFramework="native",this.sdkVersion="4.2.0";try{"quickapp"===this.gioPlatform||o(getApp)&&o(App)?this.inPlugin=!1:this.inPlugin=!0}catch(t){this.inPlugin=!0}this.inPlugin&&A("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Et,this.minipInstance=new At(this),this.dataStore=new Pt(this),this.userStore=new Ht(this),this.uploader=new Dt(this),this.plugins=new qt(this),this.plugins.innerPluginInit()}},Lt=function(){var t;const e=arguments[0];let s="g0",n=e;if(e.indexOf(".")>-1&&(s=null!==(t=e.split(".")[0])&&void 0!==t?t:"g0",n=e.split(".")[1]),i(n)&&st.includes(n)&&$t[n]){const t=c(Array.from(arguments));if("init"===n){const e=((t,e)=>{const i=p(e[0]),s=p(e[1]),n=(4===e.length?e[3]:e[2])||{};return i&&s?t.dataStore.initializedTrackingIds.some(((e,n)=>{const r=0===n?t.vdsConfig:t.subInstance[e];return r.projectId===i&&r.dataSourceId===s}))?(A("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:s,appId:p(4===e.length?e[2]:""),userOptions:n}:(A('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})($t,t);if(e){const{projectId:t,dataSourceId:i,appId:n,userOptions:r}=e;return $t.init(Object.assign(Object.assign({},r),{projectId:t,dataSourceId:i,appId:n,trackingId:s}))}return!1}if("registerPlugins"===n)$t.registerPlugins(t[0]);else{if($t.gioSDKInitialized&&$t.vdsConfig)return it.includes(n)?q((()=>$t.handlerDistribute(s,n,t))):q((()=>$t[n](...t)));A("SDK未初始化!","error")}}else if(rt.includes(n))A(`方法 ${p(n)} 已被弃用,请移除!`,"warn");else{if("canIUse"===n)return st.includes(arguments[1])&&!!$t[arguments[1]];A(`不存在名为 ${p(n)} 的方法调用!`,"error")}};M().gdp=Lt,M().gioSDKVersion=$t.sdkVersion;const Rt=q((()=>{var t;return null!==(t=$t.dataStore.eventHooks.growingApp)&&void 0!==t?t:App})),Ft=q((()=>{var t;return null!==(t=$t.dataStore.eventHooks.growingPage)&&void 0!==t?t:Page})),Gt=q((()=>{var t;return null!==(t=$t.dataStore.eventHooks.growingComponent)&&void 0!==t?t:Component})),Vt=q((()=>{var t;return null!==(t=$t.dataStore.eventHooks.growingBehavior)&&void 0!==t?t:Behavior}));export{Rt as GioApp,Vt as GioBehavior,Gt as GioComponent,Ft as GioPage,Lt as default};
@@ -1 +1 @@
1
- var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t=function(e){return["undefined","null"].includes(s(e))},r=function(e){return"string"===s(e)},n=function(e){return"NaN"===a(Number(e))},i=function(e){return"number"===s(e)},o=function(e){return"[object Object]"==={}.toString.call(e)&&!t(e)},a=function(e){return t(e)?"":"".concat(e)},c=function(e){return o(e)?Object.keys(e):[]},u=function(e){return function(e){return Array.isArray(e)&&"array"===s(e)}(e)?0===e.length:o(e)?0===c(e).length:!e},s=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},g=/^\d+_gdp_abt_sign$/,l=/^\d+_gdp_abtd$/,d=function(e,t){console.log("%c[GrowingIO]:".concat(e),{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},f=function(e,t){if(["function","asyncfunction"].includes(s(e)))try{e(t)}catch(e){d("回调执行失败!".concat(e),"error")}},v=function(e,t){void 0===t&&(t=!1);var r=0;if(u(e)||"boolean"==typeof e)return r;for(var n=0;n<e.length;)r=(r<<5)-r+e.charCodeAt(n),r|=0,n++;return t?Math.abs(r):r},y={name:"gioABTest",method:function(t,s){var y=this;this.growingIO=t,this.timeoutCheck=function(e,t){y.requestInterval=i(Number(e))&&!n(Number(e))?Number(e):5,(y.requestInterval>1440||0>y.requestInterval)&&(y.requestInterval=5),y.requestTimeout=i(Number(t))&&!n(Number(t))?Number(t):1e3,(y.requestTimeout>5e3||100>y.requestTimeout)&&(y.requestTimeout=1e3)},this.abtStorageCheck=function(){var e,t=y.growingIO.minipInstance,r=(null===(e=t.minip)||void 0===e?void 0:e.getStorageInfoSync().keys)||[];r.filter((function(e){return g.test(e)})).forEach((function(e){var r=t.getStorageSync(e);r&&r>=Date.now()||t.removeStorageSync(e)})),r.filter((function(e){return l.test(e)})).forEach((function(e){u(t.getStorageSync(e))&&t.removeStorageSync(e)}))},this.getHashKey=function(e,t){var r=y.growingIO,n=r.userStore.getUid,i=r.vdsConfig.projectId;return v("".concat(e,"#").concat(i,"#").concat(n(),"#").concat(t),!0)},this.generateUrl=function(e,t){var n,i;i="http",r(n=t)||(n=a(n)),n.slice(0,4)!==i?y.url[e]="https://".concat(t,"/diversion/specified-layer-variables"):y.url[e]="".concat(t,"/diversion/specified-layer-variables")},this.getABTest=function(e,t,r){if(u(y.url[e])&&y.generateUrl(e,"https://ab.growingio.com"),!t)return d("获取ABTest数据失败! 实验层Id不合法!","error"),void f(r,{});var n=y.growingIO.minipInstance,i=n.getStorageSync("".concat(y.getHashKey(e,t),"_gdp_abt_sign"))||0,o=n.getStorageSync("".concat(y.getHashKey(e,t),"_gdp_abtd"))||{};!i||i<Date.now()?y.initiateRequest(e,t,o,r):f(r,o)},this.initiateRequest=function(t,r,n,i){var o=y.growingIO,a=o.userStore.getUid,c=o.dataStore,u=o.minipInstance,s=c.getTrackerVds(t),g=s.projectId,l=s.dataSourceId;u.request({url:y.url[t],header:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST",data:{accountId:g,datasourceId:l,distinctId:a(),layerId:r},timeout:y.requestTimeout,success:function(o){var a=o.data;0===a.code?y.experimentVerify(t,e(e({},a),{layerId:r}),n,i):(d("获取ABTest数据失败! ".concat(a.errorMsg,"!"),"error"),f(i,{})),u.setStorageSync("".concat(y.getHashKey(t,r),"_gdp_abt_sign"),Date.now()+6e4*y.requestInterval)},fail:function(e){var o=e.errMsg;o.indexOf("timeout")>-1?(d("获取ABTest数据失败! 请求超时!","error"),f(i,{})):2>y.retryCount?(y.initiateRequest(t,r,n,i),y.retryCount+=1):(d("获取ABTest数据失败! ".concat(JSON.stringify(o).slice(0,30),"!"),"error"),f(i,{}))}})},this.experimentVerify=function(e,t,r,n){var i=t.layerId,o=t.strategyId,c=t.experimentId,u=t.variables,s="".concat(y.getHashKey(e,i),"_gdp_abtd"),g={layerId:a(i),strategyId:a(o),experimentId:a(c),variables:u};v(JSON.stringify(g))!==v(JSON.stringify(r))&&(y.growingIO.minipInstance.setStorageSync(s,g,new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1).getTime()),o&&c&&y.buildExperimentHitEvent(e,a(i),a(c),a(o))),f(n,g)},this.buildExperimentHitEvent=function(t,r,n,i){var o=y.growingIO.dataStore,a=o.eventContextBuilder;(0,o.eventConverter)(e(e({eventType:"CUSTOM",eventName:"$exp_hit",attributes:{$exp_layer_id:r,$exp_id:n,$exp_strategy_id:i}},a(t)),{customEventType:0}))};var h=null!=s?s:{},p=h.abServerUrl,I=void 0===p?"https://ab.growingio.com":p,m=h.requestInterval,S=h.requestTimeout;this.timeoutCheck(m,S);var b=this.growingIO.emitter;this.growingIO.getABTest=this.getABTest,b.on("OPTION_INITIALIZED",(function(){u(I)?d("如果您需要使用ABTest功能,请配置服务地址 abServerUrl!","warn"):(y.abtStorageCheck(),y.url={},r(I)?y.generateUrl(y.growingIO.trackingId,I):o(I)&&c(I).forEach((function(e){y.generateUrl(e,I[e])})))})),this.retryCount=0}};export{y as default};
1
+ var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t=function(e){return["undefined","null"].includes(l(e))},r=function(e){return"string"===l(e)},n=function(e){return"NaN"===c(Number(e))},i=function(e){return"number"===l(e)},o=function(e){return"[object Object]"==={}.toString.call(e)&&!t(e)},a=function(e){return Array.isArray(e)&&"array"===l(e)},c=function(e){return t(e)?"":"".concat(e)},u=function(e){return o(e)?Object.keys(e):[]},s=function(e,t){if(!o(e))return!1;try{if("string"===l(t))return delete e[t];if("array"===l(t))return t.map((function(t){return delete e[t]}));"object"===l(t)&&t.constructor===RegExp&&u(e).forEach((function(r){t.test(r)&&s(e,r)}))}catch(e){return!1}},g=function(e){return a(e)?0===e.length:o(e)?0===u(e).length:!e},l=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},f=/^\d+_gdp_abt_sign$/,d=/^\d+_gdp_abtd$/,v=function(e,t){console.log("%c[GrowingIO]:".concat(e),{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},h=function(e,t){if(["function","asyncfunction"].includes(l(e)))try{e(t)}catch(e){v("回调执行失败!".concat(e),"error")}},y=function(e){var r={};return o(e)&&(s(e,"&&sendTo"),function(e,n){u(e).forEach((function(n){return function(e,n){var i=c(n).slice(0,100);o(e)?r[i]=y(e):a(e)?(r[i]=function(e,t){if(void 0===t&&(t=!1),a(e)){for(var r=0,n=[],i=0,o=e;i<o.length;i++){var c=o[i];c&&!g(c)&&(n[r++]=c),t&&0===c&&(n[r++]=c)}return n}return e}(e.slice(0,100),!0),r[i]=r[i].join("||").slice(0,1e3)):function(e){return"date"===l(e)}(e)?r[i]=function(e){function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())}(e):r[i]=t(e)?"":c(e).slice(0,1e3)}(e[n],n)}))}(e)),r},p=function(e,t){void 0===t&&(t=!1);var r=0;if(g(e)||"boolean"==typeof e)return r;for(var n=0;n<e.length;)r=(r<<5)-r+e.charCodeAt(n),r|=0,n++;return t?Math.abs(r):r},I={name:"gioABTest",method:function(t,a){var s=this;this.growingIO=t,this.timeoutCheck=function(e,t){s.requestInterval=i(Number(e))&&!n(Number(e))?Number(e):5,(s.requestInterval>1440||0>s.requestInterval)&&(s.requestInterval=5),s.requestTimeout=i(Number(t))&&!n(Number(t))?Number(t):1e3,(s.requestTimeout>5e3||100>s.requestTimeout)&&(s.requestTimeout=1e3)},this.abtStorageCheck=function(){var e,t=s.growingIO.minipInstance,r=(null===(e=t.minip)||void 0===e?void 0:e.getStorageInfoSync().keys)||[];r.filter((function(e){return f.test(e)})).forEach((function(e){var r=t.getStorageSync(e);r&&r>=Date.now()||t.removeStorageSync(e)})),r.filter((function(e){return d.test(e)})).forEach((function(e){g(t.getStorageSync(e))&&t.removeStorageSync(e)}))},this.getHashKey=function(e,t){var r=s.growingIO,n=r.userStore.getUid,i=r.vdsConfig.projectId;return p("".concat(e,"#").concat(i,"#").concat(n(),"#").concat(t),!0)},this.generateUrl=function(e,t){var n,i;i="http",r(n=t)||(n=c(n)),n.slice(0,4)!==i?s.url[e]="https://".concat(t,"/diversion/specified-layer-variables"):s.url[e]="".concat(t,"/diversion/specified-layer-variables")},this.getABTest=function(e,t,r){if(g(s.url[e])&&s.generateUrl(e,"https://ab.growingio.com"),!t)return v("获取ABTest数据失败! 实验层Id不合法!","error"),void h(r,{});var n=s.growingIO.minipInstance,i=n.getStorageSync("".concat(s.getHashKey(e,t),"_gdp_abt_sign"))||0,o=n.getStorageSync("".concat(s.getHashKey(e,t),"_gdp_abtd"))||{};!i||i<Date.now()?s.initiateRequest(e,t,o,r):h(r,o)},this.initiateRequest=function(t,r,n,i){var o=s.growingIO,a=o.userStore.getUid,c=o.dataStore,u=o.minipInstance,g=c.getTrackerVds(t),l=g.projectId,f=g.dataSourceId;u.request({url:s.url[t],header:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST",data:{accountId:l,datasourceId:f,distinctId:a(),layerId:r},timeout:s.requestTimeout,success:function(o){var a=o.data;0===a.code?s.experimentVerify(t,e(e({},a),{layerId:r}),n,i):(v("获取ABTest数据失败! ".concat(a.errorMsg,"!"),"error"),h(i,{})),u.setStorageSync("".concat(s.getHashKey(t,r),"_gdp_abt_sign"),Date.now()+6e4*s.requestInterval)},fail:function(e){var o=e.errMsg;o.indexOf("timeout")>-1?(v("获取ABTest数据失败! 请求超时!","error"),h(i,{})):2>s.retryCount?(s.initiateRequest(t,r,n,i),s.retryCount+=1):(v("获取ABTest数据失败! ".concat(JSON.stringify(o).slice(0,30),"!"),"error"),h(i,{}))}})},this.experimentVerify=function(e,t,r,n){var i=t.layerId,o=t.strategyId,a=t.experimentId,u=t.variables,g="".concat(s.getHashKey(e,i),"_gdp_abtd"),l={layerId:c(i),strategyId:c(o),experimentId:c(a),variables:u};p(JSON.stringify(l))!==p(JSON.stringify(r))&&(s.growingIO.minipInstance.setStorageSync(g,l,new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1).getTime()),o&&a&&s.buildExperimentHitEvent(e,c(i),c(a),c(o))),h(n,l)},this.buildExperimentHitEvent=function(t,r,n,i){var o,a=s.growingIO.dataStore,c=a.eventContextBuilder,u=a.eventConverter,g=e({eventType:"CUSTOM",eventName:"$exp_hit"},c(t));g.attributes=y(e(e({},null!==(o=g.attributes)&&void 0!==o?o:{}),{$exp_layer_id:r,$exp_id:n,$exp_strategy_id:i})),u(g)},this.pluginVersion="4.2.0";var l=null!=a?a:{},I=l.abServerUrl,m=void 0===I?"https://ab.growingio.com":I,S=l.requestInterval,b=l.requestTimeout;this.timeoutCheck(S,b);var w=this.growingIO.emitter;this.growingIO.getABTest=this.getABTest,w.on("OPTION_INITIALIZED",(function(){g(m)?v("如果您需要使用ABTest功能,请配置服务地址 abServerUrl!","warn"):(s.abtStorageCheck(),s.url={},r(m)?s.generateUrl(s.growingIO.trackingId,m):o(m)&&u(m).forEach((function(e){s.generateUrl(e,m[e])})))})),this.retryCount=0}};export{I as default};
@@ -1 +1 @@
1
- var r={name:"gioCompress",method:function(r){var o=this;this.growingIO=r,this.compressToUTF16=function(r){var e=o;return null===r?"":o._compress(r,15,(function(r){return e.f(r+32)}))+" "},this.f=String.fromCharCode,this._compress=function(r,o,e){if(null===r)return"";var h,s,t,f={},a={},p="",n="",u="",i=2,l=3,c=2,d=[],w=0,C=0;for(t=0;t<r.length;t+=1)if(p=r.charAt(t),{}.hasOwnProperty.call(f,p)||(f[p]=l++,a[p]=!0),n=u+p,{}.hasOwnProperty.call(f,n))u=n;else{if({}.hasOwnProperty.call(a,u)){if(256>u.charCodeAt(0)){for(h=0;c>h;h++)w<<=1,C===o-1?(C=0,d.push(e(w)),w=0):C++;for(s=u.charCodeAt(0),h=0;8>h;h++)w=w<<1|1&s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s>>=1}else{for(s=1,h=0;c>h;h++)w=w<<1|s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s=0;for(s=u.charCodeAt(0),h=0;16>h;h++)w=w<<1|1&s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s>>=1}0==--i&&(i=Math.pow(2,c),c++),delete a[u]}else for(s=f[u],h=0;c>h;h++)w=w<<1|1&s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s>>=1;0==--i&&(i=Math.pow(2,c),c++),f[n]=l++,u=p+""}if(""!==u){if({}.hasOwnProperty.call(a,u)){if(256>u.charCodeAt(0)){for(h=0;c>h;h++)w<<=1,C===o-1?(C=0,d.push(e(w)),w=0):C++;for(s=u.charCodeAt(0),h=0;8>h;h++)w=w<<1|1&s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s>>=1}else{for(s=1,h=0;c>h;h++)w=w<<1|s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s=0;for(s=u.charCodeAt(0),h=0;16>h;h++)w=w<<1|1&s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s>>=1}0==--i&&(i=Math.pow(2,c),c++),delete a[u]}else for(s=f[u],h=0;c>h;h++)w=w<<1|1&s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s>>=1;0==--i&&(i=Math.pow(2,c),c++)}for(s=2,h=0;c>h;h++)w=w<<1|1&s,C===o-1?(C=0,d.push(e(w)),w=0):C++,s>>=1;for(;;){if(w<<=1,C===o-1){d.push(e(w));break}C++}return d.join("")}}};export{r as default};
1
+ var r={name:"gioCompress",method:function(r){var o=this;this.growingIO=r,this.compressToUTF16=function(r){var e=o;return null===r?"":o._compress(r,15,(function(r){return e.f(r+32)}))+" "},this.pluginVersion="4.2.0",this.f=String.fromCharCode,this._compress=function(r,o,e){if(null===r)return"";var s,h,t,f={},a={},p="",n="",i="",u=2,l=3,c=2,d=[],w=0,C=0;for(t=0;t<r.length;t+=1)if(p=r.charAt(t),{}.hasOwnProperty.call(f,p)||(f[p]=l++,a[p]=!0),n=i+p,{}.hasOwnProperty.call(f,n))i=n;else{if({}.hasOwnProperty.call(a,i)){if(256>i.charCodeAt(0)){for(s=0;c>s;s++)w<<=1,C===o-1?(C=0,d.push(e(w)),w=0):C++;for(h=i.charCodeAt(0),s=0;8>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1}else{for(h=1,s=0;c>s;s++)w=w<<1|h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h=0;for(h=i.charCodeAt(0),s=0;16>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1}0==--u&&(u=Math.pow(2,c),c++),delete a[i]}else for(h=f[i],s=0;c>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1;0==--u&&(u=Math.pow(2,c),c++),f[n]=l++,i=p+""}if(""!==i){if({}.hasOwnProperty.call(a,i)){if(256>i.charCodeAt(0)){for(s=0;c>s;s++)w<<=1,C===o-1?(C=0,d.push(e(w)),w=0):C++;for(h=i.charCodeAt(0),s=0;8>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1}else{for(h=1,s=0;c>s;s++)w=w<<1|h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h=0;for(h=i.charCodeAt(0),s=0;16>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1}0==--u&&(u=Math.pow(2,c),c++),delete a[i]}else for(h=f[i],s=0;c>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1;0==--u&&(u=Math.pow(2,c),c++)}for(h=2,s=0;c>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1;for(;;){if(w<<=1,C===o-1){d.push(e(w));break}C++}return d.join("")}}};export{r as default};
@@ -1 +1 @@
1
- var t=function(){return t=Object.assign||function(t){for(var e,n=1,a=arguments.length;a>n;n++)for(var i in e=arguments[n])({}).hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t},t.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var e,n=/^\d{1,10}$/,a=/^_[0-9a-z]+/,i=/^_n_[0-9]+$/,r={name:"gioEventAutoTracking",method:function(r){var o=this;this.growingIO=r,this.main=function(t,n){var a,i,r=o.growingIO,l=r.vdsConfig,d=r.platformConfig,g=r.plugins,v=r.emitter,u=r.trackingId;if(!(!l.autotrack||!n||e.get(t,"currentTarget.dataset.growingIgnore")||e.get(t,"target.dataset.growingIgnore")||!e.get(t,"target.dataset.growingTrack")&&"autoplay"===e.get(t,"detail.source")||t.type===(null===(a=o.prevEvent)||void 0===a?void 0:a.type)&&10>Math.abs(Number(t.timeStamp)-Number(null===(i=o.prevEvent)||void 0===i?void 0:i.timeStamp))||l.taro&&["eh"].includes(n))){o.prevEvent=t,l.uniVue&&(n=null==g?void 0:g.gioUniAppAdapter.getHandlerName(n,t)),l.debug&&console.log("Action:",t.type,Date.now()),v.emit("ON_COMPOSE_BEFORE",{event:n,params:null!=t?t:{}});var s=d.listeners.actions;s.click.includes(t.type)?o.buildClickEvent(u,t,n):s.change.includes(t.type)&&o.buildChangeEvent(u,t,n)}},this.getNodeXpath=function(t,e){var n,r,l,d=o.growingIO,g=d.gioPlatform,v=d.vdsConfig,u=(t.currentTarget||t.target).id;return(!u||"swan"===g&&a.test(u)||(r=(n=v.taro).Current,l=n.createComponent,n&&r&&!l&&i.test(u)))&&(u=""),"".concat(u,"#").concat(e)},this.buildClickEvent=function(a,i,r){var l,d,g,v,u=o.getNodeXpath(i,r);if(u){var s=o.growingIO.dataStore,c=s.eventContextBuilder,p=s.eventInterceptor,h=i.currentTarget||i.target,m=void 0;if(e.has(null==h?void 0:h.dataset,"index")&&""!==(null===(l=null==h?void 0:h.dataset)||void 0===l?void 0:l.index)){var f=e.toString(h.dataset.index);n.test(f)&&f-0>0&&2147483647>f-0?m=+f:(v="".concat(h.dataset.index,",index标记应为 大于 0 且小于 2147483647 的整数!"),"warn",console.log("%c[GrowingIO]:".concat(v),"color: #F59E0B"))}p(t({eventType:"VIEW_CLICK",element:[{xpath:u,index:m,textValue:null===(d=null==h?void 0:h.dataset)||void 0===d?void 0:d.title,hyperlink:null===(g=null==h?void 0:h.dataset)||void 0===g?void 0:g.src}]},c(a)))}},this.buildTabClickEvent=function(n,a){var i=o.growingIO.dataStore,r=i.eventContextBuilder;(0,i.eventInterceptor)(t({eventType:"VIEW_CLICK",element:[{xpath:"#onTabItemTap",textValue:a.text,index:a.index+1,hyperlink:e.toString(a.pagePath)}]},r(n)))},this.buildChangeEvent=function(n,a,i){var r,l,d=o.getNodeXpath(a,i);if(d){var g=o.growingIO.dataStore,v=g.eventContextBuilder,u=g.eventInterceptor,s=a.currentTarget||a.target,c=t({eventType:"VIEW_CHANGE",element:{xpath:d}},v(n)),p=e.get(a,"detail.value")||e.get(a,"target.attr.value");((null===(r=null==s?void 0:s.dataset)||void 0===r?void 0:r.growingTrack)||(null===(l=null==s?void 0:s.dataset)||void 0===l?void 0:l.growingtrack))&&(e.isNil(p)||(c.element.textValue=e.toString(p))),c.element=[c.element],u(c)}},e=this.growingIO.utils,this.prevEvent={}}};export{r as default};
1
+ var t=function(){return t=Object.assign||function(t){for(var e,n=1,r=arguments.length;r>n;n++)for(var a in e=arguments[n])({}).hasOwnProperty.call(e,a)&&(t[a]=e[a]);return t},t.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var e,n=/^\d{1,10}$/,r=/^_[0-9a-z]+/,a=/^_n_[0-9]+$/,i={name:"gioEventAutoTracking",method:function(i){var o=this;this.growingIO=i,this.main=function(t,n){var r,a,i=o.growingIO,l=i.vdsConfig,g=i.platformConfig,d=i.plugins,v=i.emitter,u=i.trackingId;if(!(!l.autotrack||!n||e.get(t,"currentTarget.dataset.growingIgnore")||e.get(t,"target.dataset.growingIgnore")||!e.get(t,"target.dataset.growingTrack")&&"autoplay"===e.get(t,"detail.source")||t.type===(null===(r=o.prevEvent)||void 0===r?void 0:r.type)&&10>Math.abs(Number(t.timeStamp)-Number(null===(a=o.prevEvent)||void 0===a?void 0:a.timeStamp))||l.taro&&["eh"].includes(n))){o.prevEvent=t,l.uniVue&&(n=null==d?void 0:d.gioUniAppAdapter.getHandlerName(n,t)),l.debug&&console.log("Action:",t.type,Date.now()),v.emit("ON_COMPOSE_BEFORE",{event:n,params:null!=t?t:{}});var s=g.listeners.actions;s.click.includes(t.type)?o.buildClickEvent(u,t,n):s.change.includes(t.type)&&o.buildChangeEvent(u,t,n)}},this.getNodeXpath=function(t,e){var n,i,l,g=o.growingIO,d=g.gioPlatform,v=g.vdsConfig,u=(t.currentTarget||t.target).id;return(!u||"swan"===d&&r.test(u)||(i=(n=v.taro).Current,l=n.createComponent,n&&i&&!l&&a.test(u)))&&(u=""),"".concat(u,"#").concat(e)},this.buildClickEvent=function(r,a,i){var l,g,d,v,u=o.getNodeXpath(a,i);if(u){var s=o.growingIO.dataStore,c=s.eventContextBuilder,p=s.eventInterceptor,h=s.eventHooks,m=a.currentTarget||a.target,f=void 0;if(e.has(null==m?void 0:m.dataset,"index")&&""!==(null===(l=null==m?void 0:m.dataset)||void 0===l?void 0:l.index)){var E=e.toString(m.dataset.index);n.test(E)&&E-0>0&&2147483647>E-0?f=+E:(v="".concat(m.dataset.index,",index标记应为 大于 0 且小于 2147483647 的整数!"),"warn",console.log("%c[GrowingIO]:".concat(v),"color: #F59E0B"))}var I=t({eventType:"VIEW_CLICK",element:[{xpath:u,index:f,textValue:null===(g=null==m?void 0:m.dataset)||void 0===g?void 0:g.title,hyperlink:null===(d=null==m?void 0:m.dataset)||void 0===d?void 0:d.src}]},c(r));I.attributes=h.currentPage.eventSetPageProps(r,I),p(I)}},this.buildTabClickEvent=function(n,r){var a=o.growingIO.dataStore,i=a.eventContextBuilder,l=a.eventInterceptor,g=a.eventHooks,d=t({eventType:"VIEW_CLICK",element:[{xpath:"#onTabItemTap",textValue:r.text,index:r.index+1,hyperlink:e.toString(r.pagePath)}]},i(n));d.attributes=g.currentPage.eventSetPageProps(n,d),l(d)},this.buildChangeEvent=function(n,r,a){var i,l,g=o.getNodeXpath(r,a);if(g){var d=o.growingIO.dataStore,v=d.eventContextBuilder,u=d.eventInterceptor,s=d.eventHooks,c=r.currentTarget||r.target,p=t({eventType:"VIEW_CHANGE",element:{xpath:g}},v(n)),h=e.get(r,"detail.value")||e.get(r,"target.attr.value");((null===(i=null==c?void 0:c.dataset)||void 0===i?void 0:i.growingTrack)||(null===(l=null==c?void 0:c.dataset)||void 0===l?void 0:l.growingtrack))&&(e.isNil(h)||(p.element.textValue=e.toString(h))),p.element=[p.element],p.attributes=s.currentPage.eventSetPageProps(n,p),u(p)}},this.pluginVersion="4.2.0",e=this.growingIO.utils,this.prevEvent={}}};export{i as default};
@@ -1 +1 @@
1
- var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t,r=/^gioTrack(.+)/,n=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,i=function(e){return["undefined","null"].includes(l(e))},o=function(e){return"string"===l(e)},s=function(e){return"[object Object]"==={}.toString.call(e)&&!i(e)},a=function(e){return Array.isArray(e)&&"array"===l(e)},c=function(e){return i(e)?"":"".concat(e)},u=function(e){return a(e)?0===e.length:s(e)?0===function(e){return s(e)?Object.keys(e):[]}(e).length:!e},l=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},g=function(e){try{return e()}catch(e){return}},d=function(e,t){void 0===t&&(t=!1);var r=0;if(u(e)||"boolean"==typeof e)return r;for(var n=0;n<e.length;)r=(r<<5)-r+e.charCodeAt(n),r|=0,n++;return t?Math.abs(r):r},p={name:"gioImpressionTracking",method:function(i){var s=this;this.growingIO=i,this.traverseListen=function(e){var r=s.growingIO.minipInstance;if(t.isFunction(null==e?void 0:e.selectAllComponents)){var n=null==e?void 0:e.selectAllComponents(".growing_collect_imp_component");t.isEmpty(n)||n.forEach((function(e){s.traverseListen(e)}))}r.initImpression(e)},this.isEqualRects=function(e,t,r){var n,i,o,c,u=(null!==(i=(null!==(n=s.rects[t])&&void 0!==n?n:{})[r])&&void 0!==i?i:[]).map((function(e){return d(JSON.stringify(e))})),l=(null!=e?e:[]).map((function(e){return d(JSON.stringify(e))}));return c=l,!(!a(o=u)||!a(c)||o.length!==c.length)&&o.every((function(e,t){return e===c[t]}))},this.getNodeId=function(e){switch(s.growingIO.gioPlatform){case"wx":case"qq":case"ks":case"jd":return e.__wxExparserNodeId__;case"my":case"tb":return e.$page?"".concat(e.$page.$id,"-").concat(e.$id):e.$id;case"swan":return e.route?c(d(e.route)):e.nodeId;case"tt":return e.route?c(d(e.route)):e.__nodeId__}},this.rectobserve=function(e,r,n){var i=s.growingIO.gioPlatform;if("tt"===i&&r.__nodeId__||"ks"===i&&r.is)return!1;var o=s.getNodeId(r),a=r.route?r:s.growingIO.minipInstance.getCurrentPage(),c=!1;if(a.route){var u=s.isEqualRects(e,a.route,o),l=t.get(s.observerIds,"".concat(a.route,".").concat(o,"._disconnected"));c=!u||!1!==l}t.isArray(e)&&!t.isEmpty(e)&&!t.isNil(e[0])&&c&&(t.isEmpty(s.rects[a.route])&&(s.rects[a.route]={}),s.rects[a.route][o]=e,s.creatObserver(r,n))},this.main=function(e,r){var n,i,o=s.growingIO.gioPlatform,a=e.route?null===(n=s.growingIO.minipInstance.minip)||void 0===n?void 0:n.createSelectorQuery():null===(i=s.growingIO.minipInstance.minip)||void 0===i?void 0:i.createSelectorQuery().in(e);["ks","qq"].includes(o)?(a.selectAll(".growing_collect_imp").boundingClientRect((function(n){var i=n[0],o=void 0===i?[]:i;o=t.isArray(o)?o:[o],u(o)||s.rectobserve(o,e,r)})),a.exec()):(a.selectAll(".growing_collect_imp").boundingClientRect(),a.exec((function(t){var n=t[0];u(n)||s.rectobserve(n,e,r)})))},this.creatObserver=function(e,r){var n,i,o=s.growingIO,a=o.gioPlatform,c=o.minipInstance,u=((n={})[r]=!0,n);["tb","my"].includes(a)&&t.compareVersion(my.SDKVersion,"2.7.0")>=-1&&(u.dataset=!0);var l=s.getNodeId(e),g=e;!e.isComponent&&e.route&&"component"!==e.mpType||(g=c.getCurrentPage()),s.observerIds[g.route]||(s.observerIds[g.route]={});var d=s.observerIds[g.route][l];d&&!d._disconnected&&d.disconnect();var p=["swan","jd"].includes(a)?null===(i=c.minip)||void 0===i?void 0:i.createIntersectionObserver(e,u):e.createIntersectionObserver(u);p=p.relativeToViewport(),s.observerIds[g.route][l]=p,s.targetObserve(p,g)},this.targetObserve=function(e,r){var n=s.growingIO.vdsConfig.taro;e.observe(".growing_collect_imp",(function(e){if(!t.isEmpty(e)&&e.intersectionRatio>0){var i=e.dataset;n&&t.isTaro3(n)&&(i=s.getTaro3Dataset(r.route,e.id));var c=s.getImpressionProperties(i),l=e.id;if(l){if("once"===i.gioImpType&&t.has(s.sentImps,l))return;s.sentImps[l]=c}if(c.eventName){var d=[];i.gioImpSendto&&(d=function(e,t){if(void 0===t&&(t=!1),a(e)){for(var r=0,n=[],i=0,o=e;i<o.length;i++){var s=o[i];s&&!u(s)&&(n[r++]=s),t&&0===s&&(n[r++]=s)}return n}return e}(a(i.gioImpSendto)?i.gioImpSendto:g((function(){return JSON.parse(i.gioImpSendto)}))||[]),u(d)&&g((function(){return i.gioImpSendto.split(",").forEach((function(e){(e=o(e)&&e.trim().replace("[","").replace("]",""))&&d.push(e)}))}))),s.buildImpEvent(c,d)}else t.consoleText("曝光事件格式不正确,事件名只能包含数字、字母和下划线,且不以数字开头!","warn")}}))},this.getImpressionProperties=function(e){var i,s,a={eventName:void 0,properties:{}};if(!(null==e?void 0:e.gioImpTrack))return a;if(a.eventName=e.gioImpTrack,t.has(e,"gioImpAttrs"))a.properties=t.niceTry((function(){return t.isObject(e.gioImpAttrs)?e.gioImpAttrs:JSON.parse(e.gioImpAttrs)}));else for(var c in e){var l=void 0,g=c.match(r);g&&"track"!==(l=t.lowerFirst(g[1]))&&(a.properties[l]=e[c])}return a.properties=t.limitObject(a.properties),i=a.eventName,s=function(){return a},(o(i)&&!u(i)&&i.match(n)?s():(console.log("%c[GrowingIO]:事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","color: #EF4444"),!1))||(a.eventName=null,a={}),a},this.getTaro3Dataset=function(e,r){var n,i=null===(n=s.growingIO)||void 0===n?void 0:n.taro3VMs[e];if(!i)return!1;var o={},a=function(e){e.some((function(e){var n;return e.uid!==r&&e.sid!==r||-1>=(null===(n=e.props)||void 0===n?void 0:n.class.indexOf("growing_collect_imp"))||t.isEmpty(e.dataset)?!!Array.isArray(e.childNodes)&&a(e.childNodes):(o=e.dataset,!0)}))};return a(i.childNodes),o},this.buildImpEvent=function(t,r){var n=t.eventName,i=t.properties,o=s.growingIO,a=o.trackingId,c=o.dataStore,l=c.eventContextBuilder,g=c.eventConverter,d=o.plugins,p=e({eventType:"CUSTOM",eventName:n,attributes:i},l(a));d.gioMultipleInstances&&!u(r)&&(p["&&sendTo"]=r),g(p)},t=this.growingIO.utils,this.observerIds={},this.rects={},this.sentImps={};var l=this.growingIO,p=l.emitter,v=l.minipInstance;this.growingIO.updateImpression=function(e){e||(e=v.getCurrentPage()),v.initImpression(e)},p.on("MINIP_LIFECYCLE",(function(e){var t,r=e.event,n=e.params,i=s.growingIO.minipInstance;if("Page onShowEnd"===r){var o=i.getCurrentPage();s.traverseListen(o)}if(["Page onHide","Page onUnload"].includes(r)){var a=n.page.route;Object.values(null!==(t=s.observerIds[a])&&void 0!==t?t:{}).forEach((function(e){return e.disconnect()}))}}))}};export{p as default};
1
+ var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t,r=/^gioTrack(.+)/,n=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,i=function(e){return["undefined","null"].includes(p(e))},o=function(e){return"string"===p(e)},s=function(e){return"[object Object]"==={}.toString.call(e)&&!i(e)},c=function(e){return Array.isArray(e)&&"array"===p(e)},a=function(e,t){if(void 0===t&&(t=!1),c(e)){for(var r=0,n=[],i=0,o=e;i<o.length;i++){var s=o[i];s&&!d(s)&&(n[r++]=s),t&&0===s&&(n[r++]=s)}return n}return e},u=function(e){return i(e)?"":"".concat(e)},l=function(e){return s(e)?Object.keys(e):[]},g=function(e,t){if(!s(e))return!1;try{if("string"===p(t))return delete e[t];if("array"===p(t))return t.map((function(t){return delete e[t]}));"object"===p(t)&&t.constructor===RegExp&&l(e).forEach((function(r){t.test(r)&&g(e,r)}))}catch(e){return!1}},d=function(e){return c(e)?0===e.length:s(e)?0===l(e).length:!e},p=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},v=function(e){try{return e()}catch(e){return}},f=function(e){var t={};return s(e)&&(g(e,"&&sendTo"),function(e,r){l(e).forEach((function(r){return function(e,r){var n=u(r).slice(0,100);s(e)?t[n]=f(e):c(e)?(t[n]=a(e.slice(0,100),!0),t[n]=t[n].join("||").slice(0,1e3)):function(e){return"date"===p(e)}(e)?t[n]=function(e){function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())}(e):t[n]=i(e)?"":u(e).slice(0,1e3)}(e[r],r)}))}(e)),t},m=function(e,t){void 0===t&&(t=!1);var r=0;if(d(e)||"boolean"==typeof e)return r;for(var n=0;n<e.length;)r=(r<<5)-r+e.charCodeAt(n),r|=0,n++;return t?Math.abs(r):r},I={name:"gioImpressionTracking",method:function(i){var l=this;this.growingIO=i,this.traverseListen=function(e){var r=l.growingIO.minipInstance;if(t.isFunction(null==e?void 0:e.selectAllComponents)){var n=null==e?void 0:e.selectAllComponents(".growing_collect_imp_component");t.isEmpty(n)||n.forEach((function(e){l.traverseListen(e)}))}r.initImpression(e)},this.isEqualRects=function(e,t,r){var n,i,o,s,a=(null!==(i=(null!==(n=l.rects[t])&&void 0!==n?n:{})[r])&&void 0!==i?i:[]).map((function(e){return m(JSON.stringify(e))})),u=(null!=e?e:[]).map((function(e){return m(JSON.stringify(e))}));return s=u,!(!c(o=a)||!c(s)||o.length!==s.length)&&o.every((function(e,t){return e===s[t]}))},this.getNodeId=function(e){switch(l.growingIO.gioPlatform){case"wx":case"qq":case"ks":case"jd":return e.__wxExparserNodeId__;case"my":case"tb":return e.$page?"".concat(e.$page.$id,"-").concat(e.$id):e.$id;case"swan":return e.route?u(m(e.route)):e.nodeId;case"tt":return e.route?u(m(e.route)):e.__nodeId__}},this.rectobserve=function(e,r,n){var i=l.growingIO.gioPlatform;if("tt"===i&&r.__nodeId__||"ks"===i&&r.is)return!1;var o=l.getNodeId(r),s=r.route?r:l.growingIO.minipInstance.getCurrentPage(),c=!1;if(s.route){var a=l.isEqualRects(e,s.route,o),u=t.get(l.observerIds,"".concat(s.route,".").concat(o,"._disconnected"));c=!a||!1!==u}t.isArray(e)&&!t.isEmpty(e)&&!t.isNil(e[0])&&c&&(t.isEmpty(l.rects[s.route])&&(l.rects[s.route]={}),l.rects[s.route][o]=e,l.creatObserver(r,n))},this.main=function(e,r){var n,i,o=l.growingIO.gioPlatform,s=e.route?null===(n=l.growingIO.minipInstance.minip)||void 0===n?void 0:n.createSelectorQuery():null===(i=l.growingIO.minipInstance.minip)||void 0===i?void 0:i.createSelectorQuery().in(e);["ks","qq"].includes(o)?(s.selectAll(".growing_collect_imp").boundingClientRect((function(n){var i=n[0],o=void 0===i?[]:i;o=t.isArray(o)?o:[o],d(o)||l.rectobserve(o,e,r)})),s.exec()):(s.selectAll(".growing_collect_imp").boundingClientRect(),s.exec((function(t){var n=t[0];d(n)||l.rectobserve(n,e,r)})))},this.creatObserver=function(e,r){var n,i,o=l.growingIO,s=o.gioPlatform,c=o.minipInstance,a=((n={})[r]=!0,n);["tb","my"].includes(s)&&t.compareVersion(my.SDKVersion,"2.7.0")>=-1&&(a.dataset=!0);var u=l.getNodeId(e),g=e;!e.isComponent&&e.route&&"component"!==e.mpType||(g=c.getCurrentPage()),l.observerIds[g.route]||(l.observerIds[g.route]={});var d=l.observerIds[g.route][u];d&&!d._disconnected&&d.disconnect();var p=["swan","jd"].includes(s)?null===(i=c.minip)||void 0===i?void 0:i.createIntersectionObserver(e,a):e.createIntersectionObserver(a);p=p.relativeToViewport(),l.observerIds[g.route][u]=p,l.targetObserve(p,g)},this.targetObserve=function(e,r){var n=l.growingIO.vdsConfig.taro;e.observe(".growing_collect_imp",(function(e){if(!t.isEmpty(e)&&e.intersectionRatio>0){var i=e.dataset;n&&t.isTaro3(n)&&(i=l.getTaro3Dataset(r.route,e.id));var s=l.getImpressionProperties(i),u=e.id;if(u){if("once"===i.gioImpType&&t.has(l.sentImps,u))return;l.sentImps[u]=s}if(s.eventName){var g=[];i.gioImpSendto&&(g=a(c(i.gioImpSendto)?i.gioImpSendto:v((function(){return JSON.parse(i.gioImpSendto)}))||[]),d(g)&&v((function(){return i.gioImpSendto.split(",").forEach((function(e){(e=o(e)&&e.trim().replace("[","").replace("]",""))&&g.push(e)}))}))),l.buildImpEvent(s,g)}else t.consoleText("曝光事件格式不正确,事件名只能包含数字、字母和下划线,且不以数字开头!","warn")}}))},this.getImpressionProperties=function(e){var i,s,c={eventName:void 0,properties:{}};if(!(null==e?void 0:e.gioImpTrack))return c;if(c.eventName=e.gioImpTrack,t.has(e,"gioImpAttrs"))c.properties=t.niceTry((function(){return t.isObject(e.gioImpAttrs)?e.gioImpAttrs:JSON.parse(e.gioImpAttrs)}));else for(var a in e){var u=void 0,l=a.match(r);l&&"track"!==(u=t.lowerFirst(l[1]))&&(c.properties[u]=e[a])}return c.properties=t.limitObject(c.properties),i=c.eventName,s=function(){return c},(o(i)&&!d(i)&&i.match(n)?s():(console.log("%c[GrowingIO]:事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","color: #EF4444"),!1))||(c.eventName=null,c={}),c},this.getTaro3Dataset=function(e,r){var n,i=null===(n=l.growingIO)||void 0===n?void 0:n.taro3VMs[e];if(!i)return!1;var o={},s=function(e){e.some((function(e){var n;return e.uid!==r&&e.sid!==r||-1>=(null===(n=e.props)||void 0===n?void 0:n.class.indexOf("growing_collect_imp"))||t.isEmpty(e.dataset)?!!Array.isArray(e.childNodes)&&s(e.childNodes):(o=e.dataset,!0)}))};return s(i.childNodes),o},this.buildImpEvent=function(t,r){var n,i=t.eventName,o=t.properties,c=l.growingIO,a=c.trackingId,u=c.dataStore,g=u.eventContextBuilder,p=u.eventConverter,v=c.plugins,m=e({eventType:"CUSTOM",eventName:i},g(a));m.attributes=f(e(e({},null!==(n=m.attributes)&&void 0!==n?n:{}),s(o)&&!d(o)?o:{})),v.gioMultipleInstances&&!d(r)&&(m["&&sendTo"]=r),p(m)},this.pluginVersion="4.2.0",t=this.growingIO.utils,this.observerIds={},this.rects={},this.sentImps={};var g=this.growingIO,p=g.emitter,I=g.minipInstance;this.growingIO.updateImpression=function(e){e||(e=I.getCurrentPage()),I.initImpression(e)},p.on("MINIP_LIFECYCLE",(function(e){var t,r=e.event,n=e.params,i=l.growingIO.minipInstance;if("Page onShowEnd"===r){var o=i.getCurrentPage();l.traverseListen(o)}if(["Page onHide","Page onUnload"].includes(r)){var s=n.page.route;Object.values(null!==(t=l.observerIds[s])&&void 0!==t?t:{}).forEach((function(e){return e.disconnect()}))}}))}};export{I as default};
@@ -1 +1 @@
1
- var n=function(){return n=Object.assign||function(n){for(var r,t=1,i=arguments.length;i>t;t++)for(var e in r=arguments[t])({}).hasOwnProperty.call(r,e)&&(n[e]=r[e]);return n},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r=function(n){return"[object Object]"==={}.toString.call(n)&&!function(n){return["undefined","null"].includes(i(n))}(n)},t=function(n,e){if(!r(n))return!1;try{if("string"===i(e))return delete n[e];if("array"===i(e))return e.map((function(r){return delete n[r]}));"object"===i(e)&&e.constructor===RegExp&&function(n){return r(n)?Object.keys(n):[]}(n).forEach((function(r){e.test(r)&&t(n,r)}))}catch(n){return!1}},i=function(n){return{}.toString.call(n).slice(8,-1).toLowerCase()},e=function(n){try{return n()}catch(n){return}},o=function(){var n;return null!==(n=e((function(){return $global})))&&void 0!==n?n:global},a=function(r){var a=this;this.growingIO=r,this.getTrackerType=function(n,r){return r.trackingId&&r.trackingId!==n?0:1},this.rewriteDataStore=function(){a.growingIO.dataStore.getTrackerVds=function(r){if(a.growingIO.trackingId===r){var i=n({},a.growingIO.vdsConfig);return t(i,"subInstance"),a.growingIO.plugins.gioTaobaoAdapter||t(i,"tbConfig"),i}return a.growingIO.subInstance[r]?n({},a.growingIO.subInstance[r]):void 0},a.growingIO.dataStore.initTrackerOptions=function(n){var r,i=a.growingIO.dataStore.initOptions(n),e=a.getTrackerType(n.trackingId,a.growingIO);return i.trackingId=n.trackingId,e?(a.growingIO.trackingId=n.trackingId,a.growingIO.vdsConfig=i,o().vdsConfig=i):(t(i,["autotrack","debug","forceLogin","keepAlive","originalSource","performance","pluginMode","taro","taroVue","tbConfig","uniVue"]),a.growingIO.subInstance[n.trackingId]=i,(null===(r=o().vdsConfig)||void 0===r?void 0:r.subInstance)||(o().vdsConfig.subInstance={}),o().vdsConfig.subInstance[n.trackingId]=i),i},a.growingIO.dataStore.initTrackerHooker=function(n){var r,t;if(a.getTrackerType(n.trackingId,a.growingIO)){var i=a.growingIO,e=i.platformConfig,o=i.inPlugin,g=i.minipInstance,c=i.plugins,u=i.dataStore,s=n.uniVue,I=n.taro;s||I||(e.canHook=!0),o&&!["tbp","jdp"].includes(g.platform)||u.eventHooks.initEventHooks(),s&&(null===(r=null==c?void 0:c.gioUniAppAdapter)||void 0===r||r.main()),I&&(null===(t=null==c?void 0:c.gioTaroAdapter)||void 0===t||t.main())}};var r=a.growingIO.dataStore.eventConverter,g=a;a.growingIO.dataStore.eventConverter=function(){for(var o=this,a=[],c=0;arguments.length>c;c++)a[c]=arguments[c];var u=a[0];if("CUSTOM"===u.eventType){var s=[u.trackingId];e((function(){u["&&sendTo"].forEach((function(n){"string"===i(n)&&g.growingIO.dataStore.getTrackerVds(n)&&!s.includes(n)&&s.push(n)}))})),t(u,"&&sendTo"),s.forEach((function(t){var i=g.growingIO.dataStore.eventContextBuilder;r.call(o,n(n({},u),i(t)))}))}else r.call(this,u)}},this.onSendBefore=function(n){var r=n.eventsQueue,t=n.requestData;n.trackingId!==a.growingIO.trackingId&&a.growingIO.uploader.sendEvent(r,t)},this.subTrackingIds=[],this.growingIO.emitter.on("ON_SDK_INITIALIZE_BEFORE",(function(){a.growingIO.trackingId||a.rewriteDataStore(),a.growingIO.subInstance||(a.growingIO.subInstance={})})),this.growingIO.emitter.on("OPTION_INITIALIZED",(function(n){var r=n.trackingId;a.growingIO.trackingId&&a.growingIO.trackingId!==r&&a.subTrackingIds.push(r)}))},g={name:"gioMultipleInstances",method:a};export{a as GioMultipleInstances,g as default};
1
+ var n=function(){return n=Object.assign||function(n){for(var r,t=1,i=arguments.length;i>t;t++)for(var e in r=arguments[t])({}).hasOwnProperty.call(r,e)&&(n[e]=r[e]);return n},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r=function(n){return"[object Object]"==={}.toString.call(n)&&!function(n){return["undefined","null"].includes(i(n))}(n)},t=function(n,e){if(!r(n))return!1;try{if("string"===i(e))return delete n[e];if("array"===i(e))return e.map((function(r){return delete n[r]}));"object"===i(e)&&e.constructor===RegExp&&function(n){return r(n)?Object.keys(n):[]}(n).forEach((function(r){e.test(r)&&t(n,r)}))}catch(n){return!1}},i=function(n){return{}.toString.call(n).slice(8,-1).toLowerCase()},e=function(n){try{return n()}catch(n){return}},o=function(){var n;return null!==(n=e((function(){return $global})))&&void 0!==n?n:global},a=function(r){var a=this;this.growingIO=r,this.getTrackerType=function(n,r){return r.trackingId&&r.trackingId!==n?0:1},this.rewriteDataStore=function(){a.growingIO.dataStore.getTrackerVds=function(r){if(a.growingIO.trackingId===r){var i=n({},a.growingIO.vdsConfig);return t(i,"subInstance"),a.growingIO.plugins.gioTaobaoAdapter||t(i,"tbConfig"),i}return a.growingIO.subInstance[r]?n({},a.growingIO.subInstance[r]):void 0},a.growingIO.dataStore.initTrackerOptions=function(n){var r,i=a.growingIO.dataStore.initOptions(n),e=a.getTrackerType(n.trackingId,a.growingIO);return i.trackingId=n.trackingId,e?(a.growingIO.trackingId=n.trackingId,a.growingIO.vdsConfig=i,o().vdsConfig=i):(t(i,["autotrack","debug","forceLogin","keepAlive","originalSource","performance","pluginMode","taro","taroVue","tbConfig","uniVue"]),a.growingIO.subInstance[n.trackingId]=i,(null===(r=o().vdsConfig)||void 0===r?void 0:r.subInstance)||(o().vdsConfig.subInstance={}),o().vdsConfig.subInstance[n.trackingId]=i),i},a.growingIO.dataStore.initTrackerHooker=function(n){var r,t;if(a.getTrackerType(n.trackingId,a.growingIO)){var i=a.growingIO,e=i.platformConfig,o=i.inPlugin,g=i.minipInstance,u=i.plugins,c=i.dataStore,s=n.uniVue,d=n.taro;s||d||(e.canHook=!0),o&&!["tbp","jdp"].includes(g.platform)||c.eventHooks.initEventHooks(),s&&(null===(r=null==u?void 0:u.gioUniAppAdapter)||void 0===r||r.main()),d&&(null===(t=null==u?void 0:u.gioTaroAdapter)||void 0===t||t.main())}};var r=a.growingIO.dataStore.eventConverter,g=a;a.growingIO.dataStore.eventConverter=function(){for(var o=this,a=[],u=0;arguments.length>u;u++)a[u]=arguments[u];var c=a[0];if("CUSTOM"===c.eventType){var s=[c.trackingId];e((function(){c["&&sendTo"].forEach((function(n){"string"===i(n)&&g.growingIO.dataStore.getTrackerVds(n)&&!s.includes(n)&&s.push(n)}))})),t(c,"&&sendTo"),s.forEach((function(t){var i=g.growingIO.dataStore.eventContextBuilder,e=n(n({},c),i(t,void 0,c.trackingId!==t));e.attributes=n(n({},e.attributes),c.attributes),r.call(o,e)}))}else r.call(this,c)}},this.onSendBefore=function(n){var r=n.eventsQueue,t=n.requestData;n.trackingId!==a.growingIO.trackingId&&a.growingIO.uploader.sendEvent(r,t)},this.pluginVersion="4.2.0",this.subTrackingIds=[],this.growingIO.emitter.on("ON_SDK_INITIALIZE_BEFORE",(function(){a.growingIO.trackingId||a.rewriteDataStore(),a.growingIO.subInstance||(a.growingIO.subInstance={})})),this.growingIO.emitter.on("OPTION_INITIALIZED",(function(n){var r=n.trackingId;a.growingIO.trackingId&&a.growingIO.trackingId!==r&&a.subTrackingIds.push(r)}))},g={name:"gioMultipleInstances",method:a};export{a as GioMultipleInstances,g as default};