gio-miniprogram-sdk 4.3.0 → 4.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/alipay.js +1 -1
- package/dist/baidu.js +1 -1
- package/dist/bytedance.js +1 -1
- package/dist/jingdong.js +1 -1
- package/dist/kuaishou.js +1 -1
- package/dist/plugins/gioABTest.js +1 -1
- package/dist/plugins/gioCompress.js +1 -1
- package/dist/plugins/gioEventAutoTracking.js +1 -1
- package/dist/plugins/gioImpressionTracking.js +1 -1
- package/dist/plugins/gioMultipleInstances.js +1 -1
- package/dist/qq.js +1 -1
- package/dist/quickapp.js +1 -1
- package/dist/taobao.js +1 -1
- package/dist/taro.js +1 -1
- package/dist/uniapp.js +1 -1
- package/dist/wechat.js +1 -1
- package/package.json +1 -1
- package/src/constants/config.ts +5 -1
- package/src/core/dataStore/eventContextBuilder.ts +1 -1
- package/src/core/dataStore/eventHooks/appEffects.ts +3 -15
- package/src/core/dataStore/eventHooks/minipPage.ts +19 -17
- package/src/core/dataStore/eventHooks/pageEffects.ts +8 -0
- package/src/core/dataStore/index.ts +50 -10
- package/src/core/growingIO.ts +3 -4
- package/src/core/userStore.ts +26 -0
- package/src/minipInstance/base.ts +4 -4
- package/src/minipInstance/my.ts +1 -1
- package/src/minipInstance/tb.ts +1 -1
- package/src/plugins/gioABTest.ts +54 -33
- package/src/plugins/gioImpressionTracking.ts +14 -10
- package/src/plugins/gioMultipleInstances.ts +2 -0
- package/src/types/base.ts +4 -0
- package/src/types/eventHooks.ts +3 -2
- package/src/types/userStore.ts +2 -0
package/dist/taro.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,t=/^__reactProps\$[a-z0-9]+$/i,i=/return [$\w]+.\w+\(/,n=/return \w+\(/,s=/return [$\w]+.\$emit\(['"]\w+/,r=/return [$\w]+.\w+/,o=/return [$\w]+/,a=e=>["undefined","null"].includes(q(e)),l=e=>"string"===q(e),g=e=>"number"===q(e),u=e=>"boolean"===q(e),c=e=>"[object Object]"==={}.toString.call(e)&&!a(e),d=e=>["function","asyncfunction"].includes(q(e)),h=e=>Array.isArray(e)&&"array"===q(e),p=e=>"date"===q(e),v=e=>{try{return Array.from(e)[0]}catch(e){return}},m=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},f=(e,t=1)=>h(e)&&g(t)?e.slice(t>0?t:1,e.length):e,I=(e,t=!1)=>{if(h(e)){let i=0;const n=[];for(const s of e)s&&!A(s)&&(n[i++]=s),t&&0===s&&(n[i++]=s);return n}return e},O=(e,t)=>{if(h(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},y=e=>a(e)?"":""+e,S=(e,t)=>"string"===q(e)?e.split(t):e,b=e=>{if(l(e)){const t=S(e,"");return`${v(t).toLowerCase()}${f(t).join("")}`}return e},w=(e,t)=>(l(e)||(e=y(e)),e.slice(0,t.length)===t),P={}.hasOwnProperty,T=(e,t)=>!a(e)&&P.call(e,t),k=e=>c(e)?Object.keys(e):[],_=(e,t)=>{k(e).forEach((i=>t(e[i],i)))},E=(e,t)=>{const i=k(e);return!(!c(e)||!c(t)||i.length!==k(t).length||i.map(((i,n)=>c(e[i])?E(e[i],t[i]):e[i]===t[i])).includes(!1))},C=(e,t,i)=>{let n=e;return c(e)?(t.split(".").forEach((e=>{n=n?n[e]:i})),n):i},x=(e,t)=>{if(!c(e))return!1;try{if("string"===q(t))return delete e[t];if("array"===q(t))return t.map((t=>delete e[t]));"object"===q(t)&&t.constructor===RegExp&&k(e).forEach((i=>{t.test(i)&&x(e,i)}))}catch(e){return!1}},j=(e,t=250,i,n)=>{let s,r=0;return"boolean"!==q(i)&&(n=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function g(){r=Date.now(),e.apply(a,o)}n&&!s&&g(),s&&clearTimeout(s),void 0===n&&l>t?g():!0!==i&&(s=setTimeout(n?function(){s=void 0}:g,void 0===n?t-l:t))}},A=e=>h(e)?0===e.length:c(e)?0===k(e).length:!e,q=e=>({}.toString.call(e).slice(8,-1).toLowerCase()),N=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())};var U=Object.freeze({__proto__:null,isNil:a,isString:l,isNaN:e=>"NaN"===y(Number(e)),isNumber:g,isBoolean:u,isObject:c,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:d,isArray:h,isDate:p,fixed:(e,t)=>g(e)?Number(e.toFixed(g(t)?t:2)):l(e)&&"NaN"!==y(Number(e))?Number(Number(e).toFixed(g(t)?t:2)):e,head:v,last:m,drop:f,dropWhile:(e,t)=>h(e)?e.filter((e=>!t(e))):e,compact:I,find:O,isEqualArray:(e,t)=>!(!h(e)||!h(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:y,split:S,lowerFirst:b,upperFirst:e=>{if(l(e)){const t=S(e,"");return`${v(t).toUpperCase()}${f(t).join("")}`}return e},startsWith:w,endsWith:(e,t)=>{const{length:i}=e;let n=i;n>i&&(n=i);const s=n;return n-=t.length,n>=0&&e.slice(n,s)===t},hasOwnProperty:P,has:T,keys:k,forEach:_,isEqual:E,get:C,unset:x,throttle:j,isEmpty:A,typeOf:q,formatDate:N});const H=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},V=(e,t=!0,i="参数不合法")=>H(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),F=e=>{try{return e()}catch(e){return}},K=(e,t)=>{if(d(e))try{e(t)}catch(e){H("回调执行失败!"+e,"error")}},$=e=>l(e)?e.trim().substring(0,100):e,L=(t,i)=>l(t)&&!A(t)&&t.match(e)?i():(H("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),D=e=>(a(e)||k(e).forEach((t=>{d(e[t])?e[t]=F((()=>e[t]())):c(e[t])?x(e,t):h(e[t])||(e[t]=y(e[t]))})),e),R=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),M=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,B=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,G=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},Q=e=>{if(l(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},z=e=>l(e)?e.startsWith("/")?e:"/"+e:"",W=e=>F((()=>{switch(e){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 e;return e||(e=F((()=>swan))),e||(e=F((()=>my))),e||(e=F((()=>tt))),e||(e=F((()=>qq))),e||(e=F((()=>ks))),e||(e=F((()=>jd))),e||(e=F((()=>wx))),e}}})),J=e=>F((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return F((()=>__ttConfig))||(null===global||void 0===global?void 0:global.TMAConfig)||(null===globalThis||void 0===globalThis?void 0:globalThis.TMAConfig);case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),Y=()=>{let e;return!e&&F((()=>swan))&&(e="swan"),!e&&F((()=>tt))&&(e="tt"),!e&&F((()=>qq))&&(e="qq"),!e&&F((()=>my.tb))&&(e="tb"),!e&&F((()=>my))&&(e="my"),!e&&F((()=>ks))&&(e="ks"),!e&&F((()=>jd))&&(e="jd"),!e&&F((()=>wx))&&(e="wx"),e||O(k(global),(e=>y(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},Z=()=>{var e;return null!==(e=F((()=>{var e;return null!==(e=F((()=>{var e;return null!==(e=F((()=>$global)))&&void 0!==e?e:global})))&&void 0!==e?e:window})))&&void 0!==e?e:globalThis},X=e=>{const t={};return c(e)&&(x(e,"&&sendTo"),_(e,((e,i)=>{const n=y(i).slice(0,100);c(e)?t[n]=X(e):h(e)?(t[n]=I(e.slice(0,100),!0),t[n]=t[n].join("||").slice(0,1e3)):p(e)?t[n]=N(e):t[n]=a(e)?"":y(e).slice(0,1e3)}))),t},ee=(e,t)=>{const i=()=>t.map((t=>e.getStorageSync(t)));try{return e.minip.canIUse("batchGetStorageSync")?e.minip.batchGetStorageSync(t):i()}catch(e){return i()}},te=(e,t)=>{const i=()=>t.map((({key:t,value:i})=>e.setStorageSync(t,i)));try{return e.minip.canIUse("batchSetStorageSync")?e.minip.batchSetStorageSync(t):i()}catch(e){return i()}},ie=e=>k(e||{}).map((t=>t?`${t}=${a(e[t])?"":e[t]}`:"")).join("&"),ne=e=>{(w(e,"?")||w(e,"&"))&&(e=e.slice(1,e.length));const t={};return e.split("&").forEach((e=>{const i=e.split("=");i[0]&&(t[i[0]]=i[1])})),t},se=(e={},t={})=>{const i={};return k(t).forEach((e=>{["string","number","boolean"].includes(q(t[e]))&&(i[e]=t[e])})),Object.assign({},i,e)};var re=Object.freeze({__proto__:null,consoleText:H,callError:V,niceTry:F,niceCallback:K,limitString:$,eventNameValidate:L,getDynamicAttributes:D,guid:R,getScreenHeight:M,getScreenWidth:B,getOS:G,compareVersion:(e="",t="")=>{const i=e=>e.replace(/\s+/g,""),n=e=>e.replace(/[vV]/g,""),s=i(n(e)),r=i(n(t)),o=s.split("."),a=r.split(".");for(let e=0;3>e;e++){let t=Number(o[e]),i=Number(a[e]);if(t>i)return 1;if(i>t)return-1;if(!isNaN(t)&&isNaN(i))return 1;if(isNaN(t)&&!isNaN(i))return-1}return 0},getVueVersion:e=>{if(e){const t=Number(v(S(e.version,".")));return Number.isNaN(t)?0:t}return 0},splitPath:Q,normalPath:z,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:W,getPlainConfig:J,getPlainPlatform:Y,getSubKeys:e=>k(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let e=F((()=>getApp({allowDefault:!0})));return e||(e=Z()),e},getGlobal:Z,limitObject:X,batchGetStorageSync:ee,batchSetStorageSync:te,qsStringify:ie,qsParse:ne,hashCode:(e,t=!1)=>{let i=0;if(A(e)||"boolean"==typeof e)return i;let n=0;for(;n<e.length;)i=(i<<5)-i+e.charCodeAt(n),i|=0,n++;return t?Math.abs(i):i},getLaunchQuery:se});const oe=e=>l(e)&&e.length>0||g(e)&&e>0,ae={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"}},le=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],ge=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...le],ue={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},ce=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],de=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],he=[...de,"appChannel","language","platformVersion"],pe={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 ve="MINIP_LIFECYCLE",me="ON_COMMIT_REQUEST",fe="ON_COMPOSE_AFTER",Ie="ON_COMPOSE_BEFORE",Oe="ON_ERROR",ye="ON_INSTALL",Se="ON_SEND_AFTER",be="ON_SEND_BEFORE",we="OPTION_CHANGE",Pe="OPTION_INITIALIZED",Te="SDK_INITIALIZED";class ke{constructor(e){this.growingIO=e,this.main=(e,t,i=!0)=>{e||(e=this.growingIO.trackingId);const{sdkVersion:n,platformConfig:s,minipInstance:r,userStore:o,dataStore:a,dataStore:{scene:l,eventHooks:{currentPage:g},generalProps:u}}=this.growingIO,{version:c,dataSourceId:d,appId:h,idMapping:p,ignoreFields:v}=a.getTrackerVds(e),m=a.locationData[e],{systemInfo:f={},network:I={}}=r,{brand:O,model:y,platform:S,language:b}=f,w=g.getPagePath(),P={appChannel:"scn:"+(l||"NA"),appVersion:c,dataSourceId:d,deviceBrand:O,deviceId:o.getUid(),deviceModel:y,deviceType:G(S,s.name),domain:h,language:b,latitude:null==m?void 0:m.latitude,longitude:null==m?void 0:m.longitude,networkState:(null==I?void 0:I.networkType)||(null==I?void 0:I.type)||(null==I?void 0:I.subtype),operatingSystem:G(S,s.name),path:w,platform:s.platform,platformVersion:s.name+(f.version?" "+f.version:""),query:w?g.getPageQeury():"",screenHeight:M(f),screenWidth:B(f),sdkVersion:n,sessionId:o.getSessionId(e),title:g.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:o.getUserId(e)};return p&&(P.userKey=o.getUserKey(e)),i&&!A(u[e])&&(P.attributes=Object.assign({},u[e])),A(P.attributes)||(P.attributes=X(D(Object.assign({},P.attributes)))),A(v)||v.forEach((e=>{x(P,e)})),A(t)?Object.assign(Object.assign({},P),{trackingId:e}):Object.assign(Object.assign(Object.assign({},P),t),{trackingId:e})}}}function _e(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class Ee{constructor(e){this.growingIO=e,this.enterParams={},this.main=(e,t)=>{var i,n;const s=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:g,dataStore:u,dataStore:{trackersExecute:c,shareOut:d,lastCloseTime:h,saveStorageInfo:p,setOriginalSource:v}}=this.growingIO;r.emit(ve,{event:"App "+e,timestamp:s,params:null!==(i=t[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",e,s);const m=l.listeners.app;switch(r.emit(Ie,{event:"App "+e,params:null!==(n=t[0])&&void 0!==n?n:{}}),e){case m.appLaunch:this.enterParams=Object.assign({},t[0]);break;case m.appCreate:case m.appShow:{const{path:e,query:i,referralPage:n}=this.enterParamsParse(t[0]);!d&&a.originalSource&&e&&c((t=>{v(t,{path:e,query:i,referralPage:n})})),h?(Date.now()-h>a.keepAlive||u.lastScene&&u.scene!==u.lastScene)&&(c((e=>{o.setSessionId(e)})),c((t=>{if(e)this.buildVisitEvent(t,{path:e,query:i});else{const e=u.lastPageEvent[t];this.buildVisitEvent(t,{path:e.path,query:e.query})}}))):c((t=>{u.lastVisitEvent[t]={path:e,query:i,referralPage:n},this.buildVisitEvent(t,{path:e,query:i,referralPage:n})}));break}case m.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),p(),o.saveUserInfo(),c((e=>{this.buildCloseEvent(e),a.forceLogin||g.initiateRequest(e,!0)}))}},this.enterParamsParse=(e={})=>{var t;const{gioPlatform:i,minipInstance:n,dataStore:s}=this.growingIO;let r="",o="",a="";if("quickapp"!==i&&n.minip.canIUse("getEnterOptionsSync")){const{path:i,query:l,scene:g,referrerInfo:u}=n.minip.getEnterOptionsSync()||{};r=i||e.path,o=l||e.query,a=(null==u?void 0:u.appId)||(null===(t=null==e?void 0:e.referrerInfo)||void 0===t?void 0:t.appId)||"",s.scene=g||e.scene,o=A(null==u?void 0:u.extraData)?ie(o):ie(se(o,u.extraData))}else{const{path:t,query:i,referrerInfo:n}=e;r=t,o=ie(i),a=(null==n?void 0:n.appId)||"",this.parseScene(e)}return{path:r,query:o,referralPage:a}},this.parseScene=e=>{var t;const{minipInstance:i,gioPlatform:n,dataStore:s}=this.growingIO;let r;if("quickapp"===n){const{extra:e,type:t}=i.getAppSource();r=(null==e?void 0:e.scene)||t}else A(e)||((null===(t=null==e?void 0:e.query)||void 0===t?void 0:t.wxShoppingListScene)?r=e.query.wxShoppingListScene:(null==e?void 0:e.scene)?r=e.scene:s.scene="NA");s.scene=r},this.buildVisitEvent=(e,t)=>{const{dataStore:{getOriginalSource:i,eventContextBuilder:n,eventInterceptor:s},vdsConfig:r}=this.growingIO,o=i(e),a=(null==t?void 0:t.query)||"";let l=Object.assign({eventType:"VISIT"},n(e,{}));!A(t)&&t.path&&(l.path=t.path||"",l.query="string"===q(a)?a:ie(a),t.referralPage&&(l.referralPage=t.referralPage)),r.originalSource&&!A(o)&&(l=Object.assign(Object.assign({},l),o)),s(l)},this.buildCloseEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},t(e)))}}}class Ce{constructor(e){this.growingIO=e,this.getPagePath=()=>{var e,t,i;const{minipInstance:n,inPlugin:s,dataStore:r,trackingId:o}=this.growingIO,a=n.getCurrentPath();if(s){const e=r.getTrackerVds(o);return a||"/插件"+e.appId}return a||(null===(e=r.eventHooks.appEffects.enterParams)||void 0===e?void 0:e.path)||(null===(t=r.lastPageEvent[o])||void 0===t?void 0:t.path)||(null===(i=r.lastVisitEvent[o])||void 0===i?void 0:i.path)},this.getPageQeury=()=>{var e,t,i,n,s,r;const{minipInstance:o,dataStore:a,trackingId:l}=this.growingIO,g=o.getCurrentPage(),u=o.getCurrentPath(),{enterParams:c={}}=a.eventHooks.appEffects;if(!u)return c.path?this.qsQuery(se(null==c?void 0:c.query,null===(i=null==c?void 0:c.referrerInfo)||void 0===i?void 0:i.extraData)):(null===(n=a.lastPageEvent[l])||void 0===n?void 0:n.path)?null===(s=a.lastPageEvent[l])||void 0===s?void 0:s.query:null===(r=a.lastVisitEvent[l])||void 0===r?void 0:r.query;{const i=null!==(e=g.options)&&void 0!==e?e:g.$taroParams;if(!A(i))return x(i,"$taroTimestamp"),this.qsQuery(i);if(!A(this.queryOption[u]))return this.qsQuery(this.queryOption[u]);if(u===c.path)return this.qsQuery(se(null==c?void 0:c.query,null===(t=null==c?void 0:c.referrerInfo)||void 0===t?void 0:t.extraData))}},this.getPageTitle=e=>{const{minipInstance:t,inPlugin:i,dataStore:n}=this.growingIO,s=t.getCurrentPath(),r=this.settedTitle[s]||t.getPageTitle(t.getCurrentPage());if(i){const t=n.getTrackerVds(e||this.growingIO.trackingId);return r||`/插件${t.appId}${s?"_"+m(s.split("/")):""}`}return r},this.qsQuery=(e={})=>{const t=Object.assign({},e);return x(t,"wxShoppingListScene"),ie(t)},this.getReferralPage=e=>{var t,i,n;const{minipInstance:s,dataStore:{lastPageEvent:r,scene:o,eventHooks:a}}=this.growingIO;return(null===(t=r[e])||void 0===t?void 0:t.path)||(null===(n=null===(i=a.appEffects.enterParams)||void 0===i?void 0:i.referrerInfo)||void 0===n?void 0:n.appId)||(o?`scn:${s.scnPrefix}${o}`:null)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=z(t+(i?"?"+i:"")),e.query=i,e},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=z(t+(i?"?"+i:"")),e.query=i,e},this.eventSetPageProps=(e,t)=>{const i=F((()=>this.pageProps[e][this.getPagePath()]));return A(i)?t.attributes:X(D(Object.assign(Object.assign({},t.attributes),i)))},this.queryOption={},this.settedTitle={},this.pageProps={}}buildShareQuery(e){var t,i;const n=Q(null!==(t=e.path)&&void 0!==t?t:"");let s=this.getPagePath(),r={},o=T(e,"path");if(o&&(s=v(n),r=ne(m(n))||{}),A(r)&&(r=ne(null!==(i=e.query)&&void 0!==i?i:"")||{},I(k(r)).forEach((e=>{e.toLowerCase().startsWith("utm_")&&x(r,e)}))),!o&&A(r)){const e=this.growingIO.minipInstance.getCurrentPage();r=e.options||this.queryOption[e.route]||{}}return[s,ie(r)]}}class xe{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var n,s;const r=Date.now(),{emitter:o,minipInstance:a,plugins:l,vdsConfig:g,platformConfig:u,dataStore:{getTrackerVds:c,getOriginalSource:h,setOriginalSource:p,trackersExecute:v,eventHooks:m,toggleShareOut:f,buildAppMessageEvent:I,buildTimelineEvent:O,buildAddFavorites:y}}=this.growingIO,{currentPage:S}=m;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=a.getCurrentPage()),e.route||(e.route=a.getCurrentPath(e));const b=e.route||e.uri||e.__route__||(null===(n=null==e?void 0:e.$page)||void 0===n?void 0:n.fullPath)||"";o.emit(ve,{event:"Page "+t,timestamp:r,params:{page:e,args:i[0]}}),g.debug&&console.log("Page:",b,"#",t,r),this.prevEvent[t]=Date.now();const w=u.listeners.page;switch(o.emit(Ie,{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),S.lastLifecycle=S.currentLifecycle,S.currentLifecycle=t,t){case w.pageLoad:S.queryOption[b]=C(e,"options")||C(e,"__displayReporter.query")||C(e,"$page.query")||C(e,"$wx.__displayReporter.query")||C(e,"$taroParams")||i[0]||{},x(S.queryOption[b],"$taroTimestamp");break;case w.pageShow:v((e=>{const t=h(e);A(t)||t.path!==b||p(e,Object.assign(Object.assign({},t),{title:S.getPageTitle()}));const{trackPage:i}=c(e);i&&this.buildPageEvent(e)})),f(!1);break;case w.pageHide:case w.pageUnload:break;case w.shareApp:f(!0),v((e=>{const{followShare:t}=c(e);t&&I(e,i)}));break;case w.shareTime:v((e=>{const{followShare:t}=c(e);t&&O(e,i)}));break;case w.addFavorites:v((e=>{const{followShare:t}=c(e);t&&y(e,i)}));break;case w.tabTap:{const e=null===(s=null==l?void 0:l.gioEventAutoTracking)||void 0===s?void 0:s.buildTabClickEvent;g.autotrack&&e&&d(e)&&e(this.growingIO.trackingId,i[0]);break}}},this.buildPageEvent=(e,t)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:n,eventHooks:{currentPage:s}}}=this.growingIO,r=Object.assign({eventType:"PAGE",referralPage:s.getReferralPage(e)},i(e));r.attributes=s.eventSetPageProps(e,r),!A(t)&&t.title&&(r.title=t.title),n(r)},this.prevEvent={}}}class je{constructor(e){var t;this.growingIO=e,this.isNormalFc=(e,t)=>d(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),T(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),T(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),T(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{h(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{d(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=()=>{})}))},this.lifeFcEffects=(e,t,i)=>{const n=this;return["onShareTimeline","onAddToFavorites"].includes(e)?function(...s){let r=t.apply(this,s);"onShareTimeline"===e&&n.growingIO.vdsConfig.followShare&&(r=n.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=n.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(s);return r&&o.push(r),n[`def${i}Cbs`][e].apply(this,o),r}:function(...s){var r;return _e(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=t.apply(this,s))&&void 0!==r?r:{},"promise"===q(o)&&(o=yield o.then((e=>e))),"promise"===q(o.promise)){const e=function(){return _e(this,void 0,void 0,(function*(){let e=o;return new Promise((t=>{let i=setTimeout((()=>{t(Object.assign({},e)),clearTimeout(i),i=void 0}),3e3);o.promise.then((n=>{e=n,t(Object.assign({},e)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield e()),x(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`][e].apply(this,a)}catch(e){H(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,s)),n.growingIO.emitter.emit(ve,{event:`${i} ${e}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(s)}}),o}))}},this.customFcEffects=(e,t)=>{const i=this;return function(...n){var s,r;let o;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let t=n[0]||{};T(t,"type")&&((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))||(t=n[n.length-1]),((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))&&i.actionEventTypes.includes(t.type)&&(d(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(t,e))}catch(e){H(e,"error")}return o=t.apply(this,n),o}},this.appApplyProxy=(e,t)=>this.appHandlers.includes(e)?this.lifeFcEffects(e,t,"App"):this.customFcEffects(e,t),this.pageApplyProxy=(e,t)=>this.pageHandlers.includes(e)?this.lifeFcEffects(e,t,"Page"):this.customFcEffects(e,t),this.appOverriding=e=>(this.setAppEffectCbs(),this.supLifeFcs(e,"app"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.appApplyProxy(e,t[e]))})),e),this.pageOverriding=e=>(this.setPageEffectCbs(),this.supLifeFcs(e,"page"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.componentOverriding=e=>(this.setPageEffectCbs(),e.methods||(e.methods={}),this.supLifeFcs(this.growingIO.inPlugin?e:e.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?e:e.methods,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.setAppEffectCbs=()=>{const e=this;this.appHandlers.forEach((t=>{this.defAppCbs[t]=function(...i){e.appEffects.main(t,i)}}))},this.setPageEffectCbs=()=>{const e=this;this.pageHandlers.forEach((t=>{this.defPageCbs[t]=function(...i){e.pageEffects.main(this,t,i)}}))},this.growingApp=e=>d(this.originalApp)?this.originalApp(this.appOverriding(e)):this.appOverriding(e),this.growingPage=e=>d(this.originalPage)?this.originalPage(this.pageOverriding(e)):this.pageOverriding(e),this.growingComponent=e=>d(this.originalComponent)?this.originalComponent(this.componentOverriding(e)):this.componentOverriding(e),this.growingBehavior=e=>d(this.originalBehavior)?this.originalBehavior(this.componentOverriding(e)):this.componentOverriding(e),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,n=i.hooks;if(e.includes("App"))try{n.App&&!this.appHooked&&(App=function(...e){return t.originalApp(t.appOverriding(e[0]))},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{n.Page&&!this.pageHooked&&(Page=function(...e){return t.originalPage(t.pageOverriding(e[0]))},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{n.Component&&!this.componentHooked&&(Component=function(...e){return t.originalComponent(t.componentOverriding(e[0]))},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{n.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.originalBehavior(t.componentOverriding(e[0]))},this.behaviorHooked=!0)}catch(e){}},this.initOriginalValue=()=>{this.setAppEffectCbs(),this.setPageEffectCbs(),this.originalApp=F((()=>App||global.App)),this.originalPage=F((()=>Page||global.Page)),this.originalComponent=F((()=>Component||global.Component)),this.originalBehavior=F((()=>Behavior||global.Behavior))},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;this.initOriginalValue(),t.canHook?(this.nativeGrowing(),Z().GioApp=F((()=>null!==App&&void 0!==App?App:this.originalApp)),Z().GioPage=F((()=>null!==Page&&void 0!==Page?Page:this.originalPage)),Z().GioComponent=F((()=>null!==Component&&void 0!==Component?Component:this.originalComponent)),Z().GioBehavior=F((()=>null!==Behavior&&void 0!==Behavior?Behavior:this.originalBehavior))):"quickapp"===i&&(Z().GioApp=function(...t){return e.appOverriding(t[0])},Z().GioPage=function(...t){return e.pageOverriding(t[0])},Z().GioComponent=function(...t){return e.pageOverriding(t[0])})};const i=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new Ee(this.growingIO),this.pageEffects=new xe(this.growingIO),this.currentPage=new Ce(this.growingIO)}}class Ae{constructor(e){var t,i;this.growingIO=e,this.ALLOW_SETTING_KEYS=k(ae),this.getStorageKey=(e,t)=>{const{inPlugin:i}=this.growingIO;return`${e===this.growingIO.trackingId?"":e}${pe[i?"plugin_"+t:t]}`},this.getGsid=e=>{let t=Number(this._gsid[e]);return Number.isNaN(t)||t>=1e9||1>t?(this.setGsid(e,1),1):t},this.setGsid=(e,t)=>{let i=Number(t);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[e]=i,10>this._gsid[e]-this._stid[e]||this.saveStorageInfo()},this.initStorageInfo=e=>{const{minipInstance:t}=this.growingIO,i=t.getStorageSync(this.getStorageKey(e,"gsid"));let n=Number(i);(Number.isNaN(n)||n>=1e9||1>n)&&(n=1),this._gsid[e]=n,this._stid[e]=n,n!==i&&t.setStorageSync(this.getStorageKey(e,"gsid"),n)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=Object.assign({},this._gsid),te(e,this.initializedTrackingIds.map((e=>({key:this.getStorageKey(e,"gsid"),value:this._gsid[e]}))))},this.setOriginalSource=(e,t)=>{const{minipInstance:i}=this.growingIO;i.setStorageSync(this.getStorageKey(e,"originalSource"),JSON.stringify(t))},this.getOriginalSource=e=>{var t;const{minipInstance:i}=this.growingIO;return null!==(t=F((()=>JSON.parse(i.getStorageSync(this.getStorageKey(e,"originalSource"))))))&&void 0!==t?t:{}},this.getTrackerVds=e=>this.growingIO.trackingId===e?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=e=>{const t=this.initOptions(e);return t.trackingId=e.trackingId,this.growingIO.trackingId=e.trackingId,this.growingIO.vdsConfig=t,t},this.initTrackerHooker=e=>{var t,i;const{platformConfig:n,inPlugin:s,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:l}=e;a||l||"quickapp"===r.platform||(n.canHook=!0),!s||["tbp","jdp"].includes(r.platform)?this.eventHooks.initEventHooks():this.eventHooks.initOriginalValue(),a&&(null===(t=null==o?void 0:o.gioUniAppAdapter)||void 0===t||t.main()),l&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=e=>{var t,i,n,s,r,o;const{projectId:a,dataSourceId:l,appId:g,trackingId:u}=e,c={};return this.ALLOW_SETTING_KEYS.forEach((t=>{const i=ae[t].type;(h(i)?i.includes(q(e[t])):q(e[t])===ae[t].type)?"ignoreFields"===t?c.ignoreFields=e.ignoreFields.filter((e=>de.includes(e))):"extraParams"===t?c.extraParams=e.extraParams.filter((e=>he.includes(e))):(c[t]=e[t],["dataCollect","autotrack"].includes(t)&&!c[t]&&H("已关闭"+ue[t],"info")):c[t]=ae[t].default})),c.uploadInterval=Math.round(c.uploadInterval),(Number.isNaN(c.uploadInterval)||0>c.uploadInterval||c.uploadInterval>3e3)&&(c.uploadInterval=1e3),c.enableIdMapping&&!c.idMapping&&(c.idMapping=!0,c.idMapping||this.growingIO.userStore.setUserKey(u,"")),x(c,"enableIdMapping"),c.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(c.requestTimeout))&&c.requestTimeout>0||(c.requestTimeout=5e3),Object.assign(Object.assign({},c),{projectId:a,dataSourceId:l,appId:g,trackingId:u,performance:{monitor:null===(i=null===(t=c.performance)||void 0===t?void 0:t.monitor)||void 0===i||i,exception:null===(s=null===(n=c.performance)||void 0===n?void 0:n.exception)||void 0===s||s,network:null!==(o=null===(r=c.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(e,t,i)=>{var n;const{userStore:s,emitter:r}=this.growingIO,o=this.getTrackerVds(e),a=l(t)&&this.ALLOW_SETTING_KEYS.includes(t),g=a&&typeof i===(null===(n=ae[t])||void 0===n?void 0:n.type);if(a&&g){const n=Object.assign({},o);return this.updateVdsConfig(e,Object.assign(Object.assign({},o),{[t]:i})),"dataCollect"===t&&n.dataCollect!==i&&i&&(s.setSessionId(e),this.sendVisit(e),this.sendPage(e)),r.emit(we,{optionName:t,optionValue:i}),!0}return V("setOption > "+t),!1},this.getOption=(e,t)=>{const i=this.getTrackerVds(e);return t&&T(this.growingIO.vdsConfig,t)?T(i,t)?i[t]:this.growingIO.vdsConfig[t]:A(t)?i:void V("getOption > "+t)},this.updateVdsConfig=(e,t)=>{e===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),t),Z().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[e]=Object.assign(Object.assign({},this.growingIO.subInstance[e]),t),Z().vdsConfig.subInstance[e]=this.growingIO.subInstance[e])},this.toggleShareOut=e=>{u(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=(e,t)=>{this.eventHooks.appEffects.buildVisitEvent(e,t)},this.sendPage=(e,t)=>{this.eventHooks.pageEffects.buildPageEvent(e,t)},this.eventConverter=e=>{const{dataStore:t,uploader:i}=this.growingIO,{dataCollect:n}=this.getTrackerVds(e.trackingId);if(n){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=t.getGsid(e.trackingId),t.setGsid(e.trackingId,e.eventSequenceId+1));const n={};_(e,((e,t)=>{var i;if("element"===t){const t=null!==(i=v(e))&&void 0!==i?i:{};_(t,((e,t)=>{A(e)&&0!==e||(n[t]=e)}))}else A(e)&&0!==e||(n[t]=e)})),this.growingIO.emitter.emit(fe,{composedEvent:n}),i.commitRequest(Object.assign(Object.assign({},n),{requestId:R()}))}},this.eventRefactor=e=>{var t,i;const n=Object.assign(Object.assign({},e),this.eventContextBuilder(e.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));return n.attributes=Object.assign(Object.assign({},null!==(t=n.attributes)&&void 0!==t?t:{}),null!==(i=e.attributes)&&void 0!==i?i:{}),n},this.eventInterceptor=e=>{const{systemInfo:t,network:i}=this.growingIO.minipInstance;A(t)||A(i)?this.interceptEvents.push(e):A(this.interceptEvents)?this.eventConverter(e):([...this.interceptEvents,e].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!A(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.buildAppMessageEvent=(e,t)=>{var i,n;const s=t[0];let r;2>t.length?1===t.length&&(r=s):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(e));g.attributes=X(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$from:s.from,$target:null===(n=null==s?void 0:s.target)||void 0===n?void 0:n.id,$share_title:null==r?void 0:r.title,$share_path:v(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildTimelineEvent=(e,t)=>{var i,n;const s=t[0];let r;2>t.length?1===t.length&&(r=s):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(e));g.attributes=X(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$target:null===(n=null==s?void 0:s.target)||void 0===n?void 0:n.id,$share_title:null==r?void 0:r.title,$share_path:v(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildAddFavorites=(e,t)=>{var i;const n=t[0];let s;2>t.length?1===t.length&&(s=n):s=t[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==s?void 0:s.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(e));l.attributes=X(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$share_title:null==s?void 0:s.title,$share_path:v(a),$share_query:a[1]})),o(l)},this.trackersExecute=e=>{this.initializedTrackingIds.forEach((t=>{"function"===q(e)&&e(t)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new ke(this.growingIO).main,this.eventHooks=new je(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:n,minipInstance:s}=this.growingIO;n.on(Te,(({trackingId:e})=>{this.initializedTrackingIds.push(e),this.initStorageInfo(e)})),n.on(me,(({eventData:e,trackingId:t})=>{"VISIT"===e.eventType&&(this.lastVisitEvent[t]=e),"PAGE"===e.eventType&&(this.lastPageEvent[t]=e)})),d(null===(t=s.minip)||void 0===t?void 0:t.onAppHide)&&s.minip.onAppHide((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];_(t,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))}))})),d(null===(i=s.minip)||void 0===i?void 0:i.onAppShow)&&s.minip.onAppShow((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];_(t,(e=>{e.start&&(e.start=+Date.now())}))}))})),n.on(we,(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.trackersExecute((e=>{this.growingIO.clearTrackTimer(e)}))}))}get scene(){return this._scene}set scene(e){const t=this._scene;this._scene=e,t!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:e,oldScene:t})}}const qe={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"]}}},Ne=Object.assign(Object.assign({},qe),{listeners:Object.assign({},qe.listeners),name:"JingDong",platform:"jdp",scnPrefix:"jd_"}),Ue=Object.assign(Object.assign({},qe),{listeners:Object.assign({},qe.listeners),name:"KuaiShou",platform:"kuaishoup",scnPrefix:"ks_"}),He=Object.assign(Object.assign({},qe),{listeners:Object.assign({},qe.listeners),name:"Alipay",platform:"alip",scnPrefix:"alip_",hooks:Object.assign(Object.assign({},qe.hooks),{Behavior:!1})}),Ve=Object.assign(Object.assign({},qe),{pageHandlers:[...qe.pageHandlers,"onInit","didMount","didUnmount"],listeners:Object.assign(Object.assign({},qe.listeners),{page:Object.assign(Object.assign({},qe.listeners.page),{onInit:"onInit",didMount:"didMount",didUnmount:"didUnmount"})}),name:"Taobao",platform:"tbp",scnPrefix:"tbp_",hooks:Object.assign(Object.assign({},qe.hooks),{Behavior:!1})}),Fe=Object.assign(Object.assign({},qe),{listeners:Object.assign({},qe.listeners),name:"QQ",platform:"qq",scnPrefix:"qq_"});Fe.pageHandlers=[...qe.pageHandlers,"onAddToFavorites"],Fe.listeners.page.addFavorites="onAddToFavorites";const Ke=Object.assign(Object.assign({},qe),{listeners:Object.assign({},qe.listeners),name:"Baidu",platform:"baidup",scnPrefix:"baidup_"}),$e=Object.assign(Object.assign({},qe),{listeners:Object.assign({},qe.listeners),name:"Bytedance",platform:"bytedance",scnPrefix:"bytedance_"}),Le=Object.assign(Object.assign({},qe),{listeners:Object.assign({},qe.listeners),name:"Weixin",platform:"MinP"});Le.pageHandlers=[...qe.pageHandlers,"onShareTimeline","onAddToFavorites"],Le.listeners.page=Object.assign(Object.assign({},qe.listeners.page),{shareTime:"onShareTimeline",addFavorites:"onAddToFavorites"});const De=Y(),Re=F((()=>{const e={jd:Ne,ks:Ue,my:He,tb:Ve,qq:Fe,swan:Ke,tt:$e,wx:Le}[De];return e.canHook=!1,e}));class Me{constructor(e){this.growingIO=e,this.minip=W("framework"),this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBarTitle,i=this;t&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const e=i.getCurrentPath(),{title:t}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.settedTitle[e]=t}return t.apply(this,arguments)}})},this.navigateTo=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateTo(e)},this.switchTab=e=>{var t;null===(t=this.minip)||void 0===t||t.switchTab(e)},this.navigateToMiniProgram=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateToMiniProgram(e)},this.getImageInfo=({src:e,success:t,fail:i,complete:n})=>{var s;return null===(s=this.minip)||void 0===s?void 0:s.getImageInfo({src:e,success:t,fail:i,complete:n})},this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"observeAll")},this.getCurrentPage=()=>F((()=>m(getCurrentPages())))||{},this.getCurrentPath=()=>{const e=this.getCurrentPage();return(null==e?void 0:e.route)||(null==e?void 0:e.uri)||(null==e?void 0:e.__route__)||""},this.getPageTitle=e=>{var t;const i=Y();let n="",s=J(i);"string"===q(s)&&(s=null!==(t=F((()=>JSON.parse(s))))&&void 0!==t?t:{});const r=(null==e?void 0:e.data)||e.$data||{};if(n=l(null==r?void 0:r.gioPageTitle)?null==r?void 0:r.gioPageTitle:"",s){const{enterParams:t}=this.growingIO.dataStore.eventHooks.appEffects;e.route||A(t)||(e.route=t.path||"",n=this._getTitleFromTabbar(s,e.route)),F((()=>{var t,r,o,a,l,g;if(!n){const u=s.page||{},c=u[e.route]||u[e.route+".html"];n=c?null===(t=null==c?void 0:c.window)||void 0===t?void 0:t.navigationBarTitleText:["wx","tt"].includes(i)?null===(a=null===(o=null===(r=s||global||$global)||void 0===r?void 0:r.global)||void 0===o?void 0:o.window)||void 0===a?void 0:a.navigationBarTitleText:null===(g=null===(l=s||global||$global)||void 0===l?void 0:l.window)||void 0===g?void 0:g.navigationBarTitleText}})),n||(n=this._getTitleFromTabbar(s,e.route))}return $(n)},this._getTitleFromTabbar=(e,t)=>{var i,n;const s=null===(n=null===(i=null==e?void 0:e.tabBar)||void 0===i?void 0:i.list)||void 0===n?void 0:n.find((e=>e.pagePath===t||e.pagePath===t+".html"));return(null==s?void 0:s.text)||""},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return c(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=e=>new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:e,success:({data:e})=>t(e),fail:()=>t("")})})),this.setStorageSync=(e,t,i)=>{var n;i&&(t={value:t,expiredAt:i}),null===(n=this.minip)||void 0===n||n.setStorageSync(e,t)},this.setStorage=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:e,data:t})},this.removeStorageSync=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorageSync(e)},this.removeStorage=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorage(e)},this.getNetworkType=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{e.network=i,t(i)},fail:()=>t(null)})}))},this.request=({url:e,data:t,header:i,timeout:n,method:s,success:r,fail:o,complete:a})=>{var l;const g=null===(l=this.minip)||void 0===l?void 0:l.request({url:e,data:t,header:i,headers:i,timeout:n,method:s,success:r,fail:o,complete:a});let u=setTimeout((()=>{(null==g?void 0:g.abort)&&d(null==g?void 0:g.abort)&&(null==g||g.abort()),clearTimeout(u),u=null}),(n||1e4)+10);return g},this.getSystemInfo=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{e.systemInfo=i,t(i)},fail:()=>t(null)})}))},this.getSetting=()=>new Promise((e=>{var t;null===(t=this.minip)||void 0===t||t.getSetting({success:e,fail:e})}));const{platformConfig:{platform:t,scnPrefix:i}}=this.growingIO;this.platform=t,this.scnPrefix=i,this.growingIO.emitter.on(Pe,(()=>{this.getNetworkType().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()}))}))}}const Be=Y();var Ge={wx:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}},swan:class extends Me{constructor(e){super(e),this.growingIO=e,this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"selectAll")},this.hookSetTitle()}},my:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBar,i=this;t&&Object.defineProperty(this.minip,"setNavigationBar",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const e=i.getCurrentPath(),{title:t}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.settedTitle[e]=t}return t.apply(this,arguments)}})},this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"selectAll")},this.getStorageSync=e=>{const{data:t}=my.getStorageSync({key:e});return t},this.setStorageSync=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorageSync({key:e,data:t})},this.removeStorageSync=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorageSync({key:e})},this.hookSetTitle()}},qq:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}},tt:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}},ks:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}},jd:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}}}[Be];const Qe=["gioPerformance"];class ze{constructor(e){var t,i,n,s,r,o;this.growingIO=e,this.innerPluginInit=()=>{var e;Qe.forEach((e=>{var t;return x(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins,e)})),k(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins).forEach((e=>{var t,i;const{name:n,method:s}=null!==(i=null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins[e])&&void 0!==i?i:{};O(this.pluginItems,(e=>e.name===n))||this.pluginItems.push({name:b(n||e),method:s||(e=>{})})})),A(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var n,s;const{emitter:r}=this.growingIO,o=t||O(this.pluginItems,(t=>t.name===e));if((null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[e])return H(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return H(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return(null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[e]=new o.method(this.growingIO,i),t&&(r.emit(ye,e),H("加载插件 "+e,"info")),!0}catch(i){return this.lifeError(t,i),H(`插件【${e}】加载异常 ${i}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>{this.install(t.name,e?t:void 0,e?null==t?void 0:t.options:void 0)&&!O(this.pluginItems,(e=>e.name===t.name))&&this.pluginItems.push({name:b(t.name),method:t.method?t.method:()=>{}})}))},this.uninstall=e=>{var t;x(this.pluginItems,e);const i=x(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||H(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>{this.growingIO.emitter.emit(Oe,{plugin:e,error:t}),H(`插件执行错误 ${e.name} ${t}`,"error")},this.callLifeCycle=(e,t)=>{this.pluginItems.forEach((i=>{const n=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][e]:void 0;if(n&&d(n))try{n(t)}catch(e){this.lifeError(i,e)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(t=this.growingIO.emitter)||void 0===t||t.on(ye,(e=>this.callLifeCycle("onInstall",e))),null===(i=this.growingIO.emitter)||void 0===i||i.on(Oe,(e=>this.callLifeCycle("onError",e))),null===(n=this.growingIO.emitter)||void 0===n||n.on(Ie,(e=>this.callLifeCycle("onComposeBefore",e))),null===(s=this.growingIO.emitter)||void 0===s||s.on(fe,(e=>this.callLifeCycle("onComposeAfter",e))),null===(r=this.growingIO.emitter)||void 0===r||r.on(be,(e=>this.callLifeCycle("onSendBefore",e))),null===(o=this.growingIO.emitter)||void 0===o||o.on(Se,(e=>this.callLifeCycle("onSendAfter",e)))}}let We;const Je={tap:"onClick",longpress:"onLongPress"},Ye=["onShareAppMessage","onShareTimeline","onAddToFavorites","onTabItemTap"];var Ze={name:"gioTaroAdapter",method:class{constructor(e){this.growingIO=e,this.main=()=>{const{taro:e,taroVue:t}=this.growingIO.vdsConfig,{Current:i,createComponent:n}=e,s=!i&&n,r=i&&!n;if(this.taro=e,s)this.taroVersion="2",this.proxyTaro2(this.taro),We.consoleText("Taro version 2","info");else if(r){if(this.taroVersion="3",this.taroVue=t,this.taroVue){const e=Number(We.head(We.split(this.taroVue.version,".")));this.taroVueVersion=e,We.consoleText("Taro version 3, Vue version "+e,"info")}else We.consoleText("Taro version 3","info");this.proxyTaro3()}else We.consoleText("未获取到Taro实例或不支持的Taro版本,请检查!","error")},this.proxyTaro2=e=>{const t=this,i=e.createApp,n=e.createComponent;i&&(e.createApp=function(e){const n=i(e);return t.growingIO.dataStore.eventHooks.appOverriding(n),n}),n&&(e.createComponent=function(e,i){const s=n(e,i),r=i?"page":"component";switch(t.growingIO.gioPlatform){case"wx":case"qq":t.growingIO.dataStore.eventHooks[r+"Overriding"](s.methods);break;case"my":case"tt":case"jd":t.growingIO.dataStore.eventHooks[r+"Overriding"](s);break;case"swan":t.growingIO.dataStore.eventHooks[r+"Overriding"](s),t.growingIO.dataStore.eventHooks[r+"Overriding"](s.methods)}return s})},this.proxyTaro3=()=>{var e,t;const i=this,{dataStore:{eventHooks:n},minipInstance:s}=this.growingIO;if(n.nativeGrowing(["App"]),2===this.taroVueVersion)return n.nativeGrowing(["Page"]),void this.taro3Vue2Proxy();3===this.taroVueVersion&&this.proxyTaro3vue3();const r=null===(t=null===(e=i.taro)||void 0===e?void 0:e.hooks)||void 0===t?void 0:t.call;r?i.defineProperty(i.taro.hooks,"call",(function(...e){var t,o;const a=Array.from(e);if("getLifecycle"===a[0]){const e=a[2];if(n.pageHandlers.includes(e)&&!Ye.includes(e)){"onLoad"===e&&i.inAppLifecycle&&(i.inAppLifecycle=!1);const t=s.getCurrentPage();t.route&&!i.inAppLifecycle&&We.niceTry((()=>n.pageEffects.main(t,e,a[1])))}}let l=r.apply(this,a);if("modifyPageObject"===a[0]){const e=a[1];Ye.forEach((t=>{e[t]&&(e[t]=n.lifeFcEffects(t,We.isFunction(e[t])?e[t]:()=>{},"Page"))}))}if("dispatchTaroEvent"===a[0]){const e=a[1],s=a[2],r=null===(o=null===(t=i.growingIO.plugins)||void 0===t?void 0:t.gioEventAutoTracking)||void 0===o?void 0:o.main;if(We.isFunction(r)&&n.actionEventTypes.includes(e.type)){const{currentTarget:t,target:n,detail:o}=e.mpEvent;if(n.id===t.id)try{let n=We.head(s.__handlers[e.type]);if(n){n.oldHandler&&(n=n.oldHandler);let a="";a=i.taroVue?i.taro3vue3GetFuncName(n,s):i.taro3reactGetFuncName(n,e,s),r(Object.assign(Object.assign({},e.mpEvent),{currentTarget:Object.assign(Object.assign({},t),{detail:o,dataset:Object.assign(Object.assign({},t.dataset),s.dataset)})}),a)}}catch(e){We.consoleText("Error: "+e,"error")}}}return l})):(We.consoleText("Taro3实例获取失败,请检查初始化逻辑!","warn"),n.nativeGrowing(["Page"]))},this.proxyTaro3vue3=()=>{const e=this;this.taroVue.mixin({beforeMount:function(){var t,i;if((null===(i=null===(t=this._)||void 0===t?void 0:t.props)||void 0===i?void 0:i.tid)&&!We.isEmpty(this._.exposed)){const t=We.head(We.split(this._.props.tid,"?")),i={};We.keys(this._.exposed).forEach((e=>{this._.exposed[e].name&&(i[this._.exposed[e].name]=e)})),e.exposedNames[t]=Object.assign({},i)}}})},this.taro3reactGetFuncName=(e,s,r)=>{var o,a,l,g,u,c,d,h,p;const v=We.keys(r).find((e=>t.test(e))),m=null!==(a=null!==(o=We.niceTry((()=>r[v][Je[s.type]])))&&void 0!==o?o:e.oldHandler)&&void 0!==a?a:e;if(null===(l=null==m?void 0:m.value)||void 0===l?void 0:l.name)return null===(g=null==m?void 0:m.value)||void 0===g?void 0:g.name;if(m.name&&!["handler","invoker"].includes(m.name)){let e=null===(c=null===(u=We.head((""+m).match(i)))||void 0===u?void 0:u.replace("return ",""))||void 0===c?void 0:c.replace("(","");return e?null!==(d=We.head(We.drop(We.split(e,"."))))&&void 0!==d?d:m.name:(e=null===(p=null===(h=We.head((""+m).match(n)))||void 0===h?void 0:h.replace("return ",""))||void 0===p?void 0:p.replace("(",""),null!=e?e:m.name)}return this.getAnonymousFunc(r)},this.taro3vue3GetFuncName=(e,t)=>{var i,n,a,l,g,u,c;if(We.startsWith((""+e.value).replace(" ",""),"function(")){let c=null===(i=We.head((""+e.value).match(s)))||void 0===i?void 0:i.replace("return ","");try{c?c=c.indexOf("'")>-1?We.head(We.drop(We.split(c,"'"))):We.head(We.drop(We.split(c,'"'))):(c=null===(n=We.head((""+e.value).match(r)))||void 0===n?void 0:n.replace("return ",""),c||(c=null===(a=We.head((""+e.value).match(o)))||void 0===a?void 0:a.replace("return ","")),c||(c=null===(l=e.value)||void 0===l?void 0:l.name))}catch(e){c=""}if(c){let e=c.indexOf(".")>-1?We.head(We.drop(We.split(c,"."))):c,i="";return i=(null===(g=null==t?void 0:t._root)||void 0===g?void 0:g.uid)?We.head(We.split(t._root.uid,"?")):this.growingIO.dataStore.eventHooks.currentPage.getPagePath(),this.exposedNames[i]&&(e=null!==(u=We.niceTry((()=>this.exposedNames[i][e])))&&void 0!==u?u:e),e}return this.getAnonymousFunc(t)}return(null===(c=null==e?void 0:e.value)||void 0===c?void 0:c.name)?e.value.name:this.getAnonymousFunc(t)},this.getAnonymousFunc=e=>{const t=this.growingIO.dataStore.eventHooks.currentPage.getPagePath().split("/"),i=t.findIndex((e=>e.indexOf("page")>-1))+1;return`${i&&t[i]?t[i]:We.last(t)}_Func${We.startsWith(e.uid,"_")?e.uid:"_"+e.uid}`},this.taro3Vue2Proxy=()=>{const e=this;this.taroVue.mixin({beforeMount:function(){const t=this.$options.methods;We.keys(t).forEach((t=>{e.defineProperty(this,t,e.proxyMethods(t,this[t]))}));const i=this._setupState;We.isEmpty(i)||We.keys(i).forEach((t=>{e.defineProperty(i,t,e.proxyMethods(t,i[t]))}))}})},this.proxyMethods=(e,t)=>{const{eventHooks:i}=this.growingIO.dataStore;return We.isFunction(t)&&!i.pageHandlers.includes(e)?function(...n){return i.customFcEffects(e,t).apply(this,n)}:t},this.defineProperty=(e,t,i)=>{Object.defineProperty(e,t,{writable:!0,enumerable:!0,configurable:!0,value:i})},this.saveFullPage=e=>{const t=e=>{e.forEach((e=>{var i;(null===(i=null==e?void 0:e.ctx)||void 0===i?void 0:i.route)?(this.growingIO.taro3VMs||(this.growingIO.taro3VMs={}),this.growingIO.taro3VMs[e.ctx.route]=e):We.isArray(e.childNodes)&&t(e.childNodes)}))};t(e.childNodes)},this.pluginVersion="__PLUGIN_VERSION__";const{utils:a,emitter:l,minipInstance:g}=this.growingIO;We=a,this.exposedNames={},this.inAppLifecycle=!0,l.on(ve,(({event:e})=>{["Page onShow","Page onReady"].includes(e)&&this.taro&&"3"===this.taroVersion&&(this.saveFullPage(document.body),setTimeout((()=>g.initImpression(g.getCurrentPage())),0))}))}}};class Xe extends ze{constructor(e){super(e),this.growingIO=e,this.pluginsContext={plugins:{gioTaroAdapter:Ze}}}}var et={},it={}.hasOwnProperty;function nt(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function st(e){try{return encodeURIComponent(e)}catch(e){return null}}et.stringify=function(e,t){t=t||"";var i,n,s=[];for(n in"string"!=typeof t&&(t="?"),e)if(it.call(e,n)){if((i=e[n])||null!=i&&!isNaN(i)||(i=""),n=st(n),i=st(i),null===n||null===i)continue;s.push(n+"="+i)}return s.length?t+s.join("&"):""},et.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,n={};t=i.exec(e);){var s=nt(t[1]),r=nt(t[2]);null===s||null===r||s in n||(n[s]=r)}return n};class rt{constructor(e){this.growingIO=e,this.generateURL=e=>{const{serverUrl:t,projectId:i}=this.growingIO.dataStore.getTrackerVds(e);return w(t,"http")?`${t}/v3/projects/${i}/collect`:`https://${t}/v3/projects/${i}/collect`},this.getHoardingQueue=e=>{var t;return null!==(t=this.hoardingQueue[e])&&void 0!==t?t:[]},this.getRequestQueue=e=>{var t;return null!==(t=this.requestQueue[e])&&void 0!==t?t:[]},this.commitRequest=e=>{var t,i;const n=Object.assign({},e),{vdsConfig:s,emitter:r}=this.growingIO;r.emit(me,{eventData:e,trackingId:e.trackingId}),s.forceLogin?(a(this.hoardingQueue[e.trackingId])&&(this.hoardingQueue[e.trackingId]=[]),null===(t=this.hoardingQueue[e.trackingId])||void 0===t||t.push(n)):(a(this.requestQueue[e.trackingId])&&(this.requestQueue[e.trackingId]=[]),null===(i=this.requestQueue[e.trackingId])||void 0===i||i.push(n),this.initiateRequest(e.trackingId))},this.initiateRequest=(e,t)=>{const{plugins:i,vdsConfig:n,minipInstance:s,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(e),...this.getRequestQueue(e)],a=e=>{var a,l;if(null===(a=null==n?void 0:n.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(l=null==i?void 0:i.gioTaobaoAdapter)||void 0===l||l.singleInvoke(e);else if(t)this.batchInvoke(e);else{const{uploadInterval:t}=this.growingIO.dataStore.getTrackerVds(e);j(this.batchInvoke,t,!1,!1)(e)}o.some((e=>"VISIT"===e.eventType))&&s.removeStorageSync(r.getStorageKey(e,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(e);else{let t=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(e),clearInterval(t),t=void 0)}),500)}},this.batchInvoke=e=>{const{vdsConfig:t,emitter:i}=this.growingIO,n=this.getHoardingQueue(e),s=this.getRequestQueue(e);let r=[...n,...s];r.length>50?(r=r.slice(0,50),n.length>50?this.hoardingQueue[e]=n.slice(50):(this.requestQueue[e]=s.slice(50-n.length),this.hoardingQueue[e]=[])):(this.hoardingQueue[e]=[],this.requestQueue[e]=[]);let o=r.filter((e=>(this.retryIds[e.requestId]||0)<=this.retryLimit));if(A(o))return;const a=o.map((e=>{const t=Object.assign({},e);return x(t,["requestId","trackingId"]),t}));t.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(be,{eventsQueue:o,requestData:a,trackingId:e})},this.sendEvent=(e,t)=>{var i;const n=v(e).trackingId,{minipInstance:s,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:g}=r.getTrackerVds(n);this.requestingNum+=1;const u={"content-type":"jdp"===s.platform?"application/json":"application/json;charset=UTF-8"};let c=[...t];const d=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);d&&(c=a.gioCompress.compressToUTF16(JSON.stringify(t)),u["X-Compress-Codec"]="1");const h=this.generateURL(n);s.request({url:`${h}?stm=${Date.now()}&compress=${d?"1":"0"}`,header:u,method:"POST",data:c,timeout:g,fail:t=>{[200,204].includes(t.code)||(e.forEach((e=>{this.requestFailFn(e)})),H("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,o.emit(Se,{result:e,requestData:t}),this.initiateRequest(n)}})},this.requestFailFn=e=>{if(this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1,!this.requestQueue[e.trackingId].some((t=>t.requestId===e.requestId))){let t=setTimeout((()=>{A(this.requestQueue[e.trackingId])?(this.requestQueue[e.trackingId].push(e),this.initiateRequest(e.trackingId)):this.requestQueue[e.trackingId].push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:t,vdsConfig:i,plugins:n}=this.growingIO;t.on(be,(({eventsQueue:e,requestData:t,trackingId:s})=>{var r,o;s===this.growingIO.trackingId&&((null===(r=null==i?void 0:i.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==n?void 0:n.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(e,t):this.sendEvent(e,t))}))}}class ot{constructor(e){this.growingIO=e,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:e}=this.growingIO;return this._uid||(this._uid=e.getStorageSync(this._getUidKey())),this._uid||(this._uid=R(),e.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=e=>{const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))},this.getSessionId=e=>(this._sessionId[e]||this.setSessionId(e),this._sessionId[e]),this.setSessionId=(e,t)=>{const i=this._sessionId[e];t||(t=R()),this._sessionId[e]=t,i!==t&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:t,oldSessionId:i})},this._getUserIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"userId"),this.getUserId=e=>{const{minipInstance:t}=this.growingIO;return this._userId[e]||(this._userId[e]=t.getStorageSync(this._getUserIdKey(e))),this._userId[e]},this.setUserId=(e,t)=>{const i=this._userId[e];this._userId[e]=a(t)?"":t,i!==this._userId[e]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(e),this._userId[e]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:t,oldUserId:i})),t&&this.setGioId(e,t)},this._getUserKeyKey=e=>this.growingIO.dataStore.getStorageKey(e,"userKey"),this.getUserKey=e=>{const{minipInstance:t}=this.growingIO;return this._userKey[e]||(this._userKey[e]=t.getStorageSync(this._getUserKeyKey(e))),this._userKey[e]},this.setUserKey=(e,t)=>{const i=this._userKey[e];this._userKey[e]=a(t)?"":t,i!==this._userKey[e]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(e),this._userKey[e]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:t,oldUserKey:i}))},this._getGioIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"gioId"),this.getGioId=e=>{const{minipInstance:t}=this.growingIO;return this._gioId[e]||(this._gioId[e]=t.getStorageSync(this._getGioIdKey(e))),this._gioId[e]},this.setGioId=(e,t)=>{const i=this._gioId[e];this._gioId[e]=a(t)?"":t,i!==this._gioId[e]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(e),this._gioId[e]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:t,oldGioId:i}))},this.initUserInfo=e=>{var t;const{minipInstance:i}=this.growingIO,n=[this._getUidKey(),this._getUserIdKey(e),this._getUserKeyKey(e),this._getGioIdKey(e)],s=null!==(t=ee(i,n))&&void 0!==t?t:[];["_uid","_userId","_userKey","_gioId"].forEach(((t,i)=>{"_uid"===t?this.getUid():this[t][e]=s[i]}))},this.saveUserInfo=()=>{const{minipInstance:e,dataStore:{trackersExecute:t}}=this.growingIO;t((t=>{te(e,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(t),value:this._userId[t]},{key:this._getUserKeyKey(t),value:this._userKey[t]},{key:this._getGioIdKey(t),value:this._gioId[t]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={}}}const at=new class{constructor(){var e;this.init=e=>{var t;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:e});try{if(H("Gio小程序SDK 初始化中...","info"),e.trackingId&&this.dataStore.initializedTrackingIds.includes(e.trackingId))throw Error(`已存在实例 ${e.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(e);return null===(t=this.emitter)||void 0===t||t.emit(Pe,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(e.trackingId),this.emitter.emit(Te,i),this.trackingId&&this.trackingId!==e.trackingId||(Z().__gio__=()=>this),H("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&H("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(e){return H(e,"error"),!1}},this.handlerDistribute=(e,t,i)=>{const{initializedTrackingIds:n,getTrackerVds:s}=this.dataStore;if(s(e)&&n.includes(e))return this[t](e,...i);H(`不存在实例:${e},请检查!`,"warn")},this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(e,t)=>this.dataStore.getOption(e,t),this.setOption=(e,t,i)=>{var n;return k(ue).includes(t)?typeof i===(null===(n=ae[t])||void 0===n?void 0:n.type)?(this.dataStore.setOption(e,t,i),H(`已修改${ue[t]}: ${i}`,"info"),!0):(H(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(H(`不存在可修改的配置项:${t},请检查后重试!`,"error"),!1)},this.setPageAttributes=(e,t)=>{if(c(t)&&!A(t)){const{currentPage:i}=this.dataStore.eventHooks,n=i.getPagePath();return A(i.pageProps[e])&&(i.pageProps[e]={}),A(i.pageProps[e][n])&&(i.pageProps[e][n]={}),A(t)||_(t,((t,s)=>{d(i.pageProps[e][n][s])&&!d(t)||(i.pageProps[e][n][s]=t)})),!0}return V("setPageAttributes"),!1},this.clearPageAttributes=(e,t)=>{try{if(!A(this.dataStore.eventHooks.currentPage.pageProps[e])){const{currentPage:i}=this.dataStore.eventHooks,n=i.getPagePath();h(t)&&!A(t)?t.forEach((t=>{x(i.pageProps[e][n],t)})):i.pageProps[e][n]={}}}catch(e){return V("clearPageAttributes"),!1}},this.sendPage=(e,t)=>{const{trackPage:i}=this.dataStore.getTrackerVds(e);i?H("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(e,t)},this.identify=(e,t)=>{if(e===this.trackingId)if(this.vdsConfig.forceLogin){if(!oe(t))return void V("identify");const e=y(t).slice(0,1e3);this.userStore.setUid(e),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((t=>{const i=this.uploader.getHoardingQueue(t);i.forEach(((t,n)=>i[n].deviceId=e)),this.uploader.initiateRequest(t,!0)}))}else V("identify",!1,"forceLogin未开启");else V("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(e,t)=>{var i,n,s,r;if(c(t)&&!A(t)){const{eventContextBuilder:o,eventInterceptor:a,lastVisitEvent:l}=this.dataStore,g=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},o(e));g.attributes=X(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),D(t))),g.path||(g.path=null===(n=l[e])||void 0===n?void 0:n.path,g.query=null===(s=l[e])||void 0===s?void 0:s.query,g.title=null===(r=l[e])||void 0===r?void 0:r.title),a(g)}else V("setUserAttributes")},this.setUserId=(e,t,i)=>{if(oe(t)){const n=this.userStore.getGioId(e);t=y(t).slice(0,1e3),i=y(i).slice(0,1e3),this.userStore.setUserId(e,t);const{idMapping:s}=this.dataStore.getTrackerVds(e);s&&this.userStore.setUserKey(e,a(i)?"":i),n&&n!==t&&(this.userStore.setSessionId(e),this.dataStore.sendVisit(e))}else V("setUserId")},this.clearUserId=e=>{this.userStore.setUserId(e,void 0),this.userStore.setUserKey(e,void 0)},this.setGeneralProps=(e,t)=>c(t)&&!A(t)?(A(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]={}),_(t,((t,i)=>{d(this.dataStore.generalProps[e][i])&&!d(t)||(this.dataStore.generalProps[e][i]=t)})),!0):(V("setGeneralProps"),!1),this.clearGeneralProps=(e,t)=>{try{A(this.dataStore.generalProps[e])||(h(t)&&!A(t)?t.forEach((t=>{x(this.dataStore.generalProps[e],t)})):this.dataStore.generalProps[e]={})}catch(e){return V("clearGeneralProps"),!1}},this.track=(e,t,i)=>{L(t,(()=>{var n;const{eventContextBuilder:s,eventInterceptor:r}=this.dataStore,o=Object.assign({eventType:"CUSTOM",eventName:t},s(e));o.attributes=X(Object.assign(Object.assign({},null!==(n=o.attributes)&&void 0!==n?n:{}),D(Object.assign({},c(i)&&!A(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(o["&&sendTo"]=i["&&sendTo"]),r(o)}))},this.trackTimerStart=(e,t)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(e);return i?L(t,(()=>{const i=R();return this.dataStore.trackTimers[e]||(this.dataStore.trackTimers[e]={}),this.dataStore.trackTimers[e][i]={eventName:t,leng:0,start:+Date.now()},i})):(H("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return e.start&&(e.leng=e.leng+(+Date.now()-e.start)),e.start=0,!0}return!1},this.trackTimerResume=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return 0===e.start&&(e.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t,i)=>{var n;const{dataCollect:s}=this.dataStore.getTrackerVds(e),r=this.dataStore.trackTimers[e];if(t&&r&&r[t]){if(s){const s=864e5,o=r[t];if(0!==o.start){const e=+Date.now()-o.start;o.leng=e>0?o.leng+e:0}const{eventContextBuilder:a,eventInterceptor:l}=this.dataStore,g=Object.assign({eventType:"CUSTOM",eventName:o.eventName},a(e));return g.attributes=X(Object.assign(Object.assign({},null!==(n=g.attributes)&&void 0!==n?n:{}),D(Object.assign(Object.assign({},c(i)&&!A(i)?i:{}),{event_duration:o.leng>s?0:o.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(g["&&sendTo"]=i["&&sendTo"]),l(g),!0}return H("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return H("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(e,t)=>{const i=this.dataStore.trackTimers[e];return t&&i&&i[t]?(delete i[t],!0):(H("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=e=>{this.dataStore.trackTimers[e]={}},this.setLocation=(e,t,i)=>{A(this.dataStore.locationData[e])&&(this.dataStore.locationData[e]={});const n=this.dataStore.locationData[e],s=e=>e>=-180&&180>=e;s(t)&&s(i)&&(n.latitude!==t||n.longitude!==i)&&(this.dataStore.locationData[e]={latitude:t,longitude:i})},this.updateImpression=()=>{H("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(e,t,i)=>{H("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),K(i,{})},this.getGioInfo=e=>{const{getUid:t,getUserId:i,getUserKey:n,getSessionId:s}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:l,idMapping:g,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(e),d={gioappid:o,giocs1:i(e)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:s(e),giou:t()};return d.giodatacollect=l,d.giodatasourceid=a,g&&(d.giouserkey=n(e)),A(u)||u.forEach((t=>{var i;c.includes(t)||(d["gio"+t]=(null!==(i=this.dataStore.lastVisitEvent[e])&&void 0!==i?i:{})[t])})),et.stringify(d)},this.utils=Object.assign(Object.assign(Object.assign({},U),re),{qs:et}),this.emitter={all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map((function(e){e(i)})),(n=e.get("*"))&&n.slice().map((function(e){e(t,i)}))}},this.gioPlatform=Y(),this.gioFramework="taro",this.sdkVersion="4.3.0";try{"quickapp"===this.gioPlatform||d(getApp)&&d(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&H("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Re,this.minipInstance=new Ge(this),this.dataStore=new Ae(this),this.userStore=new ot(this),this.uploader=new rt(this),this.plugins=new Xe(this),this.plugins.innerPluginInit()}},lt=function(){var e;const t=arguments[0];let i="g0",n=t;if(t.indexOf(".")>-1&&(i=null!==(e=t.split(".")[0])&&void 0!==e?e:"g0",n=t.split(".")[1]),l(n)&&ge.includes(n)&&at[n]){const e=f(Array.from(arguments));if("init"===n){const t=((e,t)=>{const i=y(t[0]),n=y(t[1]),s=(4===t.length?t[3]:t[2])||{};return i&&n?e.dataStore.initializedTrackingIds.some(((t,s)=>{const r=0===s?e.vdsConfig:e.subInstance[t];return r.projectId===i&&r.dataSourceId===n}))?(H("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:n,appId:y(4===t.length?t[2]:""),userOptions:s}:(H('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})(at,e);if(t){const{projectId:e,dataSourceId:n,appId:s,userOptions:r}=t;return at.init(Object.assign(Object.assign({},r),{projectId:e,dataSourceId:n,appId:s,trackingId:i}))}return!1}if("registerPlugins"===n)at.registerPlugins(e[0]);else{if(at.gioSDKInitialized&&at.vdsConfig)return le.includes(n)?F((()=>at.handlerDistribute(i,n,e))):F((()=>at[n](...e)));H("SDK未初始化!","error")}}else if(ce.includes(n))H(`方法 ${y(n)} 已被弃用,请移除!`,"warn");else{if("canIUse"===n)return ge.includes(arguments[1])&&!!at[arguments[1]];H(`不存在名为 ${y(n)} 的方法调用!`,"error")}};Z().gdp=lt,Z().gioSDKVersion=at.sdkVersion;const{growingApp:gt,growingPage:ut,growingComponent:ct,growingBehavior:dt,initOriginalValue:ht}=at.dataStore.eventHooks;ht();const pt=F((()=>null!=gt?gt:App)),vt=F((()=>null!=ut?ut:Page)),mt=F((()=>null!=ct?ct:Component)),ft=F((()=>null!=dt?dt:Behavior));export{pt as GioApp,ft as GioBehavior,mt as GioComponent,vt as GioPage,lt as default};
|
|
1
|
+
const e=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,t=/^__reactProps\$[a-z0-9]+$/i,i=/return [$\w]+.\w+\(/,n=/return \w+\(/,s=/return [$\w]+.\$emit\(['"]\w+/,r=/return [$\w]+.\w+/,o=/return [$\w]+/,a=e=>["undefined","null"].includes(q(e)),l=e=>"string"===q(e),g=e=>"number"===q(e),c=e=>"boolean"===q(e),u=e=>"[object Object]"==={}.toString.call(e)&&!a(e),d=e=>["function","asyncfunction"].includes(q(e)),h=e=>Array.isArray(e)&&"array"===q(e),p=e=>"date"===q(e),v=e=>{try{return Array.from(e)[0]}catch(e){return}},m=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},f=(e,t=1)=>h(e)&&g(t)?e.slice(t>0?t:1,e.length):e,I=(e,t=!1)=>{if(h(e)){let i=0;const n=[];for(const s of e)s&&!A(s)&&(n[i++]=s),t&&0===s&&(n[i++]=s);return n}return e},O=(e,t)=>{if(h(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},y=e=>a(e)?"":""+e,S=(e,t)=>"string"===q(e)?e.split(t):e,b=e=>{if(l(e)){const t=S(e,"");return`${v(t).toLowerCase()}${f(t).join("")}`}return e},w=(e,t)=>(l(e)||(e=y(e)),e.slice(0,t.length)===t),P={}.hasOwnProperty,k=(e,t)=>!a(e)&&P.call(e,t),T=e=>u(e)?Object.keys(e):[],_=(e,t)=>{T(e).forEach((i=>t(e[i],i)))},E=(e,t)=>{const i=T(e);return!(!u(e)||!u(t)||i.length!==T(t).length||i.map(((i,n)=>u(e[i])?E(e[i],t[i]):e[i]===t[i])).includes(!1))},C=(e,t,i)=>{let n=e;return u(e)?(t.split(".").forEach((e=>{n=n?n[e]:i})),n):i},x=(e,t)=>{if(!u(e))return!1;try{if("string"===q(t))return delete e[t];if("array"===q(t))return t.map((t=>delete e[t]));"object"===q(t)&&t.constructor===RegExp&&T(e).forEach((i=>{t.test(i)&&x(e,i)}))}catch(e){return!1}},j=(e,t=250,i,n)=>{let s,r=0;return"boolean"!==q(i)&&(n=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function g(){r=Date.now(),e.apply(a,o)}n&&!s&&g(),s&&clearTimeout(s),void 0===n&&l>t?g():!0!==i&&(s=setTimeout(n?function(){s=void 0}:g,void 0===n?t-l:t))}},A=e=>h(e)?0===e.length:u(e)?0===T(e).length:!e,q=e=>({}.toString.call(e).slice(8,-1).toLowerCase()),N=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())};var U=Object.freeze({__proto__:null,isNil:a,isString:l,isNaN:e=>"NaN"===y(Number(e)),isNumber:g,isBoolean:c,isObject:u,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:d,isArray:h,isDate:p,fixed:(e,t)=>g(e)?Number(e.toFixed(g(t)?t:2)):l(e)&&"NaN"!==y(Number(e))?Number(Number(e).toFixed(g(t)?t:2)):e,head:v,last:m,drop:f,dropWhile:(e,t)=>h(e)?e.filter((e=>!t(e))):e,compact:I,find:O,isEqualArray:(e,t)=>!(!h(e)||!h(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:y,split:S,lowerFirst:b,upperFirst:e=>{if(l(e)){const t=S(e,"");return`${v(t).toUpperCase()}${f(t).join("")}`}return e},startsWith:w,endsWith:(e,t)=>{const{length:i}=e;let n=i;n>i&&(n=i);const s=n;return n-=t.length,n>=0&&e.slice(n,s)===t},hasOwnProperty:P,has:k,keys:T,forEach:_,isEqual:E,get:C,unset:x,throttle:j,isEmpty:A,typeOf:q,formatDate:N});const H=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},V=(e,t=!0,i="参数不合法")=>H(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),L=e=>{try{return e()}catch(e){return}},F=(e,t)=>{if(d(e))try{e(t)}catch(e){H("回调执行失败!"+e,"error")}},D=e=>l(e)?e.trim().substring(0,100):e,K=(t,i)=>l(t)&&!A(t)&&t.match(e)?i():(H("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),$=e=>(a(e)||T(e).forEach((t=>{d(e[t])?e[t]=L((()=>e[t]())):u(e[t])?x(e,t):h(e[t])||(e[t]=y(e[t]))})),e),B=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),R=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,M=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,G=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},Q=e=>{if(l(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},z=e=>l(e)?e.startsWith("/")?e:"/"+e:"",W=e=>L((()=>{switch(e){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 e;return e||(e=L((()=>swan))),e||(e=L((()=>my))),e||(e=L((()=>tt))),e||(e=L((()=>qq))),e||(e=L((()=>ks))),e||(e=L((()=>jd))),e||(e=L((()=>wx))),e}}})),J=e=>L((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return L((()=>__ttConfig))||(null===global||void 0===global?void 0:global.TMAConfig)||(null===globalThis||void 0===globalThis?void 0:globalThis.TMAConfig);case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),Y=()=>{let e;return!e&&L((()=>swan))&&(e="swan"),!e&&L((()=>tt))&&(e="tt"),!e&&L((()=>qq))&&(e="qq"),!e&&L((()=>my.tb))&&(e="tb"),!e&&L((()=>my))&&(e="my"),!e&&L((()=>ks))&&(e="ks"),!e&&L((()=>jd))&&(e="jd"),!e&&L((()=>wx))&&(e="wx"),e||O(T(global),(e=>y(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},Z=()=>{var e;return null!==(e=L((()=>{var e;return null!==(e=L((()=>{var e;return null!==(e=L((()=>$global)))&&void 0!==e?e:global})))&&void 0!==e?e:window})))&&void 0!==e?e:globalThis},X=e=>{const t={};return u(e)&&(x(e,"&&sendTo"),_(e,((e,i)=>{const n=y(i).slice(0,100);u(e)?t[n]=X(e):h(e)?(t[n]=I(e.slice(0,100),!0),t[n]=t[n].join("||").slice(0,1e3)):p(e)?t[n]=N(e):t[n]=a(e)?"":y(e).slice(0,1e3)}))),t},ee=(e,t)=>{const i=()=>t.map((t=>e.getStorageSync(t)));try{return e.minip.canIUse("batchGetStorageSync")?e.minip.batchGetStorageSync(t):i()}catch(e){return i()}},te=(e,t)=>{const i=()=>t.map((({key:t,value:i})=>e.setStorageSync(t,i)));try{return e.minip.canIUse("batchSetStorageSync")?e.minip.batchSetStorageSync(t):i()}catch(e){return i()}},ie=e=>T(e||{}).map((t=>t?`${t}=${a(e[t])?"":e[t]}`:"")).join("&"),ne=e=>{(w(e,"?")||w(e,"&"))&&(e=e.slice(1,e.length));const t={};return e.split("&").forEach((e=>{const i=e.split("=");i[0]&&(t[i[0]]=i[1])})),t},se=(e={},t={})=>{const i={};return T(t).forEach((e=>{["string","number","boolean"].includes(q(t[e]))&&(i[e]=t[e])})),Object.assign({},i,e)};var re=Object.freeze({__proto__:null,consoleText:H,callError:V,niceTry:L,niceCallback:F,limitString:D,eventNameValidate:K,getDynamicAttributes:$,guid:B,getScreenHeight:R,getScreenWidth:M,getOS:G,compareVersion:(e="",t="")=>{const i=e=>e.replace(/\s+/g,""),n=e=>e.replace(/[vV]/g,""),s=i(n(e)),r=i(n(t)),o=s.split("."),a=r.split(".");for(let e=0;3>e;e++){let t=Number(o[e]),i=Number(a[e]);if(t>i)return 1;if(i>t)return-1;if(!isNaN(t)&&isNaN(i))return 1;if(isNaN(t)&&!isNaN(i))return-1}return 0},getVueVersion:e=>{if(e){const t=Number(v(S(e.version,".")));return Number.isNaN(t)?0:t}return 0},splitPath:Q,normalPath:z,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:W,getPlainConfig:J,getPlainPlatform:Y,getSubKeys:e=>T(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let e=L((()=>getApp({allowDefault:!0})));return e||(e=Z()),e},getGlobal:Z,limitObject:X,batchGetStorageSync:ee,batchSetStorageSync:te,qsStringify:ie,qsParse:ne,hashCode:(e,t=!1)=>{let i=0;if(A(e)||"boolean"==typeof e)return i;let n=0;for(;n<e.length;)i=(i<<5)-i+e.charCodeAt(n),i|=0,n++;return t?Math.abs(i):i},getLaunchQuery:se});const oe=e=>l(e)&&e.length>0||g(e)&&e>0,ae={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:[]},impressionScale:{type:"number",default:0},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},sessionExpires:{type:"number",default:-1},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"}},le=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],ge=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...le],ce={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},ue=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],de=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],he=[...de,"appChannel","language","platformVersion"],pe={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 ve="MINIP_LIFECYCLE",me="ON_COMMIT_REQUEST",fe="ON_COMPOSE_AFTER",Ie="ON_COMPOSE_BEFORE",Oe="ON_ERROR",ye="ON_INSTALL",Se="ON_SEND_AFTER",be="ON_SEND_BEFORE",we="OPTION_CHANGE",Pe="OPTION_INITIALIZED",ke="SDK_INITIALIZED",Te="SESSIONID_UPDATE";class _e{constructor(e){this.growingIO=e,this.main=(e,t,i=!0)=>{e||(e=this.growingIO.trackingId);const{sdkVersion:n,platformConfig:s,minipInstance:r,userStore:o,dataStore:a,dataStore:{scene:l,eventHooks:{currentPage:g},generalProps:c}}=this.growingIO,{version:u,dataSourceId:d,appId:h,idMapping:p,ignoreFields:v}=a.getTrackerVds(e),m=a.locationData[e],{systemInfo:f={},network:I={}}=r,{brand:O,model:y,platform:S,language:b}=f,w=g.getPagePath(),P={appChannel:"scn:"+(l||"NA"),appVersion:u,dataSourceId:d,deviceBrand:O,deviceId:o.getUid(),deviceModel:y,deviceType:G(S,s.name),domain:h,language:b,latitude:null==m?void 0:m.latitude,longitude:null==m?void 0:m.longitude,networkState:(null==I?void 0:I.networkType)||(null==I?void 0:I.type)||(null==I?void 0:I.subtype),operatingSystem:G(S,s.name),path:w,platform:s.platform,platformVersion:s.name+(f.version?" "+f.version:""),query:w?g.getPageQuery():"",screenHeight:R(f),screenWidth:M(f),sdkVersion:n,sessionId:o.getSessionId(e),title:g.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:o.getUserId(e)};return p&&(P.userKey=o.getUserKey(e)),i&&!A(c[e])&&(P.attributes=Object.assign({},c[e])),A(P.attributes)||(P.attributes=X($(Object.assign({},P.attributes)))),A(v)||v.forEach((e=>{x(P,e)})),A(t)?Object.assign(Object.assign({},P),{trackingId:e}):Object.assign(Object.assign(Object.assign({},P),t),{trackingId:e})}}}function Ee(e,t,i,n){return new(i||(i=Promise))((function(s,r){function o(e){try{l(n.next(e))}catch(e){r(e)}}function a(e){try{l(n.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?s(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((n=n.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class Ce{constructor(e){this.growingIO=e,this.enterParams={},this.main=(e,t)=>{var i,n;const s=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:g,dataStore:c,dataStore:{trackersExecute:u,shareOut:d,lastCloseTime:h,saveStorageInfo:p,setOriginalSource:v}}=this.growingIO;r.emit(ve,{event:"App "+e,timestamp:s,params:null!==(i=t[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",e,s);const m=l.listeners.app;switch(r.emit(Ie,{event:"App "+e,params:null!==(n=t[0])&&void 0!==n?n:{}}),e){case m.appLaunch:this.enterParams=Object.assign({},t[0]);break;case m.appCreate:case m.appShow:{const{path:e,query:i,referralPage:n}=this.enterParamsParse(t[0]);!d&&a.originalSource&&e&&u((t=>{v(t,{path:e,query:i,referralPage:n})})),h?(Date.now()-h>60*a.keepAlive*1e3||c.lastScene&&c.scene!==c.lastScene)&&u((e=>{o.setSessionId(e)})):u((t=>{c.lastVisitEvent[t]={path:e,query:i,referralPage:n},this.buildVisitEvent(t,{path:e,query:i,referralPage:n})}));break}case m.appClose:c.lastScene=c.scene,c.lastCloseTime=Date.now(),p(),o.saveUserInfo(),u((e=>{this.buildCloseEvent(e),a.forceLogin||g.initiateRequest(e,!0)}))}},this.enterParamsParse=(e={})=>{var t;const{gioPlatform:i,minipInstance:n,dataStore:s}=this.growingIO;let r="",o="",a="";if("quickapp"!==i&&n.minip.canIUse("getEnterOptionsSync")){const{path:i,query:l,scene:g,referrerInfo:c}=n.minip.getEnterOptionsSync()||{};r=i||e.path,o=l||e.query,a=(null==c?void 0:c.appId)||(null===(t=null==e?void 0:e.referrerInfo)||void 0===t?void 0:t.appId)||"",s.scene=g||e.scene,o=A(null==c?void 0:c.extraData)?ie(o):ie(se(o,c.extraData))}else{const{path:t,query:i,referrerInfo:n}=e;r=t,o=ie(i),a=(null==n?void 0:n.appId)||"",this.parseScene(e)}return{path:r,query:o,referralPage:a}},this.parseScene=e=>{var t;const{minipInstance:i,gioPlatform:n,dataStore:s}=this.growingIO;let r;if("quickapp"===n){const{extra:e,type:t}=i.getAppSource();r=(null==e?void 0:e.scene)||t}else A(e)||((null===(t=null==e?void 0:e.query)||void 0===t?void 0:t.wxShoppingListScene)?r=e.query.wxShoppingListScene:(null==e?void 0:e.scene)?r=e.scene:s.scene="NA");s.scene=r},this.buildVisitEvent=(e,t)=>{const{dataStore:{getOriginalSource:i,eventContextBuilder:n,eventInterceptor:s},vdsConfig:r}=this.growingIO,o=i(e),a=(null==t?void 0:t.query)||"";let l=Object.assign({eventType:"VISIT"},n(e,{}));!A(t)&&t.path&&(l.path=t.path||"",l.query="string"===q(a)?a:ie(a),t.referralPage&&(l.referralPage=t.referralPage)),r.originalSource&&!A(o)&&(l=Object.assign(Object.assign({},l),o)),s(l)},this.buildCloseEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},t(e)))}}}class xe{constructor(e){this.growingIO=e,this.lifeBeforeShow=!0,this.getPagePath=()=>{var e,t,i;const{minipInstance:n,inPlugin:s,dataStore:r,trackingId:o}=this.growingIO,a=n.getCurrentPath();if(s){const e=r.getTrackerVds(o);return a||"/插件"+e.appId}return a||(null===(e=r.eventHooks.appEffects.enterParams)||void 0===e?void 0:e.path)||(null===(t=r.lastPageEvent[o])||void 0===t?void 0:t.path)||(null===(i=r.lastVisitEvent[o])||void 0===i?void 0:i.path)},this.getPageQuery=()=>{var e,t,i,n,s,r;const{minipInstance:o,dataStore:a,trackingId:l}=this.growingIO,g=o.getCurrentPage(),c=o.getCurrentPath(),{enterParams:u={}}=a.eventHooks.appEffects;if(!c)return u.path?this.qsQuery(se(null==u?void 0:u.query,null===(i=null==u?void 0:u.referrerInfo)||void 0===i?void 0:i.extraData)):(null===(n=a.lastPageEvent[l])||void 0===n?void 0:n.path)?null===(s=a.lastPageEvent[l])||void 0===s?void 0:s.query:null===(r=a.lastVisitEvent[l])||void 0===r?void 0:r.query;{const i=null!==(e=g.options)&&void 0!==e?e:g.$taroParams;if(!A(i))return x(i,"$taroTimestamp"),this.qsQuery(i);if(!A(this.queryOption[c]))return this.qsQuery(this.queryOption[c]);if(c===u.path)return this.qsQuery(se(null==u?void 0:u.query,null===(t=null==u?void 0:u.referrerInfo)||void 0===t?void 0:t.extraData))}},this.getPageTitle=e=>{const{minipInstance:t,inPlugin:i,dataStore:n}=this.growingIO,s=t.getCurrentPath(),r=this.configuredTitle[s]||t.getPageTitle(t.getCurrentPage());if(i){const t=n.getTrackerVds(e||this.growingIO.trackingId);return r||`/插件${t.appId}${s?"_"+m(s.split("/")):""}`}return r},this.qsQuery=(e={})=>{const t=Object.assign({},e);return x(t,"wxShoppingListScene"),ie(t)},this.getReferralPage=e=>{var t,i,n;const{minipInstance:s,dataStore:{lastPageEvent:r,scene:o,eventHooks:a}}=this.growingIO;return(null===(t=r[e])||void 0===t?void 0:t.path)||(null===(n=null===(i=a.appEffects.enterParams)||void 0===i?void 0:i.referrerInfo)||void 0===n?void 0:n.appId)||(o?`scn:${s.scnPrefix}${o}`:null)},this.updateShareResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=z(t+(i?"?"+i:"")),e.query=i,e},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=z(t+(i?"?"+i:"")),e.query=i,e},this.eventSetPageProps=(e,t)=>{const i=L((()=>this.pageProps[e][this.getPagePath()]));return A(i)?t.attributes:X($(Object.assign(Object.assign({},t.attributes),i)))},this.queryOption={},this.configuredTitle={},this.pageProps={}}buildShareQuery(e){var t,i;const n=Q(null!==(t=e.path)&&void 0!==t?t:"");let s=this.getPagePath(),r={},o=k(e,"path");if(o&&(s=v(n),r=ne(m(n))||{}),A(r)&&(r=ne(null!==(i=e.query)&&void 0!==i?i:"")||{},I(T(r)).forEach((e=>{e.toLowerCase().startsWith("utm_")&&x(r,e)}))),!o&&A(r)){const e=this.growingIO.minipInstance.getCurrentPage();r=e.options||this.queryOption[e.route]||{}}return[s,ie(r)]}}class je{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var n,s;const r=Date.now(),{emitter:o,minipInstance:a,plugins:l,vdsConfig:g,platformConfig:c,dataStore:{getTrackerVds:u,getOriginalSource:h,setOriginalSource:p,trackersExecute:v,eventHooks:m,toggleShareOut:f,buildAppMessageEvent:I,buildTimelineEvent:O,buildAddFavorites:y}}=this.growingIO,{currentPage:S}=m;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=a.getCurrentPage()),e.route||(e.route=a.getCurrentPath(e));const b=e.route||e.uri||e.__route__||(null===(n=null==e?void 0:e.$page)||void 0===n?void 0:n.fullPath)||"";o.emit(ve,{event:"Page "+t,timestamp:r,params:{page:e,args:i[0]}}),g.debug&&console.log("Page:",b,"#",t,r),this.prevEvent[t]=Date.now();const w=c.listeners.page;switch(o.emit(Ie,{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),S.lastLifecycle=S.currentLifecycle,S.currentLifecycle=t,t){case w.pageLoad:S.queryOption[b]=C(e,"options")||C(e,"__displayReporter.query")||C(e,"$page.query")||C(e,"$wx.__displayReporter.query")||C(e,"$taroParams")||i[0]||{},x(S.queryOption[b],"$taroTimestamp");break;case w.pageShow:v((e=>{const t=h(e);A(t)||t.path!==b||p(e,Object.assign(Object.assign({},t),{title:S.getPageTitle()}));const{trackPage:i}=u(e);i&&this.buildPageEvent(e)})),f(!1);break;case w.pageHide:case w.pageUnload:break;case w.shareApp:f(!0),v((e=>{const{followShare:t}=u(e);t&&I(e,i)}));break;case w.shareTime:v((e=>{const{followShare:t}=u(e);t&&O(e,i)}));break;case w.addFavorites:v((e=>{const{followShare:t}=u(e);t&&y(e,i)}));break;case w.tabTap:{const e=null===(s=null==l?void 0:l.gioEventAutoTracking)||void 0===s?void 0:s.buildTabClickEvent;g.autotrack&&e&&d(e)&&e(this.growingIO.trackingId,i[0]);break}}S.lastLifecycle=S.currentLifecycle,S.currentLifecycle=t+"End",["onHideEnd","onUnloadEnd"].includes(S.currentLifecycle)&&(S.lifeBeforeShow=!0),"onShowEnd"===S.currentLifecycle&&(S.lifeBeforeShow=!1)},this.buildPageEvent=(e,t)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:n,eventHooks:{currentPage:s}}}=this.growingIO,r=Object.assign({eventType:"PAGE",referralPage:s.getReferralPage(e)},i(e));r.attributes=s.eventSetPageProps(e,r),!A(t)&&t.title&&(r.title=t.title),n(r)},this.prevEvent={}}}class Ae{constructor(e){var t;this.growingIO=e,this.isNormalFc=(e,t)=>d(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),k(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),k(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),k(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{h(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{d(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=()=>{})}))},this.lifeFcEffects=(e,t,i)=>{const n=this;return["onShareTimeline","onAddToFavorites"].includes(e)?function(...s){let r=t.apply(this,s);"onShareTimeline"===e&&n.growingIO.vdsConfig.followShare&&(r=n.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=n.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(s);return r&&o.push(r),n[`def${i}Cbs`][e].apply(this,o),r}:function(...s){var r;return Ee(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=t.apply(this,s))&&void 0!==r?r:{},"promise"===q(o)&&(o=yield o.then((e=>e))),"promise"===q(o.promise)){const e=function(){return Ee(this,void 0,void 0,(function*(){let e=o;return new Promise((t=>{let i=setTimeout((()=>{t(Object.assign({},e)),clearTimeout(i),i=void 0}),3e3);o.promise.then((n=>{e=n,t(Object.assign({},e)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield e()),x(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`][e].apply(this,a)}catch(e){H(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,s)),n.growingIO.emitter.emit(ve,{event:`${i} ${e}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(s)}}),o}))}},this.customFcEffects=(e,t)=>{const i=this;return function(...n){var s,r;let o;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let t=n[0]||{};k(t,"type")&&((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))||(t=n[n.length-1]),((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))&&i.actionEventTypes.includes(t.type)&&(d(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(t,e))}catch(e){H(e,"error")}return o=t.apply(this,n),o}},this.appApplyProxy=(e,t)=>this.appHandlers.includes(e)?this.lifeFcEffects(e,t,"App"):this.customFcEffects(e,t),this.pageApplyProxy=(e,t)=>this.pageHandlers.includes(e)?this.lifeFcEffects(e,t,"Page"):this.customFcEffects(e,t),this.appOverriding=e=>(this.setAppEffectCbs(),this.supLifeFcs(e,"app"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.appApplyProxy(e,t[e]))})),e),this.pageOverriding=e=>(this.setPageEffectCbs(),this.supLifeFcs(e,"page"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.componentOverriding=e=>(this.setPageEffectCbs(),e.methods||(e.methods={}),this.supLifeFcs(this.growingIO.inPlugin?e:e.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?e:e.methods,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.setAppEffectCbs=()=>{const e=this;this.appHandlers.forEach((t=>{this.defAppCbs[t]=function(...i){e.appEffects.main(t,i)}}))},this.setPageEffectCbs=()=>{const e=this;this.pageHandlers.forEach((t=>{this.defPageCbs[t]=function(...i){e.pageEffects.main(this,t,i)}}))},this.growingApp=e=>d(this.originalApp)?this.originalApp(this.appOverriding(e)):this.appOverriding(e),this.growingPage=e=>d(this.originalPage)?this.originalPage(this.pageOverriding(e)):this.pageOverriding(e),this.growingComponent=e=>d(this.originalComponent)?this.originalComponent(this.componentOverriding(e)):this.componentOverriding(e),this.growingBehavior=e=>d(this.originalBehavior)?this.originalBehavior(this.componentOverriding(e)):this.componentOverriding(e),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,n=i.hooks;if(e.includes("App"))try{n.App&&!this.appHooked&&(App=function(...e){return t.originalApp(t.appOverriding(e[0]))},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{n.Page&&!this.pageHooked&&(Page=function(...e){return t.originalPage(t.pageOverriding(e[0]))},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{n.Component&&!this.componentHooked&&(Component=function(...e){return t.originalComponent(t.componentOverriding(e[0]))},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{n.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.originalBehavior(t.componentOverriding(e[0]))},this.behaviorHooked=!0)}catch(e){}},this.initOriginalValue=()=>{this.setAppEffectCbs(),this.setPageEffectCbs(),this.originalApp=L((()=>App||global.App)),this.originalPage=L((()=>Page||global.Page)),this.originalComponent=L((()=>Component||global.Component)),this.originalBehavior=L((()=>Behavior||global.Behavior))},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;this.initOriginalValue(),t.canHook?(this.nativeGrowing(),Z().GioApp=L((()=>null!==App&&void 0!==App?App:this.originalApp)),Z().GioPage=L((()=>null!==Page&&void 0!==Page?Page:this.originalPage)),Z().GioComponent=L((()=>null!==Component&&void 0!==Component?Component:this.originalComponent)),Z().GioBehavior=L((()=>null!==Behavior&&void 0!==Behavior?Behavior:this.originalBehavior))):"quickapp"===i&&(Z().GioApp=function(...t){return e.appOverriding(t[0])},Z().GioPage=function(...t){return e.pageOverriding(t[0])},Z().GioComponent=function(...t){return e.pageOverriding(t[0])})};const i=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new Ce(this.growingIO),this.pageEffects=new je(this.growingIO),this.currentPage=new xe(this.growingIO)}}class qe{constructor(e){var t,i;this.growingIO=e,this.ALLOW_SETTING_KEYS=T(ae),this.getStorageKey=(e,t)=>{const{inPlugin:i}=this.growingIO;return`${e===this.growingIO.trackingId?"":e}${pe[i?"plugin_"+t:t]}`},this.getGsid=e=>{let t=Number(this._gsid[e]);return Number.isNaN(t)||t>=1e9||1>t?(this.setGsid(e,1),1):t},this.setGsid=(e,t)=>{let i=Number(t);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[e]=i,10>this._gsid[e]-this._stid[e]||this.saveStorageInfo()},this.initStorageInfo=e=>{const{minipInstance:t}=this.growingIO,i=t.getStorageSync(this.getStorageKey(e,"gsid"));let n=Number(i);(Number.isNaN(n)||n>=1e9||1>n)&&(n=1),this._gsid[e]=n,this._stid[e]=n,n!==i&&t.setStorageSync(this.getStorageKey(e,"gsid"),n)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=Object.assign({},this._gsid),te(e,this.initializedTrackingIds.map((e=>({key:this.getStorageKey(e,"gsid"),value:this._gsid[e]}))))},this.setOriginalSource=(e,t)=>{const{minipInstance:i}=this.growingIO;i.setStorageSync(this.getStorageKey(e,"originalSource"),JSON.stringify(t))},this.getOriginalSource=e=>{var t;const{minipInstance:i}=this.growingIO;return null!==(t=L((()=>JSON.parse(i.getStorageSync(this.getStorageKey(e,"originalSource"))))))&&void 0!==t?t:{}},this.getTrackerVds=e=>this.growingIO.trackingId===e?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=e=>{const t=this.initOptions(e);return t.trackingId=e.trackingId,this.growingIO.trackingId=e.trackingId,this.growingIO.vdsConfig=t,t},this.initTrackerHooker=e=>{var t,i;const{platformConfig:n,inPlugin:s,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:l}=e;a||l||"quickapp"===r.platform||(n.canHook=!0),!s||["tbp","jdp"].includes(r.platform)?this.eventHooks.initEventHooks():this.eventHooks.initOriginalValue(),a&&(null===(t=null==o?void 0:o.gioUniAppAdapter)||void 0===t||t.main()),l&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=e=>{var t,i,n,s,r,o;const{projectId:a,dataSourceId:l,appId:g,trackingId:c}=e,u={};return this.ALLOW_SETTING_KEYS.forEach((t=>{const i=ae[t].type;(h(i)?i.includes(q(e[t])):q(e[t])===ae[t].type)?"ignoreFields"===t?u.ignoreFields=e.ignoreFields.filter((e=>de.includes(e))):"extraParams"===t?u.extraParams=e.extraParams.filter((e=>he.includes(e))):(u[t]=e[t],["dataCollect","autotrack"].includes(t)&&!u[t]&&H("已关闭"+ce[t],"info")):u[t]=ae[t].default})),u.uploadInterval=Math.round(u.uploadInterval),(Number.isNaN(u.uploadInterval)||0>u.uploadInterval||u.uploadInterval>3e3)&&(u.uploadInterval=1e3),u.enableIdMapping&&!u.idMapping&&(u.idMapping=!0,u.idMapping||this.growingIO.userStore.setUserKey(c,"")),x(u,"enableIdMapping"),u.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(u.requestTimeout))&&u.requestTimeout>0||(u.requestTimeout=5e3),(0>u.impressionScale||u.impressionScale>1)&&(u.impressionScale=0),(0>u.keepAlive||u.keepAlive>1440)&&(u.keepAlive=5),(1>u.sessionExpires||u.sessionExpires>1440)&&(u.sessionExpires=-1),Object.assign(Object.assign({},u),{projectId:a,dataSourceId:l,appId:g,trackingId:c,performance:{monitor:null===(i=null===(t=u.performance)||void 0===t?void 0:t.monitor)||void 0===i||i,exception:null===(s=null===(n=u.performance)||void 0===n?void 0:n.exception)||void 0===s||s,network:null!==(o=null===(r=u.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(e,t,i)=>{var n;const{userStore:s,emitter:r}=this.growingIO,o=this.getTrackerVds(e),a=l(t)&&this.ALLOW_SETTING_KEYS.includes(t),g=a&&typeof i===(null===(n=ae[t])||void 0===n?void 0:n.type);if(a&&g){const n=Object.assign({},o);return this.updateVdsConfig(e,Object.assign(Object.assign({},o),{[t]:i})),"dataCollect"===t&&n.dataCollect!==i&&i&&s.setSessionId(e),r.emit(we,{optionName:t,optionValue:i}),!0}return V("setOption > "+t),!1},this.getOption=(e,t)=>{const i=this.getTrackerVds(e);return t&&k(this.growingIO.vdsConfig,t)?k(i,t)?i[t]:this.growingIO.vdsConfig[t]:A(t)?i:void V("getOption > "+t)},this.updateVdsConfig=(e,t)=>{e===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),t),Z().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[e]=Object.assign(Object.assign({},this.growingIO.subInstance[e]),t),Z().vdsConfig.subInstance[e]=this.growingIO.subInstance[e])},this.toggleShareOut=e=>{c(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=(e,t)=>{this.eventHooks.appEffects.buildVisitEvent(e,t)},this.sendPage=(e,t)=>{this.eventHooks.pageEffects.buildPageEvent(e,t)},this.eventConverter=e=>{const{dataStore:t,uploader:i}=this.growingIO,{dataCollect:n}=this.getTrackerVds(e.trackingId);if(n){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=t.getGsid(e.trackingId),t.setGsid(e.trackingId,e.eventSequenceId+1));const n={};_(e,((e,t)=>{var i;if("element"===t){const t=null!==(i=v(e))&&void 0!==i?i:{};_(t,((e,t)=>{A(e)&&0!==e||(n[t]=e)}))}else A(e)&&0!==e||(n[t]=e)})),this.growingIO.emitter.emit(fe,{composedEvent:n}),i.commitRequest(Object.assign(Object.assign({},n),{requestId:B()}))}},this.eventRefactor=e=>{var t,i;const n=Object.assign(Object.assign({},e),this.eventContextBuilder(e.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));return n.attributes=Object.assign(Object.assign({},null!==(t=n.attributes)&&void 0!==t?t:{}),null!==(i=e.attributes)&&void 0!==i?i:{}),n},this.eventInterceptor=e=>{const{systemInfo:t,network:i}=this.growingIO.minipInstance;A(t)||A(i)?this.interceptEvents.push(e):A(this.interceptEvents)?this.eventConverter(e):([...this.interceptEvents,e].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!A(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.buildAppMessageEvent=(e,t)=>{var i,n;const s=t[0];let r;2>t.length?1===t.length&&(r=s):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(e));g.attributes=X(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$from:s.from,$target:null===(n=null==s?void 0:s.target)||void 0===n?void 0:n.id,$share_title:null==r?void 0:r.title,$share_path:v(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildTimelineEvent=(e,t)=>{var i,n;const s=t[0];let r;2>t.length?1===t.length&&(r=s):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(e));g.attributes=X(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$target:null===(n=null==s?void 0:s.target)||void 0===n?void 0:n.id,$share_title:null==r?void 0:r.title,$share_path:v(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildAddFavorites=(e,t)=>{var i;const n=t[0];let s;2>t.length?1===t.length&&(s=n):s=t[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==s?void 0:s.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(e));l.attributes=X(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$share_title:null==s?void 0:s.title,$share_path:v(a),$share_query:a[1]})),o(l)},this.trackersExecute=e=>{this.initializedTrackingIds.forEach((t=>{"function"===q(e)&&e(t)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new _e(this.growingIO).main,this.eventHooks=new Ae(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:n,minipInstance:s}=this.growingIO;n.on(ke,(({trackingId:e})=>{this.initializedTrackingIds.push(e),this.initStorageInfo(e)})),n.on(me,(({eventData:e,trackingId:t})=>{"VISIT"===e.eventType&&(this.lastVisitEvent[t]=e),"PAGE"===e.eventType&&(this.lastPageEvent[t]=e)})),d(null===(t=s.minip)||void 0===t?void 0:t.onAppHide)&&s.minip.onAppHide((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];_(t,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))}))})),d(null===(i=s.minip)||void 0===i?void 0:i.onAppShow)&&s.minip.onAppShow((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];_(t,(e=>{e.start&&(e.start=+Date.now())}))}))})),n.on(we,(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.trackersExecute((e=>{this.growingIO.clearTrackTimer(e)}))})),this.growingIO.emitter.on(Te,(({oldSessionId:e,trackingId:t})=>{if(e){const{getPagePath:e,getPageQuery:i}=this.eventHooks.currentPage,n=e(),s=i();if(n)this.sendVisit(t,{path:n,query:s});else{const e=this.lastPageEvent[t];this.sendVisit(t,{path:e.path,query:e.query})}this.eventHooks.currentPage.lifeBeforeShow||this.sendPage(t)}}))}get scene(){return this._scene}set scene(e){const t=this._scene;this._scene=e,t!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:e,oldScene:t})}}const Ne={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"]}}},Ue=Object.assign(Object.assign({},Ne),{listeners:Object.assign({},Ne.listeners),name:"JingDong",platform:"jdp",scnPrefix:"jd_"}),He=Object.assign(Object.assign({},Ne),{listeners:Object.assign({},Ne.listeners),name:"KuaiShou",platform:"kuaishoup",scnPrefix:"ks_"}),Ve=Object.assign(Object.assign({},Ne),{listeners:Object.assign({},Ne.listeners),name:"Alipay",platform:"alip",scnPrefix:"alip_",hooks:Object.assign(Object.assign({},Ne.hooks),{Behavior:!1})}),Le=Object.assign(Object.assign({},Ne),{pageHandlers:[...Ne.pageHandlers,"onInit","didMount","didUnmount"],listeners:Object.assign(Object.assign({},Ne.listeners),{page:Object.assign(Object.assign({},Ne.listeners.page),{onInit:"onInit",didMount:"didMount",didUnmount:"didUnmount"})}),name:"Taobao",platform:"tbp",scnPrefix:"tbp_",hooks:Object.assign(Object.assign({},Ne.hooks),{Behavior:!1})}),Fe=Object.assign(Object.assign({},Ne),{listeners:Object.assign({},Ne.listeners),name:"QQ",platform:"qq",scnPrefix:"qq_"});Fe.pageHandlers=[...Ne.pageHandlers,"onAddToFavorites"],Fe.listeners.page.addFavorites="onAddToFavorites";const De=Object.assign(Object.assign({},Ne),{listeners:Object.assign({},Ne.listeners),name:"Baidu",platform:"baidup",scnPrefix:"baidup_"}),Ke=Object.assign(Object.assign({},Ne),{listeners:Object.assign({},Ne.listeners),name:"Bytedance",platform:"bytedance",scnPrefix:"bytedance_"}),$e=Object.assign(Object.assign({},Ne),{listeners:Object.assign({},Ne.listeners),name:"Weixin",platform:"MinP"});$e.pageHandlers=[...Ne.pageHandlers,"onShareTimeline","onAddToFavorites"],$e.listeners.page=Object.assign(Object.assign({},Ne.listeners.page),{shareTime:"onShareTimeline",addFavorites:"onAddToFavorites"});const Be=Y(),Re=L((()=>{const e={jd:Ue,ks:He,my:Ve,tb:Le,qq:Fe,swan:De,tt:Ke,wx:$e}[Be];return e.canHook=!1,e}));class Me{constructor(e){this.growingIO=e,this.minip=W("framework"),this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBarTitle,i=this;t&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const e=i.getCurrentPath(),{title:t}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.configuredTitle[e]=t}return t.apply(this,arguments)}})},this.navigateTo=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateTo(e)},this.switchTab=e=>{var t;null===(t=this.minip)||void 0===t||t.switchTab(e)},this.navigateToMiniProgram=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateToMiniProgram(e)},this.getImageInfo=({src:e,success:t,fail:i,complete:n})=>{var s;return null===(s=this.minip)||void 0===s?void 0:s.getImageInfo({src:e,success:t,fail:i,complete:n})},this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"observeAll")},this.getCurrentPage=()=>L((()=>m(getCurrentPages())))||{},this.getCurrentPath=()=>{const e=this.getCurrentPage();return(null==e?void 0:e.route)||(null==e?void 0:e.uri)||(null==e?void 0:e.__route__)||""},this.getPageTitle=e=>{var t;const i=Y();let n="",s=J(i);"string"===q(s)&&(s=null!==(t=L((()=>JSON.parse(s))))&&void 0!==t?t:{});const r=(null==e?void 0:e.data)||e.$data||{};if(n=l(null==r?void 0:r.gioPageTitle)?null==r?void 0:r.gioPageTitle:"",s){const{enterParams:t}=this.growingIO.dataStore.eventHooks.appEffects;e.route||A(t)||(e.route=t.path||"",n=this._getTitleFromTabBar(s,e.route)),L((()=>{var t,r,o,a,l,g;if(!n){const c=s.page||{},u=c[e.route]||c[e.route+".html"];n=u?null===(t=null==u?void 0:u.window)||void 0===t?void 0:t.navigationBarTitleText:["wx","tt"].includes(i)?null===(a=null===(o=null===(r=s||global||$global)||void 0===r?void 0:r.global)||void 0===o?void 0:o.window)||void 0===a?void 0:a.navigationBarTitleText:null===(g=null===(l=s||global||$global)||void 0===l?void 0:l.window)||void 0===g?void 0:g.navigationBarTitleText}})),n||(n=this._getTitleFromTabBar(s,e.route))}return D(n)},this._getTitleFromTabBar=(e,t)=>{var i,n;const s=null===(n=null===(i=null==e?void 0:e.tabBar)||void 0===i?void 0:i.list)||void 0===n?void 0:n.find((e=>e.pagePath===t||e.pagePath===t+".html"));return(null==s?void 0:s.text)||""},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return u(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=e=>new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:e,success:({data:e})=>t(e),fail:()=>t("")})})),this.setStorageSync=(e,t,i)=>{var n;i&&(t={value:t,expiredAt:i}),null===(n=this.minip)||void 0===n||n.setStorageSync(e,t)},this.setStorage=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:e,data:t})},this.removeStorageSync=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorageSync(e)},this.removeStorage=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorage(e)},this.getNetworkType=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{e.network=i,t(i)},fail:()=>t(null)})}))},this.request=({url:e,data:t,header:i,timeout:n,method:s,success:r,fail:o,complete:a})=>{var l;const g=null===(l=this.minip)||void 0===l?void 0:l.request({url:e,data:t,header:i,headers:i,timeout:n,method:s,success:r,fail:o,complete:a});let c=setTimeout((()=>{(null==g?void 0:g.abort)&&d(null==g?void 0:g.abort)&&(null==g||g.abort()),clearTimeout(c),c=null}),(n||1e4)+10);return g},this.getSystemInfo=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{e.systemInfo=i,t(i)},fail:()=>t(null)})}))},this.getSetting=()=>new Promise((e=>{var t;null===(t=this.minip)||void 0===t||t.getSetting({success:e,fail:e})}));const{platformConfig:{platform:t,scnPrefix:i}}=this.growingIO;this.platform=t,this.scnPrefix=i,this.growingIO.emitter.on(Pe,(()=>{this.getNetworkType().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()}))}))}}const Ge=Y();var Qe={wx:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}},swan:class extends Me{constructor(e){super(e),this.growingIO=e,this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"selectAll")},this.hookSetTitle()}},my:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBar,i=this;t&&Object.defineProperty(this.minip,"setNavigationBar",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const e=i.getCurrentPath(),{title:t}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.configuredTitle[e]=t}return t.apply(this,arguments)}})},this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"selectAll")},this.getStorageSync=e=>{const{data:t}=my.getStorageSync({key:e});return t},this.setStorageSync=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorageSync({key:e,data:t})},this.removeStorageSync=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorageSync({key:e})},this.hookSetTitle()}},qq:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}},tt:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}},ks:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}},jd:class extends Me{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}}}[Ge];const ze=["gioPerformance"];class We{constructor(e){var t,i,n,s,r,o;this.growingIO=e,this.innerPluginInit=()=>{var e;ze.forEach((e=>{var t;return x(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins,e)})),T(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins).forEach((e=>{var t,i;const{name:n,method:s}=null!==(i=null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins[e])&&void 0!==i?i:{};O(this.pluginItems,(e=>e.name===n))||this.pluginItems.push({name:b(n||e),method:s||(e=>{})})})),A(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var n,s;const{emitter:r}=this.growingIO,o=t||O(this.pluginItems,(t=>t.name===e));if((null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[e])return H(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return H(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return(null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[e]=new o.method(this.growingIO,i),t&&(r.emit(ye,e),H("加载插件 "+e,"info")),!0}catch(i){return this.lifeError(t,i),H(`插件【${e}】加载异常 ${i}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>{this.install(t.name,e?t:void 0,e?null==t?void 0:t.options:void 0)&&!O(this.pluginItems,(e=>e.name===t.name))&&this.pluginItems.push({name:b(t.name),method:t.method?t.method:()=>{}})}))},this.uninstall=e=>{var t;x(this.pluginItems,e);const i=x(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||H(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>{this.growingIO.emitter.emit(Oe,{plugin:e,error:t}),H(`插件执行错误 ${e.name} ${t}`,"error")},this.callLifeCycle=(e,t)=>{this.pluginItems.forEach((i=>{const n=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][e]:void 0;if(n&&d(n))try{n(t)}catch(e){this.lifeError(i,e)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(t=this.growingIO.emitter)||void 0===t||t.on(ye,(e=>this.callLifeCycle("onInstall",e))),null===(i=this.growingIO.emitter)||void 0===i||i.on(Oe,(e=>this.callLifeCycle("onError",e))),null===(n=this.growingIO.emitter)||void 0===n||n.on(Ie,(e=>this.callLifeCycle("onComposeBefore",e))),null===(s=this.growingIO.emitter)||void 0===s||s.on(fe,(e=>this.callLifeCycle("onComposeAfter",e))),null===(r=this.growingIO.emitter)||void 0===r||r.on(be,(e=>this.callLifeCycle("onSendBefore",e))),null===(o=this.growingIO.emitter)||void 0===o||o.on(Se,(e=>this.callLifeCycle("onSendAfter",e)))}}let Je;const Ye={tap:"onClick",longpress:"onLongPress"},Ze=["onShareAppMessage","onShareTimeline","onAddToFavorites","onTabItemTap"];var Xe={name:"gioTaroAdapter",method:class{constructor(e){this.growingIO=e,this.main=()=>{const{taro:e,taroVue:t}=this.growingIO.vdsConfig,{Current:i,createComponent:n}=e,s=!i&&n,r=i&&!n;if(this.taro=e,s)this.taroVersion="2",this.proxyTaro2(this.taro),Je.consoleText("Taro version 2","info");else if(r){if(this.taroVersion="3",this.taroVue=t,this.taroVue){const e=Number(Je.head(Je.split(this.taroVue.version,".")));this.taroVueVersion=e,Je.consoleText("Taro version 3, Vue version "+e,"info")}else Je.consoleText("Taro version 3","info");this.proxyTaro3()}else Je.consoleText("未获取到Taro实例或不支持的Taro版本,请检查!","error")},this.proxyTaro2=e=>{const t=this,i=e.createApp,n=e.createComponent;i&&(e.createApp=function(e){const n=i(e);return t.growingIO.dataStore.eventHooks.appOverriding(n),n}),n&&(e.createComponent=function(e,i){const s=n(e,i),r=i?"page":"component";switch(t.growingIO.gioPlatform){case"wx":case"qq":t.growingIO.dataStore.eventHooks[r+"Overriding"](s.methods);break;case"my":case"tt":case"jd":t.growingIO.dataStore.eventHooks[r+"Overriding"](s);break;case"swan":t.growingIO.dataStore.eventHooks[r+"Overriding"](s),t.growingIO.dataStore.eventHooks[r+"Overriding"](s.methods)}return s})},this.proxyTaro3=()=>{var e,t;const i=this,{dataStore:{eventHooks:n},minipInstance:s}=this.growingIO;if(n.nativeGrowing(["App"]),2===this.taroVueVersion)return n.nativeGrowing(["Page"]),void this.taro3Vue2Proxy();3===this.taroVueVersion&&this.proxyTaro3vue3();const r=null===(t=null===(e=i.taro)||void 0===e?void 0:e.hooks)||void 0===t?void 0:t.call;r?i.defineProperty(i.taro.hooks,"call",(function(...e){var t,o;const a=Array.from(e);if("getLifecycle"===a[0]){const e=a[2];if(n.pageHandlers.includes(e)&&!Ze.includes(e)){"onLoad"===e&&i.inAppLifecycle&&(i.inAppLifecycle=!1);const t=s.getCurrentPage();t.route&&!i.inAppLifecycle&&Je.niceTry((()=>n.pageEffects.main(t,e,a[1])))}}let l=r.apply(this,a);if("modifyPageObject"===a[0]){const e=a[1];Ze.forEach((t=>{e[t]&&(e[t]=n.lifeFcEffects(t,Je.isFunction(e[t])?e[t]:()=>{},"Page"))}))}if("dispatchTaroEvent"===a[0]){const e=a[1],s=a[2],r=null===(o=null===(t=i.growingIO.plugins)||void 0===t?void 0:t.gioEventAutoTracking)||void 0===o?void 0:o.main;if(Je.isFunction(r)&&n.actionEventTypes.includes(e.type)){const{currentTarget:t,target:n,detail:o}=e.mpEvent;if(n.id===t.id)try{let n=Je.head(s.__handlers[e.type]);if(n){n.oldHandler&&(n=n.oldHandler);let a="";a=i.taroVue?i.taro3vue3GetFuncName(n,s):i.taro3reactGetFuncName(n,e,s),r(Object.assign(Object.assign({},e.mpEvent),{currentTarget:Object.assign(Object.assign({},t),{detail:o,dataset:Object.assign(Object.assign({},t.dataset),s.dataset)})}),a)}}catch(e){Je.consoleText("Error: "+e,"error")}}}return l})):(Je.consoleText("Taro3实例获取失败,请检查初始化逻辑!","warn"),n.nativeGrowing(["Page"]))},this.proxyTaro3vue3=()=>{const e=this;this.taroVue.mixin({beforeMount:function(){var t,i;if((null===(i=null===(t=this._)||void 0===t?void 0:t.props)||void 0===i?void 0:i.tid)&&!Je.isEmpty(this._.exposed)){const t=Je.head(Je.split(this._.props.tid,"?")),i={};Je.keys(this._.exposed).forEach((e=>{this._.exposed[e].name&&(i[this._.exposed[e].name]=e)})),e.exposedNames[t]=Object.assign({},i)}}})},this.taro3reactGetFuncName=(e,s,r)=>{var o,a,l,g,c,u,d,h,p;const v=Je.keys(r).find((e=>t.test(e))),m=null!==(a=null!==(o=Je.niceTry((()=>r[v][Ye[s.type]])))&&void 0!==o?o:e.oldHandler)&&void 0!==a?a:e;if(null===(l=null==m?void 0:m.value)||void 0===l?void 0:l.name)return null===(g=null==m?void 0:m.value)||void 0===g?void 0:g.name;if(m.name&&!["handler","invoker"].includes(m.name)){let e=null===(u=null===(c=Je.head((""+m).match(i)))||void 0===c?void 0:c.replace("return ",""))||void 0===u?void 0:u.replace("(","");return e?null!==(d=Je.head(Je.drop(Je.split(e,"."))))&&void 0!==d?d:m.name:(e=null===(p=null===(h=Je.head((""+m).match(n)))||void 0===h?void 0:h.replace("return ",""))||void 0===p?void 0:p.replace("(",""),null!=e?e:m.name)}return this.getAnonymousFunc(r)},this.taro3vue3GetFuncName=(e,t)=>{var i,n,a,l,g,c,u;if(Je.startsWith((""+e.value).replace(" ",""),"function(")){let u=null===(i=Je.head((""+e.value).match(s)))||void 0===i?void 0:i.replace("return ","");try{u?u=u.indexOf("'")>-1?Je.head(Je.drop(Je.split(u,"'"))):Je.head(Je.drop(Je.split(u,'"'))):(u=null===(n=Je.head((""+e.value).match(r)))||void 0===n?void 0:n.replace("return ",""),u||(u=null===(a=Je.head((""+e.value).match(o)))||void 0===a?void 0:a.replace("return ","")),u||(u=null===(l=e.value)||void 0===l?void 0:l.name))}catch(e){u=""}if(u){let e=u.indexOf(".")>-1?Je.head(Je.drop(Je.split(u,"."))):u,i="";return i=(null===(g=null==t?void 0:t._root)||void 0===g?void 0:g.uid)?Je.head(Je.split(t._root.uid,"?")):this.growingIO.dataStore.eventHooks.currentPage.getPagePath(),this.exposedNames[i]&&(e=null!==(c=Je.niceTry((()=>this.exposedNames[i][e])))&&void 0!==c?c:e),e}return this.getAnonymousFunc(t)}return(null===(u=null==e?void 0:e.value)||void 0===u?void 0:u.name)?e.value.name:this.getAnonymousFunc(t)},this.getAnonymousFunc=e=>{const t=this.growingIO.dataStore.eventHooks.currentPage.getPagePath().split("/"),i=t.findIndex((e=>e.indexOf("page")>-1))+1;return`${i&&t[i]?t[i]:Je.last(t)}_Func${Je.startsWith(e.uid,"_")?e.uid:"_"+e.uid}`},this.taro3Vue2Proxy=()=>{const e=this;this.taroVue.mixin({beforeMount:function(){const t=this.$options.methods;Je.keys(t).forEach((t=>{e.defineProperty(this,t,e.proxyMethods(t,this[t]))}));const i=this._setupState;Je.isEmpty(i)||Je.keys(i).forEach((t=>{e.defineProperty(i,t,e.proxyMethods(t,i[t]))}))}})},this.proxyMethods=(e,t)=>{const{eventHooks:i}=this.growingIO.dataStore;return Je.isFunction(t)&&!i.pageHandlers.includes(e)?function(...n){return i.customFcEffects(e,t).apply(this,n)}:t},this.defineProperty=(e,t,i)=>{Object.defineProperty(e,t,{writable:!0,enumerable:!0,configurable:!0,value:i})},this.saveFullPage=e=>{const t=e=>{e.forEach((e=>{var i;(null===(i=null==e?void 0:e.ctx)||void 0===i?void 0:i.route)?(this.growingIO.taro3VMs||(this.growingIO.taro3VMs={}),this.growingIO.taro3VMs[e.ctx.route]=e):Je.isArray(e.childNodes)&&t(e.childNodes)}))};t(e.childNodes)},this.pluginVersion="__PLUGIN_VERSION__";const{utils:a,emitter:l,minipInstance:g}=this.growingIO;Je=a,this.exposedNames={},this.inAppLifecycle=!0,l.on(ve,(({event:e})=>{["Page onShow","Page onReady"].includes(e)&&this.taro&&"3"===this.taroVersion&&(this.saveFullPage(document.body),setTimeout((()=>g.initImpression(g.getCurrentPage())),0))}))}}};class et extends We{constructor(e){super(e),this.growingIO=e,this.pluginsContext={plugins:{gioTaroAdapter:Xe}}}}var it={},nt={}.hasOwnProperty;function st(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function rt(e){try{return encodeURIComponent(e)}catch(e){return null}}it.stringify=function(e,t){t=t||"";var i,n,s=[];for(n in"string"!=typeof t&&(t="?"),e)if(nt.call(e,n)){if((i=e[n])||null!=i&&!isNaN(i)||(i=""),n=rt(n),i=rt(i),null===n||null===i)continue;s.push(n+"="+i)}return s.length?t+s.join("&"):""},it.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,n={};t=i.exec(e);){var s=st(t[1]),r=st(t[2]);null===s||null===r||s in n||(n[s]=r)}return n};class ot{constructor(e){this.growingIO=e,this.generateURL=e=>{const{serverUrl:t,projectId:i}=this.growingIO.dataStore.getTrackerVds(e);return w(t,"http")?`${t}/v3/projects/${i}/collect`:`https://${t}/v3/projects/${i}/collect`},this.getHoardingQueue=e=>{var t;return null!==(t=this.hoardingQueue[e])&&void 0!==t?t:[]},this.getRequestQueue=e=>{var t;return null!==(t=this.requestQueue[e])&&void 0!==t?t:[]},this.commitRequest=e=>{var t,i;const n=Object.assign({},e),{vdsConfig:s,emitter:r}=this.growingIO;r.emit(me,{eventData:e,trackingId:e.trackingId}),s.forceLogin?(a(this.hoardingQueue[e.trackingId])&&(this.hoardingQueue[e.trackingId]=[]),null===(t=this.hoardingQueue[e.trackingId])||void 0===t||t.push(n)):(a(this.requestQueue[e.trackingId])&&(this.requestQueue[e.trackingId]=[]),null===(i=this.requestQueue[e.trackingId])||void 0===i||i.push(n),this.initiateRequest(e.trackingId))},this.initiateRequest=(e,t)=>{const{plugins:i,vdsConfig:n,minipInstance:s,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(e),...this.getRequestQueue(e)],a=e=>{var a,l;if(null===(a=null==n?void 0:n.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(l=null==i?void 0:i.gioTaobaoAdapter)||void 0===l||l.singleInvoke(e);else if(t)this.batchInvoke(e);else{const{uploadInterval:t}=this.growingIO.dataStore.getTrackerVds(e);j(this.batchInvoke,t,!1,!1)(e)}o.some((e=>"VISIT"===e.eventType))&&s.removeStorageSync(r.getStorageKey(e,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(e);else{let t=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(e),clearInterval(t),t=void 0)}),500)}},this.batchInvoke=e=>{const{vdsConfig:t,emitter:i}=this.growingIO,n=this.getHoardingQueue(e),s=this.getRequestQueue(e);let r=[...n,...s];r.length>50?(r=r.slice(0,50),n.length>50?this.hoardingQueue[e]=n.slice(50):(this.requestQueue[e]=s.slice(50-n.length),this.hoardingQueue[e]=[])):(this.hoardingQueue[e]=[],this.requestQueue[e]=[]);let o=r.filter((e=>(this.retryIds[e.requestId]||0)<=this.retryLimit));if(A(o))return;const a=o.map((e=>{const t=Object.assign({},e);return x(t,["requestId","trackingId"]),t}));t.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(be,{eventsQueue:o,requestData:a,trackingId:e})},this.sendEvent=(e,t)=>{var i;const n=v(e).trackingId,{minipInstance:s,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:g}=r.getTrackerVds(n);this.requestingNum+=1;const c={"content-type":"jdp"===s.platform?"application/json":"application/json;charset=UTF-8"};let u=[...t];const d=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);d&&(u=a.gioCompress.compressToUTF16(JSON.stringify(t)),c["X-Compress-Codec"]="1");const h=this.generateURL(n);s.request({url:`${h}?stm=${Date.now()}&compress=${d?"1":"0"}`,header:c,method:"POST",data:u,timeout:g,fail:t=>{[200,204].includes(t.code)||(e.forEach((e=>{this.requestFailFn(e)})),H("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,o.emit(Se,{result:e,requestData:t}),this.initiateRequest(n)}})},this.requestFailFn=e=>{if(this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1,!this.requestQueue[e.trackingId].some((t=>t.requestId===e.requestId))){let t=setTimeout((()=>{A(this.requestQueue[e.trackingId])?(this.requestQueue[e.trackingId].push(e),this.initiateRequest(e.trackingId)):this.requestQueue[e.trackingId].push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:t,vdsConfig:i,plugins:n}=this.growingIO;t.on(be,(({eventsQueue:e,requestData:t,trackingId:s})=>{var r,o;s===this.growingIO.trackingId&&((null===(r=null==i?void 0:i.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==n?void 0:n.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(e,t):this.sendEvent(e,t))}))}}class at{constructor(e){this.growingIO=e,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:e}=this.growingIO;return this._uid||(this._uid=e.getStorageSync(this._getUidKey())),this._uid||(this._uid=B(),e.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=e=>{const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))},this.getSessionId=e=>{const{vdsConfig:{sessionExpires:t},dataStore:{trackersExecute:i}}=this.growingIO;return this._sessionId[e]||this.setSessionId(e),t>-1&&(Date.now()>this._sessionExpires&&i((e=>{this.setSessionId(e)})),this._sessionExpires=Date.now()+6e4*t),this._sessionId[e]},this.setSessionId=(e,t)=>{const i=this._sessionId[e];t||(t=B()),this._sessionId[e]=t;const{sessionExpires:n}=this.growingIO.vdsConfig;n>-1&&(this._sessionExpires=Date.now()+6e4*n),i!==t&&this.growingIO.emitter.emit(Te,{trackingId:e,newSessionId:t,oldSessionId:i})},this._getUserIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"userId"),this.getUserId=e=>{const{minipInstance:t}=this.growingIO;return this._userId[e]||(this._userId[e]=t.getStorageSync(this._getUserIdKey(e))),this._userId[e]},this.setUserId=(e,t)=>{const i=this._userId[e];this._userId[e]=a(t)?"":t,i!==this._userId[e]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(e),this._userId[e]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:t,oldUserId:i})),t&&this.setGioId(e,t)},this._getUserKeyKey=e=>this.growingIO.dataStore.getStorageKey(e,"userKey"),this.getUserKey=e=>{const{minipInstance:t}=this.growingIO;return this._userKey[e]||(this._userKey[e]=t.getStorageSync(this._getUserKeyKey(e))),this._userKey[e]},this.setUserKey=(e,t)=>{const i=this._userKey[e];this._userKey[e]=a(t)?"":t,i!==this._userKey[e]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(e),this._userKey[e]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:t,oldUserKey:i}))},this._getGioIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"gioId"),this.getGioId=e=>{const{minipInstance:t}=this.growingIO;return this._gioId[e]||(this._gioId[e]=t.getStorageSync(this._getGioIdKey(e))),this._gioId[e]},this.setGioId=(e,t)=>{const i=this._gioId[e];this._gioId[e]=a(t)?"":t,i!==this._gioId[e]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(e),this._gioId[e]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:t,oldGioId:i}))},this.initUserInfo=e=>{var t;const{minipInstance:i}=this.growingIO,n=[this._getUidKey(),this._getUserIdKey(e),this._getUserKeyKey(e),this._getGioIdKey(e)],s=null!==(t=ee(i,n))&&void 0!==t?t:[];["_uid","_userId","_userKey","_gioId"].forEach(((t,i)=>{"_uid"===t?this.getUid():this[t][e]=s[i]}))},this.saveUserInfo=()=>{const{minipInstance:e,dataStore:{trackersExecute:t}}=this.growingIO;t((t=>{te(e,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(t),value:this._userId[t]},{key:this._getUserKeyKey(t),value:this._userKey[t]},{key:this._getGioIdKey(t),value:this._gioId[t]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={},this._sessionExpires=-1}}const lt=new class{constructor(){var e;this.init=e=>{var t;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:e});try{if(H("Gio小程序SDK 初始化中...","info"),e.trackingId&&this.dataStore.initializedTrackingIds.includes(e.trackingId))throw Error(`已存在实例 ${e.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(e);return null===(t=this.emitter)||void 0===t||t.emit(Pe,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(e.trackingId),this.emitter.emit(ke,i),this.trackingId&&this.trackingId!==e.trackingId||(Z().__gio__=()=>this),H("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&H("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(e){return H(e,"error"),!1}},this.handlerDistribute=(e,t,i)=>{const{initializedTrackingIds:n,getTrackerVds:s}=this.dataStore;if(s(e)&&n.includes(e))return this[t](e,...i);H(`不存在实例:${e},请检查!`,"warn")},this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(e,t)=>this.dataStore.getOption(e,t),this.setOption=(e,t,i)=>{var n;return T(ce).includes(t)?typeof i===(null===(n=ae[t])||void 0===n?void 0:n.type)?(this.dataStore.setOption(e,t,i),H(`已修改${ce[t]}: ${i}`,"info"),!0):(H(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(H(`不存在可修改的配置项:${t},请检查后重试!`,"error"),!1)},this.setPageAttributes=(e,t)=>{if(u(t)&&!A(t)){const{currentPage:i}=this.dataStore.eventHooks,n=i.getPagePath();return A(i.pageProps[e])&&(i.pageProps[e]={}),A(i.pageProps[e][n])&&(i.pageProps[e][n]={}),A(t)||_(t,((t,s)=>{d(i.pageProps[e][n][s])&&!d(t)||(i.pageProps[e][n][s]=t)})),!0}return V("setPageAttributes"),!1},this.clearPageAttributes=(e,t)=>{try{if(!A(this.dataStore.eventHooks.currentPage.pageProps[e])){const{currentPage:i}=this.dataStore.eventHooks,n=i.getPagePath();h(t)&&!A(t)?t.forEach((t=>{x(i.pageProps[e][n],t)})):i.pageProps[e][n]={}}}catch(e){return V("clearPageAttributes"),!1}},this.sendPage=(e,t)=>{const{trackPage:i}=this.dataStore.getTrackerVds(e);i?H("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(e,t)},this.identify=(e,t)=>{if(e===this.trackingId)if(this.vdsConfig.forceLogin){if(!oe(t))return void V("identify");const e=y(t).slice(0,1e3);this.userStore.setUid(e),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((t=>{const i=this.uploader.getHoardingQueue(t);i.forEach(((t,n)=>i[n].deviceId=e)),this.uploader.initiateRequest(t,!0)}))}else V("identify",!1,"forceLogin未开启");else V("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(e,t)=>{var i,n,s,r;if(u(t)&&!A(t)){const{eventContextBuilder:o,eventInterceptor:a,lastVisitEvent:l}=this.dataStore,g=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},o(e));g.attributes=X(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),$(t))),g.path||(g.path=null===(n=l[e])||void 0===n?void 0:n.path,g.query=null===(s=l[e])||void 0===s?void 0:s.query,g.title=null===(r=l[e])||void 0===r?void 0:r.title),a(g)}else V("setUserAttributes")},this.setUserId=(e,t,i)=>{if(oe(t)){const n=this.userStore.getGioId(e);t=y(t).slice(0,1e3),i=y(i).slice(0,1e3),this.userStore.setUserId(e,t);const{idMapping:s}=this.dataStore.getTrackerVds(e);s&&this.userStore.setUserKey(e,a(i)?"":i),n&&n!==t&&this.userStore.setSessionId(e)}else V("setUserId")},this.clearUserId=e=>{this.userStore.setUserId(e,void 0),this.userStore.setUserKey(e,void 0)},this.setGeneralProps=(e,t)=>u(t)&&!A(t)?(A(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]={}),_(t,((t,i)=>{d(this.dataStore.generalProps[e][i])&&!d(t)||(this.dataStore.generalProps[e][i]=t)})),!0):(V("setGeneralProps"),!1),this.clearGeneralProps=(e,t)=>{try{A(this.dataStore.generalProps[e])||(h(t)&&!A(t)?t.forEach((t=>{x(this.dataStore.generalProps[e],t)})):this.dataStore.generalProps[e]={})}catch(e){return V("clearGeneralProps"),!1}},this.track=(e,t,i)=>{K(t,(()=>{var n;const{eventContextBuilder:s,eventInterceptor:r}=this.dataStore,o=Object.assign({eventType:"CUSTOM",eventName:t},s(e));o.attributes=X(Object.assign(Object.assign({},null!==(n=o.attributes)&&void 0!==n?n:{}),$(Object.assign({},u(i)&&!A(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(o["&&sendTo"]=i["&&sendTo"]),r(o)}))},this.trackTimerStart=(e,t)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(e);return i?K(t,(()=>{const i=B();return this.dataStore.trackTimers[e]||(this.dataStore.trackTimers[e]={}),this.dataStore.trackTimers[e][i]={eventName:t,leng:0,start:+Date.now()},i})):(H("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return e.start&&(e.leng=e.leng+(+Date.now()-e.start)),e.start=0,!0}return!1},this.trackTimerResume=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return 0===e.start&&(e.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t,i)=>{var n;const{dataCollect:s}=this.dataStore.getTrackerVds(e),r=this.dataStore.trackTimers[e];if(t&&r&&r[t]){if(s){const s=864e5,o=r[t];if(0!==o.start){const e=+Date.now()-o.start;o.leng=e>0?o.leng+e:0}const{eventContextBuilder:a,eventInterceptor:l}=this.dataStore,g=Object.assign({eventType:"CUSTOM",eventName:o.eventName},a(e));return g.attributes=X(Object.assign(Object.assign({},null!==(n=g.attributes)&&void 0!==n?n:{}),$(Object.assign(Object.assign({},u(i)&&!A(i)?i:{}),{event_duration:o.leng>s?0:o.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(g["&&sendTo"]=i["&&sendTo"]),l(g),!0}return H("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return H("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(e,t)=>{const i=this.dataStore.trackTimers[e];return t&&i&&i[t]?(delete i[t],!0):(H("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=e=>{this.dataStore.trackTimers[e]={}},this.setLocation=(e,t,i)=>{A(this.dataStore.locationData[e])&&(this.dataStore.locationData[e]={});const n=this.dataStore.locationData[e],s=e=>e>=-180&&180>=e;s(t)&&s(i)&&(n.latitude!==t||n.longitude!==i)&&(this.dataStore.locationData[e]={latitude:t,longitude:i})},this.updateImpression=()=>{H("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(e,t,i)=>{H("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),F(i,{})},this.getGioInfo=e=>{const{getUid:t,getUserId:i,getUserKey:n,getSessionId:s}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:l,idMapping:g,extraParams:c,ignoreFields:u}=this.dataStore.getTrackerVds(e),d={gioappid:o,giocs1:i(e)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:s(e),giou:t()};return d.giodatacollect=l,d.giodatasourceid=a,g&&(d.giouserkey=n(e)),A(c)||c.forEach((t=>{var i;u.includes(t)||(d["gio"+t]=(null!==(i=this.dataStore.lastVisitEvent[e])&&void 0!==i?i:{})[t])})),it.stringify(d)},this.utils=Object.assign(Object.assign(Object.assign({},U),re),{qs:it}),this.emitter={all:e=e||new Map,on:function(t,i){var n=e.get(t);n?n.push(i):e.set(t,[i])},off:function(t,i){var n=e.get(t);n&&(i?n.splice(n.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var n=e.get(t);n&&n.slice().map((function(e){e(i)})),(n=e.get("*"))&&n.slice().map((function(e){e(t,i)}))}},this.gioPlatform=Y(),this.gioFramework="taro",this.sdkVersion="4.3.1";try{"quickapp"===this.gioPlatform||d(getApp)&&d(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&H("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Re,this.minipInstance=new Qe(this),this.dataStore=new qe(this),this.userStore=new at(this),this.uploader=new ot(this),this.plugins=new et(this),this.plugins.innerPluginInit()}},gt=function(){var e;const t=arguments[0];let i="g0",n=t;if(t.indexOf(".")>-1&&(i=null!==(e=t.split(".")[0])&&void 0!==e?e:"g0",n=t.split(".")[1]),l(n)&&ge.includes(n)&<[n]){const e=f(Array.from(arguments));if("init"===n){const t=((e,t)=>{const i=y(t[0]),n=y(t[1]),s=(4===t.length?t[3]:t[2])||{};return i&&n?e.dataStore.initializedTrackingIds.some(((t,s)=>{const r=0===s?e.vdsConfig:e.subInstance[t];return r.projectId===i&&r.dataSourceId===n}))?(H("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:n,appId:y(4===t.length?t[2]:""),userOptions:s}:(H('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})(lt,e);if(t){const{projectId:e,dataSourceId:n,appId:s,userOptions:r}=t;return lt.init(Object.assign(Object.assign({},r),{projectId:e,dataSourceId:n,appId:s,trackingId:i}))}return!1}if("registerPlugins"===n)lt.registerPlugins(e[0]);else{if(lt.gioSDKInitialized&<.vdsConfig)return le.includes(n)?L((()=>lt.handlerDistribute(i,n,e))):L((()=>lt[n](...e)));H("SDK未初始化!","error")}}else if(ue.includes(n))H(`方法 ${y(n)} 已被弃用,请移除!`,"warn");else{if("canIUse"===n)return ge.includes(arguments[1])&&!!lt[arguments[1]];H(`不存在名为 ${y(n)} 的方法调用!`,"error")}};Z().gdp=gt,Z().gioSDKVersion=lt.sdkVersion;const{growingApp:ct,growingPage:ut,growingComponent:dt,growingBehavior:ht,initOriginalValue:pt}=lt.dataStore.eventHooks;pt();const vt=L((()=>null!=ct?ct:App)),mt=L((()=>null!=ut?ut:Page)),ft=L((()=>null!=dt?dt:Component)),It=L((()=>null!=ht?ht:Behavior));export{vt as GioApp,It as GioBehavior,ft as GioComponent,mt as GioPage,gt as default};
|