gio-miniprogram-sdk 4.2.0 → 4.3.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/.github/workflows/publish.yml +2 -0
- package/dist/alipay.js +1 -1
- package/dist/baidu.js +1 -1
- package/dist/bytedance.js +1 -1
- package/dist/jingdong.js +1 -1
- package/dist/kuaishou.js +1 -1
- package/dist/plugins/gioABTest.js +1 -1
- package/dist/plugins/gioCompress.js +1 -1
- package/dist/plugins/gioEventAutoTracking.js +1 -1
- package/dist/plugins/gioImpressionTracking.js +1 -1
- package/dist/plugins/gioMultipleInstances.js +1 -1
- package/dist/qq.js +1 -1
- package/dist/quickapp.js +1 -1
- package/dist/taobao.js +1 -1
- package/dist/taro.js +1 -1
- package/dist/uniapp.js +1 -1
- package/dist/wechat.js +1 -1
- package/package.json +1 -1
- package/rollup.config.js +1 -1
- package/rollup.plugins.config.js +1 -1
- package/src/adapters/gioTaobaoAdapter.ts +5 -3
- package/src/adapters/gioTaroAdapter.ts +16 -10
- package/src/adapters/gioUniAppAdapter.ts +1 -32
- package/src/core/dataStore/eventContextBuilder.ts +4 -8
- package/src/core/dataStore/eventHooks/appEffects.ts +62 -76
- package/src/core/dataStore/eventHooks/index.ts +39 -23
- package/src/core/dataStore/eventHooks/minipPage.ts +92 -30
- package/src/core/dataStore/eventHooks/pageEffects.ts +23 -40
- package/src/core/dataStore/index.ts +43 -54
- package/src/core/growingIO.ts +15 -23
- package/src/index.ts +12 -12
- package/src/minipInstance/base.ts +53 -26
- package/src/minipInstance/my.ts +5 -0
- package/src/minipInstance/tb.ts +5 -0
- package/src/types/eventHooks.ts +10 -8
- package/src/utils/tools.ts +22 -3
package/dist/quickapp.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import t from"@system.app";import e from"@system.device";import i from"@system.fetch";import s from"@system.image";import n from"@system.network";import r from"@system.router";import o from"@system.share";import a from"@system.storage";const g=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,l=t=>["undefined","null"].includes(U(t)),u=t=>"string"===U(t),c=t=>"number"===U(t),h=t=>"boolean"===U(t),d=t=>"[object Object]"==={}.toString.call(t)&&!l(t),p=t=>["function","asyncfunction"].includes(U(t)),v=t=>Array.isArray(t)&&"array"===U(t),m=t=>"date"===U(t),f=t=>{try{return Array.from(t)[0]}catch(t){return}},I=t=>{try{const e=Array.from(t);return e[e.length-1]}catch(t){return}},y=(t,e=1)=>v(t)&&c(e)?t.slice(e>0?e:1,t.length):t,S=(t,e=!1)=>{if(v(t)){let i=0;const s=[];for(const n of t)n&&!N(n)&&(s[i++]=n),e&&0===n&&(s[i++]=n);return s}return t},O=(t,e)=>{if(v(t)){const i=t.findIndex(e);return 0>i?void 0:t[i]}},w=t=>l(t)?"":""+t,b=(t,e)=>"string"===U(t)?t.split(e):t,P=t=>{if(u(t)){const e=b(t,"");return`${f(e).toLowerCase()}${y(e).join("")}`}return t},k=(t,e)=>(u(t)||(t=w(t)),t.slice(0,e.length)===e),_={}.hasOwnProperty,T=(t,e)=>!l(t)&&_.call(t,e),C=t=>d(t)?Object.keys(t):[],E=(t,e)=>{C(t).forEach((i=>e(t[i],i)))},A=(t,e)=>{const i=C(t);return!(!d(t)||!d(e)||i.length!==C(e).length||i.map(((i,s)=>d(t[i])?A(t[i],e[i]):t[i]===e[i])).includes(!1))},q=(t,e,i)=>{let s=t;return d(t)?(e.split(".").forEach((t=>{s=s?s[t]:i})),s):i},j=(t,e)=>{if(!d(t))return!1;try{if("string"===U(e))return delete t[e];if("array"===U(e))return e.map((e=>delete t[e]));"object"===U(e)&&e.constructor===RegExp&&C(t).forEach((i=>{e.test(i)&&j(t,i)}))}catch(t){return!1}},x=(t,e=250,i,s)=>{let n,r=0;return"boolean"!==U(i)&&(s=t,t=i,i=void 0),function(...o){let a=this,g=Date.now()-r;function l(){r=Date.now(),t.apply(a,o)}s&&!n&&l(),n&&clearTimeout(n),void 0===s&&g>e?l():!0!==i&&(n=setTimeout(s?function(){n=void 0}:l,void 0===s?e-g:e))}},N=t=>v(t)?0===t.length:d(t)?0===C(t).length:!t,U=t=>({}.toString.call(t).slice(8,-1).toLowerCase()),D=t=>{function e(t){return 10>t?"0"+t:t}return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+" "+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+"."+e(t.getMilliseconds())};var K=Object.freeze({__proto__:null,isNil:l,isString:u,isNaN:t=>"NaN"===w(Number(t)),isNumber:c,isBoolean:h,isObject:d,isRegExp:t=>"[object RegExp]"==={}.toString.call(t),isFunction:p,isArray:v,isDate:m,fixed:(t,e)=>c(t)?Number(t.toFixed(c(e)?e:2)):u(t)&&"NaN"!==w(Number(t))?Number(Number(t).toFixed(c(e)?e:2)):t,head:f,last:I,drop:y,dropWhile:(t,e)=>v(t)?t.filter((t=>!e(t))):t,compact:S,find:O,isEqualArray:(t,e)=>!(!v(t)||!v(e)||t.length!==e.length)&&t.every(((t,i)=>t===e[i])),toString:w,split:b,lowerFirst:P,upperFirst:t=>{if(u(t)){const e=b(t,"");return`${f(e).toUpperCase()}${y(e).join("")}`}return t},startsWith:k,endsWith:(t,e)=>{const{length:i}=t;let s=i;s>i&&(s=i);const n=s;return s-=e.length,s>=0&&t.slice(s,n)===e},hasOwnProperty:_,has:T,keys:C,forEach:E,isEqual:A,get:q,unset:j,throttle:x,isEmpty:N,typeOf:U,formatDate:D});const H=(t,e)=>{console.log("%c[GrowingIO]:"+t,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[e]||"")},$=(t,e=!0,i="参数不合法")=>H(`${e?"调用":"设置"} ${t} 失败,${i}!`,"warn"),L=t=>{try{return t()}catch(t){return}},R=(t,e)=>{if(p(t))try{t(e)}catch(t){H("回调执行失败!"+t,"error")}},V=t=>u(t)?t.trim().substring(0,100):t,F=(t,e)=>u(t)&&!N(t)&&t.match(g)?e():(H("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),G=t=>(l(t)||C(t).forEach((e=>{p(t[e])?t[e]=L((()=>t[e]())):d(t[e])?j(t,e):v(t[e])||(t[e]=w(t[e]))})),t),M=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})),B=t=>t.pixelRatio?Math.round(t.screenHeight*t.pixelRatio):t.screenHeight,Q=t=>t.pixelRatio?Math.round(t.screenWidth*t.pixelRatio):t.screenWidth,z=(t,e)=>{if(t){const i=t.toLowerCase();return-1!==i.indexOf("android")?e+"-Android":-1!==i.indexOf("ios")?e+"-iOS":t}},W=t=>{if(u(t)){const e=t.indexOf("?");return-1!==e?[t.substring(0,e),t.substring(e+1)]:[t,""]}return["",""]},Y=t=>u(t)?t.startsWith("/")?t:"/"+t:"",J=t=>L((()=>{switch(t){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let t;return t||(t=L((()=>swan))),t||(t=L((()=>my))),t||(t=L((()=>tt))),t||(t=L((()=>qq))),t||(t=L((()=>ks))),t||(t=L((()=>jd))),t||(t=L((()=>wx))),t}}})),Z=t=>L((()=>{switch(t){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return __ttConfig;case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),X=()=>{let t;return!t&&L((()=>swan))&&(t="swan"),!t&&L((()=>tt))&&(t="tt"),!t&&L((()=>qq))&&(t="qq"),!t&&L((()=>my.tb))&&(t="tb"),!t&&L((()=>my))&&(t="my"),!t&&L((()=>ks))&&(t="ks"),!t&&L((()=>jd))&&(t="jd"),!t&&L((()=>wx))&&(t="wx"),t||O(C(global),(t=>w(t).toLowerCase().includes("quickapp")))&&(t="quickapp"),t},et=()=>{var t;return null!==(t=L((()=>$global)))&&void 0!==t?t:global},it=t=>{const e={};return d(t)&&(j(t,"&&sendTo"),E(t,((t,i)=>{const s=w(i).slice(0,100);d(t)?e[s]=it(t):v(t)?(e[s]=S(t.slice(0,100),!0),e[s]=e[s].join("||").slice(0,1e3)):m(t)?e[s]=D(t):e[s]=l(t)?"":w(t).slice(0,1e3)}))),e},st=(t,e)=>{const i=()=>e.map((e=>t.getStorageSync(e)));try{return t.minip.canIUse("batchGetStorageSync")?t.minip.batchGetStorageSync(e):i()}catch(t){return i()}},nt=(t,e)=>{const i=()=>e.map((({key:e,value:i})=>t.setStorageSync(e,i)));try{return t.minip.canIUse("batchSetStorageSync")?t.minip.batchSetStorageSync(e):i()}catch(t){return i()}},rt=t=>C(t||{}).map((e=>e?`${e}=${l(t[e])?"":t[e]}`:"")).join("&"),ot=t=>{(k(t,"?")||k(t,"&"))&&(t=t.slice(1,t.length));const e={};return t.split("&").forEach((t=>{const i=t.split("=");i[0]&&(e[i[0]]=i[1])})),e};var at=Object.freeze({__proto__:null,consoleText:H,callError:$,niceTry:L,niceCallback:R,limitString:V,eventNameValidate:F,getDynamicAttributes:G,guid:M,getScreenHeight:B,getScreenWidth:Q,getOS:z,compareVersion:(t="",e="")=>{const i=t=>t.replace(/\s+/g,""),s=t=>t.replace(/[vV]/g,""),n=i(s(t)),r=i(s(e)),o=n.split("."),a=r.split(".");for(let t=0;3>t;t++){let e=Number(o[t]),i=Number(a[t]);if(e>i)return 1;if(i>e)return-1;if(!isNaN(e)&&isNaN(i))return 1;if(isNaN(e)&&!isNaN(i))return-1}return 0},getVueVersion:t=>{if(t){const e=Number(f(b(t.version,".")));return Number.isNaN(e)?0:e}return 0},splitPath:W,normalPath:Y,isTaro3:t=>{const{Current:e,createComponent:i}=t;return!(!t||!e||i)},getPlainMinip:J,getPlainConfig:Z,getPlainPlatform:X,getSubKeys:t=>C(t).filter((t=>t.indexOf("__sub")>-1&&t.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let t=L((()=>getApp({allowDefault:!0})));return t||(t=et()),t},getGlobal:et,limitObject:it,batchGetStorageSync:st,batchSetStorageSync:nt,qsStringify:rt,qsParse:ot,hashCode:(t,e=!1)=>{let i=0;if(N(t)||"boolean"==typeof t)return i;let s=0;for(;s<t.length;)i=(i<<5)-i+t.charCodeAt(s),i|=0,s++;return e?Math.abs(i):i}});const gt=t=>u(t)&&t.length>0||c(t)&&t>0,lt={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"}},ut=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],ct=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...ut],ht={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},dt=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],pt=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],vt=[...pt,"appChannel","language","platformVersion"],mt={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 ft="MINIP_LIFECYCLE",It="ON_COMMIT_REQUEST",yt="ON_COMPOSE_AFTER",St="ON_COMPOSE_BEFORE",Ot="ON_ERROR",wt="ON_INSTALL",bt="ON_SEND_AFTER",Pt="ON_SEND_BEFORE",kt="OPTION_CHANGE",_t="OPTION_INITIALIZED",Tt="SDK_INITIALIZED";class Ct{constructor(t){this.growingIO=t,this.main=(t,e,i=!0)=>{var s;t||(t=this.growingIO.trackingId);const{sdkVersion:n,platformConfig:r,minipInstance:o,userStore:a,dataStore:g,dataStore:{scene:l,eventHooks:{currentPage:u},lastVisitEvent:c,lastPageEvent:h,generalProps:d}}=this.growingIO,{version:p,dataSourceId:v,appId:m,idMapping:f,ignoreFields:I}=g.getTrackerVds(t),y=g.locationData[t],{systemInfo:S={},network:O={}}=o,{brand:w,model:b,platform:P,language:k}=S,_={appChannel:"scn:"+(l||"NA"),appVersion:p,dataSourceId:v,deviceBrand:w,deviceId:a.getUid(),deviceModel:b,deviceType:z(P,r.name),domain:m,language:k,latitude:null==y?void 0:y.latitude,longitude:null==y?void 0:y.longitude,networkState:(null==O?void 0:O.networkType)||(null==O?void 0:O.type)||(null==O?void 0:O.subtype),operatingSystem:z(P,r.name),path:(null==u?void 0:u.path)?null==u?void 0:u.path:c.path,platform:r.platform,platformVersion:r.name+(S.version?" "+S.version:""),query:(null==u?void 0:u.path)?null==u?void 0:u.query:c.query,screenHeight:B(S),screenWidth:Q(S),sdkVersion:n,sessionId:a.getSessionId(t),title:(null===(s=h[t])||void 0===s?void 0:s.title)||(null==u?void 0:u.title)||o.getPageTitle(o.getCurrentPage()),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:a.getUserId(t)};return f&&(_.userKey=a.getUserKey(t)),i&&!N(d[t])&&(_.attributes=Object.assign({},d[t])),N(_.attributes)||(_.attributes=it(G(Object.assign({},_.attributes)))),N(I)||I.forEach((t=>{j(_,t)})),N(e)?Object.assign(Object.assign({},_),{trackingId:t}):Object.assign(Object.assign(Object.assign({},_),e),{trackingId:t})}}}function Et(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{g(s.next(t))}catch(t){r(t)}}function a(t){try{g(s.throw(t))}catch(t){r(t)}}function g(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}g((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class At{constructor(t){this.growingIO=t,this.main=(t,e)=>{var i,s;const n=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:g,uploader:l,dataStore:u,dataStore:{trackersExecute:c,shareOut:h,lastCloseTime:d,eventHooks:p,saveStorageInfo:v,setOriginalSource:m}}=this.growingIO;r.emit(ft,{event:"App "+t,timestamp:n,params:null!==(i=e[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",t,n);const f=g.listeners.app;switch(r.emit(St,{event:"App "+t,params:null!==(s=e[0])&&void 0!==s?s:{}}),t){case f.appCreate:case f.appShow:{const{path:t,query:i}=this.enterParamsParse(e[0]);!h&&a.originalSource&&c((e=>{m(e,{path:t,query:i})})),d?(Date.now()-d>a.keepAlive||u.lastScene&&u.scene!==u.lastScene)&&(c((t=>{o.setSessionId(t)})),p.currentPage.time=void 0,c((e=>{this.buildVisitEvent(e,{path:t,query:i})}))):(u.lastVisitEvent={path:t,query:i},c((e=>{this.buildVisitEvent(e,{path:t,query:i})})));break}case f.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),v(),o.saveUserInfo(),c((t=>{this.buildCloseEvent(t),a.forceLogin||l.initiateRequest(t,!0)}))}},this.enterParamsParse=t=>{const{gioPlatform:e,minipInstance:i,dataStore:s}=this.growingIO;let n="",r="";const o=(t,e={})=>{n=t,r=C(e).map((t=>`${t}=${e[t]}`)).join("&")};if("quickapp"!==e&&i.minip.canIUse("getEnterOptionsSync")){const{path:e,query:n,scene:a,referrerInfo:g}=i.minip.getEnterOptionsSync()||{},l=t.query||n;if(o(t.path||e,l),s.scene=t.scene||a,!N(g)&&d(null==g?void 0:g.extraData)){let t=[];E(g.extraData,((e,i)=>{!T(l,i)&&["string","number","boolean"].includes(U(e))&&t.push(`${i}=${e}`)}));const e=t.join("&");r=r&&e?`${r}&${e}`:r||e}}else{const{path:e,query:i}=t;o(e,i),this.parseScene(t)}return{path:n,query:r}},this.parseScene=t=>{var e;const{minipInstance:i,gioPlatform:s,dataStore:n}=this.growingIO;let r;if("quickapp"===s){const{extra:t,type:e}=i.getAppSource();r=(null==t?void 0:t.scene)||e}else N(t)||((null===(e=null==t?void 0:t.query)||void 0===e?void 0:e.wxShoppingListScene)?r=t.query.wxShoppingListScene:(null==t?void 0:t.scene)?r=t.scene:n.scene="NA");n.scene=r},this.buildVisitEvent=(t,e)=>{var i;const{dataStore:{getOriginalSource:s,eventContextBuilder:n,eventInterceptor:r,eventHooks:o},minipInstance:a,vdsConfig:g}=this.growingIO,u=s(t),c=(null==e?void 0:e.query)||"";let h=Object.assign({eventType:"VISIT"},n(t,{path:(null==e?void 0:e.path)||"",query:"string"===U(c)?c:rt(c),title:(null===(i=o.currentPage)||void 0===i?void 0:i.title)||a.getPageTitle(a.getCurrentPage()),timestamp:o.currentPage.time?o.currentPage.time-1:+Date.now()}));g.originalSource&&!l(u)&&(h=Object.assign(Object.assign({},h),u)),r(h)},this.buildCloseEvent=t=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},e(t)))}}}class qt{constructor(t){this.growingIO=t,this.parsePage=(t,e)=>{var i;const s=t.route||t.uri||t.__route__||(null===(i=null==t?void 0:t.$page)||void 0===i?void 0:i.fullPath)||"";N(e)?this.query=void 0:this.query=this.getQuery(e),this.path!==s&&(this.time=Date.now()),this.path=s,this.title=this.settedTitle[this.path]||this.growingIO.minipInstance.getPageTitle(t||this.growingIO.minipInstance.getCurrentPage())},this.getQuery=t=>{const e=Object.assign({},t);return j(e,"wxShoppingListScene"),rt(e)},this.getReferralPage=t=>{var e;const{minipInstance:i,dataStore:{lastPageEvent:s,scene:n}}=this.growingIO;return(null===(e=s[t])||void 0===e?void 0:e.path)||(n?`scn:${i.scnPrefix}${n}`:null)},this.updateShareResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=Y(e+(i?"?"+i:"")),t.query=i,t},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=Y(e+(i?"?"+i:"")),t.query=i,t},this.eventSetPageProps=(t,e)=>{const i=L((()=>this.pageProps[t][this.path]));return N(i)?e.attributes:it(G(Object.assign(Object.assign({},e.attributes),i)))},this.query=void 0,this.settedTitle={},this.pageProps={}}buildShareQuery(t){var e,i,s;const n=W(null!==(e=t.path)&&void 0!==e?e:"");let r=this.path,o={},a=T(t,"path");return a&&(r=f(n),o=ot(I(n))||{}),N(o)&&(o=ot(null!==(i=t.query)&&void 0!==i?i:"")||{},S(C(o)).forEach((t=>{t.toLowerCase().startsWith("utm_")&&j(o,t)}))),!a&&N(o)&&(o=ot(null!==(s=this.query)&&void 0!==s?s:"")||{}),[r,rt(o)]}}class jt{constructor(t){this.growingIO=t,this.main=(t,e,i)=>{var s,n;const r=Date.now(),{emitter:o,minipInstance:a,plugins:g,vdsConfig:l,platformConfig:u,dataStore:{getTrackerVds:c,trackersExecute:h,shareOut:d,eventHooks:v,toggleShareOut:m,buildAppMessageEvent:f,buildTimelineEvent:I,buildAddFavorites:y},inPlugin:S}=this.growingIO,{currentPage:O}=v;if(this.prevEvent[e]&&50>Date.now()-Number(this.prevEvent[e]))return;t||(t=a.getCurrentPage()),t.route||(t.route=a.getCurrentPath(t));const w=t.route||t.uri||t.__route__||(null===(s=null==t?void 0:t.$page)||void 0===s?void 0:s.fullPath)||"";o.emit(ft,{event:"Page "+e,timestamp:r,params:{page:t,args:i[0]}}),l.debug&&console.log("Page:",w,"#",e,r),this.prevEvent[e]=Date.now();const b=u.listeners.page;switch(o.emit(St,{page:t,event:"Page "+e,params:{page:t,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=e,e){case b.pageLoad:this.argQuery[w]=q(t,"options")||q(t,"__displayReporter.query")||q(t,"$page.query")||q(t,"$wx.__displayReporter.query")||i[0]||{},j(this.argQuery[w],"$taroTimestamp"),O.parsePage(t,this.argQuery[w]);break;case b.pageShow:S?(O.parsePage(t,this.argQuery[w]),O.path||(O.path=`/插件${l.appId}}`,O.title=`/插件${l.appId}}`),h((t=>{const{trackPage:e}=c(t);e&&this.buildPageEvent(t)}))):d&&v.currentPage.time||(O.parsePage(t,this.argQuery[w]),v.currentPage.time=Date.now(),h((t=>{const{trackPage:e}=c(t);e&&this.buildPageEvent(t)}))),m(!1);break;case b.pageHide:case b.pageUnload:break;case b.shareApp:m(!0),h((t=>{const{followShare:e}=c(t);e&&f(t,i)}));break;case b.shareTime:h((t=>{const{followShare:e}=c(t);e&&I(t,i)}));break;case b.addFavorites:h((t=>{const{followShare:e}=c(t);e&&y(t,i)}));break;case b.tabTap:{const t=null===(n=null==g?void 0:g.gioEventAutoTracking)||void 0===n?void 0:n.buildTabClickEvent;l.autotrack&&t&&p(t)&&t(this.growingIO.trackingId,i[0]);break}}},this.buildPageEvent=(t,e)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:s,eventHooks:{currentPage:n}},minipInstance:r}=this.growingIO,o=Object.assign(Object.assign({eventType:"PAGE",referralPage:n.getReferralPage(t)},i(t)),{title:(null==n?void 0:n.title)||r.getPageTitle(r.getCurrentPage()),timestamp:n.time});o.attributes=n.eventSetPageProps(t,o),!N(e)&&e.title&&(o.title=e.title),s(o)},this.prevEvent={},this.argQuery={}}}class xt{constructor(t){var e;this.growingIO=t,this.isNormalFc=(t,e)=>p(e)&&"constructor"!==t,this.objectTraverse=(t,e)=>{Object.getOwnPropertyNames(t).forEach((i=>e(i,t))),T(t,"methods")&&Object.getOwnPropertyNames(t.methods).forEach((i=>{t[i]||e(i,t.methods)})),T(t,"lifetimes")&&Object.getOwnPropertyNames(t.lifetimes).forEach((i=>{t[i]||e(i,t.lifetimes)})),T(t,"pageLifetimes")&&Object.getOwnPropertyNames(t.pageLifetimes).forEach((i=>{t[i]||e(i,t.pageLifetimes)}))},this.supLifeFcs=(t,e)=>{v(this[e+"Handlers"])&&this[e+"Handlers"].forEach((e=>{p(t[e])||["onShareAppMessage","onShareTimeline"].includes(e)||(t[e]=()=>{})}))},this.lifeFcEffects=(t,e,i)=>{const s=this;return["onShareTimeline","onAddToFavorites"].includes(t)?function(...n){let r=e.apply(this,n);"onShareTimeline"===t&&s.growingIO.vdsConfig.followShare&&(r=s.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===t&&(r=s.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(n);return r&&o.push(r),s[`def${i}Cbs`][t].apply(this,o),r}:function(...n){var r;return Et(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===t){if(o=null!==(r=e.apply(this,n))&&void 0!==r?r:{},"promise"===U(o)&&(o=yield o.then((t=>t))),"promise"===U(o.promise)){const t=function(){return Et(this,void 0,void 0,(function*(){let t=o;return new Promise((e=>{let i=setTimeout((()=>{e(Object.assign({},t)),clearTimeout(i),i=void 0}),3e3);o.promise.then((s=>{t=s,e(Object.assign({},t)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield t()),j(o,"promise")}s.growingIO.vdsConfig.followShare&&(o=s.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(n);o&&a.push(o),s[`def${i}Cbs`][t].apply(this,a)}catch(t){H(t,"error")}return"onShareAppMessage"!==t&&(o=e.apply(this,n)),s.growingIO.emitter.emit(ft,{event:`${i} ${t}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(n)}}),o}))}},this.customFcEffects=(t,e)=>{const i=this;return function(...s){var n,r;let o;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let e=s[0]||{};T(e,"type")&&((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))||(e=s[s.length-1]),((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))&&i.actionEventTypes.includes(e.type)&&(p(i.actionEffects)||(i.actionEffects=(null===(r=null===(n=i.growingIO.plugins)||void 0===n?void 0:n.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(e,t))}catch(t){H(t,"error")}return o=e.apply(this,s),o}},this.appApplyProxy=(t,e)=>this.appHandlers.includes(t)?this.lifeFcEffects(t,e,"App"):this.customFcEffects(t,e),this.pageApplyProxy=(t,e)=>this.pageHandlers.includes(t)?this.lifeFcEffects(t,e,"Page"):this.customFcEffects(t,e),this.appOverriding=t=>(this.setAppEffectCbs(),this.supLifeFcs(t,"app"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.appApplyProxy(t,e[t]))})),t),this.pageOverriding=t=>(this.setPageEffectCbs(),this.supLifeFcs(t,"page"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.componentOverriding=t=>(this.setPageEffectCbs(),t.methods||(t.methods={}),this.supLifeFcs(this.growingIO.inPlugin?t:t.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?t:t.methods,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.setAppEffectCbs=()=>{const t=this;this.appHandlers.forEach((e=>{this.defAppCbs[e]=function(...i){t.appEffects.main(e,i)}}))},this.setPageEffectCbs=()=>{const t=this;this.pageHandlers.forEach((e=>{this.defPageCbs[e]=function(...i){t.pageEffects.main(this,e,i)}}))},this.growingApp=t=>this.originalApp(this.appOverriding(t)),this.growingPage=t=>this.originalPage(this.pageOverriding(t)),this.growingComponent=t=>this.originalComponent(this.componentOverriding(t)),this.growingBehavior=t=>this.originalBehavior(this.componentOverriding(t)),this.nativeGrowing=(t=["App","Page","Component","Behavior"])=>{const e=this,{platformConfig:i}=this.growingIO,s=i.hooks;if(this.setAppEffectCbs(),this.setPageEffectCbs(),t.includes("App"))try{s.App&&!this.appHooked&&(this.originalApp=App||global.App||function(){},App=function(...t){return e.growingApp(t[0])},this.appHooked=!0)}catch(t){}if(t.includes("Page"))try{s.Page&&!this.pageHooked&&(this.originalPage=Page||global.Page||function(){},Page=function(...t){return e.growingPage(t[0])},this.pageHooked=!0)}catch(t){}if(t.includes("Component"))try{s.Component&&!this.componentHooked&&(this.originalComponent=Component||global.Component||function(){},Component=function(...t){return e.growingComponent(t[0])},this.componentHooked=!0)}catch(t){}if(t.includes("Behavior"))try{s.Behavior&&!this.behaviorHooked&&(this.originalBehavior=Behavior||global.Behavior||function(){},Behavior=function(...t){return e.growingBehavior(t[0])},this.behaviorHooked=!0)}catch(t){}},this.initEventHooks=()=>{const t=this,{platformConfig:e,gioPlatform:i}=this.growingIO;e.canHook?(this.nativeGrowing(),et().GioApp=L((()=>null!==App&&void 0!==App?App:window.GioApp)),et().GioPage=L((()=>null!==Page&&void 0!==Page?Page:window.GioPage)),et().GioComponent=L((()=>null!==Component&&void 0!==Component?Component:window.GioComponent)),et().GioBehavior=L((()=>Behavior))):"quickapp"===i&&(window.GioApp=function(...e){return t.appOverriding(e[0])},window.GioPage=function(...e){return t.pageOverriding(e[0])},window.GioComponent=function(...e){return t.pageOverriding(e[0])})};const i=null===(e=this.growingIO)||void 0===e?void 0:e.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new At(this.growingIO),this.pageEffects=new jt(this.growingIO),this.currentPage=new qt(this.growingIO)}}class Nt{constructor(t){var e,i;this.growingIO=t,this.ALLOW_SETTING_KEYS=C(lt),this.getStorageKey=(t,e)=>{const{inPlugin:i}=this.growingIO;return`${t===this.growingIO.trackingId?"":t}${mt[i?"plugin_"+e:e]}`},this.getGsid=t=>{let e=Number(this._gsid[t]);return Number.isNaN(e)||e>=1e9||1>e?(this.setGsid(t,1),1):e},this.setGsid=(t,e)=>{let i=Number(e);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[t]=i,10>this._gsid[t]-this._stid[t]||this.saveStorageInfo()},this.initStorageInfo=t=>{const{minipInstance:e}=this.growingIO,i=e.getStorageSync(this.getStorageKey(t,"gsid"));let s=Number(i);(Number.isNaN(s)||s>=1e9||1>s)&&(s=1),this._gsid[t]=s,this._stid[t]=s,s!==i&&e.setStorageSync(this.getStorageKey(t,"gsid"),s)},this.saveStorageInfo=()=>{const{minipInstance:t}=this.growingIO;this._stid=Object.assign({},this._gsid),nt(t,this.initializedTrackingIds.map((t=>({key:this.getStorageKey(t,"gsid"),value:this._gsid[t]}))))},this.setOriginalSource=(t,{path:e,query:i})=>{const{minipInstance:s}=this.growingIO;if(l(this.getOriginalSource(t))){const n={path:e,query:i,title:""};s.setStorageSync(this.getStorageKey(t,"originalSource"),JSON.stringify(n))}},this.getOriginalSource=t=>{const{minipInstance:e}=this.growingIO;return L((()=>JSON.parse(e.getStorageSync(this.getStorageKey(t,"originalSource")))))},this.getTrackerVds=t=>this.growingIO.trackingId===t?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=t=>{const e=this.initOptions(t);return e.trackingId=t.trackingId,this.growingIO.trackingId=t.trackingId,this.growingIO.vdsConfig=e,e},this.initTrackerHooker=t=>{var e,i;const{platformConfig:s,inPlugin:n,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:g}=t;a||g||(s.canHook=!0),n&&!["tbp","jdp"].includes(r.platform)||this.eventHooks.initEventHooks(),a&&(null===(e=null==o?void 0:o.gioUniAppAdapter)||void 0===e||e.main()),g&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=t=>{var e,i,s,n,r,o;const{projectId:a,dataSourceId:g,appId:l,trackingId:u}=t,c={};return this.ALLOW_SETTING_KEYS.forEach((e=>{const i=lt[e].type;(v(i)?i.includes(U(t[e])):U(t[e])===lt[e].type)?"ignoreFields"===e?c.ignoreFields=t.ignoreFields.filter((t=>pt.includes(t))):"extraParams"===e?c.extraParams=t.extraParams.filter((t=>vt.includes(t))):(c[e]=t[e],["dataCollect","autotrack"].includes(e)&&!c[e]&&H("已关闭"+ht[e],"info")):c[e]=lt[e].default})),c.uploadInterval=Math.round(c.uploadInterval),(Number.isNaN(c.uploadInterval)||0>c.uploadInterval||c.uploadInterval>3e3)&&(c.uploadInterval=1e3),c.enableIdMapping&&!c.idMapping&&(c.idMapping=!0,c.idMapping||this.growingIO.userStore.setUserKey(u,"")),j(c,"enableIdMapping"),c.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(c.requestTimeout))&&c.requestTimeout>0||(c.requestTimeout=5e3),Object.assign(Object.assign({},c),{projectId:a,dataSourceId:g,appId:l,trackingId:u,performance:{monitor:null===(i=null===(e=c.performance)||void 0===e?void 0:e.monitor)||void 0===i||i,exception:null===(n=null===(s=c.performance)||void 0===s?void 0:s.exception)||void 0===n||n,network:null!==(o=null===(r=c.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(t,e,i)=>{var s;const{userStore:n,emitter:r}=this.growingIO,o=this.getTrackerVds(t),a=u(e)&&this.ALLOW_SETTING_KEYS.includes(e),g=a&&typeof i===(null===(s=lt[e])||void 0===s?void 0:s.type);if(a&&g){const s=Object.assign({},o);if(this.updateVdsConfig(t,Object.assign(Object.assign({},o),{[e]:i})),"dataCollect"===e&&s.dataCollect!==i&&i){n.setSessionId(t);const{path:e,query:i,settedTitle:s}=this.eventHooks.currentPage;this.eventHooks.currentPage.title=s[e]||this.growingIO.minipInstance.getPageTitle(this.growingIO.minipInstance.getCurrentPage()),this.sendVisit(t,{path:e,query:i}),this.eventHooks.currentPage.time=Date.now(),this.sendPage(t,{path:e,query:i})}return r.emit(kt,{optionName:e,optionValue:i}),!0}return $("setOption > "+e),!1},this.getOption=(t,e)=>{const i=this.getTrackerVds(t);return e&&T(this.growingIO.vdsConfig,e)?T(i,e)?i[e]:this.growingIO.vdsConfig[e]:N(e)?i:void $("getOption > "+e)},this.updateVdsConfig=(t,e)=>{t===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),e),et().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[t]=Object.assign(Object.assign({},this.growingIO.subInstance[t]),e),et().vdsConfig.subInstance[t]=this.growingIO.subInstance[t])},this.toggleShareOut=t=>{h(t)?this.shareOut=t:this.shareOut=!this.shareOut},this.sendVisit=(t,e)=>{this.eventHooks.appEffects.buildVisitEvent(t,null!=e?e:this.lastVisitEvent)},this.sendPage=(t,e)=>{this.eventHooks.pageEffects.buildPageEvent(t,e)},this.eventConverter=t=>{const{dataStore:e,uploader:i}=this.growingIO,{dataCollect:s}=this.getTrackerVds(t.trackingId);if(s){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(t.eventType)||(t.eventSequenceId=e.getGsid(t.trackingId),e.setGsid(t.trackingId,t.eventSequenceId+1));const s={};E(t,((t,e)=>{var i;if("element"===e){const e=null!==(i=f(t))&&void 0!==i?i:{};E(e,((t,e)=>{N(t)&&0!==t||(s[e]=t)}))}else N(t)&&0!==t||(s[e]=t)})),this.growingIO.emitter.emit(yt,{composedEvent:s}),i.commitRequest(Object.assign(Object.assign({},s),{requestId:M()}))}},this.eventInterceptor=t=>{const{systemInfo:e,network:i}=this.growingIO.minipInstance;N(e)||N(i)?this.interceptEvents.push(t):N(this.interceptEvents)?this.eventConverter(t):([...this.interceptEvents,t].forEach((e=>{const i=Object.assign(Object.assign({},e),this.eventContextBuilder(t.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));this.eventConverter(i)})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:t,network:e}}=this.growingIO;t&&e&&!N(this.interceptEvents)&&([...this.interceptEvents].forEach((t=>{const e=Object.assign(Object.assign({},t),this.eventContextBuilder(t.trackingId,{path:t.path,query:t.query,timestamp:t.timestamp}));this.eventConverter(e)})),this.interceptEvents=[])},this.buildAppMessageEvent=(t,e)=>{var i,s;const n=e[0];let r;2>e.length?1===e.length&&(r=n):r=e[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,g=((null==r?void 0:r.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(t));l.attributes=it(Object.assign(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$from:n.from,$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:f(g),$share_query:g[1]}),null==r?void 0:r.attributes)),a(l)},this.buildTimelineEvent=(t,e)=>{var i,s;const n=e[0];let r;2>e.length?1===e.length&&(r=n):r=e[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,g=((null==r?void 0:r.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(t));l.attributes=it(Object.assign(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:f(g),$share_query:g[1]}),null==r?void 0:r.attributes)),a(l)},this.buildAddFavorites=(t,e)=>{var i;const s=e[0];let n;2>e.length?1===e.length&&(n=s):n=e[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==n?void 0:n.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(t));g.attributes=it(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$share_title:null==n?void 0:n.title,$share_path:f(a),$share_query:a[1]})),o(g)},this.trackersExecute=t=>{this.initializedTrackingIds.forEach((e=>{"function"===U(t)&&t(e)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new Ct(this.growingIO).main,this.eventHooks=new xt(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:s,minipInstance:n}=this.growingIO;s.on(Tt,(({trackingId:t})=>{this.initializedTrackingIds.push(t),this.initStorageInfo(t)})),s.on(It,(({eventData:t,trackingId:e})=>{"VISIT"===t.eventType&&(this.lastVisitEvent=t),"PAGE"===t.eventType&&(this.lastPageEvent[e]=t)})),p(null===(e=n.minip)||void 0===e?void 0:e.onAppHide)&&n.minip.onAppHide((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];E(e,(t=>{t.start&&(t.leng=t.leng+(+Date.now()-t.start))}))}))})),p(null===(i=n.minip)||void 0===i?void 0:i.onAppShow)&&n.minip.onAppShow((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];E(e,(t=>{t.start&&(t.start=+Date.now())}))}))})),s.on(kt,(({optionName:t,optionValue:e})=>{"dataCollect"===t&&!1===e&&this.trackersExecute((t=>{this.growingIO.clearTrackTimer(t)}))}))}get scene(){return this._scene}set scene(t){const e=this._scene;this._scene=t,e!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:t,oldScene:e})}}const Ut={name:"QuickApp",platform:"quickapp",scnPrefix:"quickapp_",appHandlers:["onCreate","onShow","onHide","onDestroy","onError"],pageHandlers:["onInit","onReady","onShow","onHide","onDestroy","onMenuPress","onShareAppMessage"],actionEventTypes:["click","longpress","blur","change"],canHook:!1,hooks:{App:!1,Page:!1,Component:!1,Behavior:!1},listeners:{app:{appCreate:"onCreate",appShow:"onShow",appHide:"onHide",appClose:"onDestroy"},page:{pageLoad:"onInit",pageReady:"onReady",pageShow:"onShow",pageHide:"onHide",pageClose:"onDestroy",menuPress:"onMenuPress",tabTap:void 0,shareApp:"onShareAppMessage"},actions:{click:["click","longpress"],change:["blur","change"],submit:[]}}};class Dt{constructor(t){this.growingIO=t,this.minip=J("quickapp"),this.hookSetTitle=()=>{var t;const e=null===(t=this.minip)||void 0===t?void 0:t.setNavigationBarTitle,i=this;e&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const t=i.getCurrentPath(),{title:e}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.settedTitle[t]=e}return e.apply(this,arguments)}})},this.navigateTo=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateTo(t)},this.switchTab=t=>{var e;null===(e=this.minip)||void 0===e||e.switchTab(t)},this.navigateToMiniProgram=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateToMiniProgram(t)},this.getImageInfo=({src:t,success:e,fail:i,complete:s})=>{var n;return null===(n=this.minip)||void 0===n?void 0:n.getImageInfo({src:t,success:e,fail:i,complete:s})},this.initImpression=t=>{var e,i;null===(i=null===(e=this.growingIO.plugins)||void 0===e?void 0:e.gioImpressionTracking)||void 0===i||i.main(t,"observeAll")},this.getCurrentPage=()=>L((()=>I(getCurrentPages())))||{},this.getCurrentPath=()=>{const t=this.getCurrentPage();return(null==t?void 0:t.route)||(null==t?void 0:t.uri)||(null==t?void 0:t.__route__)||""},this.getPageTitle=t=>{var e,i;let s="";const n=Z(X());try{const r=(null==t?void 0:t.data)||t.$data||{};if(s=u(null==r?void 0:r.gioPageTitle)?null==r?void 0:r.gioPageTitle:"",0===s.length){const e=n.page[t.route]||n.page[t.route+".html"];s=e?e.window.navigationBarTitleText:n.global.window.navigationBarTitleText}if(0===s.length){const r=null===(i=null===(e=null==n?void 0:n.tabBar)||void 0===e?void 0:e.list)||void 0===i?void 0:i.find((e=>e.pagePath===t.route||e.pagePath===t.route+".html"));s=(null==r?void 0:r.text)||""}}catch(t){return""}return V(s)},this.getStorageSync=t=>{var e;let i=null===(e=this.minip)||void 0===e?void 0:e.getStorageSync(t);return d(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=t=>new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:t,success:({data:t})=>e(t),fail:()=>e("")})})),this.setStorageSync=(t,e,i)=>{var s;i&&(e={value:e,expiredAt:i}),null===(s=this.minip)||void 0===s||s.setStorageSync(t,e)},this.setStorage=(t,e)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:t,data:e})},this.removeStorageSync=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorageSync(t)},this.removeStorage=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorage(t)},this.getNetworkType=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{t.network=i,e(i)},fail:()=>e(null)})}))},this.request=({url:t,data:e,header:i,timeout:s,method:n,success:r,fail:o,complete:a})=>{var g;const l=null===(g=this.minip)||void 0===g?void 0:g.request({url:t,data:e,header:i,headers:i,timeout:s,method:n,success:r,fail:o,complete:a});let u=setTimeout((()=>{(null==l?void 0:l.abort)&&p(null==l?void 0:l.abort)&&(null==l||l.abort()),clearTimeout(u),u=null}),(s||1e4)+10);return l},this.getSystemInfo=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{t.systemInfo=i,e(i)},fail:()=>e(null)})}))},this.getSetting=()=>new Promise((t=>{var e;null===(e=this.minip)||void 0===e||e.getSetting({success:t,fail:t})}));const{platformConfig:{platform:e,scnPrefix:i}}=this.growingIO;this.platform=e,this.scnPrefix=i,this.growingIO.emitter.on(_t,(()=>{this.getNetworkType().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()}))}))}}class Kt extends Dt{constructor(g){super(g),this.growingIO=g,this.getAppSource=()=>{const{source:e}=t.getInfo();return this.appSource=e||{},this.appSource},this.navigateTo=()=>{},this.switchTab=()=>{},this.navigateToMiniProgram=()=>{},this.onAppShow=()=>{},this.onAppHide=()=>{},this.getImageInfo=({src:t,success:e,fail:i,complete:n})=>null==s?void 0:s.getImageInfo({uri:t,success:e,fail:i,complete:n}),this.initImpression=()=>{},this.initShareAppMessage=t=>{const{platformConfig:e}=t;try{this.growingIO.shareAppMessage=function(){var i;const s=arguments[0];null==o||o.share(s),null===(i=null==t?void 0:t.eventTracking)||void 0===i||i.pageEffects(this,e.listeners.page.shareApp,arguments)}}catch(t){}},this.getCurrentPage=()=>(null==r?void 0:r.getPages)?I(null==r?void 0:r.getPages()):{},this.getCurrentPath=()=>{const t=null==r?void 0:r.getState();return null==t?void 0:t.path},this.getPageTitle=t=>{var e,i,s,n,o;let a="";try{if(a=u(null==t?void 0:t.gioPageTitle)?null==t?void 0:t.gioPageTitle:"",!a){const r=null!==(o=null===(n=null===(s=null===(i=null===(e=null==t?void 0:t.$app)||void 0===e?void 0:e.$def)||void 0===i?void 0:i.manifast)||void 0===s?void 0:s.display)||void 0===n?void 0:n.pages)&&void 0!==o?o:{},g=null==r?void 0:r[t.route];g&&(a=g.titleBarText)}if(!a){const t=null==r?void 0:r.getState();a=(null==t?void 0:t.name)||""}}catch(t){return""}return V(a)},this.getStorageSync=()=>"",this.getStorage=t=>Et(this,void 0,void 0,(function*(){return yield new Promise((e=>{null==a||a.get({key:t,success:t=>e(t),fail:()=>e(null)})}))})),this.setStorageSync=()=>{},this.setStorage=(t,e)=>{},this.removeStorageSync=()=>{},this.removeStorage=t=>{null==a||a.delete({key:t})},this.getNetworkType=()=>Et(this,void 0,void 0,(function*(){const t=this;return yield new Promise((e=>{null==n||n.getType({success:i=>{t.network=i,e(i)},fail:()=>e(null)})}))})),this.request=({url:t,header:e,method:s,data:n,success:r,fail:o,complete:a})=>null==i?void 0:i.fetch({url:t,header:e,method:s,data:n,success:r,fail:o,complete:a}),this.getSystemInfo=()=>Et(this,void 0,void 0,(function*(){const t=this;return yield new Promise((i=>{null==e||e.getInfo({success:e=>{const s=Object.assign(Object.assign({},e),{version:e.platformVersionName,platform:e.osType});t.systemInfo=s,i(s)},fail:()=>i(null)})}))})),this.growingIO.emitter.on(ft,(({event:t})=>{switch(t){case"App onCreate":this.getNetworkType().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()}));break;case"App onCreateEnd":this.setStorage=(t,e)=>{null==a||a.set({key:t,value:e})}}}))}}const Ht=["gioPerformance"];class $t{constructor(t){var e,i,s,n,r,o;this.growingIO=t,this.innerPluginInit=()=>{var t;Ht.forEach((t=>{var e;return j(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins,t)})),C(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins).forEach((t=>{var e,i;const{name:s,method:n}=null!==(i=null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins[t])&&void 0!==i?i:{};O(this.pluginItems,(t=>t.name===s))||this.pluginItems.push({name:P(s||t),method:n||(t=>{})})})),N(this.pluginItems)||this.installAll()},this.install=(t,e,i)=>{var s,n;const{emitter:r}=this.growingIO,o=e||O(this.pluginItems,(e=>e.name===t));if((null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[t])return H(`重复加载插件 ${t} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return H(`插件加载失败!不存在名为 ${t} 的插件!`,"error"),!1;try{return(null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[t]=new o.method(this.growingIO,i),e&&(r.emit(wt,t),H("加载插件 "+t,"info")),!0}catch(i){return this.lifeError(e,i),H(`插件【${t}】加载异常 ${i}`,"error"),!1}},this.installAll=t=>{(t||this.pluginItems).forEach((e=>{this.install(e.name,t?e:void 0,t?null==e?void 0:e.options:void 0)&&!O(this.pluginItems,(t=>t.name===e.name))&&this.pluginItems.push({name:P(e.name),method:e.method?e.method:()=>{}})}))},this.uninstall=t=>{var e;j(this.pluginItems,t);const i=j(null===(e=this.growingIO)||void 0===e?void 0:e.plugins,t);return i||H(`卸载插件 ${t} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((t=>this.uninstall(t.name)))},this.lifeError=(t,e)=>{this.growingIO.emitter.emit(Ot,{plugin:t,error:e}),H(`插件执行错误 ${t.name} ${e}`,"error")},this.callLifeCycle=(t,e)=>{this.pluginItems.forEach((i=>{const s=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][t]:void 0;if(s&&p(s))try{s(e)}catch(t){this.lifeError(i,t)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(e=this.growingIO.emitter)||void 0===e||e.on(wt,(t=>this.callLifeCycle("onInstall",t))),null===(i=this.growingIO.emitter)||void 0===i||i.on(Ot,(t=>this.callLifeCycle("onError",t))),null===(s=this.growingIO.emitter)||void 0===s||s.on(St,(t=>this.callLifeCycle("onComposeBefore",t))),null===(n=this.growingIO.emitter)||void 0===n||n.on(yt,(t=>this.callLifeCycle("onComposeAfter",t))),null===(r=this.growingIO.emitter)||void 0===r||r.on(Pt,(t=>this.callLifeCycle("onSendBefore",t))),null===(o=this.growingIO.emitter)||void 0===o||o.on(bt,(t=>this.callLifeCycle("onSendAfter",t)))}}var Lt={},Rt={}.hasOwnProperty;function Vt(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(t){return null}}function Ft(t){try{return encodeURIComponent(t)}catch(t){return null}}Lt.stringify=function(t,e){e=e||"";var i,s,n=[];for(s in"string"!=typeof e&&(e="?"),t)if(Rt.call(t,s)){if((i=t[s])||null!=i&&!isNaN(i)||(i=""),s=Ft(s),i=Ft(i),null===s||null===i)continue;n.push(s+"="+i)}return n.length?e+n.join("&"):""},Lt.parse=function(t){for(var e,i=/([^=?#&]+)=?([^&]*)/g,s={};e=i.exec(t);){var n=Vt(e[1]),r=Vt(e[2]);null===n||null===r||n in s||(s[n]=r)}return s};class Gt{constructor(t){this.growingIO=t,this.generateURL=t=>{const{serverUrl:e,projectId:i}=this.growingIO.dataStore.getTrackerVds(t);return k(e,"http")?`${e}/v3/projects/${i}/collect`:`https://${e}/v3/projects/${i}/collect`},this.getHoardingQueue=t=>{var e;return null!==(e=this.hoardingQueue[t])&&void 0!==e?e:[]},this.getRequestQueue=t=>{var e;return null!==(e=this.requestQueue[t])&&void 0!==e?e:[]},this.commitRequest=t=>{var e,i;const s=Object.assign({},t),{vdsConfig:n,emitter:r}=this.growingIO;r.emit(It,{eventData:t,trackingId:t.trackingId}),n.forceLogin?(l(this.hoardingQueue[t.trackingId])&&(this.hoardingQueue[t.trackingId]=[]),null===(e=this.hoardingQueue[t.trackingId])||void 0===e||e.push(s)):(l(this.requestQueue[t.trackingId])&&(this.requestQueue[t.trackingId]=[]),null===(i=this.requestQueue[t.trackingId])||void 0===i||i.push(s),this.initiateRequest(t.trackingId))},this.initiateRequest=(t,e)=>{const{plugins:i,vdsConfig:s,minipInstance:n,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(t),...this.getRequestQueue(t)],a=t=>{var a,g;if(null===(a=null==s?void 0:s.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(g=null==i?void 0:i.gioTaobaoAdapter)||void 0===g||g.singleInvoke(t);else if(e)this.batchInvoke(t);else{const{uploadInterval:e}=this.growingIO.dataStore.getTrackerVds(t);x(this.batchInvoke,e,!1,!1)(t)}o.some((t=>"VISIT"===t.eventType))&&n.removeStorageSync(r.getStorageKey(t,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(t);else{let e=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(t),clearInterval(e),e=void 0)}),500)}},this.batchInvoke=t=>{const{vdsConfig:e,emitter:i}=this.growingIO,s=this.getHoardingQueue(t),n=this.getRequestQueue(t);let r=[...s,...n];r.length>50?(r=r.slice(0,50),s.length>50?this.hoardingQueue[t]=s.slice(50):(this.requestQueue[t]=n.slice(50-s.length),this.hoardingQueue[t]=[])):(this.hoardingQueue[t]=[],this.requestQueue[t]=[]);let o=r.filter((t=>(this.retryIds[t.requestId]||0)<=this.retryLimit));if(N(o))return;const a=o.map((t=>{const e=Object.assign({},t);return j(e,["requestId","trackingId"]),e}));e.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(Pt,{eventsQueue:o,requestData:a,trackingId:t})},this.sendEvent=(t,e)=>{var i;const s=f(t).trackingId,{minipInstance:n,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:g,requestTimeout:l}=r.getTrackerVds(s);this.requestingNum+=1;const u={"content-type":"jdp"===n.platform?"application/json":"application/json;charset=UTF-8"};let c=[...e];const h=!!g&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);h&&(c=a.gioCompress.compressToUTF16(JSON.stringify(e)),u["X-Compress-Codec"]="1");const d=this.generateURL(s);n.request({url:`${d}?stm=${Date.now()}&compress=${h?"1":"0"}`,header:u,method:"POST",data:c,timeout:l,fail:e=>{[200,204].includes(e.code)||(t.forEach((t=>{this.requestFailFn(t)})),H("请求失败!"+JSON.stringify(e),"error"))},complete:t=>{this.requestingNum-=1,o.emit(bt,{result:t,requestData:e}),this.initiateRequest(s)}})},this.requestFailFn=t=>{if(this.retryIds[t.requestId]||(this.retryIds[t.requestId]=0),this.retryIds[t.requestId]+=1,!this.requestQueue[t.trackingId].some((e=>e.requestId===t.requestId))){let e=setTimeout((()=>{N(this.requestQueue[t.trackingId])?(this.requestQueue[t.trackingId].push(t),this.initiateRequest(t.trackingId)):this.requestQueue[t.trackingId].push(t),clearTimeout(e),e=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:e,vdsConfig:i,plugins:s}=this.growingIO;e.on(Pt,(({eventsQueue:t,requestData:e,trackingId:n})=>{var r,o;n===this.growingIO.trackingId&&((null===(r=null==i?void 0:i.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==s?void 0:s.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(t,e):this.sendEvent(t,e))}))}}class Mt{constructor(t){this.growingIO=t,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:t}=this.growingIO;return this._uid||(this._uid=t.getStorageSync(this._getUidKey())),this._uid||(this._uid=M(),t.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=t=>{const e=this._uid;this._uid=t,e!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:t,oldUId:e}))},this.getSessionId=t=>(this._sessionId[t]||this.setSessionId(t),this._sessionId[t]),this.setSessionId=(t,e)=>{const i=this._sessionId[t];e||(e=M()),this._sessionId[t]=e,i!==e&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:e,oldSessionId:i})},this._getUserIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"userId"),this.getUserId=t=>{const{minipInstance:e}=this.growingIO;return this._userId[t]||(this._userId[t]=e.getStorageSync(this._getUserIdKey(t))),this._userId[t]},this.setUserId=(t,e)=>{const i=this._userId[t];this._userId[t]=l(e)?"":e,i!==this._userId[t]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(t),this._userId[t]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:e,oldUserId:i})),e&&this.setGioId(t,e)},this._getUserKeyKey=t=>this.growingIO.dataStore.getStorageKey(t,"userKey"),this.getUserKey=t=>{const{minipInstance:e}=this.growingIO;return this._userKey[t]||(this._userKey[t]=e.getStorageSync(this._getUserKeyKey(t))),this._userKey[t]},this.setUserKey=(t,e)=>{const i=this._userKey[t];this._userKey[t]=l(e)?"":e,i!==this._userKey[t]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(t),this._userKey[t]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:e,oldUserKey:i}))},this._getGioIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"gioId"),this.getGioId=t=>{const{minipInstance:e}=this.growingIO;return this._gioId[t]||(this._gioId[t]=e.getStorageSync(this._getGioIdKey(t))),this._gioId[t]},this.setGioId=(t,e)=>{const i=this._gioId[t];this._gioId[t]=l(e)?"":e,i!==this._gioId[t]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(t),this._gioId[t]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:e,oldGioId:i}))},this.initUserInfo=t=>{var e;const{minipInstance:i}=this.growingIO,s=[this._getUidKey(),this._getUserIdKey(t),this._getUserKeyKey(t),this._getGioIdKey(t)],n=null!==(e=st(i,s))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,i)=>{"_uid"===e?this.getUid():this[e][t]=n[i]}))},this.saveUserInfo=()=>{const{minipInstance:t,dataStore:{trackersExecute:e}}=this.growingIO;e((e=>{nt(t,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(e),value:this._userId[e]},{key:this._getUserKeyKey(e),value:this._userKey[e]},{key:this._getGioIdKey(e),value:this._gioId[e]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={}}}const Bt=new class{constructor(){var t;this.init=t=>{var e;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:t});try{if(H("Gio小程序SDK 初始化中...","info"),t.trackingId&&this.dataStore.initializedTrackingIds.includes(t.trackingId))throw Error(`已存在实例 ${t.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(t);return null===(e=this.emitter)||void 0===e||e.emit(_t,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(t.trackingId),this.emitter.emit(Tt,i),this.trackingId&&this.trackingId!==t.trackingId||(et().__gio__=()=>this),H("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&H("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(t){return H(t,"error"),!1}},this.handlerDistribute=(t,e,i)=>{const{initializedTrackingIds:s,getTrackerVds:n}=this.dataStore;if(n(t)&&s.includes(t))return this[e](t,...i);H(`不存在实例:${t},请检查!`,"warn")},this.registerPlugins=t=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...t],this.plugins.installAll(t)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(t,e)=>this.dataStore.getOption(t,e),this.setOption=(t,e,i)=>{var s;return C(ht).includes(e)?typeof i===(null===(s=lt[e])||void 0===s?void 0:s.type)?(this.dataStore.setOption(t,e,i),H(`已修改${ht[e]}: ${i}`,"info"),!0):(H(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(H(`不存在可修改的配置项:${e},请检查后重试!`,"error"),!1)},this.setPageAttributes=(t,e)=>{if(d(e)&&!N(e)){const{currentPage:i}=this.dataStore.eventHooks;return N(i.pageProps[t])&&(i.pageProps[t]={}),N(i.pageProps[t][i.path])&&(i.pageProps[t][i.path]={}),N(e)||E(e,((e,s)=>{p(i.pageProps[t][i.path][s])&&!p(e)||(i.pageProps[t][i.path][s]=e)})),!0}return $("setPageAttributes"),!1},this.clearPageAttributes=(t,e)=>{try{if(!N(this.dataStore.eventHooks.currentPage.pageProps[t])){const{currentPage:i}=this.dataStore.eventHooks;v(e)&&!N(e)?e.forEach((e=>{j(i.pageProps[t][i.path],e)})):i.pageProps[t][i.path]={}}}catch(t){return $("clearPageAttributes"),!1}},this.sendPage=(t,e)=>{const{trackPage:i}=this.dataStore.getTrackerVds(t);i?H("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(t,e)},this.identify=(t,e)=>{if(t===this.trackingId)if(this.vdsConfig.forceLogin){if(!gt(e))return void $("identify");const t=w(e).slice(0,1e3);this.userStore.setUid(t),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((e=>{const i=this.uploader.getHoardingQueue(e);i.forEach(((e,s)=>i[s].deviceId=t)),this.uploader.initiateRequest(e,!0)}))}else $("identify",!1,"forceLogin未开启");else $("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(t,e)=>{var i;if(d(e)&&!N(e)){const{eventContextBuilder:s,eventInterceptor:n,lastVisitEvent:r}=this.dataStore,o=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},s(t));o.attributes=it(Object.assign(Object.assign({},null!==(i=o.attributes)&&void 0!==i?i:{}),G(e))),o.path||(o.path=r.path,o.query=r.query,o.title=r.title),n(o)}else $("setUserAttributes")},this.setUserId=(t,e,i)=>{if(gt(e)){const s=this.userStore.getGioId(t);e=w(e).slice(0,1e3),i=w(i).slice(0,1e3),this.userStore.setUserId(t,e);const{idMapping:n}=this.dataStore.getTrackerVds(t);if(n&&this.userStore.setUserKey(t,l(i)?"":i),s&&s!==e){this.userStore.setSessionId(t);const{path:e,query:i,settedTitle:s}=this.dataStore.eventHooks.currentPage;this.dataStore.eventHooks.currentPage.title=s[e]||this.minipInstance.getPageTitle(this.minipInstance.getCurrentPage()),this.dataStore.sendVisit(t,{path:e,query:i})}}else $("setUserId")},this.clearUserId=t=>{this.userStore.setUserId(t,void 0),this.userStore.setUserKey(t,void 0)},this.setGeneralProps=(t,e)=>d(e)&&!N(e)?(N(this.dataStore.generalProps[t])&&(this.dataStore.generalProps[t]={}),E(e,((e,i)=>{p(this.dataStore.generalProps[t][i])&&!p(e)||(this.dataStore.generalProps[t][i]=e)})),!0):($("setGeneralProps"),!1),this.clearGeneralProps=(t,e)=>{try{N(this.dataStore.generalProps[t])||(v(e)&&!N(e)?e.forEach((e=>{j(this.dataStore.generalProps[t],e)})):this.dataStore.generalProps[t]={})}catch(t){return $("clearGeneralProps"),!1}},this.track=(t,e,i)=>{F(e,(()=>{var s;const{eventContextBuilder:n,eventInterceptor:r}=this.dataStore,o=Object.assign({eventType:"CUSTOM",eventName:e},n(t));o.attributes=it(Object.assign(Object.assign({},null!==(s=o.attributes)&&void 0!==s?s:{}),G(Object.assign({},d(i)&&!N(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(o["&&sendTo"]=i["&&sendTo"]),r(o)}))},this.trackTimerStart=(t,e)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(t);return i?F(e,(()=>{const i=M();return this.dataStore.trackTimers[t]||(this.dataStore.trackTimers[t]={}),this.dataStore.trackTimers[t][i]={eventName:e,leng:0,start:+Date.now()},i})):(H("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(t,e,i)=>{var s;const{dataCollect:n}=this.dataStore.getTrackerVds(t),r=this.dataStore.trackTimers[t];if(e&&r&&r[e]){if(n){const n=864e5,o=r[e];if(0!==o.start){const t=+Date.now()-o.start;o.leng=t>0?o.leng+t:0}const{eventContextBuilder:a,eventInterceptor:g}=this.dataStore,l=Object.assign({eventType:"CUSTOM",eventName:o.eventName},a(t));return l.attributes=it(Object.assign(Object.assign({},null!==(s=l.attributes)&&void 0!==s?s:{}),G(Object.assign(Object.assign({},d(i)&&!N(i)?i:{}),{event_duration:o.leng>n?0:o.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(l["&&sendTo"]=i["&&sendTo"]),g(l),!0}return H("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return H("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(t,e)=>{const i=this.dataStore.trackTimers[t];return e&&i&&i[e]?(delete i[e],!0):(H("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=t=>{this.dataStore.trackTimers[t]={}},this.setLocation=(t,e,i)=>{N(this.dataStore.locationData[t])&&(this.dataStore.locationData[t]={});const s=this.dataStore.locationData[t],n=t=>t>=-180&&180>=t;n(e)&&n(i)&&(s.latitude!==e||s.longitude!==i)&&(this.dataStore.locationData[t]={latitude:e,longitude:i})},this.updateImpression=()=>{H("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(t,e,i)=>{H("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),R(i,{})},this.getGioInfo=t=>{const{getUid:e,getUserId:i,getUserKey:s,getSessionId:n}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:g,idMapping:l,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(t),h={gioappid:o,giocs1:i(t)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:n(t),giou:e()};return h.giodatacollect=g,h.giodatasourceid=a,l&&(h.giouserkey=s(t)),N(u)||u.forEach((t=>{c.includes(t)||(h["gio"+t]=this.dataStore.lastVisitEvent[t])})),Lt.stringify(h)},this.utils=Object.assign(Object.assign(Object.assign({},K),at),{qs:Lt}),this.emitter={all:t=t||new Map,on:function(e,i){var s=t.get(e);s?s.push(i):t.set(e,[i])},off:function(e,i){var s=t.get(e);s&&(i?s.splice(s.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var s=t.get(e);s&&s.slice().map((function(t){t(i)})),(s=t.get("*"))&&s.slice().map((function(t){t(e,i)}))}},this.gioPlatform="quickapp",this.gioFramework="native",this.sdkVersion="4.2.0";try{"quickapp"===this.gioPlatform||p(getApp)&&p(App)?this.inPlugin=!1:this.inPlugin=!0}catch(t){this.inPlugin=!0}this.inPlugin&&H("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Ut,this.minipInstance=new Kt(this),this.dataStore=new Nt(this),this.userStore=new Mt(this),this.uploader=new Gt(this),this.plugins=new $t(this),this.plugins.innerPluginInit()}},Qt=function(){var t;const e=arguments[0];let i="g0",s=e;if(e.indexOf(".")>-1&&(i=null!==(t=e.split(".")[0])&&void 0!==t?t:"g0",s=e.split(".")[1]),u(s)&&ct.includes(s)&&Bt[s]){const t=y(Array.from(arguments));if("init"===s){const e=((t,e)=>{const i=w(e[0]),s=w(e[1]),n=(4===e.length?e[3]:e[2])||{};return i&&s?t.dataStore.initializedTrackingIds.some(((e,n)=>{const r=0===n?t.vdsConfig:t.subInstance[e];return r.projectId===i&&r.dataSourceId===s}))?(H("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:s,appId:w(4===e.length?e[2]:""),userOptions:n}:(H('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})(Bt,t);if(e){const{projectId:t,dataSourceId:s,appId:n,userOptions:r}=e;return Bt.init(Object.assign(Object.assign({},r),{projectId:t,dataSourceId:s,appId:n,trackingId:i}))}return!1}if("registerPlugins"===s)Bt.registerPlugins(t[0]);else{if(Bt.gioSDKInitialized&&Bt.vdsConfig)return ut.includes(s)?L((()=>Bt.handlerDistribute(i,s,t))):L((()=>Bt[s](...t)));H("SDK未初始化!","error")}}else if(dt.includes(s))H(`方法 ${w(s)} 已被弃用,请移除!`,"warn");else{if("canIUse"===s)return ct.includes(arguments[1])&&!!Bt[arguments[1]];H(`不存在名为 ${w(s)} 的方法调用!`,"error")}};et().gdp=Qt,et().gioSDKVersion=Bt.sdkVersion;const zt=L((()=>{var t;return null!==(t=Bt.dataStore.eventHooks.growingApp)&&void 0!==t?t:App})),Wt=L((()=>{var t;return null!==(t=Bt.dataStore.eventHooks.growingPage)&&void 0!==t?t:Page})),Yt=L((()=>{var t;return null!==(t=Bt.dataStore.eventHooks.growingComponent)&&void 0!==t?t:Component})),Jt=L((()=>{var t;return null!==(t=Bt.dataStore.eventHooks.growingBehavior)&&void 0!==t?t:Behavior}));export{zt as GioApp,Jt as GioBehavior,Yt as GioComponent,Wt as GioPage,Qt as default};
|
|
1
|
+
import t from"@system.app";import e from"@system.device";import i from"@system.fetch";import s from"@system.image";import n from"@system.network";import r from"@system.router";import o from"@system.share";import a from"@system.storage";const l=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,g=t=>["undefined","null"].includes(U(t)),u=t=>"string"===U(t),c=t=>"number"===U(t),d=t=>"boolean"===U(t),h=t=>"[object Object]"==={}.toString.call(t)&&!g(t),p=t=>["function","asyncfunction"].includes(U(t)),v=t=>Array.isArray(t)&&"array"===U(t),m=t=>"date"===U(t),f=t=>{try{return Array.from(t)[0]}catch(t){return}},I=t=>{try{const e=Array.from(t);return e[e.length-1]}catch(t){return}},y=(t,e=1)=>v(t)&&c(e)?t.slice(e>0?e:1,t.length):t,S=(t,e=!1)=>{if(v(t)){let i=0;const s=[];for(const n of t)n&&!N(n)&&(s[i++]=n),e&&0===n&&(s[i++]=n);return s}return t},O=(t,e)=>{if(v(t)){const i=t.findIndex(e);return 0>i?void 0:t[i]}},b=t=>g(t)?"":""+t,w=(t,e)=>"string"===U(t)?t.split(e):t,P=t=>{if(u(t)){const e=w(t,"");return`${f(e).toLowerCase()}${y(e).join("")}`}return t},k=(t,e)=>(u(t)||(t=b(t)),t.slice(0,e.length)===e),_={}.hasOwnProperty,T=(t,e)=>!g(t)&&_.call(t,e),E=t=>h(t)?Object.keys(t):[],C=(t,e)=>{E(t).forEach((i=>e(t[i],i)))},A=(t,e)=>{const i=E(t);return!(!h(t)||!h(e)||i.length!==E(e).length||i.map(((i,s)=>h(t[i])?A(t[i],e[i]):t[i]===e[i])).includes(!1))},q=(t,e,i)=>{let s=t;return h(t)?(e.split(".").forEach((t=>{s=s?s[t]:i})),s):i},j=(t,e)=>{if(!h(t))return!1;try{if("string"===U(e))return delete t[e];if("array"===U(e))return e.map((e=>delete t[e]));"object"===U(e)&&e.constructor===RegExp&&E(t).forEach((i=>{e.test(i)&&j(t,i)}))}catch(t){return!1}},x=(t,e=250,i,s)=>{let n,r=0;return"boolean"!==U(i)&&(s=t,t=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function g(){r=Date.now(),t.apply(a,o)}s&&!n&&g(),n&&clearTimeout(n),void 0===s&&l>e?g():!0!==i&&(n=setTimeout(s?function(){n=void 0}:g,void 0===s?e-l:e))}},N=t=>v(t)?0===t.length:h(t)?0===E(t).length:!t,U=t=>({}.toString.call(t).slice(8,-1).toLowerCase()),D=t=>{function e(t){return 10>t?"0"+t:t}return t.getFullYear()+"-"+e(t.getMonth()+1)+"-"+e(t.getDate())+" "+e(t.getHours())+":"+e(t.getMinutes())+":"+e(t.getSeconds())+"."+e(t.getMilliseconds())};var K=Object.freeze({__proto__:null,isNil:g,isString:u,isNaN:t=>"NaN"===b(Number(t)),isNumber:c,isBoolean:d,isObject:h,isRegExp:t=>"[object RegExp]"==={}.toString.call(t),isFunction:p,isArray:v,isDate:m,fixed:(t,e)=>c(t)?Number(t.toFixed(c(e)?e:2)):u(t)&&"NaN"!==b(Number(t))?Number(Number(t).toFixed(c(e)?e:2)):t,head:f,last:I,drop:y,dropWhile:(t,e)=>v(t)?t.filter((t=>!e(t))):t,compact:S,find:O,isEqualArray:(t,e)=>!(!v(t)||!v(e)||t.length!==e.length)&&t.every(((t,i)=>t===e[i])),toString:b,split:w,lowerFirst:P,upperFirst:t=>{if(u(t)){const e=w(t,"");return`${f(e).toUpperCase()}${y(e).join("")}`}return t},startsWith:k,endsWith:(t,e)=>{const{length:i}=t;let s=i;s>i&&(s=i);const n=s;return s-=e.length,s>=0&&t.slice(s,n)===e},hasOwnProperty:_,has:T,keys:E,forEach:C,isEqual:A,get:q,unset:j,throttle:x,isEmpty:N,typeOf:U,formatDate:D});const $=(t,e)=>{console.log("%c[GrowingIO]:"+t,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[e]||"")},H=(t,e=!0,i="参数不合法")=>$(`${e?"调用":"设置"} ${t} 失败,${i}!`,"warn"),L=t=>{try{return t()}catch(t){return}},R=(t,e)=>{if(p(t))try{t(e)}catch(t){$("回调执行失败!"+t,"error")}},V=t=>u(t)?t.trim().substring(0,100):t,F=(t,e)=>u(t)&&!N(t)&&t.match(l)?e():($("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),M=t=>(g(t)||E(t).forEach((e=>{p(t[e])?t[e]=L((()=>t[e]())):h(t[e])?j(t,e):v(t[e])||(t[e]=b(t[e]))})),t),B=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){const e=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})),G=t=>t.pixelRatio?Math.round(t.screenHeight*t.pixelRatio):t.screenHeight,Q=t=>t.pixelRatio?Math.round(t.screenWidth*t.pixelRatio):t.screenWidth,z=(t,e)=>{if(t){const i=t.toLowerCase();return-1!==i.indexOf("android")?e+"-Android":-1!==i.indexOf("ios")?e+"-iOS":t}},W=t=>{if(u(t)){const e=t.indexOf("?");return-1!==e?[t.substring(0,e),t.substring(e+1)]:[t,""]}return["",""]},J=t=>u(t)?t.startsWith("/")?t:"/"+t:"",Y=t=>L((()=>{switch(t){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let t;return t||(t=L((()=>swan))),t||(t=L((()=>my))),t||(t=L((()=>tt))),t||(t=L((()=>qq))),t||(t=L((()=>ks))),t||(t=L((()=>jd))),t||(t=L((()=>wx))),t}}})),Z=t=>L((()=>{switch(t){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return L((()=>__ttConfig))||(null===global||void 0===global?void 0:global.TMAConfig)||(null===globalThis||void 0===globalThis?void 0:globalThis.TMAConfig);case"qq":return __qqConfig;case"ks":return __ksConfig;case"jd":return __jdConfig;default:return}})),X=()=>{let t;return!t&&L((()=>swan))&&(t="swan"),!t&&L((()=>tt))&&(t="tt"),!t&&L((()=>qq))&&(t="qq"),!t&&L((()=>my.tb))&&(t="tb"),!t&&L((()=>my))&&(t="my"),!t&&L((()=>ks))&&(t="ks"),!t&&L((()=>jd))&&(t="jd"),!t&&L((()=>wx))&&(t="wx"),t||O(E(global),(t=>b(t).toLowerCase().includes("quickapp")))&&(t="quickapp"),t},et=()=>{var t;return null!==(t=L((()=>{var t;return null!==(t=L((()=>{var t;return null!==(t=L((()=>$global)))&&void 0!==t?t:global})))&&void 0!==t?t:window})))&&void 0!==t?t:globalThis},it=t=>{const e={};return h(t)&&(j(t,"&&sendTo"),C(t,((t,i)=>{const s=b(i).slice(0,100);h(t)?e[s]=it(t):v(t)?(e[s]=S(t.slice(0,100),!0),e[s]=e[s].join("||").slice(0,1e3)):m(t)?e[s]=D(t):e[s]=g(t)?"":b(t).slice(0,1e3)}))),e},st=(t,e)=>{const i=()=>e.map((e=>t.getStorageSync(e)));try{return t.minip.canIUse("batchGetStorageSync")?t.minip.batchGetStorageSync(e):i()}catch(t){return i()}},nt=(t,e)=>{const i=()=>e.map((({key:e,value:i})=>t.setStorageSync(e,i)));try{return t.minip.canIUse("batchSetStorageSync")?t.minip.batchSetStorageSync(e):i()}catch(t){return i()}},rt=t=>E(t||{}).map((e=>e?`${e}=${g(t[e])?"":t[e]}`:"")).join("&"),ot=t=>{(k(t,"?")||k(t,"&"))&&(t=t.slice(1,t.length));const e={};return t.split("&").forEach((t=>{const i=t.split("=");i[0]&&(e[i[0]]=i[1])})),e},at=(t={},e={})=>{const i={};return E(e).forEach((t=>{["string","number","boolean"].includes(U(e[t]))&&(i[t]=e[t])})),Object.assign({},i,t)};var lt=Object.freeze({__proto__:null,consoleText:$,callError:H,niceTry:L,niceCallback:R,limitString:V,eventNameValidate:F,getDynamicAttributes:M,guid:B,getScreenHeight:G,getScreenWidth:Q,getOS:z,compareVersion:(t="",e="")=>{const i=t=>t.replace(/\s+/g,""),s=t=>t.replace(/[vV]/g,""),n=i(s(t)),r=i(s(e)),o=n.split("."),a=r.split(".");for(let t=0;3>t;t++){let e=Number(o[t]),i=Number(a[t]);if(e>i)return 1;if(i>e)return-1;if(!isNaN(e)&&isNaN(i))return 1;if(isNaN(e)&&!isNaN(i))return-1}return 0},getVueVersion:t=>{if(t){const e=Number(f(w(t.version,".")));return Number.isNaN(e)?0:e}return 0},splitPath:W,normalPath:J,isTaro3:t=>{const{Current:e,createComponent:i}=t;return!(!t||!e||i)},getPlainMinip:Y,getPlainConfig:Z,getPlainPlatform:X,getSubKeys:t=>E(t).filter((t=>t.indexOf("__sub")>-1&&t.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let t=L((()=>getApp({allowDefault:!0})));return t||(t=et()),t},getGlobal:et,limitObject:it,batchGetStorageSync:st,batchSetStorageSync:nt,qsStringify:rt,qsParse:ot,hashCode:(t,e=!1)=>{let i=0;if(N(t)||"boolean"==typeof t)return i;let s=0;for(;s<t.length;)i=(i<<5)-i+t.charCodeAt(s),i|=0,s++;return e?Math.abs(i):i},getLaunchQuery:at});const gt=t=>u(t)&&t.length>0||c(t)&&t>0,ut={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"}},ct=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],dt=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...ct],ht={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},pt=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],vt=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],mt=[...vt,"appChannel","language","platformVersion"],ft={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 It="MINIP_LIFECYCLE",yt="ON_COMMIT_REQUEST",St="ON_COMPOSE_AFTER",Ot="ON_COMPOSE_BEFORE",bt="ON_ERROR",wt="ON_INSTALL",Pt="ON_SEND_AFTER",kt="ON_SEND_BEFORE",_t="OPTION_CHANGE",Tt="OPTION_INITIALIZED",Et="SDK_INITIALIZED";class Ct{constructor(t){this.growingIO=t,this.main=(t,e,i=!0)=>{t||(t=this.growingIO.trackingId);const{sdkVersion:s,platformConfig:n,minipInstance:r,userStore:o,dataStore:a,dataStore:{scene:l,eventHooks:{currentPage:g},generalProps:u}}=this.growingIO,{version:c,dataSourceId:d,appId:h,idMapping:p,ignoreFields:v}=a.getTrackerVds(t),m=a.locationData[t],{systemInfo:f={},network:I={}}=r,{brand:y,model:S,platform:O,language:b}=f,w=g.getPagePath(),P={appChannel:"scn:"+(l||"NA"),appVersion:c,dataSourceId:d,deviceBrand:y,deviceId:o.getUid(),deviceModel:S,deviceType:z(O,n.name),domain:h,language:b,latitude:null==m?void 0:m.latitude,longitude:null==m?void 0:m.longitude,networkState:(null==I?void 0:I.networkType)||(null==I?void 0:I.type)||(null==I?void 0:I.subtype),operatingSystem:z(O,n.name),path:w,platform:n.platform,platformVersion:n.name+(f.version?" "+f.version:""),query:w?g.getPageQeury():"",screenHeight:G(f),screenWidth:Q(f),sdkVersion:s,sessionId:o.getSessionId(t),title:g.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:o.getUserId(t)};return p&&(P.userKey=o.getUserKey(t)),i&&!N(u[t])&&(P.attributes=Object.assign({},u[t])),N(P.attributes)||(P.attributes=it(M(Object.assign({},P.attributes)))),N(v)||v.forEach((t=>{j(P,t)})),N(e)?Object.assign(Object.assign({},P),{trackingId:t}):Object.assign(Object.assign(Object.assign({},P),e),{trackingId:t})}}}function At(t,e,i,s){return new(i||(i=Promise))((function(n,r){function o(t){try{l(s.next(t))}catch(t){r(t)}}function a(t){try{l(s.throw(t))}catch(t){r(t)}}function l(t){var e;t.done?n(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(o,a)}l((s=s.apply(t,e||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class qt{constructor(t){this.growingIO=t,this.enterParams={},this.main=(t,e)=>{var i,s;const n=Date.now(),{emitter:r,userStore:o,vdsConfig:a,platformConfig:l,uploader:g,dataStore:u,dataStore:{trackersExecute:c,shareOut:d,lastCloseTime:h,saveStorageInfo:p,setOriginalSource:v}}=this.growingIO;r.emit(It,{event:"App "+t,timestamp:n,params:null!==(i=e[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",t,n);const m=l.listeners.app;switch(r.emit(Ot,{event:"App "+t,params:null!==(s=e[0])&&void 0!==s?s:{}}),t){case m.appLaunch:this.enterParams=Object.assign({},e[0]);break;case m.appCreate:case m.appShow:{const{path:t,query:i,referralPage:s}=this.enterParamsParse(e[0]);!d&&a.originalSource&&t&&c((e=>{v(e,{path:t,query:i,referralPage:s})})),h?(Date.now()-h>a.keepAlive||u.lastScene&&u.scene!==u.lastScene)&&(c((t=>{o.setSessionId(t)})),c((e=>{if(t)this.buildVisitEvent(e,{path:t,query:i});else{const t=u.lastPageEvent[e];this.buildVisitEvent(e,{path:t.path,query:t.query})}}))):c((e=>{u.lastVisitEvent[e]={path:t,query:i,referralPage:s},this.buildVisitEvent(e,{path:t,query:i,referralPage:s})}));break}case m.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),p(),o.saveUserInfo(),c((t=>{this.buildCloseEvent(t),a.forceLogin||g.initiateRequest(t,!0)}))}},this.enterParamsParse=(t={})=>{var e;const{gioPlatform:i,minipInstance:s,dataStore:n}=this.growingIO;let r="",o="",a="";if("quickapp"!==i&&s.minip.canIUse("getEnterOptionsSync")){const{path:i,query:l,scene:g,referrerInfo:u}=s.minip.getEnterOptionsSync()||{};r=i||t.path,o=l||t.query,a=(null==u?void 0:u.appId)||(null===(e=null==t?void 0:t.referrerInfo)||void 0===e?void 0:e.appId)||"",n.scene=g||t.scene,o=N(null==u?void 0:u.extraData)?rt(o):rt(at(o,u.extraData))}else{const{path:e,query:i,referrerInfo:s}=t;r=e,o=rt(i),a=(null==s?void 0:s.appId)||"",this.parseScene(t)}return{path:r,query:o,referralPage:a}},this.parseScene=t=>{var e;const{minipInstance:i,gioPlatform:s,dataStore:n}=this.growingIO;let r;if("quickapp"===s){const{extra:t,type:e}=i.getAppSource();r=(null==t?void 0:t.scene)||e}else N(t)||((null===(e=null==t?void 0:t.query)||void 0===e?void 0:e.wxShoppingListScene)?r=t.query.wxShoppingListScene:(null==t?void 0:t.scene)?r=t.scene:n.scene="NA");n.scene=r},this.buildVisitEvent=(t,e)=>{const{dataStore:{getOriginalSource:i,eventContextBuilder:s,eventInterceptor:n},vdsConfig:r}=this.growingIO,o=i(t),a=(null==e?void 0:e.query)||"";let l=Object.assign({eventType:"VISIT"},s(t,{}));!N(e)&&e.path&&(l.path=e.path||"",l.query="string"===U(a)?a:rt(a),e.referralPage&&(l.referralPage=e.referralPage)),r.originalSource&&!N(o)&&(l=Object.assign(Object.assign({},l),o)),n(l)},this.buildCloseEvent=t=>{const{dataStore:{eventContextBuilder:e,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},e(t)))}}}class jt{constructor(t){this.growingIO=t,this.getPagePath=()=>{var t,e,i;const{minipInstance:s,inPlugin:n,dataStore:r,trackingId:o}=this.growingIO,a=s.getCurrentPath();if(n){const t=r.getTrackerVds(o);return a||"/插件"+t.appId}return a||(null===(t=r.eventHooks.appEffects.enterParams)||void 0===t?void 0:t.path)||(null===(e=r.lastPageEvent[o])||void 0===e?void 0:e.path)||(null===(i=r.lastVisitEvent[o])||void 0===i?void 0:i.path)},this.getPageQeury=()=>{var t,e,i,s,n,r;const{minipInstance:o,dataStore:a,trackingId:l}=this.growingIO,g=o.getCurrentPage(),u=o.getCurrentPath(),{enterParams:c={}}=a.eventHooks.appEffects;if(!u)return c.path?this.qsQuery(at(null==c?void 0:c.query,null===(i=null==c?void 0:c.referrerInfo)||void 0===i?void 0:i.extraData)):(null===(s=a.lastPageEvent[l])||void 0===s?void 0:s.path)?null===(n=a.lastPageEvent[l])||void 0===n?void 0:n.query:null===(r=a.lastVisitEvent[l])||void 0===r?void 0:r.query;{const i=null!==(t=g.options)&&void 0!==t?t:g.$taroParams;if(!N(i))return j(i,"$taroTimestamp"),this.qsQuery(i);if(!N(this.queryOption[u]))return this.qsQuery(this.queryOption[u]);if(u===c.path)return this.qsQuery(at(null==c?void 0:c.query,null===(e=null==c?void 0:c.referrerInfo)||void 0===e?void 0:e.extraData))}},this.getPageTitle=t=>{const{minipInstance:e,inPlugin:i,dataStore:s}=this.growingIO,n=e.getCurrentPath(),r=this.settedTitle[n]||e.getPageTitle(e.getCurrentPage());if(i){const e=s.getTrackerVds(t||this.growingIO.trackingId);return r||`/插件${e.appId}${n?"_"+I(n.split("/")):""}`}return r},this.qsQuery=(t={})=>{const e=Object.assign({},t);return j(e,"wxShoppingListScene"),rt(e)},this.getReferralPage=t=>{var e,i,s;const{minipInstance:n,dataStore:{lastPageEvent:r,scene:o,eventHooks:a}}=this.growingIO;return(null===(e=r[t])||void 0===e?void 0:e.path)||(null===(s=null===(i=a.appEffects.enterParams)||void 0===i?void 0:i.referrerInfo)||void 0===s?void 0:s.appId)||(o?`scn:${n.scnPrefix}${o}`:null)},this.updateShareResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=J(e+(i?"?"+i:"")),t.query=i,t},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=t=>{const[e,i]=this.buildShareQuery(t);return t.path=J(e+(i?"?"+i:"")),t.query=i,t},this.eventSetPageProps=(t,e)=>{const i=L((()=>this.pageProps[t][this.getPagePath()]));return N(i)?e.attributes:it(M(Object.assign(Object.assign({},e.attributes),i)))},this.queryOption={},this.settedTitle={},this.pageProps={}}buildShareQuery(t){var e,i;const s=W(null!==(e=t.path)&&void 0!==e?e:"");let n=this.getPagePath(),r={},o=T(t,"path");if(o&&(n=f(s),r=ot(I(s))||{}),N(r)&&(r=ot(null!==(i=t.query)&&void 0!==i?i:"")||{},S(E(r)).forEach((t=>{t.toLowerCase().startsWith("utm_")&&j(r,t)}))),!o&&N(r)){const t=this.growingIO.minipInstance.getCurrentPage();r=t.options||this.queryOption[t.route]||{}}return[n,rt(r)]}}class xt{constructor(t){this.growingIO=t,this.main=(t,e,i)=>{var s,n;const r=Date.now(),{emitter:o,minipInstance:a,plugins:l,vdsConfig:g,platformConfig:u,dataStore:{getTrackerVds:c,getOriginalSource:d,setOriginalSource:h,trackersExecute:v,eventHooks:m,toggleShareOut:f,buildAppMessageEvent:I,buildTimelineEvent:y,buildAddFavorites:S}}=this.growingIO,{currentPage:O}=m;if(this.prevEvent[e]&&50>Date.now()-Number(this.prevEvent[e]))return;t||(t=a.getCurrentPage()),t.route||(t.route=a.getCurrentPath(t));const b=t.route||t.uri||t.__route__||(null===(s=null==t?void 0:t.$page)||void 0===s?void 0:s.fullPath)||"";o.emit(It,{event:"Page "+e,timestamp:r,params:{page:t,args:i[0]}}),g.debug&&console.log("Page:",b,"#",e,r),this.prevEvent[e]=Date.now();const w=u.listeners.page;switch(o.emit(Ot,{page:t,event:"Page "+e,params:{page:t,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=e,e){case w.pageLoad:O.queryOption[b]=q(t,"options")||q(t,"__displayReporter.query")||q(t,"$page.query")||q(t,"$wx.__displayReporter.query")||q(t,"$taroParams")||i[0]||{},j(O.queryOption[b],"$taroTimestamp");break;case w.pageShow:v((t=>{const e=d(t);N(e)||e.path!==b||h(t,Object.assign(Object.assign({},e),{title:O.getPageTitle()}));const{trackPage:i}=c(t);i&&this.buildPageEvent(t)})),f(!1);break;case w.pageHide:case w.pageUnload:break;case w.shareApp:f(!0),v((t=>{const{followShare:e}=c(t);e&&I(t,i)}));break;case w.shareTime:v((t=>{const{followShare:e}=c(t);e&&y(t,i)}));break;case w.addFavorites:v((t=>{const{followShare:e}=c(t);e&&S(t,i)}));break;case w.tabTap:{const t=null===(n=null==l?void 0:l.gioEventAutoTracking)||void 0===n?void 0:n.buildTabClickEvent;g.autotrack&&t&&p(t)&&t(this.growingIO.trackingId,i[0]);break}}},this.buildPageEvent=(t,e)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:s,eventHooks:{currentPage:n}}}=this.growingIO,r=Object.assign({eventType:"PAGE",referralPage:n.getReferralPage(t)},i(t));r.attributes=n.eventSetPageProps(t,r),!N(e)&&e.title&&(r.title=e.title),s(r)},this.prevEvent={}}}class Nt{constructor(t){var e;this.growingIO=t,this.isNormalFc=(t,e)=>p(e)&&"constructor"!==t,this.objectTraverse=(t,e)=>{Object.getOwnPropertyNames(t).forEach((i=>e(i,t))),T(t,"methods")&&Object.getOwnPropertyNames(t.methods).forEach((i=>{t[i]||e(i,t.methods)})),T(t,"lifetimes")&&Object.getOwnPropertyNames(t.lifetimes).forEach((i=>{t[i]||e(i,t.lifetimes)})),T(t,"pageLifetimes")&&Object.getOwnPropertyNames(t.pageLifetimes).forEach((i=>{t[i]||e(i,t.pageLifetimes)}))},this.supLifeFcs=(t,e)=>{v(this[e+"Handlers"])&&this[e+"Handlers"].forEach((e=>{p(t[e])||["onShareAppMessage","onShareTimeline"].includes(e)||(t[e]=()=>{})}))},this.lifeFcEffects=(t,e,i)=>{const s=this;return["onShareTimeline","onAddToFavorites"].includes(t)?function(...n){let r=e.apply(this,n);"onShareTimeline"===t&&s.growingIO.vdsConfig.followShare&&(r=s.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===t&&(r=s.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(n);return r&&o.push(r),s[`def${i}Cbs`][t].apply(this,o),r}:function(...n){var r;return At(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===t){if(o=null!==(r=e.apply(this,n))&&void 0!==r?r:{},"promise"===U(o)&&(o=yield o.then((t=>t))),"promise"===U(o.promise)){const t=function(){return At(this,void 0,void 0,(function*(){let t=o;return new Promise((e=>{let i=setTimeout((()=>{e(Object.assign({},t)),clearTimeout(i),i=void 0}),3e3);o.promise.then((s=>{t=s,e(Object.assign({},t)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield t()),j(o,"promise")}s.growingIO.vdsConfig.followShare&&(o=s.currentPage.updateAppMessageResult(null!=o?o:{}))}const a=[].slice.call(n);o&&a.push(o),s[`def${i}Cbs`][t].apply(this,a)}catch(t){$(t,"error")}return"onShareAppMessage"!==t&&(o=e.apply(this,n)),s.growingIO.emitter.emit(It,{event:`${i} ${t}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(n)}}),o}))}},this.customFcEffects=(t,e)=>{const i=this;return function(...s){var n,r;let o;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let e=s[0]||{};T(e,"type")&&((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))||(e=s[s.length-1]),((null==e?void 0:e.currentTarget)||(null==e?void 0:e.target))&&i.actionEventTypes.includes(e.type)&&(p(i.actionEffects)||(i.actionEffects=(null===(r=null===(n=i.growingIO.plugins)||void 0===n?void 0:n.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(e,t))}catch(t){$(t,"error")}return o=e.apply(this,s),o}},this.appApplyProxy=(t,e)=>this.appHandlers.includes(t)?this.lifeFcEffects(t,e,"App"):this.customFcEffects(t,e),this.pageApplyProxy=(t,e)=>this.pageHandlers.includes(t)?this.lifeFcEffects(t,e,"Page"):this.customFcEffects(t,e),this.appOverriding=t=>(this.setAppEffectCbs(),this.supLifeFcs(t,"app"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.appApplyProxy(t,e[t]))})),t),this.pageOverriding=t=>(this.setPageEffectCbs(),this.supLifeFcs(t,"page"),this.objectTraverse(t,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.componentOverriding=t=>(this.setPageEffectCbs(),t.methods||(t.methods={}),this.supLifeFcs(this.growingIO.inPlugin?t:t.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?t:t.methods,((t,e)=>{this.isNormalFc(t,e[t])&&(e[t]=this.pageApplyProxy(t,e[t]))})),t),this.setAppEffectCbs=()=>{const t=this;this.appHandlers.forEach((e=>{this.defAppCbs[e]=function(...i){t.appEffects.main(e,i)}}))},this.setPageEffectCbs=()=>{const t=this;this.pageHandlers.forEach((e=>{this.defPageCbs[e]=function(...i){t.pageEffects.main(this,e,i)}}))},this.growingApp=t=>p(this.originalApp)?this.originalApp(this.appOverriding(t)):this.appOverriding(t),this.growingPage=t=>p(this.originalPage)?this.originalPage(this.pageOverriding(t)):this.pageOverriding(t),this.growingComponent=t=>p(this.originalComponent)?this.originalComponent(this.componentOverriding(t)):this.componentOverriding(t),this.growingBehavior=t=>p(this.originalBehavior)?this.originalBehavior(this.componentOverriding(t)):this.componentOverriding(t),this.nativeGrowing=(t=["App","Page","Component","Behavior"])=>{const e=this,{platformConfig:i}=this.growingIO,s=i.hooks;if(t.includes("App"))try{s.App&&!this.appHooked&&(App=function(...t){return e.originalApp(e.appOverriding(t[0]))},this.appHooked=!0)}catch(t){}if(t.includes("Page"))try{s.Page&&!this.pageHooked&&(Page=function(...t){return e.originalPage(e.pageOverriding(t[0]))},this.pageHooked=!0)}catch(t){}if(t.includes("Component"))try{s.Component&&!this.componentHooked&&(Component=function(...t){return e.originalComponent(e.componentOverriding(t[0]))},this.componentHooked=!0)}catch(t){}if(t.includes("Behavior"))try{s.Behavior&&!this.behaviorHooked&&(Behavior=function(...t){return e.originalBehavior(e.componentOverriding(t[0]))},this.behaviorHooked=!0)}catch(t){}},this.initOriginalValue=()=>{this.setAppEffectCbs(),this.setPageEffectCbs(),this.originalApp=L((()=>App||global.App)),this.originalPage=L((()=>Page||global.Page)),this.originalComponent=L((()=>Component||global.Component)),this.originalBehavior=L((()=>Behavior||global.Behavior))},this.initEventHooks=()=>{const t=this,{platformConfig:e,gioPlatform:i}=this.growingIO;this.initOriginalValue(),e.canHook?(this.nativeGrowing(),et().GioApp=L((()=>null!==App&&void 0!==App?App:this.originalApp)),et().GioPage=L((()=>null!==Page&&void 0!==Page?Page:this.originalPage)),et().GioComponent=L((()=>null!==Component&&void 0!==Component?Component:this.originalComponent)),et().GioBehavior=L((()=>null!==Behavior&&void 0!==Behavior?Behavior:this.originalBehavior))):"quickapp"===i&&(et().GioApp=function(...e){return t.appOverriding(e[0])},et().GioPage=function(...e){return t.pageOverriding(e[0])},et().GioComponent=function(...e){return t.pageOverriding(e[0])})};const i=null===(e=this.growingIO)||void 0===e?void 0:e.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new qt(this.growingIO),this.pageEffects=new xt(this.growingIO),this.currentPage=new jt(this.growingIO)}}class Ut{constructor(t){var e,i;this.growingIO=t,this.ALLOW_SETTING_KEYS=E(ut),this.getStorageKey=(t,e)=>{const{inPlugin:i}=this.growingIO;return`${t===this.growingIO.trackingId?"":t}${ft[i?"plugin_"+e:e]}`},this.getGsid=t=>{let e=Number(this._gsid[t]);return Number.isNaN(e)||e>=1e9||1>e?(this.setGsid(t,1),1):e},this.setGsid=(t,e)=>{let i=Number(e);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[t]=i,10>this._gsid[t]-this._stid[t]||this.saveStorageInfo()},this.initStorageInfo=t=>{const{minipInstance:e}=this.growingIO,i=e.getStorageSync(this.getStorageKey(t,"gsid"));let s=Number(i);(Number.isNaN(s)||s>=1e9||1>s)&&(s=1),this._gsid[t]=s,this._stid[t]=s,s!==i&&e.setStorageSync(this.getStorageKey(t,"gsid"),s)},this.saveStorageInfo=()=>{const{minipInstance:t}=this.growingIO;this._stid=Object.assign({},this._gsid),nt(t,this.initializedTrackingIds.map((t=>({key:this.getStorageKey(t,"gsid"),value:this._gsid[t]}))))},this.setOriginalSource=(t,e)=>{const{minipInstance:i}=this.growingIO;i.setStorageSync(this.getStorageKey(t,"originalSource"),JSON.stringify(e))},this.getOriginalSource=t=>{var e;const{minipInstance:i}=this.growingIO;return null!==(e=L((()=>JSON.parse(i.getStorageSync(this.getStorageKey(t,"originalSource"))))))&&void 0!==e?e:{}},this.getTrackerVds=t=>this.growingIO.trackingId===t?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=t=>{const e=this.initOptions(t);return e.trackingId=t.trackingId,this.growingIO.trackingId=t.trackingId,this.growingIO.vdsConfig=e,e},this.initTrackerHooker=t=>{var e,i;const{platformConfig:s,inPlugin:n,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:l}=t;a||l||"quickapp"===r.platform||(s.canHook=!0),!n||["tbp","jdp"].includes(r.platform)?this.eventHooks.initEventHooks():this.eventHooks.initOriginalValue(),a&&(null===(e=null==o?void 0:o.gioUniAppAdapter)||void 0===e||e.main()),l&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=t=>{var e,i,s,n,r,o;const{projectId:a,dataSourceId:l,appId:g,trackingId:u}=t,c={};return this.ALLOW_SETTING_KEYS.forEach((e=>{const i=ut[e].type;(v(i)?i.includes(U(t[e])):U(t[e])===ut[e].type)?"ignoreFields"===e?c.ignoreFields=t.ignoreFields.filter((t=>vt.includes(t))):"extraParams"===e?c.extraParams=t.extraParams.filter((t=>mt.includes(t))):(c[e]=t[e],["dataCollect","autotrack"].includes(e)&&!c[e]&&$("已关闭"+ht[e],"info")):c[e]=ut[e].default})),c.uploadInterval=Math.round(c.uploadInterval),(Number.isNaN(c.uploadInterval)||0>c.uploadInterval||c.uploadInterval>3e3)&&(c.uploadInterval=1e3),c.enableIdMapping&&!c.idMapping&&(c.idMapping=!0,c.idMapping||this.growingIO.userStore.setUserKey(u,"")),j(c,"enableIdMapping"),c.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(c.requestTimeout))&&c.requestTimeout>0||(c.requestTimeout=5e3),Object.assign(Object.assign({},c),{projectId:a,dataSourceId:l,appId:g,trackingId:u,performance:{monitor:null===(i=null===(e=c.performance)||void 0===e?void 0:e.monitor)||void 0===i||i,exception:null===(n=null===(s=c.performance)||void 0===s?void 0:s.exception)||void 0===n||n,network:null!==(o=null===(r=c.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(t,e,i)=>{var s;const{userStore:n,emitter:r}=this.growingIO,o=this.getTrackerVds(t),a=u(e)&&this.ALLOW_SETTING_KEYS.includes(e),l=a&&typeof i===(null===(s=ut[e])||void 0===s?void 0:s.type);if(a&&l){const s=Object.assign({},o);return this.updateVdsConfig(t,Object.assign(Object.assign({},o),{[e]:i})),"dataCollect"===e&&s.dataCollect!==i&&i&&(n.setSessionId(t),this.sendVisit(t),this.sendPage(t)),r.emit(_t,{optionName:e,optionValue:i}),!0}return H("setOption > "+e),!1},this.getOption=(t,e)=>{const i=this.getTrackerVds(t);return e&&T(this.growingIO.vdsConfig,e)?T(i,e)?i[e]:this.growingIO.vdsConfig[e]:N(e)?i:void H("getOption > "+e)},this.updateVdsConfig=(t,e)=>{t===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),e),et().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[t]=Object.assign(Object.assign({},this.growingIO.subInstance[t]),e),et().vdsConfig.subInstance[t]=this.growingIO.subInstance[t])},this.toggleShareOut=t=>{d(t)?this.shareOut=t:this.shareOut=!this.shareOut},this.sendVisit=(t,e)=>{this.eventHooks.appEffects.buildVisitEvent(t,e)},this.sendPage=(t,e)=>{this.eventHooks.pageEffects.buildPageEvent(t,e)},this.eventConverter=t=>{const{dataStore:e,uploader:i}=this.growingIO,{dataCollect:s}=this.getTrackerVds(t.trackingId);if(s){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(t.eventType)||(t.eventSequenceId=e.getGsid(t.trackingId),e.setGsid(t.trackingId,t.eventSequenceId+1));const s={};C(t,((t,e)=>{var i;if("element"===e){const e=null!==(i=f(t))&&void 0!==i?i:{};C(e,((t,e)=>{N(t)&&0!==t||(s[e]=t)}))}else N(t)&&0!==t||(s[e]=t)})),this.growingIO.emitter.emit(St,{composedEvent:s}),i.commitRequest(Object.assign(Object.assign({},s),{requestId:B()}))}},this.eventRefactor=t=>{var e,i;const s=Object.assign(Object.assign({},t),this.eventContextBuilder(t.trackingId,{path:t.path,query:t.query,timestamp:t.timestamp}));return s.attributes=Object.assign(Object.assign({},null!==(e=s.attributes)&&void 0!==e?e:{}),null!==(i=t.attributes)&&void 0!==i?i:{}),s},this.eventInterceptor=t=>{const{systemInfo:e,network:i}=this.growingIO.minipInstance;N(e)||N(i)?this.interceptEvents.push(t):N(this.interceptEvents)?this.eventConverter(t):([...this.interceptEvents,t].forEach((t=>{this.eventConverter(this.eventRefactor(t))})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:t,network:e}}=this.growingIO;t&&e&&!N(this.interceptEvents)&&([...this.interceptEvents].forEach((t=>{this.eventConverter(this.eventRefactor(t))})),this.interceptEvents=[])},this.buildAppMessageEvent=(t,e)=>{var i,s;const n=e[0];let r;2>e.length?1===e.length&&(r=n):r=e[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(t));g.attributes=it(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$from:n.from,$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:f(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildTimelineEvent=(t,e)=>{var i,s;const n=e[0];let r;2>e.length?1===e.length&&(r=n):r=e[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),g=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(t));g.attributes=it(Object.assign(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),{$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:f(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(g)},this.buildAddFavorites=(t,e)=>{var i;const s=e[0];let n;2>e.length?1===e.length&&(n=s):n=e[1];const{dataStore:{eventContextBuilder:r,eventInterceptor:o}}=this.growingIO,a=((null==n?void 0:n.path)||"").split("?"),l=Object.assign({eventType:"CUSTOM",eventName:"$mp_add_favorites"},r(t));l.attributes=it(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$share_title:null==n?void 0:n.title,$share_path:f(a),$share_query:a[1]})),o(l)},this.trackersExecute=t=>{this.initializedTrackingIds.forEach((e=>{"function"===U(t)&&t(e)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new Ct(this.growingIO).main,this.eventHooks=new Nt(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:s,minipInstance:n}=this.growingIO;s.on(Et,(({trackingId:t})=>{this.initializedTrackingIds.push(t),this.initStorageInfo(t)})),s.on(yt,(({eventData:t,trackingId:e})=>{"VISIT"===t.eventType&&(this.lastVisitEvent[e]=t),"PAGE"===t.eventType&&(this.lastPageEvent[e]=t)})),p(null===(e=n.minip)||void 0===e?void 0:e.onAppHide)&&n.minip.onAppHide((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];C(e,(t=>{t.start&&(t.leng=t.leng+(+Date.now()-t.start))}))}))})),p(null===(i=n.minip)||void 0===i?void 0:i.onAppShow)&&n.minip.onAppShow((()=>{this.trackersExecute((t=>{const e=this.trackTimers[t];C(e,(t=>{t.start&&(t.start=+Date.now())}))}))})),s.on(_t,(({optionName:t,optionValue:e})=>{"dataCollect"===t&&!1===e&&this.trackersExecute((t=>{this.growingIO.clearTrackTimer(t)}))}))}get scene(){return this._scene}set scene(t){const e=this._scene;this._scene=t,e!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:t,oldScene:e})}}const Dt={name:"QuickApp",platform:"quickapp",scnPrefix:"quickapp_",appHandlers:["onCreate","onShow","onHide","onDestroy","onError"],pageHandlers:["onInit","onReady","onShow","onHide","onDestroy","onMenuPress","onShareAppMessage"],actionEventTypes:["click","longpress","blur","change"],canHook:!1,hooks:{App:!1,Page:!1,Component:!1,Behavior:!1},listeners:{app:{appCreate:"onCreate",appShow:"onShow",appHide:"onHide",appClose:"onDestroy"},page:{pageLoad:"onInit",pageReady:"onReady",pageShow:"onShow",pageHide:"onHide",pageClose:"onDestroy",menuPress:"onMenuPress",tabTap:void 0,shareApp:"onShareAppMessage"},actions:{click:["click","longpress"],change:["blur","change"],submit:[]}}};class Kt{constructor(t){this.growingIO=t,this.minip=Y("quickapp"),this.hookSetTitle=()=>{var t;const e=null===(t=this.minip)||void 0===t?void 0:t.setNavigationBarTitle,i=this;e&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const t=i.getCurrentPath(),{title:e}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.settedTitle[t]=e}return e.apply(this,arguments)}})},this.navigateTo=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateTo(t)},this.switchTab=t=>{var e;null===(e=this.minip)||void 0===e||e.switchTab(t)},this.navigateToMiniProgram=t=>{var e;return null===(e=this.minip)||void 0===e?void 0:e.navigateToMiniProgram(t)},this.getImageInfo=({src:t,success:e,fail:i,complete:s})=>{var n;return null===(n=this.minip)||void 0===n?void 0:n.getImageInfo({src:t,success:e,fail:i,complete:s})},this.initImpression=t=>{var e,i;null===(i=null===(e=this.growingIO.plugins)||void 0===e?void 0:e.gioImpressionTracking)||void 0===i||i.main(t,"observeAll")},this.getCurrentPage=()=>L((()=>I(getCurrentPages())))||{},this.getCurrentPath=()=>{const t=this.getCurrentPage();return(null==t?void 0:t.route)||(null==t?void 0:t.uri)||(null==t?void 0:t.__route__)||""},this.getPageTitle=t=>{var e;const i=X();let s="",n=Z(i);"string"===U(n)&&(n=null!==(e=L((()=>JSON.parse(n))))&&void 0!==e?e:{});const r=(null==t?void 0:t.data)||t.$data||{};if(s=u(null==r?void 0:r.gioPageTitle)?null==r?void 0:r.gioPageTitle:"",n){const{enterParams:e}=this.growingIO.dataStore.eventHooks.appEffects;t.route||N(e)||(t.route=e.path||"",s=this._getTitleFromTabbar(n,t.route)),L((()=>{var e,r,o,a,l,g;if(!s){const u=n.page||{},c=u[t.route]||u[t.route+".html"];s=c?null===(e=null==c?void 0:c.window)||void 0===e?void 0:e.navigationBarTitleText:["wx","tt"].includes(i)?null===(a=null===(o=null===(r=n||global||$global)||void 0===r?void 0:r.global)||void 0===o?void 0:o.window)||void 0===a?void 0:a.navigationBarTitleText:null===(g=null===(l=n||global||$global)||void 0===l?void 0:l.window)||void 0===g?void 0:g.navigationBarTitleText}})),s||(s=this._getTitleFromTabbar(n,t.route))}return V(s)},this._getTitleFromTabbar=(t,e)=>{var i,s;const n=null===(s=null===(i=null==t?void 0:t.tabBar)||void 0===i?void 0:i.list)||void 0===s?void 0:s.find((t=>t.pagePath===e||t.pagePath===e+".html"));return(null==n?void 0:n.text)||""},this.getStorageSync=t=>{var e;let i=null===(e=this.minip)||void 0===e?void 0:e.getStorageSync(t);return h(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=t=>new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:t,success:({data:t})=>e(t),fail:()=>e("")})})),this.setStorageSync=(t,e,i)=>{var s;i&&(e={value:e,expiredAt:i}),null===(s=this.minip)||void 0===s||s.setStorageSync(t,e)},this.setStorage=(t,e)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:t,data:e})},this.removeStorageSync=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorageSync(t)},this.removeStorage=t=>{var e;null===(e=this.minip)||void 0===e||e.removeStorage(t)},this.getNetworkType=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{t.network=i,e(i)},fail:()=>e(null)})}))},this.request=({url:t,data:e,header:i,timeout:s,method:n,success:r,fail:o,complete:a})=>{var l;const g=null===(l=this.minip)||void 0===l?void 0:l.request({url:t,data:e,header:i,headers:i,timeout:s,method:n,success:r,fail:o,complete:a});let u=setTimeout((()=>{(null==g?void 0:g.abort)&&p(null==g?void 0:g.abort)&&(null==g||g.abort()),clearTimeout(u),u=null}),(s||1e4)+10);return g},this.getSystemInfo=()=>{const t=this;return new Promise((e=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{t.systemInfo=i,e(i)},fail:()=>e(null)})}))},this.getSetting=()=>new Promise((t=>{var e;null===(e=this.minip)||void 0===e||e.getSetting({success:t,fail:t})}));const{platformConfig:{platform:e,scnPrefix:i}}=this.growingIO;this.platform=e,this.scnPrefix=i,this.growingIO.emitter.on(Tt,(()=>{this.getNetworkType().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()}))}))}}class $t extends Kt{constructor(l){super(l),this.growingIO=l,this.getAppSource=()=>{const{source:e}=t.getInfo();return this.appSource=e||{},this.appSource},this.navigateTo=()=>{},this.switchTab=()=>{},this.navigateToMiniProgram=()=>{},this.onAppShow=()=>{},this.onAppHide=()=>{},this.getImageInfo=({src:t,success:e,fail:i,complete:n})=>null==s?void 0:s.getImageInfo({uri:t,success:e,fail:i,complete:n}),this.initImpression=()=>{},this.initShareAppMessage=t=>{const{platformConfig:e}=t;try{this.growingIO.shareAppMessage=function(){var i;const s=arguments[0];null==o||o.share(s),null===(i=null==t?void 0:t.eventTracking)||void 0===i||i.pageEffects(this,e.listeners.page.shareApp,arguments)}}catch(t){}},this.getCurrentPage=()=>(null==r?void 0:r.getPages)?I(null==r?void 0:r.getPages()):{},this.getCurrentPath=()=>{const t=null==r?void 0:r.getState();return null==t?void 0:t.path},this.getPageTitle=t=>{var e,i,s,n,o;let a="";try{if(a=u(null==t?void 0:t.gioPageTitle)?null==t?void 0:t.gioPageTitle:"",!a){const r=null!==(o=null===(n=null===(s=null===(i=null===(e=null==t?void 0:t.$app)||void 0===e?void 0:e.$def)||void 0===i?void 0:i.manifast)||void 0===s?void 0:s.display)||void 0===n?void 0:n.pages)&&void 0!==o?o:{},l=null==r?void 0:r[t.route];l&&(a=l.titleBarText)}if(!a){const t=null==r?void 0:r.getState();a=(null==t?void 0:t.name)||""}}catch(t){return""}return V(a)},this.getStorageSync=()=>"",this.getStorage=t=>At(this,void 0,void 0,(function*(){return yield new Promise((e=>{null==a||a.get({key:t,success:t=>e(t),fail:()=>e(null)})}))})),this.setStorageSync=()=>{},this.setStorage=(t,e)=>{},this.removeStorageSync=()=>{},this.removeStorage=t=>{null==a||a.delete({key:t})},this.getNetworkType=()=>At(this,void 0,void 0,(function*(){const t=this;return yield new Promise((e=>{null==n||n.getType({success:i=>{t.network=i,e(i)},fail:()=>e(null)})}))})),this.request=({url:t,header:e,method:s,data:n,success:r,fail:o,complete:a})=>null==i?void 0:i.fetch({url:t,header:e,method:s,data:n,success:r,fail:o,complete:a}),this.getSystemInfo=()=>At(this,void 0,void 0,(function*(){const t=this;return yield new Promise((i=>{null==e||e.getInfo({success:e=>{const s=Object.assign(Object.assign({},e),{version:e.platformVersionName,platform:e.osType});t.systemInfo=s,i(s)},fail:()=>i(null)})}))})),this.growingIO.emitter.on(It,(({event:t})=>{switch(t){case"App onCreate":this.getNetworkType().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var t;return null===(t=this.growingIO.dataStore)||void 0===t?void 0:t.eventReleaseInspector()}));break;case"App onCreateEnd":this.setStorage=(t,e)=>{null==a||a.set({key:t,value:e})}}}))}}const Ht=["gioPerformance"];class Lt{constructor(t){var e,i,s,n,r,o;this.growingIO=t,this.innerPluginInit=()=>{var t;Ht.forEach((t=>{var e;return j(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins,t)})),E(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins).forEach((t=>{var e,i;const{name:s,method:n}=null!==(i=null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins[t])&&void 0!==i?i:{};O(this.pluginItems,(t=>t.name===s))||this.pluginItems.push({name:P(s||t),method:n||(t=>{})})})),N(this.pluginItems)||this.installAll()},this.install=(t,e,i)=>{var s,n;const{emitter:r}=this.growingIO,o=e||O(this.pluginItems,(e=>e.name===t));if((null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[t])return $(`重复加载插件 ${t} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return $(`插件加载失败!不存在名为 ${t} 的插件!`,"error"),!1;try{return(null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[t]=new o.method(this.growingIO,i),e&&(r.emit(wt,t),$("加载插件 "+t,"info")),!0}catch(i){return this.lifeError(e,i),$(`插件【${t}】加载异常 ${i}`,"error"),!1}},this.installAll=t=>{(t||this.pluginItems).forEach((e=>{this.install(e.name,t?e:void 0,t?null==e?void 0:e.options:void 0)&&!O(this.pluginItems,(t=>t.name===e.name))&&this.pluginItems.push({name:P(e.name),method:e.method?e.method:()=>{}})}))},this.uninstall=t=>{var e;j(this.pluginItems,t);const i=j(null===(e=this.growingIO)||void 0===e?void 0:e.plugins,t);return i||$(`卸载插件 ${t} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((t=>this.uninstall(t.name)))},this.lifeError=(t,e)=>{this.growingIO.emitter.emit(bt,{plugin:t,error:e}),$(`插件执行错误 ${t.name} ${e}`,"error")},this.callLifeCycle=(t,e)=>{this.pluginItems.forEach((i=>{const s=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][t]:void 0;if(s&&p(s))try{s(e)}catch(t){this.lifeError(i,t)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(e=this.growingIO.emitter)||void 0===e||e.on(wt,(t=>this.callLifeCycle("onInstall",t))),null===(i=this.growingIO.emitter)||void 0===i||i.on(bt,(t=>this.callLifeCycle("onError",t))),null===(s=this.growingIO.emitter)||void 0===s||s.on(Ot,(t=>this.callLifeCycle("onComposeBefore",t))),null===(n=this.growingIO.emitter)||void 0===n||n.on(St,(t=>this.callLifeCycle("onComposeAfter",t))),null===(r=this.growingIO.emitter)||void 0===r||r.on(kt,(t=>this.callLifeCycle("onSendBefore",t))),null===(o=this.growingIO.emitter)||void 0===o||o.on(Pt,(t=>this.callLifeCycle("onSendAfter",t)))}}var Rt={},Vt={}.hasOwnProperty;function Ft(t){try{return decodeURIComponent(t.replace(/\+/g," "))}catch(t){return null}}function Mt(t){try{return encodeURIComponent(t)}catch(t){return null}}Rt.stringify=function(t,e){e=e||"";var i,s,n=[];for(s in"string"!=typeof e&&(e="?"),t)if(Vt.call(t,s)){if((i=t[s])||null!=i&&!isNaN(i)||(i=""),s=Mt(s),i=Mt(i),null===s||null===i)continue;n.push(s+"="+i)}return n.length?e+n.join("&"):""},Rt.parse=function(t){for(var e,i=/([^=?#&]+)=?([^&]*)/g,s={};e=i.exec(t);){var n=Ft(e[1]),r=Ft(e[2]);null===n||null===r||n in s||(s[n]=r)}return s};class Bt{constructor(t){this.growingIO=t,this.generateURL=t=>{const{serverUrl:e,projectId:i}=this.growingIO.dataStore.getTrackerVds(t);return k(e,"http")?`${e}/v3/projects/${i}/collect`:`https://${e}/v3/projects/${i}/collect`},this.getHoardingQueue=t=>{var e;return null!==(e=this.hoardingQueue[t])&&void 0!==e?e:[]},this.getRequestQueue=t=>{var e;return null!==(e=this.requestQueue[t])&&void 0!==e?e:[]},this.commitRequest=t=>{var e,i;const s=Object.assign({},t),{vdsConfig:n,emitter:r}=this.growingIO;r.emit(yt,{eventData:t,trackingId:t.trackingId}),n.forceLogin?(g(this.hoardingQueue[t.trackingId])&&(this.hoardingQueue[t.trackingId]=[]),null===(e=this.hoardingQueue[t.trackingId])||void 0===e||e.push(s)):(g(this.requestQueue[t.trackingId])&&(this.requestQueue[t.trackingId]=[]),null===(i=this.requestQueue[t.trackingId])||void 0===i||i.push(s),this.initiateRequest(t.trackingId))},this.initiateRequest=(t,e)=>{const{plugins:i,vdsConfig:s,minipInstance:n,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(t),...this.getRequestQueue(t)],a=t=>{var a,l;if(null===(a=null==s?void 0:s.tbConfig)||void 0===a?void 0:a.cloudFuncSend)null===(l=null==i?void 0:i.gioTaobaoAdapter)||void 0===l||l.singleInvoke(t);else if(e)this.batchInvoke(t);else{const{uploadInterval:e}=this.growingIO.dataStore.getTrackerVds(t);x(this.batchInvoke,e,!1,!1)(t)}o.some((t=>"VISIT"===t.eventType))&&n.removeStorageSync(r.getStorageKey(t,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(t);else{let e=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(t),clearInterval(e),e=void 0)}),500)}},this.batchInvoke=t=>{const{vdsConfig:e,emitter:i}=this.growingIO,s=this.getHoardingQueue(t),n=this.getRequestQueue(t);let r=[...s,...n];r.length>50?(r=r.slice(0,50),s.length>50?this.hoardingQueue[t]=s.slice(50):(this.requestQueue[t]=n.slice(50-s.length),this.hoardingQueue[t]=[])):(this.hoardingQueue[t]=[],this.requestQueue[t]=[]);let o=r.filter((t=>(this.retryIds[t.requestId]||0)<=this.retryLimit));if(N(o))return;const a=o.map((t=>{const e=Object.assign({},t);return j(e,["requestId","trackingId"]),e}));e.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(kt,{eventsQueue:o,requestData:a,trackingId:t})},this.sendEvent=(t,e)=>{var i;const s=f(t).trackingId,{minipInstance:n,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:g}=r.getTrackerVds(s);this.requestingNum+=1;const u={"content-type":"jdp"===n.platform?"application/json":"application/json;charset=UTF-8"};let c=[...e];const d=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);d&&(c=a.gioCompress.compressToUTF16(JSON.stringify(e)),u["X-Compress-Codec"]="1");const h=this.generateURL(s);n.request({url:`${h}?stm=${Date.now()}&compress=${d?"1":"0"}`,header:u,method:"POST",data:c,timeout:g,fail:e=>{[200,204].includes(e.code)||(t.forEach((t=>{this.requestFailFn(t)})),$("请求失败!"+JSON.stringify(e),"error"))},complete:t=>{this.requestingNum-=1,o.emit(Pt,{result:t,requestData:e}),this.initiateRequest(s)}})},this.requestFailFn=t=>{if(this.retryIds[t.requestId]||(this.retryIds[t.requestId]=0),this.retryIds[t.requestId]+=1,!this.requestQueue[t.trackingId].some((e=>e.requestId===t.requestId))){let e=setTimeout((()=>{N(this.requestQueue[t.trackingId])?(this.requestQueue[t.trackingId].push(t),this.initiateRequest(t.trackingId)):this.requestQueue[t.trackingId].push(t),clearTimeout(e),e=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:e,vdsConfig:i,plugins:s}=this.growingIO;e.on(kt,(({eventsQueue:t,requestData:e,trackingId:n})=>{var r,o;n===this.growingIO.trackingId&&((null===(r=null==i?void 0:i.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==s?void 0:s.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(t,e):this.sendEvent(t,e))}))}}class Gt{constructor(t){this.growingIO=t,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:t}=this.growingIO;return this._uid||(this._uid=t.getStorageSync(this._getUidKey())),this._uid||(this._uid=B(),t.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=t=>{const e=this._uid;this._uid=t,e!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:t,oldUId:e}))},this.getSessionId=t=>(this._sessionId[t]||this.setSessionId(t),this._sessionId[t]),this.setSessionId=(t,e)=>{const i=this._sessionId[t];e||(e=B()),this._sessionId[t]=e,i!==e&&this.growingIO.emitter.emit("SESSIONID_UPDATE",{newSessionId:e,oldSessionId:i})},this._getUserIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"userId"),this.getUserId=t=>{const{minipInstance:e}=this.growingIO;return this._userId[t]||(this._userId[t]=e.getStorageSync(this._getUserIdKey(t))),this._userId[t]},this.setUserId=(t,e)=>{const i=this._userId[t];this._userId[t]=g(e)?"":e,i!==this._userId[t]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(t),this._userId[t]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:e,oldUserId:i})),e&&this.setGioId(t,e)},this._getUserKeyKey=t=>this.growingIO.dataStore.getStorageKey(t,"userKey"),this.getUserKey=t=>{const{minipInstance:e}=this.growingIO;return this._userKey[t]||(this._userKey[t]=e.getStorageSync(this._getUserKeyKey(t))),this._userKey[t]},this.setUserKey=(t,e)=>{const i=this._userKey[t];this._userKey[t]=g(e)?"":e,i!==this._userKey[t]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(t),this._userKey[t]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:e,oldUserKey:i}))},this._getGioIdKey=t=>this.growingIO.dataStore.getStorageKey(t,"gioId"),this.getGioId=t=>{const{minipInstance:e}=this.growingIO;return this._gioId[t]||(this._gioId[t]=e.getStorageSync(this._getGioIdKey(t))),this._gioId[t]},this.setGioId=(t,e)=>{const i=this._gioId[t];this._gioId[t]=g(e)?"":e,i!==this._gioId[t]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(t),this._gioId[t]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:e,oldGioId:i}))},this.initUserInfo=t=>{var e;const{minipInstance:i}=this.growingIO,s=[this._getUidKey(),this._getUserIdKey(t),this._getUserKeyKey(t),this._getGioIdKey(t)],n=null!==(e=st(i,s))&&void 0!==e?e:[];["_uid","_userId","_userKey","_gioId"].forEach(((e,i)=>{"_uid"===e?this.getUid():this[e][t]=n[i]}))},this.saveUserInfo=()=>{const{minipInstance:t,dataStore:{trackersExecute:e}}=this.growingIO;e((e=>{nt(t,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(e),value:this._userId[e]},{key:this._getUserKeyKey(e),value:this._userKey[e]},{key:this._getGioIdKey(e),value:this._gioId[e]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={}}}const Qt=new class{constructor(){var t;this.init=t=>{var e;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:t});try{if($("Gio小程序SDK 初始化中...","info"),t.trackingId&&this.dataStore.initializedTrackingIds.includes(t.trackingId))throw Error(`已存在实例 ${t.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(t);return null===(e=this.emitter)||void 0===e||e.emit(Tt,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(t.trackingId),this.emitter.emit(Et,i),this.trackingId&&this.trackingId!==t.trackingId||(et().__gio__=()=>this),$("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&$("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(t){return $(t,"error"),!1}},this.handlerDistribute=(t,e,i)=>{const{initializedTrackingIds:s,getTrackerVds:n}=this.dataStore;if(n(t)&&s.includes(t))return this[e](t,...i);$(`不存在实例:${t},请检查!`,"warn")},this.registerPlugins=t=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...t],this.plugins.installAll(t)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(t,e)=>this.dataStore.getOption(t,e),this.setOption=(t,e,i)=>{var s;return E(ht).includes(e)?typeof i===(null===(s=ut[e])||void 0===s?void 0:s.type)?(this.dataStore.setOption(t,e,i),$(`已修改${ht[e]}: ${i}`,"info"),!0):($(`参数格式不正确:${i},请检查后重试!`,"error"),!1):($(`不存在可修改的配置项:${e},请检查后重试!`,"error"),!1)},this.setPageAttributes=(t,e)=>{if(h(e)&&!N(e)){const{currentPage:i}=this.dataStore.eventHooks,s=i.getPagePath();return N(i.pageProps[t])&&(i.pageProps[t]={}),N(i.pageProps[t][s])&&(i.pageProps[t][s]={}),N(e)||C(e,((e,n)=>{p(i.pageProps[t][s][n])&&!p(e)||(i.pageProps[t][s][n]=e)})),!0}return H("setPageAttributes"),!1},this.clearPageAttributes=(t,e)=>{try{if(!N(this.dataStore.eventHooks.currentPage.pageProps[t])){const{currentPage:i}=this.dataStore.eventHooks,s=i.getPagePath();v(e)&&!N(e)?e.forEach((e=>{j(i.pageProps[t][s],e)})):i.pageProps[t][s]={}}}catch(t){return H("clearPageAttributes"),!1}},this.sendPage=(t,e)=>{const{trackPage:i}=this.dataStore.getTrackerVds(t);i?$("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(t,e)},this.identify=(t,e)=>{if(t===this.trackingId)if(this.vdsConfig.forceLogin){if(!gt(e))return void H("identify");const t=b(e).slice(0,1e3);this.userStore.setUid(t),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((e=>{const i=this.uploader.getHoardingQueue(e);i.forEach(((e,s)=>i[s].deviceId=t)),this.uploader.initiateRequest(e,!0)}))}else H("identify",!1,"forceLogin未开启");else H("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(t,e)=>{var i,s,n,r;if(h(e)&&!N(e)){const{eventContextBuilder:o,eventInterceptor:a,lastVisitEvent:l}=this.dataStore,g=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},o(t));g.attributes=it(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),M(e))),g.path||(g.path=null===(s=l[t])||void 0===s?void 0:s.path,g.query=null===(n=l[t])||void 0===n?void 0:n.query,g.title=null===(r=l[t])||void 0===r?void 0:r.title),a(g)}else H("setUserAttributes")},this.setUserId=(t,e,i)=>{if(gt(e)){const s=this.userStore.getGioId(t);e=b(e).slice(0,1e3),i=b(i).slice(0,1e3),this.userStore.setUserId(t,e);const{idMapping:n}=this.dataStore.getTrackerVds(t);n&&this.userStore.setUserKey(t,g(i)?"":i),s&&s!==e&&(this.userStore.setSessionId(t),this.dataStore.sendVisit(t))}else H("setUserId")},this.clearUserId=t=>{this.userStore.setUserId(t,void 0),this.userStore.setUserKey(t,void 0)},this.setGeneralProps=(t,e)=>h(e)&&!N(e)?(N(this.dataStore.generalProps[t])&&(this.dataStore.generalProps[t]={}),C(e,((e,i)=>{p(this.dataStore.generalProps[t][i])&&!p(e)||(this.dataStore.generalProps[t][i]=e)})),!0):(H("setGeneralProps"),!1),this.clearGeneralProps=(t,e)=>{try{N(this.dataStore.generalProps[t])||(v(e)&&!N(e)?e.forEach((e=>{j(this.dataStore.generalProps[t],e)})):this.dataStore.generalProps[t]={})}catch(t){return H("clearGeneralProps"),!1}},this.track=(t,e,i)=>{F(e,(()=>{var s;const{eventContextBuilder:n,eventInterceptor:r}=this.dataStore,o=Object.assign({eventType:"CUSTOM",eventName:e},n(t));o.attributes=it(Object.assign(Object.assign({},null!==(s=o.attributes)&&void 0!==s?s:{}),M(Object.assign({},h(i)&&!N(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(o["&&sendTo"]=i["&&sendTo"]),r(o)}))},this.trackTimerStart=(t,e)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(t);return i?F(e,(()=>{const i=B();return this.dataStore.trackTimers[t]||(this.dataStore.trackTimers[t]={}),this.dataStore.trackTimers[t][i]={eventName:e,leng:0,start:+Date.now()},i})):($("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return t.start&&(t.leng=t.leng+(+Date.now()-t.start)),t.start=0,!0}return!1},this.trackTimerResume=(t,e)=>{const i=this.dataStore.trackTimers[t];if(e&&i&&i[e]){const t=i[e];return 0===t.start&&(t.start=+Date.now()),!0}return!1},this.trackTimerEnd=(t,e,i)=>{var s;const{dataCollect:n}=this.dataStore.getTrackerVds(t),r=this.dataStore.trackTimers[t];if(e&&r&&r[e]){if(n){const n=864e5,o=r[e];if(0!==o.start){const t=+Date.now()-o.start;o.leng=t>0?o.leng+t:0}const{eventContextBuilder:a,eventInterceptor:l}=this.dataStore,g=Object.assign({eventType:"CUSTOM",eventName:o.eventName},a(t));return g.attributes=it(Object.assign(Object.assign({},null!==(s=g.attributes)&&void 0!==s?s:{}),M(Object.assign(Object.assign({},h(i)&&!N(i)?i:{}),{event_duration:o.leng>n?0:o.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(g["&&sendTo"]=i["&&sendTo"]),l(g),!0}return $("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return $("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(t,e)=>{const i=this.dataStore.trackTimers[t];return e&&i&&i[e]?(delete i[e],!0):($("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=t=>{this.dataStore.trackTimers[t]={}},this.setLocation=(t,e,i)=>{N(this.dataStore.locationData[t])&&(this.dataStore.locationData[t]={});const s=this.dataStore.locationData[t],n=t=>t>=-180&&180>=t;n(e)&&n(i)&&(s.latitude!==e||s.longitude!==i)&&(this.dataStore.locationData[t]={latitude:e,longitude:i})},this.updateImpression=()=>{$("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(t,e,i)=>{$("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),R(i,{})},this.getGioInfo=t=>{const{getUid:e,getUserId:i,getUserKey:s,getSessionId:n}=this.userStore,{projectId:r,appId:o,dataSourceId:a,dataCollect:l,idMapping:g,extraParams:u,ignoreFields:c}=this.dataStore.getTrackerVds(t),d={gioappid:o,giocs1:i(t)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:n(t),giou:e()};return d.giodatacollect=l,d.giodatasourceid=a,g&&(d.giouserkey=s(t)),N(u)||u.forEach((e=>{var i;c.includes(e)||(d["gio"+e]=(null!==(i=this.dataStore.lastVisitEvent[t])&&void 0!==i?i:{})[e])})),Rt.stringify(d)},this.utils=Object.assign(Object.assign(Object.assign({},K),lt),{qs:Rt}),this.emitter={all:t=t||new Map,on:function(e,i){var s=t.get(e);s?s.push(i):t.set(e,[i])},off:function(e,i){var s=t.get(e);s&&(i?s.splice(s.indexOf(i)>>>0,1):t.set(e,[]))},emit:function(e,i){var s=t.get(e);s&&s.slice().map((function(t){t(i)})),(s=t.get("*"))&&s.slice().map((function(t){t(e,i)}))}},this.gioPlatform="quickapp",this.gioFramework="native",this.sdkVersion="4.3.0";try{"quickapp"===this.gioPlatform||p(getApp)&&p(App)?this.inPlugin=!1:this.inPlugin=!0}catch(t){this.inPlugin=!0}this.inPlugin&&$("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Dt,this.minipInstance=new $t(this),this.dataStore=new Ut(this),this.userStore=new Gt(this),this.uploader=new Bt(this),this.plugins=new Lt(this),this.plugins.innerPluginInit()}},zt=function(){var t;const e=arguments[0];let i="g0",s=e;if(e.indexOf(".")>-1&&(i=null!==(t=e.split(".")[0])&&void 0!==t?t:"g0",s=e.split(".")[1]),u(s)&&dt.includes(s)&&Qt[s]){const t=y(Array.from(arguments));if("init"===s){const e=((t,e)=>{const i=b(e[0]),s=b(e[1]),n=(4===e.length?e[3]:e[2])||{};return i&&s?t.dataStore.initializedTrackingIds.some(((e,n)=>{const r=0===n?t.vdsConfig:t.subInstance[e];return r.projectId===i&&r.dataSourceId===s}))?($("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:s,appId:b(4===e.length?e[2]:""),userOptions:n}:($('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})(Qt,t);if(e){const{projectId:t,dataSourceId:s,appId:n,userOptions:r}=e;return Qt.init(Object.assign(Object.assign({},r),{projectId:t,dataSourceId:s,appId:n,trackingId:i}))}return!1}if("registerPlugins"===s)Qt.registerPlugins(t[0]);else{if(Qt.gioSDKInitialized&&Qt.vdsConfig)return ct.includes(s)?L((()=>Qt.handlerDistribute(i,s,t))):L((()=>Qt[s](...t)));$("SDK未初始化!","error")}}else if(pt.includes(s))$(`方法 ${b(s)} 已被弃用,请移除!`,"warn");else{if("canIUse"===s)return dt.includes(arguments[1])&&!!Qt[arguments[1]];$(`不存在名为 ${b(s)} 的方法调用!`,"error")}};et().gdp=zt,et().gioSDKVersion=Qt.sdkVersion;const{growingApp:Wt,growingPage:Jt,growingComponent:Yt,growingBehavior:Zt,initOriginalValue:Xt}=Qt.dataStore.eventHooks;Xt();const te=L((()=>null!=Wt?Wt:App)),ee=L((()=>null!=Jt?Jt:Page)),ie=L((()=>null!=Yt?Yt:Component)),se=L((()=>null!=Zt?Zt:Behavior));export{te as GioApp,se as GioBehavior,ie as GioComponent,ee as GioPage,zt as default};
|