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