gio-miniprogram-sdk 4.3.2 → 4.4.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 +3 -3
- 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/plugins/gioPerformance.js +1 -0
- package/dist/qq.js +1 -1
- package/dist/quickapp.js +1 -1
- package/dist/taobao.js +1 -1
- package/dist/taro.js +1 -1
- package/dist/uniapp.js +1 -1
- package/dist/wechat.js +1 -1
- package/dist/xiaohongshu.js +1 -0
- package/package.json +12 -6
- package/rollup.config.js +9 -6
- package/rollup.plugins.config.js +1 -1
- package/src/constants/emitMsg.ts +1 -0
- package/src/core/dataStore/eventHooks/appEffects.ts +3 -0
- package/src/core/dataStore/eventHooks/index.ts +4 -2
- package/src/core/dataStore/eventHooks/pageEffects.ts +1 -0
- package/src/core/growingIO.ts +27 -3
- package/src/core/uploader.ts +12 -3
- package/src/core/userStore.ts +1 -2
- package/src/minipInstance/base.ts +62 -23
- package/src/minipInstance/framework.ts +3 -1
- package/src/minipInstance/quickapp.ts +11 -0
- package/src/minipInstance/wx.ts +15 -0
- package/src/minipInstance/xhs.ts +20 -0
- package/src/platformConfig/base.ts +1 -0
- package/src/platformConfig/xhs.ts +20 -0
- package/src/plugins/gioABTest.ts +32 -3
- package/src/plugins/gioEventAutoTracking.ts +99 -1
- package/src/plugins/gioImpressionTracking.ts +3 -1
- package/src/plugins/gioPerformance/exception.ts +152 -0
- package/src/plugins/gioPerformance/monitor.ts +284 -0
- package/src/plugins/gioPerformance/network.ts +197 -0
- package/src/plugins/gioPerformance.ts +131 -0
- package/src/types/base.ts +5 -1
- package/src/types/minipInstance.ts +3 -1
- package/src/types/platforms.ts +3 -0
- package/src/utils/tools.ts +46 -3
- package/src/utils/verifiers.ts +4 -3
- package/tsconfig.json +1 -1
- package/typings/global.d.ts +8 -0
- package/bin/build.sh +0 -38
package/dist/kuaishou.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,t=e=>["undefined","null"].includes(T(e)),i=e=>"string"===T(e),s=e=>"number"===T(e),n=e=>"boolean"===T(e),r=e=>"[object Object]"==={}.toString.call(e)&&!t(e),o=e=>["function","asyncfunction"].includes(T(e)),a=e=>Array.isArray(e)&&"array"===T(e),l=e=>"date"===T(e),g=e=>{try{return Array.from(e)[0]}catch(e){return}},u=e=>{try{const t=Array.from(e);return t[t.length-1]}catch(e){return}},c=(e,t=1)=>a(e)&&s(t)?e.slice(t>0?t:1,e.length):e,d=(e,t=!1)=>{if(a(e)){let i=0;const s=[];for(const n of e)n&&!_(n)&&(s[i++]=n),t&&0===n&&(s[i++]=n);return s}return e},h=(e,t)=>{if(a(e)){const i=e.findIndex(t);return 0>i?void 0:e[i]}},p=e=>t(e)?"":""+e,v=(e,t)=>"string"===T(e)?e.split(t):e,m=e=>{if(i(e)){const t=v(e,"");return`${g(t).toLowerCase()}${c(t).join("")}`}return e},f=(e,t)=>(i(e)||(e=p(e)),e.slice(0,t.length)===t),I={}.hasOwnProperty,S=(e,i)=>!t(e)&&I.call(e,i),y=e=>r(e)?Object.keys(e):[],O=(e,t)=>{y(e).forEach((i=>t(e[i],i)))},b=(e,t)=>{const i=y(e);return!(!r(e)||!r(t)||i.length!==y(t).length||i.map(((i,s)=>r(e[i])?b(e[i],t[i]):e[i]===t[i])).includes(!1))},w=(e,t,i)=>{let s=e;return r(e)?(t.split(".").forEach((e=>{s=s?s[e]:i})),s):i},P=(e,t)=>{if(!r(e))return!1;try{if("string"===T(t))return delete e[t];if("array"===T(t))return t.map((t=>delete e[t]));"object"===T(t)&&t.constructor===RegExp&&y(e).forEach((i=>{t.test(i)&&P(e,i)}))}catch(e){return!1}},k=(e,t=250,i,s)=>{let n,r=0;return"boolean"!==T(i)&&(s=e,e=i,i=void 0),function(...o){let a=this,l=Date.now()-r;function g(){r=Date.now(),e.apply(a,o)}s&&!n&&g(),n&&clearTimeout(n),void 0===s&&l>t?g():!0!==i&&(n=setTimeout(s?function(){n=void 0}:g,void 0===s?t-l:t))}},_=e=>a(e)?0===e.length:r(e)?0===y(e).length:!e,T=e=>({}.toString.call(e).slice(8,-1).toLowerCase()),E=e=>{function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())};var C=Object.freeze({__proto__:null,isNil:t,isString:i,isNaN:e=>"NaN"===p(Number(e)),isNumber:s,isBoolean:n,isObject:r,isRegExp:e=>"[object RegExp]"==={}.toString.call(e),isFunction:o,isArray:a,isDate:l,fixed:(e,t)=>s(e)?Number(e.toFixed(s(t)?t:2)):i(e)&&"NaN"!==p(Number(e))?Number(Number(e).toFixed(s(t)?t:2)):e,head:g,last:u,drop:c,dropWhile:(e,t)=>a(e)?e.filter((e=>!t(e))):e,compact:d,find:h,isEqualArray:(e,t)=>!(!a(e)||!a(t)||e.length!==t.length)&&e.every(((e,i)=>e===t[i])),toString:p,split:v,lowerFirst:m,upperFirst:e=>{if(i(e)){const t=v(e,"");return`${g(t).toUpperCase()}${c(t).join("")}`}return e},startsWith:f,endsWith:(e,t)=>{const{length:i}=e;let s=i;s>i&&(s=i);const n=s;return s-=t.length,s>=0&&e.slice(s,n)===t},hasOwnProperty:I,has:S,keys:y,forEach:O,isEqual:b,get:w,unset:P,throttle:k,isEmpty:_,typeOf:T,formatDate:E});const A=(e,t)=>{console.log("%c[GrowingIO]:"+e,{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},x=(e,t=!0,i="参数不合法")=>A(`${t?"调用":"设置"} ${e} 失败,${i}!`,"warn"),j=e=>{try{return e()}catch(e){return}},q=(e,t)=>{if(o(e))try{e(t)}catch(e){A("回调执行失败!"+e,"error")}},N=e=>i(e)?e.trim().substring(0,100):e,U=(t,s)=>i(t)&&!_(t)&&t.match(e)?s():(A("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1),K=e=>(t(e)||y(e).forEach((t=>{o(e[t])?e[t]=j((()=>e[t]())):r(e[t])?P(e,t):a(e[t])||(e[t]=p(e[t]))})),e),D=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})),L=e=>e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight,H=e=>e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth,$=(e,t)=>{if(e){const i=e.toLowerCase();return-1!==i.indexOf("android")?t+"-Android":-1!==i.indexOf("ios")?t+"-iOS":e}},R=e=>{if(i(e)){const t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},B=e=>i(e)?e.startsWith("/")?e:"/"+e:"",V=e=>j((()=>{switch(e){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;default:{let e;return e||(e=j((()=>swan))),e||(e=j((()=>my))),e||(e=j((()=>tt))),e||(e=j((()=>qq))),e||(e=j((()=>ks))),e||(e=j((()=>jd))),e||(e=j((()=>wx))),e}}})),F=e=>j((()=>{switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return j((()=>__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}})),G=()=>{let e;return!e&&j((()=>swan))&&(e="swan"),!e&&j((()=>tt))&&(e="tt"),!e&&j((()=>qq))&&(e="qq"),!e&&j((()=>my.tb))&&(e="tb"),!e&&j((()=>my))&&(e="my"),!e&&j((()=>ks))&&(e="ks"),!e&&j((()=>jd))&&(e="jd"),!e&&j((()=>wx))&&(e="wx"),e||h(y(global),(e=>p(e).toLowerCase().includes("quickapp")))&&(e="quickapp"),e},M=()=>{var e;return null!==(e=j((()=>{var e;return null!==(e=j((()=>{var e;return null!==(e=j((()=>$global)))&&void 0!==e?e:global})))&&void 0!==e?e:window})))&&void 0!==e?e:globalThis},Q=e=>{const i={};return r(e)&&(P(e,"&&sendTo"),O(e,((e,s)=>{const n=p(s).slice(0,100);r(e)?i[n]=Q(e):a(e)?(i[n]=d(e.slice(0,100),!0),i[n]=i[n].join("||").slice(0,1e3)):l(e)?i[n]=E(e):i[n]=t(e)?"":p(e).slice(0,1e3)}))),i},z=(e,t)=>{const i=()=>t.map((t=>e.getStorageSync(t)));try{return e.minip.canIUse("batchGetStorageSync")?e.minip.batchGetStorageSync(t):i()}catch(e){return i()}},W=(e,t)=>{const i=()=>t.map((({key:t,value:i})=>e.setStorageSync(t,i)));try{return e.minip.canIUse("batchSetStorageSync")?e.minip.batchSetStorageSync(t):i()}catch(e){return i()}},J=e=>y(e||{}).map((i=>i?`${i}=${t(e[i])?"":e[i]}`:"")).join("&"),Y=e=>{(f(e,"?")||f(e,"&"))&&(e=e.slice(1,e.length));const t={};return e.split("&").forEach((e=>{const i=e.split("=");i[0]&&(t[i[0]]=i[1])})),t},Z=(e={},t={})=>{const i={};return y(t).forEach((e=>{["string","number","boolean"].includes(T(t[e]))&&(i[e]=t[e])})),Object.assign({},i,e)};var X=Object.freeze({__proto__:null,consoleText:A,callError:x,niceTry:j,niceCallback:q,limitString:N,eventNameValidate:U,getDynamicAttributes:K,guid:D,getScreenHeight:L,getScreenWidth:H,getOS:$,compareVersion:(e="",t="")=>{const i=e=>e.replace(/\s+/g,""),s=e=>e.replace(/[vV]/g,""),n=i(s(e)),r=i(s(t)),o=n.split("."),a=r.split(".");for(let e=0;3>e;e++){let t=Number(o[e]),i=Number(a[e]);if(t>i)return 1;if(i>t)return-1;if(!isNaN(t)&&isNaN(i))return 1;if(isNaN(t)&&!isNaN(i))return-1}return 0},getVueVersion:e=>{if(e){const t=Number(g(v(e.version,".")));return Number.isNaN(t)?0:t}return 0},splitPath:R,normalPath:B,isTaro3:e=>{const{Current:t,createComponent:i}=e;return!(!e||!t||i)},getPlainMinip:V,getPlainConfig:F,getPlainPlatform:G,getSubKeys:e=>y(e).filter((e=>e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1)).sort(),getAppInst:()=>{let e=j((()=>getApp({allowDefault:!0})));return e||(e=M()),e},getGlobal:M,limitObject:Q,batchGetStorageSync:z,batchSetStorageSync:W,qsStringify:J,qsParse:Y,hashCode:(e,t=!1)=>{let i=0;if(_(e)||"boolean"==typeof e)return i;let s=0;for(;s<e.length;)i=(i<<5)-i+e.charCodeAt(s),i|=0,s++;return t?Math.abs(i):i},getLaunchQuery:Z});const ee=e=>i(e)&&e.length>0||s(e)&&e>0,te={autotrack:{type:"boolean",default:!0},compress:{type:"boolean",default:!0},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},extraParams:{type:"array",default:[]},followShare:{type:"boolean",default:!0},forceLogin:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},impressionScale:{type:"number",default:0},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},sessionExpires:{type:"number",default:-1},requestTimeout:{type:"number",default:5e3},taro:{type:["object","module"],default:!1},taroVue:{type:["object","function"],default:!1},tbConfig:{type:"object",default:{cloud:void 0,cloudFuncSend:!1,cloudFuncName:"httpTunnel",cloudFuncHandler:"main",cloudAppId:void 0,path:void 0}},trackPage:{type:"boolean",default:!0},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},ie=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],se=["init","registerPlugins","getPlugins","getDeviceId","updateImpression",...ie],ne={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},re=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],oe=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],ae=[...oe,"appChannel","language","platformVersion"],le={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 ge="MINIP_LIFECYCLE",ue="ON_COMMIT_REQUEST",ce="ON_COMPOSE_AFTER",de="ON_COMPOSE_BEFORE",he="ON_ERROR",pe="ON_INSTALL",ve="ON_SEND_AFTER",me="ON_SEND_BEFORE",fe="OPTION_CHANGE",Ie="OPTION_INITIALIZED",Se="SDK_INITIALIZED",ye="SESSIONID_UPDATE";class Oe{constructor(e){this.growingIO=e,this.main=(e,t,i=!0)=>{e||(e=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(e),m=a.locationData[e],{systemInfo:f={},network:I={}}=r,{brand:S,model:y,platform:O,language:b}=f,w=g.getPagePath(),k={appChannel:"scn:"+(l||"NA"),appVersion:c,dataSourceId:d,deviceBrand:S,deviceId:o.getUid(),deviceModel:y,deviceType:$(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:$(O,n.name),path:w,platform:n.platform,platformVersion:n.name+(f.version?" "+f.version:""),query:w?g.getPageQuery():"",screenHeight:L(f),screenWidth:H(f),sdkVersion:s,sessionId:o.getSessionId(e),title:g.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:o.getUserId(e)};return p&&(k.userKey=o.getUserKey(e)),i&&!_(u[e])&&(k.attributes=Object.assign({},u[e])),_(k.attributes)||(k.attributes=Q(K(Object.assign({},k.attributes)))),_(v)||v.forEach((e=>{P(k,e)})),_(t)?Object.assign(Object.assign({},k),{trackingId:e}):Object.assign(Object.assign(Object.assign({},k),t),{trackingId:e})}}}function be(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{l(s.next(e))}catch(e){r(e)}}function a(e){try{l(s.throw(e))}catch(e){r(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}l((s=s.apply(e,t||[])).next())}))}"function"==typeof SuppressedError&&SuppressedError;class we{constructor(e){this.growingIO=e,this.enterParams={},this.main=(e,t)=>{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(ge,{event:"App "+e,timestamp:n,params:null!==(i=t[0])&&void 0!==i?i:{}}),a.debug&&console.log("App:",e,n);const m=l.listeners.app;switch(r.emit(de,{event:"App "+e,params:null!==(s=t[0])&&void 0!==s?s:{}}),e){case m.appLaunch:this.enterParams=Object.assign({},t[0]);break;case m.appCreate:case m.appShow:{const{path:e,query:i,referralPage:s}=this.enterParamsParse(t[0]);!d&&a.originalSource&&e&&c((t=>{v(t,{path:e,query:i,referralPage:s})})),h?(Date.now()-h>60*a.keepAlive*1e3||u.lastScene&&u.scene!==u.lastScene)&&c((e=>{o.setSessionId(e)})):c((t=>{u.lastVisitEvent[t]={path:e,query:i,referralPage:s},this.buildVisitEvent(t,{path:e,query:i,referralPage:s})}));break}case m.appClose:u.lastScene=u.scene,u.lastCloseTime=Date.now(),p(),o.saveUserInfo(),c((e=>{this.buildCloseEvent(e),a.forceLogin||g.initiateRequest(e,!0)}))}},this.enterParamsParse=(e={})=>{var t;const{gioPlatform:i,minipInstance: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||e.path,o=l||e.query,a=(null==u?void 0:u.appId)||(null===(t=null==e?void 0:e.referrerInfo)||void 0===t?void 0:t.appId)||"",n.scene=g||e.scene,o=_(null==u?void 0:u.extraData)?J(o):J(Z(o,u.extraData))}else{const{path:t,query:i,referrerInfo:s}=e;r=t,o=J(i),a=(null==s?void 0:s.appId)||"",this.parseScene(e)}return{path:r,query:o,referralPage:a}},this.parseScene=e=>{var t;const{minipInstance:i,gioPlatform:s,dataStore:n}=this.growingIO;let r;if("quickapp"===s){const{extra:e,type:t}=i.getAppSource();r=(null==e?void 0:e.scene)||t}else _(e)||((null===(t=null==e?void 0:e.query)||void 0===t?void 0:t.wxShoppingListScene)?r=e.query.wxShoppingListScene:(null==e?void 0:e.scene)?r=e.scene:n.scene="NA");n.scene=r},this.buildVisitEvent=(e,t)=>{const{dataStore:{getOriginalSource:i,eventContextBuilder:s,eventInterceptor:n},vdsConfig:r}=this.growingIO,o=i(e),a=(null==t?void 0:t.query)||"";let l=Object.assign({eventType:"VISIT"},s(e,{}));!_(t)&&t.path&&(l.path=t.path||"",l.query="string"===T(a)?a:J(a),t.referralPage&&(l.referralPage=t.referralPage)),r.originalSource&&!_(o)&&(l=Object.assign(Object.assign({},l),o)),n(l)},this.buildCloseEvent=e=>{const{dataStore:{eventContextBuilder:t,eventInterceptor:i}}=this.growingIO;i(Object.assign({eventType:"APP_CLOSED"},t(e)))}}}class Pe{constructor(e){this.growingIO=e,this.lifeBeforeShow=!0,this.getPagePath=()=>{var e,t,i;const{minipInstance:s,inPlugin:n,dataStore:r,trackingId:o}=this.growingIO,a=s.getCurrentPath();if(n){const e=r.getTrackerVds(o);return a||"/插件"+e.appId}return a||(null===(e=r.eventHooks.appEffects.enterParams)||void 0===e?void 0:e.path)||(null===(t=r.lastPageEvent[o])||void 0===t?void 0:t.path)||(null===(i=r.lastVisitEvent[o])||void 0===i?void 0:i.path)},this.getPageQuery=()=>{var e,t,i,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(Z(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!==(e=g.options)&&void 0!==e?e:g.$taroParams;if(!_(i))return P(i,"$taroTimestamp"),this.qsQuery(i);if(!_(this.queryOption[u]))return this.qsQuery(this.queryOption[u]);if(u===c.path)return this.qsQuery(Z(null==c?void 0:c.query,null===(t=null==c?void 0:c.referrerInfo)||void 0===t?void 0:t.extraData))}},this.getPageTitle=e=>{const{minipInstance:t,inPlugin:i,dataStore:s}=this.growingIO,n=t.getCurrentPath(),r=this.configuredTitle[n]||t.getPageTitle(t.getCurrentPage());if(i){const t=s.getTrackerVds(e||this.growingIO.trackingId);return r||`/插件${t.appId}${n?"_"+u(n.split("/")):""}`}return r},this.qsQuery=(e={})=>{const t=Object.assign({},e);return P(t,"wxShoppingListScene"),J(t)},this.getReferralPage=e=>{var t,i,s;const{minipInstance:n,dataStore:{lastPageEvent:r,scene:o,eventHooks:a}}=this.growingIO;return(null===(t=r[e])||void 0===t?void 0:t.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=e=>{const[t,i]=this.buildShareQuery(e);return e.path=B(t+(i?"?"+i:"")),e.query=i,e},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=e=>{const[t,i]=this.buildShareQuery(e);return e.path=B(t+(i?"?"+i:"")),e.query=i,e},this.eventSetPageProps=(e,t)=>{const i=j((()=>this.pageProps[e][this.getPagePath()]));return _(i)?t.attributes:Q(K(Object.assign(Object.assign({},t.attributes),i)))},this.queryOption={},this.configuredTitle={},this.pageProps={}}buildShareQuery(e){var t,i;const s=R(null!==(t=e.path)&&void 0!==t?t:"");let n=this.getPagePath(),r={},o=S(e,"path");if(o&&(n=g(s),r=Y(u(s))||{}),_(r)&&(r=Y(null!==(i=e.query)&&void 0!==i?i:"")||{},d(y(r)).forEach((e=>{e.toLowerCase().startsWith("utm_")&&P(r,e)}))),!o&&_(r)){const e=this.growingIO.minipInstance.getCurrentPage();r=e.options||this.queryOption[e.route]||{}}return[n,J(r)]}}class ke{constructor(e){this.growingIO=e,this.main=(e,t,i)=>{var s,n;const r=Date.now(),{emitter:a,minipInstance:l,plugins:g,vdsConfig:u,platformConfig:c,dataStore:{getTrackerVds:d,getOriginalSource:h,setOriginalSource:p,trackersExecute:v,eventHooks:m,toggleShareOut:f,buildAppMessageEvent:I,buildTimelineEvent:S,buildAddFavorites:y}}=this.growingIO,{currentPage:O}=m;if(this.prevEvent[t]&&50>Date.now()-Number(this.prevEvent[t]))return;e||(e=l.getCurrentPage()),e.route||(e.route=l.getCurrentPath(e));const b=e.route||e.uri||e.__route__||(null===(s=null==e?void 0:e.$page)||void 0===s?void 0:s.fullPath)||"";a.emit(ge,{event:"Page "+t,timestamp:r,params:{page:e,args:i[0]}}),u.debug&&console.log("Page:",b,"#",t,r),this.prevEvent[t]=Date.now();const k=c.listeners.page;switch(a.emit(de,{page:e,event:"Page "+t,params:{page:e,args:i[0]}}),O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=t,t){case k.pageLoad:O.queryOption[b]=w(e,"options")||w(e,"__displayReporter.query")||w(e,"$page.query")||w(e,"$wx.__displayReporter.query")||w(e,"$taroParams")||i[0]||{},P(O.queryOption[b],"$taroTimestamp");break;case k.pageShow:v((e=>{const t=h(e);_(t)||t.path!==b||p(e,Object.assign(Object.assign({},t),{title:O.getPageTitle()}));const{trackPage:i}=d(e);i&&this.buildPageEvent(e)})),f(!1);break;case k.pageHide:case k.pageUnload:break;case k.shareApp:f(!0),v((e=>{const{followShare:t}=d(e);t&&I(e,i)}));break;case k.shareTime:v((e=>{const{followShare:t}=d(e);t&&S(e,i)}));break;case k.addFavorites:v((e=>{const{followShare:t}=d(e);t&&y(e,i)}));break;case k.tabTap:{const e=null===(n=null==g?void 0:g.gioEventAutoTracking)||void 0===n?void 0:n.buildTabClickEvent;u.autotrack&&e&&o(e)&&e(this.growingIO.trackingId,i[0]);break}}O.lastLifecycle=O.currentLifecycle,O.currentLifecycle=t+"End",["onHideEnd","onUnloadEnd"].includes(O.currentLifecycle)&&(O.lifeBeforeShow=!0),"onShowEnd"===O.currentLifecycle&&(O.lifeBeforeShow=!1)},this.buildPageEvent=(e,t)=>{const{dataStore:{eventContextBuilder:i,eventInterceptor:s,eventHooks:{currentPage:n}}}=this.growingIO,r=Object.assign({eventType:"PAGE",referralPage:n.getReferralPage(e)},i(e));r.attributes=n.eventSetPageProps(e,r),!_(t)&&t.title&&(r.title=t.title),s(r)},this.prevEvent={}}}class _e{constructor(e){var t;this.growingIO=e,this.isNormalFc=(e,t)=>o(t)&&"constructor"!==e,this.objectTraverse=(e,t)=>{Object.getOwnPropertyNames(e).forEach((i=>t(i,e))),S(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((i=>{e[i]||t(i,e.methods)})),S(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((i=>{e[i]||t(i,e.lifetimes)})),S(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((i=>{e[i]||t(i,e.pageLifetimes)}))},this.supLifeFcs=(e,t)=>{a(this[t+"Handlers"])&&this[t+"Handlers"].forEach((t=>{o(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=()=>{})}))},this.lifeFcEffects=(e,t,i)=>{const s=this;return["onShareTimeline","onAddToFavorites"].includes(e)?function(...n){let r=t.apply(this,n);"onShareTimeline"===e&&s.growingIO.vdsConfig.followShare&&(r=s.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=s.currentPage.updateAddFavoritesResult(null!=r?r:{}));const o=[].slice.call(n);return r&&o.push(r),s[`def${i}Cbs`][e].apply(this,o),r}:function(...n){var r;return be(this,void 0,void 0,(function*(){let o;try{if("onShareAppMessage"===e){if(o=null!==(r=t.apply(this,n))&&void 0!==r?r:{},"promise"===T(o)&&(o=yield o.then((e=>e))),"promise"===T(o.promise)){const e=function(){return be(this,void 0,void 0,(function*(){let e=o;return new Promise((t=>{let i=setTimeout((()=>{t(Object.assign({},e)),clearTimeout(i),i=void 0}),3e3);o.promise.then((s=>{e=s,t(Object.assign({},e)),clearTimeout(i),i=void 0}))}))}))};o=Object.assign(Object.assign({},o),yield e()),P(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`][e].apply(this,a)}catch(e){A(e,"error")}return"onShareAppMessage"!==e&&(o=t.apply(this,n)),s.growingIO.emitter.emit(ge,{event:`${i} ${e}End`,timestamp:Date.now(),params:{instance:this,arguments:Array.from(n)}}),o}))}},this.customFcEffects=(e,t)=>{const i=this;return function(...s){var n,r;let a;if(i.growingIO.vdsConfig.autotrack&&i.growingIO.plugins.gioEventAutoTracking)try{let t=s[0]||{};S(t,"type")&&((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))||(t=s[s.length-1]),((null==t?void 0:t.currentTarget)||(null==t?void 0:t.target))&&i.actionEventTypes.includes(t.type)&&(o(i.actionEffects)||(i.actionEffects=(null===(r=null===(n=i.growingIO.plugins)||void 0===n?void 0:n.gioEventAutoTracking)||void 0===r?void 0:r.main)||function(){}),null==i||i.actionEffects(t,e))}catch(e){A(e,"error")}return a=t.apply(this,s),a}},this.appApplyProxy=(e,t)=>this.appHandlers.includes(e)?this.lifeFcEffects(e,t,"App"):this.customFcEffects(e,t),this.pageApplyProxy=(e,t)=>this.pageHandlers.includes(e)?this.lifeFcEffects(e,t,"Page"):this.customFcEffects(e,t),this.appOverriding=e=>(this.setAppEffectCbs(),this.supLifeFcs(e,"app"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.appApplyProxy(e,t[e]))})),e),this.pageOverriding=e=>(this.setPageEffectCbs(),this.supLifeFcs(e,"page"),this.objectTraverse(e,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.componentOverriding=e=>(this.setPageEffectCbs(),e.methods||(e.methods={}),this.supLifeFcs(this.growingIO.inPlugin?e:e.methods,"page"),this.objectTraverse(this.growingIO.inPlugin?e:e.methods,((e,t)=>{this.isNormalFc(e,t[e])&&(t[e]=this.pageApplyProxy(e,t[e]))})),e),this.setAppEffectCbs=()=>{const e=this;this.appHandlers.forEach((t=>{this.defAppCbs[t]=function(...i){e.appEffects.main(t,i)}}))},this.setPageEffectCbs=()=>{const e=this;this.pageHandlers.forEach((t=>{this.defPageCbs[t]=function(...i){e.pageEffects.main(this,t,i)}}))},this.growingApp=e=>o(this.originalApp)?this.originalApp(this.appOverriding(e)):this.appOverriding(e),this.growingPage=e=>o(this.originalPage)?this.originalPage(this.pageOverriding(e)):this.pageOverriding(e),this.growingComponent=e=>o(this.originalComponent)?this.originalComponent(this.componentOverriding(e)):this.componentOverriding(e),this.growingBehavior=e=>o(this.originalBehavior)?this.originalBehavior(this.componentOverriding(e)):this.componentOverriding(e),this.nativeGrowing=(e=["App","Page","Component","Behavior"])=>{const t=this,{platformConfig:i}=this.growingIO,s=i.hooks;if(e.includes("App"))try{s.App&&!this.appHooked&&(App=function(...e){return t.originalApp(t.appOverriding(e[0]))},this.appHooked=!0)}catch(e){}if(e.includes("Page"))try{s.Page&&!this.pageHooked&&(Page=function(...e){return t.originalPage(t.pageOverriding(e[0]))},this.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{s.Component&&!this.componentHooked&&(Component=function(...e){return t.originalComponent(t.componentOverriding(e[0]))},this.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{s.Behavior&&!this.behaviorHooked&&(Behavior=function(...e){return t.originalBehavior(t.componentOverriding(e[0]))},this.behaviorHooked=!0)}catch(e){}},this.initOriginalValue=()=>{this.setAppEffectCbs(),this.setPageEffectCbs(),this.originalApp=j((()=>App||global.App)),this.originalPage=j((()=>Page||global.Page)),this.originalComponent=j((()=>Component||global.Component)),this.originalBehavior=j((()=>Behavior||global.Behavior))},this.initEventHooks=()=>{const e=this,{platformConfig:t,gioPlatform:i}=this.growingIO;this.initOriginalValue(),t.canHook?(this.nativeGrowing(),M().GioApp=j((()=>null!==App&&void 0!==App?App:this.originalApp)),M().GioPage=j((()=>null!==Page&&void 0!==Page?Page:this.originalPage)),M().GioComponent=j((()=>null!==Component&&void 0!==Component?Component:this.originalComponent)),M().GioBehavior=j((()=>null!==Behavior&&void 0!==Behavior?Behavior:this.originalBehavior))):"quickapp"===i&&(M().GioApp=function(...t){return e.appOverriding(t[0])},M().GioPage=function(...t){return e.pageOverriding(t[0])},M().GioComponent=function(...t){return e.pageOverriding(t[0])})};const i=null===(t=this.growingIO)||void 0===t?void 0:t.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=i.appHandlers,this.pageHandlers=i.pageHandlers,this.actionEventTypes=i.actionEventTypes,this.appEffects=new we(this.growingIO),this.pageEffects=new ke(this.growingIO),this.currentPage=new Pe(this.growingIO)}}class Te{constructor(e){var t,s;this.growingIO=e,this.ALLOW_SETTING_KEYS=y(te),this.getStorageKey=(e,t)=>{const{inPlugin:i}=this.growingIO;return`${e===this.growingIO.trackingId?"":e}${le[i?"plugin_"+t:t]}`},this.getGsid=e=>{let t=Number(this._gsid[e]);return Number.isNaN(t)||t>=1e9||1>t?(this.setGsid(e,1),1):t},this.setGsid=(e,t)=>{let i=Number(t);(Number.isNaN(i)||i>=1e9||1>i)&&(i=1),this._gsid[e]=i,10>this._gsid[e]-this._stid[e]||this.saveStorageInfo()},this.initStorageInfo=e=>{const{minipInstance:t}=this.growingIO,i=t.getStorageSync(this.getStorageKey(e,"gsid"));let s=Number(i);(Number.isNaN(s)||s>=1e9||1>s)&&(s=1),this._gsid[e]=s,this._stid[e]=s,s!==i&&t.setStorageSync(this.getStorageKey(e,"gsid"),s)},this.saveStorageInfo=()=>{const{minipInstance:e}=this.growingIO;this._stid=Object.assign({},this._gsid),W(e,this.initializedTrackingIds.map((e=>({key:this.getStorageKey(e,"gsid"),value:this._gsid[e]}))))},this.setOriginalSource=(e,t)=>{const{minipInstance:i}=this.growingIO;i.setStorageSync(this.getStorageKey(e,"originalSource"),JSON.stringify(t))},this.getOriginalSource=e=>{var t;const{minipInstance:i}=this.growingIO;return null!==(t=j((()=>JSON.parse(i.getStorageSync(this.getStorageKey(e,"originalSource"))))))&&void 0!==t?t:{}},this.getTrackerVds=e=>this.growingIO.trackingId===e?Object.assign({},this.growingIO.vdsConfig):void 0,this.initTrackerOptions=e=>{const t=this.initOptions(e);return t.trackingId=e.trackingId,this.growingIO.trackingId=e.trackingId,this.growingIO.vdsConfig=t,t},this.initTrackerHooker=e=>{var t,i;const{platformConfig:s,inPlugin:n,minipInstance:r,plugins:o}=this.growingIO,{uniVue:a,taro:l}=e;a||l||"quickapp"===r.platform||(s.canHook=!0),!n||["tbp","jdp"].includes(r.platform)?this.eventHooks.initEventHooks():this.eventHooks.initOriginalValue(),a&&(null===(t=null==o?void 0:o.gioUniAppAdapter)||void 0===t||t.main()),l&&(null===(i=null==o?void 0:o.gioTaroAdapter)||void 0===i||i.main())},this.initOptions=e=>{var t,i,s,n,r,o;const{projectId:l,dataSourceId:g,appId:u,trackingId:c}=e,d={};return this.ALLOW_SETTING_KEYS.forEach((t=>{const i=te[t].type;(a(i)?i.includes(T(e[t])):T(e[t])===te[t].type)?"ignoreFields"===t?d.ignoreFields=e.ignoreFields.filter((e=>oe.includes(e))):"extraParams"===t?d.extraParams=e.extraParams.filter((e=>ae.includes(e))):(d[t]=e[t],["dataCollect","autotrack"].includes(t)&&!d[t]&&A("已关闭"+ne[t],"info")):d[t]=te[t].default})),d.uploadInterval=Math.round(d.uploadInterval),(Number.isNaN(d.uploadInterval)||0>d.uploadInterval||d.uploadInterval>3e3)&&(d.uploadInterval=1e3),d.enableIdMapping&&!d.idMapping&&(d.idMapping=!0,d.idMapping||this.growingIO.userStore.setUserKey(c,"")),P(d,"enableIdMapping"),d.pluginMode&&(this.growingIO.inPlugin=!0),!isNaN(Number(d.requestTimeout))&&d.requestTimeout>0||(d.requestTimeout=5e3),(0>d.impressionScale||d.impressionScale>1)&&(d.impressionScale=0),(0>d.keepAlive||d.keepAlive>1440)&&(d.keepAlive=5),(1>d.sessionExpires||d.sessionExpires>1440)&&(d.sessionExpires=-1),Object.assign(Object.assign({},d),{projectId:l,dataSourceId:g,appId:u,trackingId:c,performance:{monitor:null===(i=null===(t=d.performance)||void 0===t?void 0:t.monitor)||void 0===i||i,exception:null===(n=null===(s=d.performance)||void 0===s?void 0:s.exception)||void 0===n||n,network:null!==(o=null===(r=d.performance)||void 0===r?void 0:r.network)&&void 0!==o&&o}})},this.setOption=(e,t,s)=>{var n;const{userStore:r,emitter:o}=this.growingIO,a=this.getTrackerVds(e),l=i(t)&&this.ALLOW_SETTING_KEYS.includes(t),g=l&&typeof s===(null===(n=te[t])||void 0===n?void 0:n.type);if(l&&g){const i=Object.assign({},a);return this.updateVdsConfig(e,Object.assign(Object.assign({},a),{[t]:s})),"dataCollect"===t&&i.dataCollect!==s&&s&&r.setSessionId(e),o.emit(fe,{optionName:t,optionValue:s}),!0}return x("setOption > "+t),!1},this.getOption=(e,t)=>{const i=this.getTrackerVds(e);return t&&S(this.growingIO.vdsConfig,t)?S(i,t)?i[t]:this.growingIO.vdsConfig[t]:_(t)?i:void x("getOption > "+t)},this.updateVdsConfig=(e,t)=>{e===this.growingIO.trackingId?(this.growingIO.vdsConfig=Object.assign(Object.assign({},this.growingIO.vdsConfig),t),M().vdsConfig=this.growingIO.vdsConfig):(this.growingIO.subInstance[e]=Object.assign(Object.assign({},this.growingIO.subInstance[e]),t),M().vdsConfig.subInstance[e]=this.growingIO.subInstance[e])},this.toggleShareOut=e=>{n(e)?this.shareOut=e:this.shareOut=!this.shareOut},this.sendVisit=(e,t)=>{this.eventHooks.appEffects.buildVisitEvent(e,t)},this.sendPage=(e,t)=>{this.eventHooks.pageEffects.buildPageEvent(e,t)},this.eventConverter=e=>{const{dataStore:t,uploader:i}=this.growingIO,{dataCollect:s}=this.getTrackerVds(e.trackingId);if(s){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=t.getGsid(e.trackingId),t.setGsid(e.trackingId,e.eventSequenceId+1));const s={};O(e,((e,t)=>{var i;if("element"===t){const t=null!==(i=g(e))&&void 0!==i?i:{};O(t,((e,t)=>{_(e)&&0!==e||(s[t]=e)}))}else _(e)&&0!==e||(s[t]=e)})),this.growingIO.emitter.emit(ce,{composedEvent:s}),i.commitRequest(Object.assign(Object.assign({},s),{requestId:D()}))}},this.eventRefactor=e=>{var t,i;const s=Object.assign(Object.assign({},e),this.eventContextBuilder(e.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));return s.attributes=Object.assign(Object.assign({},null!==(t=s.attributes)&&void 0!==t?t:{}),null!==(i=e.attributes)&&void 0!==i?i:{}),s},this.eventInterceptor=e=>{const{systemInfo:t,network:i}=this.growingIO.minipInstance;_(t)||_(i)?this.interceptEvents.push(e):_(this.interceptEvents)?this.eventConverter(e):([...this.interceptEvents,e].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.eventReleaseInspector=()=>{const{minipInstance:{systemInfo:e,network:t}}=this.growingIO;e&&t&&!_(this.interceptEvents)&&([...this.interceptEvents].forEach((e=>{this.eventConverter(this.eventRefactor(e))})),this.interceptEvents=[])},this.buildAppMessageEvent=(e,t)=>{var i,s;const n=t[0];let r;2>t.length?1===t.length&&(r=n):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),u=Object.assign({eventType:"CUSTOM",eventName:"$mp_on_share"},o(e));u.attributes=Q(Object.assign(Object.assign(Object.assign({},null!==(i=u.attributes)&&void 0!==i?i:{}),{$from:n.from,$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:g(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(u)},this.buildTimelineEvent=(e,t)=>{var i,s;const n=t[0];let r;2>t.length?1===t.length&&(r=n):r=t[1];const{dataStore:{eventContextBuilder:o,eventInterceptor:a}}=this.growingIO,l=((null==r?void 0:r.path)||"").split("?"),u=Object.assign({eventType:"CUSTOM",eventName:"$mp_share_timeline"},o(e));u.attributes=Q(Object.assign(Object.assign(Object.assign({},null!==(i=u.attributes)&&void 0!==i?i:{}),{$target:null===(s=null==n?void 0:n.target)||void 0===s?void 0:s.id,$share_title:null==r?void 0:r.title,$share_path:g(l),$share_query:l[1]}),null==r?void 0:r.attributes)),a(u)},this.buildAddFavorites=(e,t)=>{var i;const s=t[0];let n;2>t.length?1===t.length&&(n=s):n=t[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(e));l.attributes=Q(Object.assign(Object.assign({},null!==(i=l.attributes)&&void 0!==i?i:{}),{$share_title:null==n?void 0:n.title,$share_path:g(a),$share_query:a[1]})),o(l)},this.trackersExecute=e=>{this.initializedTrackingIds.forEach((t=>{"function"===T(e)&&e(t)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new Oe(this.growingIO).main,this.eventHooks=new _e(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];const{emitter:r,minipInstance:l}=this.growingIO;r.on(Se,(({trackingId:e})=>{this.initializedTrackingIds.push(e),this.initStorageInfo(e)})),r.on(ue,(({eventData:e,trackingId:t})=>{"VISIT"===e.eventType&&(this.lastVisitEvent[t]=e),"PAGE"===e.eventType&&(this.lastPageEvent[t]=e)})),o(null===(t=l.minip)||void 0===t?void 0:t.onAppHide)&&l.minip.onAppHide((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];O(t,(e=>{e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))}))})),o(null===(s=l.minip)||void 0===s?void 0:s.onAppShow)&&l.minip.onAppShow((()=>{this.trackersExecute((e=>{const t=this.trackTimers[e];O(t,(e=>{e.start&&(e.start=+Date.now())}))}))})),r.on(fe,(({optionName:e,optionValue:t})=>{"dataCollect"===e&&!1===t&&this.trackersExecute((e=>{this.growingIO.clearTrackTimer(e)}))})),this.growingIO.emitter.on(ye,(({oldSessionId:e,trackingId:t})=>{if(e){const{getPagePath:e,getPageQuery:i}=this.eventHooks.currentPage,s=e(),n=i();if(s)this.sendVisit(t,{path:s,query:n});else{const e=this.lastPageEvent[t];this.sendVisit(t,{path:e.path,query:e.query})}this.eventHooks.currentPage.lifeBeforeShow||this.sendPage(t)}}))}get scene(){return this._scene}set scene(e){const t=this._scene;this._scene=e,t!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:e,oldScene:t})}}const Ee={scnPrefix:"",appHandlers:["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange"],pageHandlers:["onLoad","onShow","onReady","onHide","onShareAppMessage","onTabItemTap","onUnload","onPullDownRefresh","onReachBottom","onResize"],actionEventTypes:["onclick","tap","onTap","longpress","longTap","blur","change","onChange","submit","confirm","getuserinfo","getphonenumber","contact","mouseup"],canHook:!0,hooks:{App:!0,Page:!0,Component:!0,Behavior:!0},listeners:{app:{appLaunch:"onLaunch",appShow:"onShow",appClose:"onHide"},page:{pageLoad:"onLoad",pageShow:"onShow",pageReady:"onReady",pageHide:"onHide",pageUnload:"onUnload",tabTap:"onTabItemTap",shareApp:"onShareAppMessage"},actions:{click:["onclick","tap","longpress","longTap","getuserinfo","getphonenumber","contact","mouseup"],change:["blur","change","confirm"],submit:["submit"]}}},Ce=Object.assign(Object.assign({},Ee),{listeners:Object.assign({},Ee.listeners),name:"KuaiShou",platform:"kuaishoup",scnPrefix:"ks_"});class Ae{constructor(e){this.growingIO=e,this.minip=V("ks"),this.hookSetTitle=()=>{var e;const t=null===(e=this.minip)||void 0===e?void 0:e.setNavigationBarTitle,i=this;t&&Object.defineProperty(this.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(i.growingIO.gioSDKInitialized){const e=i.getCurrentPath(),{title:t}=arguments[0]||{};i.growingIO.dataStore.eventHooks.currentPage.configuredTitle[e]=t}return t.apply(this,arguments)}})},this.navigateTo=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateTo(e)},this.switchTab=e=>{var t;null===(t=this.minip)||void 0===t||t.switchTab(e)},this.navigateToMiniProgram=e=>{var t;return null===(t=this.minip)||void 0===t?void 0:t.navigateToMiniProgram(e)},this.getImageInfo=({src:e,success:t,fail:i,complete:s})=>{var n;return null===(n=this.minip)||void 0===n?void 0:n.getImageInfo({src:e,success:t,fail:i,complete:s})},this.initImpression=e=>{var t,i;null===(i=null===(t=this.growingIO.plugins)||void 0===t?void 0:t.gioImpressionTracking)||void 0===i||i.main(e,"observeAll")},this.getCurrentPage=()=>j((()=>u(getCurrentPages())))||{},this.getCurrentPath=()=>{const e=this.getCurrentPage();return(null==e?void 0:e.route)||(null==e?void 0:e.uri)||(null==e?void 0:e.__route__)||""},this.getPageTitle=e=>{var t;const s=G();let n="",r=F(s);"string"===T(r)&&(r=null!==(t=j((()=>JSON.parse(r))))&&void 0!==t?t:{});const o=(null==e?void 0:e.data)||e.$data||{};if(n=i(null==o?void 0:o.gioPageTitle)?null==o?void 0:o.gioPageTitle:"",r){const{enterParams:t}=this.growingIO.dataStore.eventHooks.appEffects;e.route||_(t)||(e.route=t.path||"",n=this._getTitleFromTabBar(r,e.route)),j((()=>{var t,i,o,a,l,g;if(!n){const u=r.page||{},c=u[e.route]||u[e.route+".html"];n=c?null===(t=null==c?void 0:c.window)||void 0===t?void 0:t.navigationBarTitleText:["wx","tt"].includes(s)?null===(a=null===(o=null===(i=r||global||$global)||void 0===i?void 0:i.global)||void 0===o?void 0:o.window)||void 0===a?void 0:a.navigationBarTitleText:null===(g=null===(l=r||global||$global)||void 0===l?void 0:l.window)||void 0===g?void 0:g.navigationBarTitleText}})),n||(n=this._getTitleFromTabBar(r,e.route))}return N(n)},this._getTitleFromTabBar=(e,t)=>{var i,s;const n=null===(s=null===(i=null==e?void 0:e.tabBar)||void 0===i?void 0:i.list)||void 0===s?void 0:s.find((e=>e.pagePath===t||e.pagePath===t+".html"));return(null==n?void 0:n.text)||""},this.getStorageSync=e=>{var t;let i=null===(t=this.minip)||void 0===t?void 0:t.getStorageSync(e);return r(i)&&i.expiredAt?i.expiredAt<Date.now()?"":i.value:i},this.getStorage=e=>new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getStorage({key:e,success:({data:e})=>t(e),fail:()=>t("")})})),this.setStorageSync=(e,t,i)=>{var s;i&&(t={value:t,expiredAt:i}),null===(s=this.minip)||void 0===s||s.setStorageSync(e,t)},this.setStorage=(e,t)=>{var i;null===(i=this.minip)||void 0===i||i.setStorage({key:e,data:t})},this.removeStorageSync=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorageSync(e)},this.removeStorage=e=>{var t;null===(t=this.minip)||void 0===t||t.removeStorage(e)},this.getNetworkType=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getNetworkType({success:i=>{e.network=i,t(i)},fail:()=>t(null)})}))},this.request=({url:e,data:t,header:i,timeout:s,method:n,success:r,fail:a,complete:l})=>{var g;const u=null===(g=this.minip)||void 0===g?void 0:g.request({url:e,data:t,header:i,timeout:s,method:n,success:r,fail:a,complete:l});let c=setTimeout((()=>{(null==u?void 0:u.abort)&&o(null==u?void 0:u.abort)&&(null==u||u.abort()),clearTimeout(c),c=null}),(s||1e4)+10);return u},this.getSystemInfo=()=>{const e=this;return new Promise((t=>{var i;null===(i=this.minip)||void 0===i||i.getSystemInfo({success:i=>{e.systemInfo=i,t(i)},fail:()=>t(null)})}))},this.getSetting=()=>new Promise((e=>{var t;null===(t=this.minip)||void 0===t||t.getSetting({success:e,fail:e})}));const{platformConfig:{platform:t,scnPrefix:s}}=this.growingIO;this.platform=t,this.scnPrefix=s,this.growingIO.emitter.on(Ie,(()=>{this.getNetworkType().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()})),this.getSystemInfo().then((()=>{var e;return null===(e=this.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()}))}))}}class xe extends Ae{constructor(e){super(e),this.growingIO=e,this.hookSetTitle()}}const je=["gioPerformance"];class qe{constructor(e){var t,i,s,n,r,a;this.growingIO=e,this.innerPluginInit=()=>{var e;je.forEach((e=>{var t;return P(null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins,e)})),y(null===(e=this.pluginsContext)||void 0===e?void 0:e.plugins).forEach((e=>{var t,i;const{name:s,method:n}=null!==(i=null===(t=this.pluginsContext)||void 0===t?void 0:t.plugins[e])&&void 0!==i?i:{};h(this.pluginItems,(e=>e.name===s))||this.pluginItems.push({name:m(s||e),method:n||(e=>{})})})),_(this.pluginItems)||this.installAll()},this.install=(e,t,i)=>{var s,n;const{emitter:r}=this.growingIO,o=t||h(this.pluginItems,(t=>t.name===e));if((null===(s=this.growingIO)||void 0===s?void 0:s.plugins)[e])return A(`重复加载插件 ${e} 或插件重名,已跳过加载!`,"warn"),!1;if(!o)return A(`插件加载失败!不存在名为 ${e} 的插件!`,"error"),!1;try{return(null===(n=this.growingIO)||void 0===n?void 0:n.plugins)[e]=new o.method(this.growingIO,i),t&&(r.emit(pe,e),A("加载插件 "+e,"info")),!0}catch(i){return this.lifeError(t,i),A(`插件【${e}】加载异常 ${i}`,"error"),!1}},this.installAll=e=>{(e||this.pluginItems).forEach((t=>{this.install(t.name,e?t:void 0,e?null==t?void 0:t.options:void 0)&&!h(this.pluginItems,(e=>e.name===t.name))&&this.pluginItems.push({name:m(t.name),method:t.method?t.method:()=>{}})}))},this.uninstall=e=>{var t;P(this.pluginItems,e);const i=P(null===(t=this.growingIO)||void 0===t?void 0:t.plugins,e);return i||A(`卸载插件 ${e} 失败!`,"error"),i},this.uninstallAll=()=>{this.pluginItems.forEach((e=>this.uninstall(e.name)))},this.lifeError=(e,t)=>{this.growingIO.emitter.emit(he,{plugin:e,error:t}),A(`插件执行错误 ${e.name} ${t}`,"error")},this.callLifeCycle=(e,t)=>{this.pluginItems.forEach((i=>{const s=this.growingIO.plugins[i.name]?this.growingIO.plugins[i.name][e]:void 0;if(s&&o(s))try{s(t)}catch(e){this.lifeError(i,e)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(t=this.growingIO.emitter)||void 0===t||t.on(pe,(e=>this.callLifeCycle("onInstall",e))),null===(i=this.growingIO.emitter)||void 0===i||i.on(he,(e=>this.callLifeCycle("onError",e))),null===(s=this.growingIO.emitter)||void 0===s||s.on(de,(e=>this.callLifeCycle("onComposeBefore",e))),null===(n=this.growingIO.emitter)||void 0===n||n.on(ce,(e=>this.callLifeCycle("onComposeAfter",e))),null===(r=this.growingIO.emitter)||void 0===r||r.on(me,(e=>this.callLifeCycle("onSendBefore",e))),null===(a=this.growingIO.emitter)||void 0===a||a.on(ve,(e=>this.callLifeCycle("onSendAfter",e)))}}var Ne={},Ue={}.hasOwnProperty;function Ke(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function De(e){try{return encodeURIComponent(e)}catch(e){return null}}Ne.stringify=function(e,t){t=t||"";var i,s,n=[];for(s in"string"!=typeof t&&(t="?"),e)if(Ue.call(e,s)){if((i=e[s])||null!=i&&!isNaN(i)||(i=""),s=De(s),i=De(i),null===s||null===i)continue;n.push(s+"="+i)}return n.length?t+n.join("&"):""},Ne.parse=function(e){for(var t,i=/([^=?#&]+)=?([^&]*)/g,s={};t=i.exec(e);){var n=Ke(t[1]),r=Ke(t[2]);null===n||null===r||n in s||(s[n]=r)}return s};class Le{constructor(e){this.growingIO=e,this.generateURL=e=>{const{serverUrl:t,projectId:i}=this.growingIO.dataStore.getTrackerVds(e);return f(t,"http")?`${t}/v3/projects/${i}/collect`:`https://${t}/v3/projects/${i}/collect`},this.getHoardingQueue=e=>{var t;return null!==(t=this.hoardingQueue[e])&&void 0!==t?t:[]},this.getRequestQueue=e=>{var t;return null!==(t=this.requestQueue[e])&&void 0!==t?t:[]},this.commitRequest=e=>{var i,s;const n=Object.assign({},e),{vdsConfig:r,emitter:o}=this.growingIO;o.emit(ue,{eventData:e,trackingId:e.trackingId}),r.forceLogin?(t(this.hoardingQueue[e.trackingId])&&(this.hoardingQueue[e.trackingId]=[]),null===(i=this.hoardingQueue[e.trackingId])||void 0===i||i.push(n)):(t(this.requestQueue[e.trackingId])&&(this.requestQueue[e.trackingId]=[]),null===(s=this.requestQueue[e.trackingId])||void 0===s||s.push(n),this.initiateRequest(e.trackingId))},this.initiateRequest=(e,t)=>{const{plugins:i,vdsConfig:s,minipInstance:n,dataStore:r}=this.growingIO,o=[...this.getHoardingQueue(e),...this.getRequestQueue(e)],a=e=>{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(e);else if(t)this.batchInvoke(e);else{const{uploadInterval:t}=this.growingIO.dataStore.getTrackerVds(e);k(this.batchInvoke,t,!1,!1)(e)}o.some((e=>"VISIT"===e.eventType))&&n.removeStorageSync(r.getStorageKey(e,"originalSource"))};if(o.length>0)if(this.requestingNum<this.requestLimit)a(e);else{let t=setInterval((()=>{this.requestingNum<this.requestLimit&&(a(e),clearInterval(t),t=void 0)}),500)}},this.batchInvoke=e=>{const{vdsConfig:t,emitter:i}=this.growingIO,s=this.getHoardingQueue(e),n=this.getRequestQueue(e);let r=[...s,...n];r.length>50?(r=r.slice(0,50),s.length>50?this.hoardingQueue[e]=s.slice(50):(this.requestQueue[e]=n.slice(50-s.length),this.hoardingQueue[e]=[])):(this.hoardingQueue[e]=[],this.requestQueue[e]=[]);let o=r.filter((e=>(this.retryIds[e.requestId]||0)<=this.retryLimit));if(_(o))return;const a=o.map((e=>{const t=Object.assign({},e);return P(t,["requestId","trackingId"]),t}));t.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(a,null,2)),i.emit(me,{eventsQueue:o,requestData:a,trackingId:e})},this.sendEvent=(e,t)=>{var i;const s=g(e).trackingId,{minipInstance:n,dataStore:r,emitter:o,plugins:a}=this.growingIO,{compress:l,requestTimeout:u}=r.getTrackerVds(s);this.requestingNum+=1;const c={"content-type":"jdp"===n.platform?"application/json":"application/json;charset=UTF-8"};let d=[...t];const h=!!l&&(null===(i=null==a?void 0:a.gioCompress)||void 0===i?void 0:i.compressToUTF16);h&&(d=a.gioCompress.compressToUTF16(JSON.stringify(t)),c["X-Compress-Codec"]="1");const p=this.generateURL(s);n.request({url:`${p}?stm=${Date.now()}&compress=${h?"1":"0"}`,header:c,method:"POST",data:d,timeout:u,fail:t=>{[200,204].includes(t.code)||(e.forEach((e=>{this.requestFailFn(e)})),A("请求失败!"+JSON.stringify(t),"error"))},complete:e=>{this.requestingNum-=1,o.emit(ve,{result:e,requestData:t}),this.initiateRequest(s)}})},this.requestFailFn=e=>{if(this.retryIds[e.requestId]||(this.retryIds[e.requestId]=0),this.retryIds[e.requestId]+=1,!this.requestQueue[e.trackingId].some((t=>t.requestId===e.requestId))){let t=setTimeout((()=>{_(this.requestQueue[e.trackingId])?(this.requestQueue[e.trackingId].push(e),this.initiateRequest(e.trackingId)):this.requestQueue[e.trackingId].push(e),clearTimeout(t),t=null}),800)}},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0;const{emitter:i,vdsConfig:s,plugins:n}=this.growingIO;i.on(me,(({eventsQueue:e,requestData:t,trackingId:i})=>{var r,o;i===this.growingIO.trackingId&&((null===(r=null==s?void 0:s.tbConfig)||void 0===r?void 0:r.cloudAppId)?null===(o=null==n?void 0:n.gioTaobaoAdapter)||void 0===o||o.tbCloudAppInvoke(e,t):this.sendEvent(e,t))}))}}class He{constructor(e){this.growingIO=e,this._getUidKey=()=>this.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_",this.getUid=()=>{const{minipInstance:e}=this.growingIO;return this._uid||(this._uid=e.getStorageSync(this._getUidKey())),this._uid||(this._uid=D(),e.setStorage(this._getUidKey(),this._uid)),this._uid},this.setUid=e=>{const t=this._uid;this._uid=e,t!==this._uid&&(this.growingIO.minipInstance.setStorage(this._getUidKey(),this._uid),this.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:t}))},this.getSessionId=e=>{const{vdsConfig:{sessionExpires:t},dataStore:{trackersExecute:i}}=this.growingIO;return this._sessionId[e]||this.setSessionId(e),t>-1&&(Date.now()>this._sessionExpires&&i((e=>{this.setSessionId(e)})),this._sessionExpires=Date.now()+6e4*t),this._sessionId[e]},this.setSessionId=(e,t)=>{const i=this._sessionId[e];t||(t=D()),this._sessionId[e]=t;const{sessionExpires:s}=this.growingIO.vdsConfig;s>-1&&(this._sessionExpires=Date.now()+6e4*s),i!==t&&this.growingIO.emitter.emit(ye,{trackingId:e,newSessionId:t,oldSessionId:i})},this._getUserIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"userId"),this.getUserId=e=>{const{minipInstance:t}=this.growingIO;return this._userId[e]||(this._userId[e]=t.getStorageSync(this._getUserIdKey(e))),this._userId[e]},this.setUserId=(e,i)=>{const s=this._userId[e];this._userId[e]=t(i)?"":i,s!==this._userId[e]&&(this.growingIO.minipInstance.setStorage(this._getUserIdKey(e),this._userId[e]),this.growingIO.emitter.emit("USERID_UPDATE",{newUserId:i,oldUserId:s})),i&&this.setGioId(e,i)},this._getUserKeyKey=e=>this.growingIO.dataStore.getStorageKey(e,"userKey"),this.getUserKey=e=>{const{minipInstance:t}=this.growingIO;return this._userKey[e]||(this._userKey[e]=t.getStorageSync(this._getUserKeyKey(e))),this._userKey[e]},this.setUserKey=(e,i)=>{const s=this._userKey[e];this._userKey[e]=t(i)?"":i,s!==this._userKey[e]&&(this.growingIO.minipInstance.setStorage(this._getUserKeyKey(e),this._userKey[e]),this.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:i,oldUserKey:s}))},this._getGioIdKey=e=>this.growingIO.dataStore.getStorageKey(e,"gioId"),this.getGioId=e=>{const{minipInstance:t}=this.growingIO;return this._gioId[e]||(this._gioId[e]=t.getStorageSync(this._getGioIdKey(e))),this._gioId[e]},this.setGioId=(e,i)=>{const s=this._gioId[e];this._gioId[e]=t(i)?"":i,s!==this._gioId[e]&&(this.growingIO.minipInstance.setStorage(this._getGioIdKey(e),this._gioId[e]),this.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:i,oldGioId:s}))},this.initUserInfo=e=>{var t;const{minipInstance:i}=this.growingIO,s=[this._getUidKey(),this._getUserIdKey(e),this._getUserKeyKey(e),this._getGioIdKey(e)],n=null!==(t=z(i,s))&&void 0!==t?t:[];["_uid","_userId","_userKey","_gioId"].forEach(((t,i)=>{"_uid"===t?this.getUid():this[t][e]=n[i]}))},this.saveUserInfo=()=>{const{minipInstance:e,dataStore:{trackersExecute:t}}=this.growingIO;t((t=>{W(e,[{key:this._getUidKey(),value:this._uid},{key:this._getUserIdKey(t),value:this._userId[t]},{key:this._getUserKeyKey(t),value:this._userKey[t]},{key:this._getGioIdKey(t),value:this._gioId[t]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={},this._sessionExpires=-1}}const $e=new class{constructor(){var e;this.init=e=>{var t;this.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:e});try{if(A("Gio小程序SDK 初始化中...","info"),e.trackingId&&this.dataStore.initializedTrackingIds.includes(e.trackingId))throw Error(`已存在实例 ${e.trackingId},请勿重复初始化!`);if(this.trackingId&&!this.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");const i=this.dataStore.initTrackerOptions(e);return null===(t=this.emitter)||void 0===t||t.emit(Ie,i),this.gioSDKInitialized=!0,this.dataStore.initTrackerHooker(i),"quickapp"!==this.gioPlatform&&this.userStore.initUserInfo(e.trackingId),this.emitter.emit(Se,i),this.trackingId&&this.trackingId!==e.trackingId||(M().__gio__=()=>this),A("Gio小程序SDK 初始化完成!","success"),this.inPlugin&&"tbp"!==this.minipInstance.platform&&this.dataStore.sendVisit(i.trackingId),this.vdsConfig.forceLogin&&A("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(e){return A(e,"error"),!1}},this.handlerDistribute=(e,t,i)=>{const{initializedTrackingIds:s,getTrackerVds:n}=this.dataStore;if(n(e)&&s.includes(e))return this[t](e,...i);A(`不存在实例:${e},请检查!`,"warn")},this.registerPlugins=e=>{this.plugins.pluginItems=[...this.plugins.pluginItems,...e],this.plugins.installAll(e)},this.getPlugins=()=>this.plugins.pluginItems,this.getDeviceId=()=>this.userStore.getUid(),this.getOption=(e,t)=>this.dataStore.getOption(e,t),this.setOption=(e,t,i)=>{var s;return y(ne).includes(t)?typeof i===(null===(s=te[t])||void 0===s?void 0:s.type)?(this.dataStore.setOption(e,t,i),A(`已修改${ne[t]}: ${i}`,"info"),!0):(A(`参数格式不正确:${i},请检查后重试!`,"error"),!1):(A(`不存在可修改的配置项:${t},请检查后重试!`,"error"),!1)},this.setPageAttributes=(e,t)=>{if(r(t)&&!_(t)){const{currentPage:i}=this.dataStore.eventHooks,s=i.getPagePath();return _(i.pageProps[e])&&(i.pageProps[e]={}),_(i.pageProps[e][s])&&(i.pageProps[e][s]={}),_(t)||O(t,((t,n)=>{o(i.pageProps[e][s][n])&&!o(t)||(i.pageProps[e][s][n]=t)})),!0}return x("setPageAttributes"),!1},this.clearPageAttributes=(e,t)=>{try{if(!_(this.dataStore.eventHooks.currentPage.pageProps[e])){const{currentPage:i}=this.dataStore.eventHooks,s=i.getPagePath();a(t)&&!_(t)?t.forEach((t=>{P(i.pageProps[e][s],t)})):i.pageProps[e][s]={}}}catch(e){return x("clearPageAttributes"),!1}},this.sendPage=(e,t)=>{const{trackPage:i}=this.dataStore.getTrackerVds(e);i?A("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):this.dataStore.sendPage(e,t)},this.identify=(e,t)=>{if(e===this.trackingId)if(this.vdsConfig.forceLogin){if(!ee(t))return void x("identify");const e=p(t).slice(0,1e3);this.userStore.setUid(e),this.dataStore.setOption(this.trackingId,"forceLogin",!1),this.dataStore.trackersExecute((t=>{const i=this.uploader.getHoardingQueue(t);i.forEach(((t,s)=>i[s].deviceId=e)),this.uploader.initiateRequest(t,!0)}))}else x("identify",!1,"forceLogin未开启");else x("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=(e,t)=>{var i,s,n,o;if(r(t)&&!_(t)){const{eventContextBuilder:r,eventInterceptor:a,lastVisitEvent:l}=this.dataStore,g=Object.assign({eventType:"LOGIN_USER_ATTRIBUTES"},r(e));g.attributes=Q(Object.assign(Object.assign({},null!==(i=g.attributes)&&void 0!==i?i:{}),K(t))),g.path||(g.path=null===(s=l[e])||void 0===s?void 0:s.path,g.query=null===(n=l[e])||void 0===n?void 0:n.query,g.title=null===(o=l[e])||void 0===o?void 0:o.title),a(g)}else x("setUserAttributes")},this.setUserId=(e,i,s)=>{if(ee(i)){const n=this.userStore.getGioId(e);i=p(i).slice(0,1e3),s=p(s).slice(0,1e3),this.userStore.setUserId(e,i);const{idMapping:r}=this.dataStore.getTrackerVds(e);r&&this.userStore.setUserKey(e,t(s)?"":s),n&&n!==i&&this.userStore.setSessionId(e)}else x("setUserId")},this.clearUserId=e=>{this.userStore.setUserId(e,void 0),this.userStore.setUserKey(e,void 0)},this.setGeneralProps=(e,t)=>r(t)&&!_(t)?(_(this.dataStore.generalProps[e])&&(this.dataStore.generalProps[e]={}),O(t,((t,i)=>{o(this.dataStore.generalProps[e][i])&&!o(t)||(this.dataStore.generalProps[e][i]=t)})),!0):(x("setGeneralProps"),!1),this.clearGeneralProps=(e,t)=>{try{_(this.dataStore.generalProps[e])||(a(t)&&!_(t)?t.forEach((t=>{P(this.dataStore.generalProps[e],t)})):this.dataStore.generalProps[e]={})}catch(e){return x("clearGeneralProps"),!1}},this.track=(e,t,i)=>{U(t,(()=>{var s;const{eventContextBuilder:n,eventInterceptor:o}=this.dataStore,a=Object.assign({eventType:"CUSTOM",eventName:t},n(e));a.attributes=Q(Object.assign(Object.assign({},null!==(s=a.attributes)&&void 0!==s?s:{}),K(Object.assign({},r(i)&&!_(i)?i:{})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(a["&&sendTo"]=i["&&sendTo"]),o(a)}))},this.trackTimerStart=(e,t)=>{const{dataCollect:i}=this.dataStore.getTrackerVds(e);return i?U(t,(()=>{const i=D();return this.dataStore.trackTimers[e]||(this.dataStore.trackTimers[e]={}),this.dataStore.trackTimers[e][i]={eventName:t,leng:0,start:+Date.now()},i})):(A("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return e.start&&(e.leng=e.leng+(+Date.now()-e.start)),e.start=0,!0}return!1},this.trackTimerResume=(e,t)=>{const i=this.dataStore.trackTimers[e];if(t&&i&&i[t]){const e=i[t];return 0===e.start&&(e.start=+Date.now()),!0}return!1},this.trackTimerEnd=(e,t,i)=>{var s;const{dataCollect:n}=this.dataStore.getTrackerVds(e),o=this.dataStore.trackTimers[e];if(t&&o&&o[t]){if(n){const n=864e5,a=o[t];if(0!==a.start){const e=+Date.now()-a.start;a.leng=e>0?a.leng+e:0}const{eventContextBuilder:l,eventInterceptor:g}=this.dataStore,u=Object.assign({eventType:"CUSTOM",eventName:a.eventName},l(e));return u.attributes=Q(Object.assign(Object.assign({},null!==(s=u.attributes)&&void 0!==s?s:{}),K(Object.assign(Object.assign({},r(i)&&!_(i)?i:{}),{event_duration:a.leng>n?0:a.leng/1e3})))),this.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(u["&&sendTo"]=i["&&sendTo"]),g(u),!0}return A("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return A("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=(e,t)=>{const i=this.dataStore.trackTimers[e];return t&&i&&i[t]?(delete i[t],!0):(A("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=e=>{this.dataStore.trackTimers[e]={}},this.setLocation=(e,t,i)=>{_(this.dataStore.locationData[e])&&(this.dataStore.locationData[e]={});const s=this.dataStore.locationData[e],n=e=>e>=-180&&180>=e;n(t)&&n(i)&&(s.latitude!==t||s.longitude!==i)&&(this.dataStore.locationData[e]={latitude:t,longitude:i})},this.updateImpression=()=>{A("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=(e,t,i)=>{A("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),q(i,{})},this.getGioInfo=e=>{const{getUid:t,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(e),d={gioappid:o,giocs1:i(e)||"",gioplatform:this.platformConfig.platform,gioprojectid:r,gios:n(e),giou:t()};return d.giodatacollect=l,d.giodatasourceid=a,g&&(d.giouserkey=s(e)),_(u)||u.forEach((t=>{var i;c.includes(t)||(d["gio"+t]=(null!==(i=this.dataStore.lastVisitEvent[e])&&void 0!==i?i:{})[t])})),Ne.stringify(d)},this.utils=Object.assign(Object.assign(Object.assign({},C),X),{qs:Ne}),this.emitter={all:e=e||new Map,on:function(t,i){var s=e.get(t);s?s.push(i):e.set(t,[i])},off:function(t,i){var s=e.get(t);s&&(i?s.splice(s.indexOf(i)>>>0,1):e.set(t,[]))},emit:function(t,i){var s=e.get(t);s&&s.slice().map((function(e){e(i)})),(s=e.get("*"))&&s.slice().map((function(e){e(t,i)}))}},this.gioPlatform="ks",this.gioFramework="native",this.sdkVersion="4.3.2";try{"quickapp"===this.gioPlatform||o(getApp)&&o(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&A("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=Ce,this.minipInstance=new xe(this),this.dataStore=new Te(this),this.userStore=new He(this),this.uploader=new Le(this),this.plugins=new qe(this),this.plugins.innerPluginInit()}},Re=function(){var e;const t=arguments[0];let s="g0",n=t;if(t.indexOf(".")>-1&&(s=null!==(e=t.split(".")[0])&&void 0!==e?e:"g0",n=t.split(".")[1]),i(n)&&se.includes(n)&&$e[n]){const e=c(Array.from(arguments));if("init"===n){const t=((e,t)=>{const i=p(t[0]),s=p(t[1]),n=(4===t.length?t[3]:t[2])||{};return i&&s?e.dataStore.initializedTrackingIds.some(((t,n)=>{const r=0===n?e.vdsConfig:e.subInstance[t];return r.projectId===i&&r.dataSourceId===s}))?(A("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:i,dataSourceId:s,appId:p(4===t.length?t[2]:""),userOptions:n}:(A('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)})($e,e);if(t){const{projectId:e,dataSourceId:i,appId:n,userOptions:r}=t;return $e.init(Object.assign(Object.assign({},r),{projectId:e,dataSourceId:i,appId:n,trackingId:s}))}return!1}if("registerPlugins"===n)$e.registerPlugins(e[0]);else{if($e.gioSDKInitialized&&$e.vdsConfig)return ie.includes(n)?j((()=>$e.handlerDistribute(s,n,e))):j((()=>$e[n](...e)));A("SDK未初始化!","error")}}else if(re.includes(n))A(`方法 ${p(n)} 已被弃用,请移除!`,"warn");else{if("canIUse"===n)return se.includes(arguments[1])&&!!$e[arguments[1]];A(`不存在名为 ${p(n)} 的方法调用!`,"error")}};M().gdp=Re,M().gioSDKVersion=$e.sdkVersion;const{growingApp:Be,growingPage:Ve,growingComponent:Fe,growingBehavior:Ge,initOriginalValue:Me}=$e.dataStore.eventHooks;Me();const Qe=j((()=>null!=Be?Be:App)),ze=j((()=>null!=Ve?Ve:Page)),We=j((()=>null!=Fe?Fe:Component)),Je=j((()=>null!=Ge?Ge:Behavior));export{Qe as GioApp,Je as GioBehavior,We as GioComponent,ze as GioPage,Re as default};
|
|
1
|
+
var e=function(t,n){return e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)({}).hasOwnProperty.call(t,n)&&(e[n]=t[n])},e(t,n)},t=function(){return t=Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++)for(var i in t=arguments[n])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},t.apply(this,arguments)};function n(e,t,n,r){return new(n||(n=Promise))((function(i,o){function a(e){try{s(r.next(e))}catch(e){o(e)}}function u(e){try{s(r.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,u)}s((r=r.apply(e,t||[])).next())}))}function r(e,t){var n,r,i,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]},a=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return a.next=u(0),a.throw=u(1),a.return=u(2),"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(u){return function(s){return function(u){if(n)throw new TypeError("Generator is already executing.");for(;a&&(a=0,u[0]&&(o=0)),o;)try{if(n=1,r&&(i=2&u[0]?r.return:u[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,u[1])).done)return i;switch(r=0,i&&(u=[2&u[0],i.value]),u[0]){case 0:case 1:i=u;break;case 4:return o.label++,{value:u[1],done:!1};case 5:o.label++,r=u[1],u=[0];continue;case 7:u=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==u[0]&&2!==u[0])){o=0;continue}if(3===u[0]&&(!i||u[1]>i[0]&&u[1]<i[3])){o.label=u[1];break}if(6===u[0]&&o.label<i[1]){o.label=i[1],i=u;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(u);break}i[2]&&o.ops.pop(),o.trys.pop();continue}u=t.call(e,o)}catch(e){u=[6,e],r=0}finally{n=i=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}([u,s])}}}function i(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;o>i;i++)!r&&i in t||(r||(r=[].slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||[].slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var o=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,a=function(e){return["undefined","null"].includes(q(e))},u=function(e){return"string"===q(e)},s=function(e){return"number"===q(e)},c=function(e){return"boolean"===q(e)},l=function(e){return"[object Object]"==={}.toString.call(e)&&!a(e)},g=function(e){return["function","asyncfunction"].includes(q(e))},d=function(e){return Array.isArray(e)&&"array"===q(e)},p=function(e){return"date"===q(e)},f=function(e){try{return Array.from(e)[0]}catch(e){return}},v=function(e){try{var t=Array.from(e);return t[t.length-1]}catch(e){return}},h=function(e,t){return void 0===t&&(t=1),d(e)&&s(t)?e.slice(t>0?t:1,e.length):e},m=function(e,t){if(void 0===t&&(t=!1),d(e)){for(var n=0,r=[],i=0,o=e;i<o.length;i++){var a=o[i];a&&!x(a)&&(r[n++]=a),t&&0===a&&(r[n++]=a)}return r}return e},I=function(e,t){if(d(e)){var n=e.findIndex(t);return 0>n?void 0:e[n]}},y=function(e){return a(e)?"":"".concat(e)},S=function(e,t){return"string"===q(e)?e.split(t):e},w=function(e){if(u(e)){var t=S(e,"");return"".concat(f(t).toLowerCase()).concat(h(t).join(""))}return e},_=function(e,t){return u(e)||(e=y(e)),e.slice(0,t.length)===t},O={}.hasOwnProperty,P=function(e,t){return!a(e)&&O.call(e,t)},b=function(e){return l(e)?Object.keys(e):[]},k=function(e,t){b(e).forEach((function(n){return t(e[n],n)}))},T=function(e,t){var n=b(e);return!(!l(e)||!l(t)||n.length!==b(t).length||n.map((function(n,r){return l(e[n])?T(e[n],t[n]):e[n]===t[n]})).includes(!1))},E=function(e,t,n){var r=e;return l(e)?(t.split(".").forEach((function(e){r=r?r[e]:n})),r):n},C=function(e,t){if(!l(e))return!1;try{if("string"===q(t))return delete e[t];if("array"===q(t))return t.map((function(t){return delete e[t]}));"object"===q(t)&&t.constructor===RegExp&&b(e).forEach((function(n){t.test(n)&&C(e,n)}))}catch(e){return!1}},A=function(e,t,n,r){var i;void 0===t&&(t=250);var o=0;return"boolean"!==q(n)&&(r=e,e=n,n=void 0),function(){for(var a=[],u=0;arguments.length>u;u++)a[u]=arguments[u];var s=this,c=Date.now()-o;function l(){o=Date.now(),e.apply(s,a)}r&&!i&&l(),i&&clearTimeout(i),void 0===r&&c>t?l():!0!==n&&(i=setTimeout(r?function(){i=void 0}:l,void 0===r?t-c:t))}},x=function(e){return d(e)?0===e.length:l(e)?0===b(e).length:!e},q=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},N=function(e){function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())},U=Object.freeze({__proto__:null,isNil:a,isString:u,isNaN:function(e){return"NaN"===y(Number(e))},isNumber:s,isBoolean:c,isObject:l,isRegExp:function(e){return"[object RegExp]"==={}.toString.call(e)},isFunction:g,isArray:d,isDate:p,fixed:function(e,t){return s(e)?Number(e.toFixed(s(t)?t:2)):u(e)&&"NaN"!==y(Number(e))?Number(Number(e).toFixed(s(t)?t:2)):e},head:f,last:v,drop:h,dropWhile:function(e,t){return d(e)?e.filter((function(e){return!t(e)})):e},compact:m,find:I,isEqualArray:function(e,t){return!(!d(e)||!d(t)||e.length!==t.length)&&e.every((function(e,n){return e===t[n]}))},toString:y,split:S,lowerFirst:w,upperFirst:function(e){if(u(e)){var t=S(e,"");return"".concat(f(t).toUpperCase()).concat(h(t).join(""))}return e},startsWith:_,endsWith:function(e,t){var n=e.length,r=n;r>n&&(r=n);var i=r;return(r-=t.length)>=0&&e.slice(r,i)===t},hasOwnProperty:O,has:P,keys:b,forEach:k,isEqual:T,get:E,unset:C,throttle:A,isEmpty:x,typeOf:q,formatDate:N}),D=function(e,t){console.log("%c[GrowingIO]:".concat(e),{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},K=function(e,t,n){return void 0===t&&(t=!0),void 0===n&&(n="参数不合法"),D("".concat(t?"调用":"设置"," ").concat(e," 失败,").concat(n,"!"),"warn")},L=function(e){try{return e()}catch(e){return}},R=function(e,t){if(g(e))try{e(t)}catch(e){D("回调执行失败!".concat(e),"error")}},H=function(e){return u(e)?e.trim().substring(0,100):e},B=function(e,t){return u(e)&&!x(e)&&e.match(o)?t():(D("事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","error"),!1)},j=function(e){return a(e)||b(e).forEach((function(t){g(e[t])?e[t]=L((function(){return e[t]()})):l(e[t])?C(e,t):d(e[t])||(e[t]=y(e[t]))})),e},V=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},F=function(e){return e.pixelRatio?Math.round(e.screenHeight*e.pixelRatio):e.screenHeight},M=function(e){return e.pixelRatio?Math.round(e.screenWidth*e.pixelRatio):e.screenWidth},G=function(e,t){if(e){var n=e.toLowerCase();return-1!==n.indexOf("android")?"".concat(t,"-Android"):-1!==n.indexOf("ios")?"".concat(t,"-iOS"):-1!==n.indexOf("harmonyos")||-1!==n.indexOf("ohos")?"".concat(t,"-HarmonyOS"):"".concat(t,"-").concat(e)}},Q=function(e){if(u(e)){var t=e.indexOf("?");return-1!==t?[e.substring(0,t),e.substring(t+1)]:[e,""]}return["",""]},$=function(e){return u(e)?e.startsWith("/")?e:"/".concat(e):""},z=function(e){return L((function(){switch(e){case"wx":return wx;case"my":case"tb":return my;case"swan":return swan;case"tt":return tt;case"qq":return qq;case"ks":return ks;case"jd":return jd;case"xhs":return xhs;default:var t=void 0;return t||(t=L((function(){return xhs}))),t||(t=L((function(){return swan}))),t||(t=L((function(){return my}))),t||(t=L((function(){return tt}))),t||(t=L((function(){return qq}))),t||(t=L((function(){return ks}))),t||(t=L((function(){return jd}))),t||(t=L((function(){return wx}))),t}}))},W=function(e){return L((function(){switch(e){case"wx":return __wxConfig;case"swan":return appConfig;case"tt":return L((function(){return __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;case"xhs":return null!==__MP_APP_JSON_MIGRATION__&&void 0!==__MP_APP_JSON_MIGRATION__?__MP_APP_JSON_MIGRATION__:__MP_APP_JSON__;default:return}}))},J=function(e){return L((function(){switch(e){case"wx":case"qq":return __wxAppCode__;case"tt":return __allConfig__;case"ks":return __module__;case"jd":return __jdAppCode__;default:return}}))},Y=function(){var e;return!e&&L((function(){return xhs}))&&(e="xhs"),!e&&L((function(){return swan}))&&(e="swan"),!e&&L((function(){return tt}))&&(e="tt"),!e&&L((function(){return qq}))&&(e="qq"),!e&&L((function(){return my.tb}))&&(e="tb"),!e&&L((function(){return my}))&&(e="my"),!e&&L((function(){return ks}))&&(e="ks"),!e&&L((function(){return jd}))&&(e="jd"),!e&&L((function(){return wx}))&&(e="wx"),e||I(b(global),(function(e){return y(e).toLowerCase().includes("quickapp")}))&&(e="quickapp"),e},Z=function(){var e;return null!==(e=L((function(){var e;return null!==(e=L((function(){var e;return null!==(e=L((function(){return $global})))&&void 0!==e?e:global})))&&void 0!==e?e:window})))&&void 0!==e?e:globalThis},X=function(e){var t={};return l(e)&&(C(e,"&&sendTo"),k(e,(function(e,n){var r=y(n).slice(0,100);l(e)?t[r]=X(e):d(e)?(t[r]=m(e.slice(0,100),!0),t[r]=t[r].join("||").slice(0,1e3)):p(e)?t[r]=N(e):t[r]=a(e)?"":y(e).slice(0,1e3)}))),t},ee=function(e,t){var n=function(){return t.map((function(t){return e.getStorageSync(t)}))};try{return e.minip.canIUse("batchGetStorageSync")?e.minip.batchGetStorageSync(t):n()}catch(e){return n()}},te=function(e,t){var n=function(){return t.map((function(t){var n=t.key,r=t.value;return e.setStorageSync(n,r)}))};try{return e.minip.canIUse("batchSetStorageSync")?e.minip.batchSetStorageSync(t):n()}catch(e){return n()}},ne=function(e){return b(e||{}).map((function(t){return t?"".concat(t,"=").concat(a(e[t])?"":e[t]):""})).join("&")},re=function(e){(_(e,"?")||_(e,"&"))&&(e=e.slice(1,e.length));var t={};return e.split("&").forEach((function(e){var n=e.split("=");n[0]&&(t[n[0]]=n[1])})),t},ie=function(e){var t;return u(e)?null!==(t=L((function(){return JSON.parse(e)})))&&void 0!==t?t:{}:null!=e?e:{}},oe=function(e,t){void 0===e&&(e={}),void 0===t&&(t={});var n={},r=ie(t);return b(r).forEach((function(e){"gdpCircleRoomCollectUrl"!==e&&["string","number","boolean"].includes(q(r[e]))&&(n[e]=r[e])})),Object.assign({},n,e)},ae=Object.freeze({__proto__:null,consoleText:D,callError:K,niceTry:L,niceCallback:R,limitString:H,eventNameValidate:B,getDynamicAttributes:j,guid:V,getScreenHeight:F,getScreenWidth:M,getOS:G,compareVersion:function(e,t){void 0===e&&(e=""),void 0===t&&(t="");for(var n=function(e){return e.replace(/\s+/g,"")},r=function(e){return e.replace(/[vV]/g,"")},i=n(r(e)),o=n(r(t)),a=i.split("."),u=o.split("."),s=0;3>s;s++){var c=Number(a[s]),l=Number(u[s]);if(c>l)return 1;if(l>c)return-1;if(!isNaN(c)&&isNaN(l))return 1;if(isNaN(c)&&!isNaN(l))return-1}return 0},getVueVersion:function(e){if(e){var t=Number(f(S(e.version,".")));return Number.isNaN(t)?0:t}return 0},splitPath:Q,normalPath:$,isTaro3:function(e){var t=e.Current,n=e.createComponent;return!(!e||!t||n)},getPlainMinip:z,getPlainConfig:W,getPlainAppCode:J,getPlainPlatform:Y,getSubKeys:function(e){return b(e).filter((function(e){return e.indexOf("__sub")>-1&&e.indexOf("gio__")>-1})).sort()},getAppInst:function(){var e=L((function(){return getApp({allowDefault:!0})}));return e||(e=Z()),e},getGlobal:Z,limitObject:X,batchGetStorageSync:ee,batchSetStorageSync:te,qsStringify:ne,qsParse:re,hashCode:function(e,t){void 0===t&&(t=!1);var n=0;if(x(e)||"boolean"==typeof e)return n;for(var r=0;r<e.length;)n=(n<<5)-n+e.charCodeAt(r),n|=0,r++;return t?Math.abs(n):n},getExtraData:ie,getLaunchQuery:oe}),ue=function(e){return(u(e)&&e.length>0||s(e)&&e>0)&&!["-","null","undefined"].includes(e)},se={autotrack:{type:"boolean",default:!0},compress:{type:"boolean",default:!0},dataCollect:{type:"boolean",default:!0},debug:{type:"boolean",default:!1},idMapping:{type:"boolean",default:!1},enableIdMapping:{type:"boolean",default:!1},extraParams:{type:"array",default:[]},followShare:{type:"boolean",default:!0},forceLogin:{type:"boolean",default:!1},ignoreFields:{type:"array",default:[]},impressionScale:{type:"number",default:0},pluginMode:{type:"boolean",default:!1},originalSource:{type:"boolean",default:!0},keepAlive:{type:"number",default:5},performance:{type:"object",default:{monitor:!0,exception:!0}},serverUrl:{type:"string",default:"https://napi.growingio.com"},sessionExpires:{type:"number",default:-1},requestTimeout:{type:"number",default:5e3},taro:{type:["object","module"],default:!1},taroVue:{type:["object","function"],default:!1},tbConfig:{type:"object",default:{cloud:void 0,cloudFuncSend:!1,cloudFuncName:"httpTunnel",cloudFuncHandler:"main",cloudAppId:void 0,path:void 0}},trackPage:{type:"boolean",default:!0},uniVue:{type:["object","function"],default:!1},uploadInterval:{type:"number",default:1e3},version:{type:"string",default:"1.0.0"}},ce=["clearGeneralProps","clearPageAttributes","clearTrackTimer","clearUserId","getABTest","getGioInfo","getOption","identify","removeTimer","sendPage","sendVisit","setGeneralProps","setLocation","setOption","setPageAttributes","setUserAttributes","setUserId","track","trackTimerEnd","trackTimerPause","trackTimerResume","trackTimerStart"],le=i(i(["init","registerPlugins"],["getPlugins","getDeviceId","updateImpression"],!0),ce,!0),ge={autotrack:"无埋点",dataCollect:"数据采集",debug:"调试模式",serverUrl:"数据上报服务地址"},de=["enableDebug","setAutotrack","setDataCollect","setTrackerHost","setTrackerScheme","setConfig","collectImp","setPlatformProfile","getLocation"],pe=["deviceBrand","deviceModel","deviceType","networkState","screenHeight","screenWidth","operatingSystem"],fe=i(i([],pe,!0),["appChannel","language","platformVersion"],!1),ve={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_"},he="MINIP_LIFECYCLE",me="ON_COMMIT_REQUEST",Ie="ON_COMPOSE_AFTER",ye="ON_COMPOSE_BEFORE",Se="ON_ERROR",we="ON_INSTALL",_e="ON_SEND_AFTER",Oe="ON_SEND_BEFORE",Pe="OPTION_CHANGE",be="OPTION_INITIALIZED",ke="SDK_INITIALIZED",Te="SESSIONID_UPDATE",Ee=function(e){var n=this;this.growingIO=e,this.main=function(e,r,i){void 0===i&&(i=!0),e||(e=n.growingIO.trackingId);var o=n.growingIO,a=o.sdkVersion,u=o.platformConfig,s=o.minipInstance,c=o.userStore,l=o.dataStore,g=o.dataStore,d=g.scene,p=g.eventHooks.currentPage,f=g.generalProps,v=l.getTrackerVds(e),h=v.version,m=v.dataSourceId,I=v.appId,y=v.idMapping,S=v.ignoreFields,w=l.locationData[e],_=s.systemInfo,O=void 0===_?{}:_,P=s.network,b=void 0===P?{}:P,k=O.brand,T=O.model,E=O.platform,A=O.language,q=p.getPagePath(),N={appChannel:"scn:".concat(d||"NA"),appVersion:h,dataSourceId:m,deviceBrand:k,deviceId:c.getUid(),deviceModel:T,deviceType:G(E,u.name),domain:I,language:A,latitude:null==w?void 0:w.latitude,longitude:null==w?void 0:w.longitude,networkState:(null==b?void 0:b.networkType)||(null==b?void 0:b.type)||(null==b?void 0:b.subtype),operatingSystem:G(E,u.name),path:q,platform:u.platform,platformVersion:u.name+(O.version?" ".concat(O.version):""),query:q?p.getPageQuery():"",screenHeight:F(O),screenWidth:M(O),sdkVersion:a,sessionId:c.getSessionId(e),title:p.getPageTitle(),timestamp:Date.now(),timezoneOffset:(new Date).getTimezoneOffset(),userId:c.getUserId(e)};return y&&(N.userKey=c.getUserKey(e)),i&&!x(f[e])&&(N.attributes=t({},f[e])),x(N.attributes)||(N.attributes=X(j(t({},N.attributes)))),x(S)||S.forEach((function(e){C(N,e)})),x(r)?t(t({},N),{trackingId:e}):t(t(t({},N),r),{trackingId:e})}},Ce=function(e){var n=this;this.growingIO=e,this.enterParams={},this.main=function(e,r){var i,o,a=Date.now(),u=n.growingIO,s=u.emitter,c=u.userStore,l=u.vdsConfig,g=u.platformConfig,d=u.uploader,p=u.dataStore,f=u.minipInstance,v=u.dataStore,h=v.trackersExecute,m=v.shareOut,I=v.lastCloseTime,y=v.saveStorageInfo,S=v.setOriginalSource;s.emit(he,{event:"App ".concat(e),timestamp:a,params:null!==(i=r[0])&&void 0!==i?i:{}}),l.debug&&console.log("App:",e,a);var w=g.listeners.app;switch(s.emit(ye,{event:"App ".concat(e),params:null!==(o=r[0])&&void 0!==o?o:{}}),e){case w.appLaunch:n.enterParams=t({},r[0]);break;case w.appCreate:case w.appShow:var _=n.enterParamsParse(r[0]),O=_.path,P=_.query,b=_.referralPage;!m&&l.originalSource&&O&&h((function(e){S(e,{path:O,query:P,referralPage:b})})),I?(Date.now()-I>60*l.keepAlive*1e3||p.lastScene&&p.scene!==p.lastScene)&&h((function(e){c.setSessionId(e)})):h((function(e){p.lastVisitEvent[e]={path:O,query:P,referralPage:b},n.buildVisitEvent(e,{path:O,query:P,referralPage:b})})),f.setNetworkStatusListener();break;case w.appClose:p.lastScene=p.scene,p.lastCloseTime=Date.now(),y(),c.saveUserInfo(),h((function(e){n.buildCloseEvent(e),l.forceLogin||d.initiateRequest(e,!0)}))}},this.enterParamsParse=function(e){var t;void 0===e&&(e={});var r=n.growingIO,i=r.gioPlatform,o=r.minipInstance,a=r.dataStore,u="",s="",c="";if("quickapp"!==i&&o.minip.canIUse("getEnterOptionsSync")){var l=o.minip.getEnterOptionsSync()||{},g=l.path,d=l.query,p=l.scene,f=l.referrerInfo;u=g||e.path,s=d||e.query,c=(null==f?void 0:f.appId)||(null===(t=null==e?void 0:e.referrerInfo)||void 0===t?void 0:t.appId)||"",a.scene=p||e.scene,s=x(null==f?void 0:f.extraData)?ne(s):ne(oe(s,f.extraData))}else g=e.path,d=e.query,f=e.referrerInfo,u=g,s=ne(d),c=(null==f?void 0:f.appId)||"",n.parseScene(e);return{path:u,query:s,referralPage:c}},this.parseScene=function(e){var t,r,i=n.growingIO,o=i.minipInstance,a=i.gioPlatform,u=i.dataStore;if("quickapp"===a){var s=o.getAppSource(),c=s.extra,l=s.type;r=(null==c?void 0:c.scene)||l}else x(e)||((null===(t=null==e?void 0:e.query)||void 0===t?void 0:t.wxShoppingListScene)?r=e.query.wxShoppingListScene:(null==e?void 0:e.scene)?r=e.scene:u.scene="NA");u.scene=r},this.buildVisitEvent=function(e,r){var i=n.growingIO,o=i.dataStore,a=o.getOriginalSource,u=o.eventContextBuilder,s=o.eventInterceptor,c=i.vdsConfig,l=a(e),g=(null==r?void 0:r.query)||"",d=t({eventType:"VISIT"},u(e,{}));!x(r)&&r.path&&(d.path=r.path||"",d.query="string"===q(g)?g:ne(g),r.referralPage&&(d.referralPage=r.referralPage)),c.originalSource&&!x(l)&&(d=t(t({},d),l)),s(d)},this.buildCloseEvent=function(e){var r=n.growingIO.dataStore,i=r.eventContextBuilder;(0,r.eventInterceptor)(t({eventType:"APP_CLOSED"},i(e)))}},Ae=function(){function e(e){var n=this;this.growingIO=e,this.lifeBeforeShow=!0,this.getPagePath=function(){var e,t,r,i=n.growingIO,o=i.minipInstance,a=i.inPlugin,u=i.dataStore,s=i.trackingId,c=o.getCurrentPath();if(a){var l=u.getTrackerVds(s);return c||"/插件".concat(l.appId)}return c||(null===(e=u.eventHooks.appEffects.enterParams)||void 0===e?void 0:e.path)||(null===(t=u.lastPageEvent[s])||void 0===t?void 0:t.path)||(null===(r=u.lastVisitEvent[s])||void 0===r?void 0:r.path)},this.getPageQuery=function(){var e,t,r,i,o,a,u=n.growingIO,s=u.minipInstance,c=u.dataStore,l=u.trackingId,g=s.getCurrentPage(),d=s.getCurrentPath(),p=c.eventHooks.appEffects.enterParams,f=void 0===p?{}:p;if(!d)return f.path?n.qsQuery(oe(null==f?void 0:f.query,null===(r=null==f?void 0:f.referrerInfo)||void 0===r?void 0:r.extraData)):(null===(i=c.lastPageEvent[l])||void 0===i?void 0:i.path)?null===(o=c.lastPageEvent[l])||void 0===o?void 0:o.query:null===(a=c.lastVisitEvent[l])||void 0===a?void 0:a.query;var v=null!==(e=g.options)&&void 0!==e?e:g.$taroParams;return x(v)?x(n.queryOption[d])?d===f.path?n.qsQuery(oe(null==f?void 0:f.query,null===(t=null==f?void 0:f.referrerInfo)||void 0===t?void 0:t.extraData)):void 0:n.qsQuery(n.queryOption[d]):(C(v,"$taroTimestamp"),n.qsQuery(v))},this.getPageTitle=function(e){var t=n.growingIO,r=t.minipInstance,i=t.inPlugin,o=t.dataStore,a=r.getCurrentPath(),u=n.configuredTitle[a]||r.getPageTitle(r.getCurrentPage());if(i){var s=o.getTrackerVds(e||n.growingIO.trackingId);return u||"/插件".concat(s.appId).concat(a?"_"+v(a.split("/")):"")}return u},this.qsQuery=function(e){void 0===e&&(e={});var n=t({},e);return C(n,"wxShoppingListScene"),ne(n)},this.getReferralPage=function(e){var t,r,i,o=n.growingIO,a=o.minipInstance,u=o.dataStore,s=u.lastPageEvent,c=u.scene,l=u.eventHooks;return(null===(t=s[e])||void 0===t?void 0:t.path)||(null===(i=null===(r=l.appEffects.enterParams)||void 0===r?void 0:r.referrerInfo)||void 0===i?void 0:i.appId)||(c?"scn:".concat(a.scnPrefix).concat(c):null)},this.updateShareResult=function(e){var t=n.buildShareQuery(e),r=t[0],i=t[1];return e.path=$(r+(i?"?".concat(i):"")),e.query=i,e},this.updateAppMessageResult=this.updateShareResult,this.updateTimelineResult=this.updateShareResult,this.updateAddFavoritesResult=function(e){var t=n.buildShareQuery(e),r=t[0],i=t[1];return e.path=$(r+(i?"?".concat(i):"")),e.query=i,e},this.eventSetPageProps=function(e,r){var i=L((function(){return n.pageProps[e][n.getPagePath()]}));return x(i)?r.attributes:X(j(t(t({},r.attributes),i)))},this.queryOption={},this.configuredTitle={},this.pageProps={}}return e.prototype.buildShareQuery=function(e){var t,n,r=Q(null!==(t=e.path)&&void 0!==t?t:""),i=this.getPagePath(),o={},a=P(e,"path");if(a&&(i=f(r),o=re(v(r))||{}),x(o)&&(o=re(null!==(n=e.query)&&void 0!==n?n:"")||{},m(b(o)).forEach((function(e){e.toLowerCase().startsWith("utm_")&&C(o,e)}))),!a&&x(o)){var u=this.growingIO.minipInstance.getCurrentPage();o=u.options||this.queryOption[u.route]||{}}return[i,ne(o)]},e}(),xe=function(e){var n=this;this.growingIO=e,this.main=function(e,r,i){var o,a,u=Date.now(),s=n.growingIO,c=s.emitter,l=s.minipInstance,d=s.plugins,p=s.vdsConfig,f=s.platformConfig,v=s.dataStore,h=v.getTrackerVds,m=v.getOriginalSource,I=v.setOriginalSource,y=v.trackersExecute,S=v.eventHooks,w=v.toggleShareOut,_=v.buildAppMessageEvent,O=v.buildTimelineEvent,P=v.buildAddFavorites,b=S.currentPage;if(!n.prevEvent[r]||Date.now()-Number(n.prevEvent[r])>=50){e||(e=l.getCurrentPage()),e.route||(e.route=l.getCurrentPath(e));var k=e.route||e.uri||e.__route__||(null===(o=null==e?void 0:e.$page)||void 0===o?void 0:o.fullPath)||"";c.emit(he,{event:"Page ".concat(r),timestamp:u,params:{page:e,args:i[0]}}),p.debug&&console.log("Page:",k,"#",r,u),n.prevEvent[r]=Date.now();var T=f.listeners.page;switch(c.emit(ye,{page:e,event:"Page ".concat(r),params:{page:e,args:i[0]}}),b.lastLifecycle=b.currentLifecycle,b.currentLifecycle=r,r){case T.pageLoad:b.queryOption[k]=E(e,"options")||E(e,"__displayReporter.query")||E(e,"$page.query")||E(e,"$wx.__displayReporter.query")||E(e,"$taroParams")||i[0]||{},C(b.queryOption[k],"$taroTimestamp");break;case T.pageShow:y((function(e){var r=m(e);x(r)||r.path!==k||I(e,t(t({},r),{title:b.getPageTitle()})),h(e).trackPage&&n.buildPageEvent(e)})),w(!1);break;case T.pageHide:case T.pageUnload:break;case T.shareChat:case T.shareApp:w(!0),y((function(e){h(e).followShare&&_(e,i)}));break;case T.shareTime:y((function(e){h(e).followShare&&O(e,i)}));break;case T.addFavorites:y((function(e){h(e).followShare&&P(e,i)}));break;case T.tabTap:var A=null===(a=null==d?void 0:d.gioEventAutoTracking)||void 0===a?void 0:a.buildTabClickEvent;p.autotrack&&A&&g(A)&&A(n.growingIO.trackingId,i[0])}b.lastLifecycle=b.currentLifecycle,b.currentLifecycle="".concat(r,"End"),["onHideEnd","onUnloadEnd"].includes(b.currentLifecycle)&&(b.lifeBeforeShow=!0),"onShowEnd"===b.currentLifecycle&&(b.lifeBeforeShow=!1)}},this.buildPageEvent=function(e,r){var i=n.growingIO.dataStore,o=i.eventContextBuilder,a=i.eventInterceptor,u=i.eventHooks.currentPage,s=t({eventType:"PAGE",referralPage:u.getReferralPage(e)},o(e));s.attributes=u.eventSetPageProps(e,s),!x(r)&&r.title&&(s.title=r.title),a(s)},this.prevEvent={}},qe=function(e){var i,o=this;this.growingIO=e,this.isNormalFc=function(e,t){return g(t)&&"constructor"!==e},this.objectTraverse=function(e,t){Object.getOwnPropertyNames(e).forEach((function(n){return t(n,e)})),P(e,"methods")&&Object.getOwnPropertyNames(e.methods).forEach((function(n){e[n]||t(n,e.methods)})),P(e,"lifetimes")&&Object.getOwnPropertyNames(e.lifetimes).forEach((function(n){e[n]||t(n,e.lifetimes)})),P(e,"pageLifetimes")&&Object.getOwnPropertyNames(e.pageLifetimes).forEach((function(n){e[n]||t(n,e.pageLifetimes)}))},this.supLifeFcs=function(e,t){d(o["".concat(t,"Handlers")])&&o["".concat(t,"Handlers")].forEach((function(t){g(e[t])||["onShareAppMessage","onShareTimeline"].includes(t)||(e[t]=function(){})}))},this.lifeFcEffects=function(e,i,a){var u=o;return["onShareTimeline","onAddToFavorites"].includes(e)?function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];var r=i.apply(this,t);"onShareTimeline"===e&&u.growingIO.vdsConfig.followShare&&(r=u.currentPage.updateTimelineResult(null!=r?r:{})),"onAddToFavorites"===e&&(r=u.currentPage.updateAddFavoritesResult(null!=r?r:{}));var o=[].slice.call(t);return r&&o.push(r),u["def".concat(a,"Cbs")][e].apply(this,o),r}:function(){for(var o,s=[],c=0;arguments.length>c;c++)s[c]=arguments[c];return n(this,void 0,void 0,(function(){var c,l,g,d,p;return r(this,(function(f){switch(f.label){case 0:return f.trys.push([0,6,,7]),u.shareEventTypes.includes(e)?(c=null!==(o=i.apply(this,s))&&void 0!==o?o:{},"promise"!==q(c)?[3,2]:[4,c.then((function(e){return e}))]):[3,5];case 1:c=f.sent(),f.label=2;case 2:return"promise"!==q(c.promise)?[3,4]:(l=function(){return n(this,void 0,void 0,(function(){var e;return r(this,(function(n){return e=c,[2,new Promise((function(n){var r=setTimeout((function(){n(t({},e)),clearTimeout(r),r=void 0}),3e3);c.promise.then((function(i){n(t({},e=i)),clearTimeout(r),r=void 0}))}))]}))}))},g=[t({},c)],[4,l()]);case 3:c=t.apply(void 0,g.concat([f.sent()])),C(c,"promise"),f.label=4;case 4:u.growingIO.vdsConfig.followShare&&(c=u.currentPage.updateAppMessageResult(null!=c?c:{})),f.label=5;case 5:return d=[].slice.call(s),c&&d.push(c),u["def".concat(a,"Cbs")][e].apply(this,d),[3,7];case 6:return p=f.sent(),D(p,"error"),[3,7];case 7:return u.shareEventTypes.includes(e)||(c=i.apply(this,s)),u.growingIO.emitter.emit(he,{event:"".concat(a," ").concat(e,"End"),timestamp:Date.now(),params:{instance:this,arguments:Array.from(s)}}),[2,c]}}))}))}},this.customFcEffects=function(e,t){var n=o;return function(){for(var r,i,o=[],a=0;arguments.length>a;a++)o[a]=arguments[a];if(n.growingIO.vdsConfig.autotrack&&n.growingIO.plugins.gioEventAutoTracking)try{var u=o[0]||{};P(u,"type")&&((null==u?void 0:u.currentTarget)||(null==u?void 0:u.target))||(u=o[o.length-1]),((null==u?void 0:u.currentTarget)||(null==u?void 0:u.target))&&n.actionEventTypes.includes(u.type)&&(g(n.actionEffects)||(n.actionEffects=(null===(i=null===(r=n.growingIO.plugins)||void 0===r?void 0:r.gioEventAutoTracking)||void 0===i?void 0:i.main)||function(){}),null==n||n.actionEffects(u,e))}catch(e){D(e,"error")}return t.apply(this,o)}},this.appApplyProxy=function(e,t){return o.appHandlers.includes(e)?o.lifeFcEffects(e,t,"App"):o.customFcEffects(e,t)},this.pageApplyProxy=function(e,t){return o.pageHandlers.includes(e)?o.lifeFcEffects(e,t,"Page"):o.customFcEffects(e,t)},this.appOverriding=function(e){return o.setAppEffectCbs(),o.supLifeFcs(e,"app"),o.objectTraverse(e,(function(e,t){o.isNormalFc(e,t[e])&&(t[e]=o.appApplyProxy(e,t[e]))})),e},this.pageOverriding=function(e){return o.setPageEffectCbs(),o.supLifeFcs(e,"page"),o.objectTraverse(e,(function(e,t){o.isNormalFc(e,t[e])&&(t[e]=o.pageApplyProxy(e,t[e]))})),e},this.componentOverriding=function(e){return o.setPageEffectCbs(),e.methods||(e.methods={}),o.supLifeFcs(o.growingIO.inPlugin?e:e.methods,"page"),o.objectTraverse(o.growingIO.inPlugin?e:e.methods,(function(e,t){o.isNormalFc(e,t[e])&&(t[e]=o.pageApplyProxy(e,t[e]))})),e},this.setAppEffectCbs=function(){var e=o;o.appHandlers.forEach((function(t){o.defAppCbs[t]=function(){for(var n=[],r=0;arguments.length>r;r++)n[r]=arguments[r];e.appEffects.main(t,n)}}))},this.setPageEffectCbs=function(){var e=o;o.pageHandlers.forEach((function(t){o.defPageCbs[t]=function(){for(var n=[],r=0;arguments.length>r;r++)n[r]=arguments[r];e.pageEffects.main(this,t,n)}}))},this.growingApp=function(e){return g(o.originalApp)?o.originalApp(o.appOverriding(e)):o.appOverriding(e)},this.growingPage=function(e){return g(o.originalPage)?o.originalPage(o.pageOverriding(e)):o.pageOverriding(e)},this.growingComponent=function(e){return g(o.originalComponent)?o.originalComponent(o.componentOverriding(e)):o.componentOverriding(e)},this.growingBehavior=function(e){return g(o.originalBehavior)?o.originalBehavior(o.componentOverriding(e)):o.componentOverriding(e)},this.nativeGrowing=function(e){void 0===e&&(e=["App","Page","Component","Behavior"]);var t=o,n=o.growingIO.platformConfig.hooks;if(e.includes("App"))try{n.App&&!o.appHooked&&(App=function(){for(var e=[],n=0;arguments.length>n;n++)e[n]=arguments[n];return t.originalApp(t.appOverriding(e[0]))},o.appHooked=!0)}catch(e){}if(e.includes("Page"))try{n.Page&&!o.pageHooked&&(Page=function(){for(var e=[],n=0;arguments.length>n;n++)e[n]=arguments[n];return t.originalPage(t.pageOverriding(e[0]))},o.pageHooked=!0)}catch(e){}if(e.includes("Component"))try{n.Component&&!o.componentHooked&&(Component=function(){for(var e=[],n=0;arguments.length>n;n++)e[n]=arguments[n];return t.originalComponent(t.componentOverriding(e[0]))},o.componentHooked=!0)}catch(e){}if(e.includes("Behavior"))try{n.Behavior&&!o.behaviorHooked&&(Behavior=function(){for(var e=[],n=0;arguments.length>n;n++)e[n]=arguments[n];return t.originalBehavior(t.componentOverriding(e[0]))},o.behaviorHooked=!0)}catch(e){}},this.initOriginalValue=function(){o.setAppEffectCbs(),o.setPageEffectCbs(),o.originalApp=L((function(){return App||global.App})),o.originalPage=L((function(){return Page||global.Page})),o.originalComponent=L((function(){return Component||global.Component})),o.originalBehavior=L((function(){return Behavior||global.Behavior}))},this.initEventHooks=function(){var e=o,t=o.growingIO,n=t.platformConfig,r=t.gioPlatform;o.initOriginalValue(),n.canHook?(o.nativeGrowing(),Z().GioApp=L((function(){return null!==App&&void 0!==App?App:o.originalApp})),Z().GioPage=L((function(){return null!==Page&&void 0!==Page?Page:o.originalPage})),Z().GioComponent=L((function(){return null!==Component&&void 0!==Component?Component:o.originalComponent})),Z().GioBehavior=L((function(){return null!==Behavior&&void 0!==Behavior?Behavior:o.originalBehavior}))):"quickapp"===r&&(Z().GioApp=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];return e.appOverriding(t[0])},Z().GioPage=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];return e.pageOverriding(t[0])},Z().GioComponent=function(){for(var t=[],n=0;arguments.length>n;n++)t[n]=arguments[n];return e.pageOverriding(t[0])})};var a=null===(i=this.growingIO)||void 0===i?void 0:i.platformConfig;this.defAppCbs={},this.defPageCbs={},this.appHandlers=a.appHandlers,this.pageHandlers=a.pageHandlers,this.shareEventTypes=a.shareEventTypes,this.actionEventTypes=a.actionEventTypes,this.appEffects=new Ce(this.growingIO),this.pageEffects=new xe(this.growingIO),this.currentPage=new Ae(this.growingIO)},Ne=function(){function e(e){var n,r,o=this;this.growingIO=e,this.ALLOW_SETTING_KEYS=b(se),this.getStorageKey=function(e,t){var n=o.growingIO.inPlugin;return"".concat(e===o.growingIO.trackingId?"":e).concat(ve[n?"plugin_"+t:t])},this.getGsid=function(e){var t=Number(o._gsid[e]);return Number.isNaN(t)||t>=1e9||1>t?(o.setGsid(e,1),1):t},this.setGsid=function(e,t){var n=Number(t);(Number.isNaN(n)||n>=1e9||1>n)&&(n=1),o._gsid[e]=n,10>o._gsid[e]-o._stid[e]||o.saveStorageInfo()},this.initStorageInfo=function(e){var t=o.growingIO.minipInstance,n=t.getStorageSync(o.getStorageKey(e,"gsid")),r=Number(n);(Number.isNaN(r)||r>=1e9||1>r)&&(r=1),o._gsid[e]=r,o._stid[e]=r,r!==n&&t.setStorageSync(o.getStorageKey(e,"gsid"),r)},this.saveStorageInfo=function(){var e=o.growingIO.minipInstance;o._stid=t({},o._gsid),te(e,o.initializedTrackingIds.map((function(e){return{key:o.getStorageKey(e,"gsid"),value:o._gsid[e]}})))},this.setOriginalSource=function(e,t){o.growingIO.minipInstance.setStorageSync(o.getStorageKey(e,"originalSource"),JSON.stringify(t))},this.getOriginalSource=function(e){var t,n=o.growingIO.minipInstance;return null!==(t=L((function(){return JSON.parse(n.getStorageSync(o.getStorageKey(e,"originalSource")))})))&&void 0!==t?t:{}},this.getTrackerVds=function(e){return o.growingIO.trackingId===e?t({},o.growingIO.vdsConfig):void 0},this.initTrackerOptions=function(e){var t=o.initOptions(e);return t.trackingId=e.trackingId,o.growingIO.trackingId=e.trackingId,o.growingIO.vdsConfig=t,t},this.initTrackerHooker=function(e){var t,n,r=o.growingIO,i=r.platformConfig,a=r.inPlugin,u=r.minipInstance,s=r.plugins,c=e.uniVue,l=e.taro;c||l||"quickapp"===u.platform||(i.canHook=!0),!a||["tbp","jdp"].includes(u.platform)?o.eventHooks.initEventHooks():o.eventHooks.initOriginalValue(),c&&(null===(t=null==s?void 0:s.gioUniAppAdapter)||void 0===t||t.main()),l&&(null===(n=null==s?void 0:s.gioTaroAdapter)||void 0===n||n.main())},this.initOptions=function(e){var n,r,i,a,u,s,c=e.projectId,l=e.dataSourceId,g=e.appId,p=e.trackingId,f={};return o.ALLOW_SETTING_KEYS.forEach((function(t){var n=se[t].type;(d(n)?n.includes(q(e[t])):q(e[t])===se[t].type)?"ignoreFields"===t?f.ignoreFields=e.ignoreFields.filter((function(e){return pe.includes(e)})):"extraParams"===t?f.extraParams=e.extraParams.filter((function(e){return fe.includes(e)})):(f[t]=e[t],["dataCollect","autotrack"].includes(t)&&!f[t]&&D("已关闭".concat(ge[t]),"info")):f[t]=se[t].default})),f.uploadInterval=Math.round(f.uploadInterval),(Number.isNaN(f.uploadInterval)||0>f.uploadInterval||f.uploadInterval>3e3)&&(f.uploadInterval=1e3),f.enableIdMapping&&!f.idMapping&&(f.idMapping=!0,f.idMapping||o.growingIO.userStore.setUserKey(p,"")),C(f,"enableIdMapping"),f.pluginMode&&(o.growingIO.inPlugin=!0),!isNaN(Number(f.requestTimeout))&&f.requestTimeout>0||(f.requestTimeout=5e3),(0>f.impressionScale||f.impressionScale>1)&&(f.impressionScale=0),(0>f.keepAlive||f.keepAlive>1440)&&(f.keepAlive=5),(1>f.sessionExpires||f.sessionExpires>1440)&&(f.sessionExpires=-1),t(t({},f),{projectId:c,dataSourceId:l,appId:g,trackingId:p,performance:{monitor:null===(r=null===(n=f.performance)||void 0===n?void 0:n.monitor)||void 0===r||r,exception:null===(a=null===(i=f.performance)||void 0===i?void 0:i.exception)||void 0===a||a,network:null!==(s=null===(u=f.performance)||void 0===u?void 0:u.network)&&void 0!==s&&s}})},this.setOption=function(e,n,r){var i,a,s=o.growingIO,c=s.userStore,l=s.emitter,g=o.getTrackerVds(e),d=u(n)&&o.ALLOW_SETTING_KEYS.includes(n),p=d&&typeof r===(null===(a=se[n])||void 0===a?void 0:a.type);if(d&&p){var f=t({},g);return o.updateVdsConfig(e,t(t({},g),((i={})[n]=r,i))),"dataCollect"===n&&f.dataCollect!==r&&r&&c.setSessionId(e),l.emit(Pe,{optionName:n,optionValue:r}),!0}return K("setOption > ".concat(n)),!1},this.getOption=function(e,t){var n=o.getTrackerVds(e);return t&&P(o.growingIO.vdsConfig,t)?P(n,t)?n[t]:o.growingIO.vdsConfig[t]:x(t)?n:void K("getOption > ".concat(t))},this.updateVdsConfig=function(e,n){e===o.growingIO.trackingId?(o.growingIO.vdsConfig=t(t({},o.growingIO.vdsConfig),n),Z().vdsConfig=o.growingIO.vdsConfig):(o.growingIO.subInstance[e]=t(t({},o.growingIO.subInstance[e]),n),Z().vdsConfig.subInstance[e]=o.growingIO.subInstance[e])},this.toggleShareOut=function(e){c(e)?o.shareOut=e:o.shareOut=!o.shareOut},this.sendVisit=function(e,t){o.eventHooks.appEffects.buildVisitEvent(e,t)},this.sendPage=function(e,t){o.eventHooks.pageEffects.buildPageEvent(e,t)},this.eventConverter=function(e){var n=o.growingIO,r=n.dataStore,i=n.uploader;if(o.getTrackerVds(e.trackingId).dataCollect){["LOGIN_USER_ATTRIBUTES","APP_CLOSED"].includes(e.eventType)||(e.eventSequenceId=r.getGsid(e.trackingId),r.setGsid(e.trackingId,e.eventSequenceId+1));var a={};k(e,(function(e,t){var n;if("element"===t){var r=null!==(n=f(e))&&void 0!==n?n:{};k(r,(function(e,t){x(e)&&0!==e||(a[t]=e)}))}else x(e)&&0!==e||(a[t]=e)})),o.growingIO.emitter.emit(Ie,{composedEvent:a}),i.commitRequest(t(t({},a),{requestId:V()}))}},this.eventRefactor=function(e){var n,r,i=t(t({},e),o.eventContextBuilder(e.trackingId,{path:e.path,query:e.query,timestamp:e.timestamp}));return i.attributes=t(t({},null!==(n=i.attributes)&&void 0!==n?n:{}),null!==(r=e.attributes)&&void 0!==r?r:{}),i},this.eventInterceptor=function(e){var t=o.growingIO.minipInstance,n=t.systemInfo,r=t.network;x(n)||x(r)?o.interceptEvents.push(e):x(o.interceptEvents)?o.eventConverter(e):(i(i([],o.interceptEvents,!0),[e],!1).forEach((function(e){o.eventConverter(o.eventRefactor(e))})),o.interceptEvents=[])},this.eventReleaseInspector=function(){var e=o.growingIO.minipInstance,t=e.systemInfo,n=e.network;t&&n&&!x(o.interceptEvents)&&(i([],o.interceptEvents,!0).forEach((function(e){o.eventConverter(o.eventRefactor(e))})),o.interceptEvents=[])},this.buildAppMessageEvent=function(e,n){var r,i,a,u=n[0];2>n.length?1===n.length&&(a=u):a=n[1];var s=o.growingIO.dataStore,c=s.eventContextBuilder,l=s.eventInterceptor,g=((null==a?void 0:a.path)||"").split("?"),d=t({eventType:"CUSTOM",eventName:"$mp_on_share"},c(e));d.attributes=X(t(t(t({},null!==(r=d.attributes)&&void 0!==r?r:{}),{$from:u.from,$target:null===(i=null==u?void 0:u.target)||void 0===i?void 0:i.id,$share_title:null==a?void 0:a.title,$share_path:f(g),$share_query:g[1]}),null==a?void 0:a.attributes)),l(d)},this.buildTimelineEvent=function(e,n){var r,i,a,u=n[0];2>n.length?1===n.length&&(a=u):a=n[1];var s=o.growingIO.dataStore,c=s.eventContextBuilder,l=s.eventInterceptor,g=((null==a?void 0:a.path)||"").split("?"),d=t({eventType:"CUSTOM",eventName:"$mp_share_timeline"},c(e));d.attributes=X(t(t(t({},null!==(r=d.attributes)&&void 0!==r?r:{}),{$target:null===(i=null==u?void 0:u.target)||void 0===i?void 0:i.id,$share_title:null==a?void 0:a.title,$share_path:f(g),$share_query:g[1]}),null==a?void 0:a.attributes)),l(d)},this.buildAddFavorites=function(e,n){var r,i,a=n[0];2>n.length?1===n.length&&(i=a):i=n[1];var u=o.growingIO.dataStore,s=u.eventContextBuilder,c=u.eventInterceptor,l=((null==i?void 0:i.path)||"").split("?"),g=t({eventType:"CUSTOM",eventName:"$mp_add_favorites"},s(e));g.attributes=X(t(t({},null!==(r=g.attributes)&&void 0!==r?r:{}),{$share_title:null==i?void 0:i.title,$share_path:f(l),$share_query:l[1]})),c(g)},this.trackersExecute=function(e){o.initializedTrackingIds.forEach((function(t){"function"===q(e)&&e(t)}))},this.initializedTrackingIds=[],this.eventContextBuilder=new Ee(this.growingIO).main,this.eventHooks=new qe(this.growingIO),this.shareOut=!1,this._gsid={},this._stid={},this.lastVisitEvent={},this.lastPageEvent={},this.locationData={},this.generalProps={},this.trackTimers={},this.interceptEvents=[];var a=this.growingIO,s=a.emitter,l=a.minipInstance;s.on(ke,(function(e){var t=e.trackingId;o.initializedTrackingIds.push(t),o.initStorageInfo(t)})),s.on(me,(function(e){var t=e.eventData,n=e.trackingId;"VISIT"===t.eventType&&(o.lastVisitEvent[n]=t),"PAGE"===t.eventType&&(o.lastPageEvent[n]=t)})),g(null===(n=l.minip)||void 0===n?void 0:n.onAppHide)&&l.minip.onAppHide((function(){o.trackersExecute((function(e){var t=o.trackTimers[e];k(t,(function(e){e.start&&(e.leng=e.leng+(+Date.now()-e.start))}))}))})),g(null===(r=l.minip)||void 0===r?void 0:r.onAppShow)&&l.minip.onAppShow((function(){o.trackersExecute((function(e){var t=o.trackTimers[e];k(t,(function(e){e.start&&(e.start=+Date.now())}))}))})),s.on(Pe,(function(e){var t=e.optionName,n=e.optionValue;"dataCollect"===t&&!1===n&&o.trackersExecute((function(e){o.growingIO.clearTrackTimer(e)}))})),this.growingIO.emitter.on(Te,(function(e){var t=e.oldSessionId,n=e.trackingId;if(t){var r=o.eventHooks.currentPage,i=r.getPagePath,a=r.getPageQuery,u=i(),s=a();if(u)o.sendVisit(n,{path:u,query:s});else{var c=o.lastPageEvent[n];o.sendVisit(n,{path:c.path,query:c.query})}o.eventHooks.currentPage.lifeBeforeShow||o.sendPage(n)}}))}return Object.defineProperty(e.prototype,"scene",{get:function(){return this._scene},set:function(e){var t=this._scene;this._scene=e,t!==this._scene&&this.growingIO.emitter.emit("SCENE_UPDATE",{newScene:e,oldScene:t})},enumerable:!1,configurable:!0}),e}(),Ue={scnPrefix:"",appHandlers:["onLaunch","onShow","onHide","onError","onPageNotFound","onUnhandledRejection","onThemeChange"],pageHandlers:["onLoad","onShow","onReady","onHide","onShareAppMessage","onTabItemTap","onUnload","onPullDownRefresh","onReachBottom","onResize"],shareEventTypes:["onShareAppMessage"],actionEventTypes:["onclick","tap","onTap","longpress","longTap","blur","change","onChange","submit","confirm","getuserinfo","getphonenumber","contact","mouseup"],canHook:!0,hooks:{App:!0,Page:!0,Component:!0,Behavior:!0},listeners:{app:{appLaunch:"onLaunch",appShow:"onShow",appClose:"onHide"},page:{pageLoad:"onLoad",pageShow:"onShow",pageReady:"onReady",pageHide:"onHide",pageUnload:"onUnload",tabTap:"onTabItemTap",shareApp:"onShareAppMessage"},actions:{click:["onclick","tap","longpress","longTap","getuserinfo","getphonenumber","contact","mouseup"],change:["blur","change","confirm"],submit:["submit"]}}},De=t(t({},Ue),{listeners:t({},Ue.listeners),name:"KuaiShou",platform:"kuaishoup",scnPrefix:"ks_"}),Ke=function(t){function n(e){var n=t.call(this,e)||this;return n.growingIO=e,n.hookSetTitle(),n}return function(t,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+n+" is not a constructor or null");function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}(n,t),n}((function(e){var t=this;this.growingIO=e,this.minip=z("ks"),this.hookSetTitle=function(){var e,n=null===(e=t.minip)||void 0===e?void 0:e.setNavigationBarTitle,r=t;n&&Object.defineProperty(t.minip,"setNavigationBarTitle",{writable:!0,enumerable:!0,configurable:!0,value:function(){if(r.growingIO.gioSDKInitialized){var e=r.getCurrentPath(),t=(arguments[0]||{}).title;r.growingIO.dataStore.eventHooks.currentPage.configuredTitle[e]=t}return n.apply(this,arguments)}})},this.navigateTo=function(e){var n;return null===(n=t.minip)||void 0===n?void 0:n.navigateTo(e)},this.switchTab=function(e){var n;null===(n=t.minip)||void 0===n||n.switchTab(e)},this.navigateToMiniProgram=function(e){var n;return null===(n=t.minip)||void 0===n?void 0:n.navigateToMiniProgram(e)},this.getImageInfo=function(e){var n,r=e.src,i=e.success,o=e.fail,a=e.complete;return null===(n=t.minip)||void 0===n?void 0:n.getImageInfo({src:r,success:i,fail:o,complete:a})},this.initImpression=function(e){var n,r;null===(r=null===(n=t.growingIO.plugins)||void 0===n?void 0:n.gioImpressionTracking)||void 0===r||r.main(e,"observeAll")},this.getCurrentPage=function(){return L((function(){return v(getCurrentPages())}))||{}},this.getCurrentPath=function(){var e=t.getCurrentPage();return(null==e?void 0:e.route)||(null==e?void 0:e.uri)||(null==e?void 0:e.__route__)||""},this.getPageTitle=function(e){var n,r,i,o,a,s,c,l,g=Y(),p="",f=W(g);"string"===q(f)&&(f=null!==(n=L((function(){return JSON.parse(f)})))&&void 0!==n?n:{});var v,h=(null==e?void 0:e.data)||e.$data||{};if((p=u(null==h?void 0:h.gioPageTitle)?null==h?void 0:h.gioPageTitle:"")||L((function(){var t,n,r=J(g);r&&(v=r["".concat(e.route,".json")]||{},p=(null==v?void 0:v.navigationBarTitleText)||(null===(n=null===(t=null==v?void 0:v.mod)||void 0===t?void 0:t.exports)||void 0===n?void 0:n.navigationBarTitleText))})),!p&&f){var m=t.growingIO.dataStore.eventHooks.appEffects.enterParams;if(e.route||x(m)||(e.route=m.path||"",p=e.route?t._getTitleFromTabBar(f,e.route):""),!p&&(v=d(f.pages)?null!==(r=f.pages.find((function(t){return t.path===e.route})))&&void 0!==r?r:{}:f.page||{})){var I=v[e.route]||v["".concat(e.route,".html")]||v;p=(null==I?void 0:I.navigationBarTitleText)||(null===(i=null==I?void 0:I.window)||void 0===i?void 0:i.navigationBarTitleText)}p||(p=t._getTitleFromTabBar(f,e.route))}return p||(p=["wx","tt"].includes(g)?null===(s=null===(a=null===(o=f||global||$global)||void 0===o?void 0:o.global)||void 0===a?void 0:a.window)||void 0===s?void 0:s.navigationBarTitleText:null===(l=null===(c=f||global||$global)||void 0===c?void 0:c.window)||void 0===l?void 0:l.navigationBarTitleText),H(p)},this._getTitleFromTabBar=function(e,t){var n,r,i=null===(r=null===(n=null==e?void 0:e.tabBar)||void 0===n?void 0:n.list)||void 0===r?void 0:r.find((function(e){return e.pagePath===t||e.pagePath==="".concat(t,".html")}));return(null==i?void 0:i.text)||""},this.getStorageSync=function(e){var n,r=null===(n=t.minip)||void 0===n?void 0:n.getStorageSync(e);return l(r)&&r.expiredAt?r.expiredAt<Date.now()?"":r.value:r},this.getStorage=function(e){return new Promise((function(n){var r;null===(r=t.minip)||void 0===r||r.getStorage({key:e,success:function(e){var t=e.data;return n(t)},fail:function(){return n("")}})}))},this.setStorageSync=function(e,n,r){var i;r&&(n={value:n,expiredAt:r}),null===(i=t.minip)||void 0===i||i.setStorageSync(e,n)},this.setStorage=function(e,n){var r;null===(r=t.minip)||void 0===r||r.setStorage({key:e,data:n})},this.removeStorageSync=function(e){var n;null===(n=t.minip)||void 0===n||n.removeStorageSync(e)},this.removeStorage=function(e){var n;null===(n=t.minip)||void 0===n||n.removeStorage(e)},this.getNetworkType=function(){var e=t;return new Promise((function(n){var r;null===(r=t.minip)||void 0===r||r.getNetworkType({success:function(t){e.network=t,n(t)},fail:function(){return n(null)}})}))},this.request=function(e){var n,r=e.url,i=e.data,o=e.header,a=e.timeout,u=e.method,s=e.success,c=e.fail,l=e.complete,d=null===(n=t.minip)||void 0===n?void 0:n.request({url:r,data:i,header:o,timeout:a,method:u,success:s,fail:c,complete:l}),p=setTimeout((function(){(null==d?void 0:d.abort)&&g(null==d?void 0:d.abort)&&(null==d||d.abort()),clearTimeout(p),p=null}),(a||1e4)+10);return d},this.getSystemInfo=function(){var e=t;return new Promise((function(n){var r;null===(r=t.minip)||void 0===r||r.getSystemInfo({success:function(t){e.systemInfo=t,n(t)},fail:function(){return n(null)}})}))},this.getSetting=function(){return new Promise((function(e){var n;null===(n=t.minip)||void 0===n||n.getSetting({success:e,fail:e})}))},this.setNetworkStatusListener=function(){var e;null===(e=t.minip)||void 0===e||e.onNetworkStatusChange((function(e){var n=e.networkType;n&&(t.network.networkType=n)}))};var n=this.growingIO.platformConfig,r=n.platform,i=n.scnPrefix;this.platform=r,this.scnPrefix=i,this.growingIO.emitter.on(be,(function(){t.getNetworkType().then((function(){var e;return null===(e=t.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()})),t.getSystemInfo().then((function(){var e;return null===(e=t.growingIO.dataStore)||void 0===e?void 0:e.eventReleaseInspector()}))}))})),Le=["gioPerformance"],Re=function(e){var t,n,r,i,o,a,u=this;this.growingIO=e,this.innerPluginInit=function(){var e;Le.forEach((function(e){var t;return C(null===(t=u.pluginsContext)||void 0===t?void 0:t.plugins,e)})),b(null===(e=u.pluginsContext)||void 0===e?void 0:e.plugins).forEach((function(e){var t,n,r=null!==(n=null===(t=u.pluginsContext)||void 0===t?void 0:t.plugins[e])&&void 0!==n?n:{},i=r.name,o=r.method;I(u.pluginItems,(function(e){return e.name===i}))||u.pluginItems.push({name:w(i||e),method:o||function(e){}})})),x(u.pluginItems)||u.installAll()},this.install=function(e,t,n){var r,i,o=u.growingIO.emitter,a=t||I(u.pluginItems,(function(t){return t.name===e}));if((null===(r=u.growingIO)||void 0===r?void 0:r.plugins)[e])return D("重复加载插件 ".concat(e," 或插件重名,已跳过加载!"),"warn"),!1;if(!a)return D("插件加载失败!不存在名为 ".concat(e," 的插件!"),"error"),!1;try{return(null===(i=u.growingIO)||void 0===i?void 0:i.plugins)[e]=new a.method(u.growingIO,n),t&&(o.emit(we,e),D("加载插件 ".concat(e),"info")),!0}catch(n){return u.lifeError(t,n),D("插件【".concat(e,"】加载异常 ").concat(n),"error"),!1}},this.installAll=function(e){(e||u.pluginItems).forEach((function(t){u.install(t.name,e?t:void 0,e?null==t?void 0:t.options:void 0)&&!I(u.pluginItems,(function(e){return e.name===t.name}))&&u.pluginItems.push({name:w(t.name),method:t.method?t.method:function(){}})}))},this.uninstall=function(e){var t;C(u.pluginItems,e);var n=C(null===(t=u.growingIO)||void 0===t?void 0:t.plugins,e);return n||D("卸载插件 ".concat(e," 失败!"),"error"),n},this.uninstallAll=function(){u.pluginItems.forEach((function(e){return u.uninstall(e.name)}))},this.lifeError=function(e,t){u.growingIO.emitter.emit(Se,{plugin:e,error:t}),D("插件执行错误 ".concat(e.name," ").concat(t),"error")},this.callLifeCycle=function(e,t){u.pluginItems.forEach((function(n){var r=u.growingIO.plugins[n.name]?u.growingIO.plugins[n.name][e]:void 0;if(r&&g(r))try{r(t)}catch(e){u.lifeError(n,e)}}))},this.pluginsContext={plugins:{}},this.pluginItems=[],null===(t=this.growingIO.emitter)||void 0===t||t.on(we,(function(e){return u.callLifeCycle("onInstall",e)})),null===(n=this.growingIO.emitter)||void 0===n||n.on(Se,(function(e){return u.callLifeCycle("onError",e)})),null===(r=this.growingIO.emitter)||void 0===r||r.on(ye,(function(e){return u.callLifeCycle("onComposeBefore",e)})),null===(i=this.growingIO.emitter)||void 0===i||i.on(Ie,(function(e){return u.callLifeCycle("onComposeAfter",e)})),null===(o=this.growingIO.emitter)||void 0===o||o.on(Oe,(function(e){return u.callLifeCycle("onSendBefore",e)})),null===(a=this.growingIO.emitter)||void 0===a||a.on(_e,(function(e){return u.callLifeCycle("onSendAfter",e)}))},He={},Be={}.hasOwnProperty;function je(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch(e){return null}}function Ve(e){try{return encodeURIComponent(e)}catch(e){return null}}He.stringify=function(e,t){t=t||"";var n,r,i=[];for(r in"string"!=typeof t&&(t="?"),e)if(Be.call(e,r)){if((n=e[r])||null!=n&&!isNaN(n)||(n=""),r=Ve(r),n=Ve(n),null===r||null===n)continue;i.push(r+"="+n)}return i.length?t+i.join("&"):""},He.parse=function(e){for(var t,n=/([^=?#&]+)=?([^&]*)/g,r={};t=n.exec(e);){var i=je(t[1]),o=je(t[2]);null===i||null===o||i in r||(r[i]=o)}return r};var Fe=function(e){var n=this;this.growingIO=e,this.generateURL=function(e){var t=n.growingIO.dataStore.getTrackerVds(e),r=t.serverUrl,i=t.projectId;return _(r,"http")?"".concat(r,"/v3/projects/").concat(i,"/collect"):"https://".concat(r,"/v3/projects/").concat(i,"/collect")},this.getHoardingQueue=function(e){var t;return null!==(t=n.hoardingQueue[e])&&void 0!==t?t:[]},this.getRequestQueue=function(e){var t;return null!==(t=n.requestQueue[e])&&void 0!==t?t:[]},this.commitRequest=function(e){var r,i,o=t({},e),u=n.growingIO,s=u.vdsConfig;u.emitter.emit(me,{eventData:e,trackingId:e.trackingId}),s.forceLogin?(a(n.hoardingQueue[e.trackingId])&&(n.hoardingQueue[e.trackingId]=[]),null===(r=n.hoardingQueue[e.trackingId])||void 0===r||r.push(o)):(a(n.requestQueue[e.trackingId])&&(n.requestQueue[e.trackingId]=[]),null===(i=n.requestQueue[e.trackingId])||void 0===i||i.push(o),n.initiateRequest(e.trackingId))},this.initiateRequest=function(e,t){var r=n.growingIO,o=r.plugins,a=r.vdsConfig,u=r.minipInstance,s=r.dataStore,c=n.getHoardingQueue(e),l=n.getRequestQueue(e),g=i(i([],c,!0),l,!0),d=function(e){var r,i;if(null===(r=null==a?void 0:a.tbConfig)||void 0===r?void 0:r.cloudFuncSend)null===(i=null==o?void 0:o.gioTaobaoAdapter)||void 0===i||i.singleInvoke(e);else if(t)n.batchInvoke(e);else{var c=n.growingIO.dataStore.getTrackerVds(e).uploadInterval;A(n.batchInvoke,c,!1,!1)(e)}g.some((function(e){return"VISIT"===e.eventType}))&&u.removeStorageSync(s.getStorageKey(e,"originalSource"))};if(g.length>0)if(n.requestingNum<n.requestLimit)d(e);else var p=setInterval((function(){n.requestingNum<n.requestLimit&&(d(e),clearInterval(p),p=void 0)}),500)},this.batchInvoke=function(e){var r=n.growingIO,o=r.vdsConfig,a=r.emitter,u=n.getHoardingQueue(e),s=n.getRequestQueue(e),c=i(i([],u,!0),s,!0);c.length>50?(c=c.slice(0,50),u.length>50?n.hoardingQueue[e]=u.slice(50):(n.requestQueue[e]=s.slice(50-u.length),n.hoardingQueue[e]=[])):(n.hoardingQueue[e]=[],n.requestQueue[e]=[]);var l=c.filter((function(e){return(n.retryIds[e.requestId]||0)<=n.retryLimit}));if(!x(l)){var g=l.map((function(e){var n=t({},e);return C(n,["requestId","trackingId"]),n}));o.debug&&console.log("[GrowingIO Debug]:",JSON.stringify(g,null,2)),a.emit(Oe,{eventsQueue:l,requestData:g,trackingId:e})}},this.sendEvent=function(e,t){var r,o=f(e).trackingId,a=n.growingIO,u=a.minipInstance,s=a.dataStore,c=a.emitter,l=a.plugins,g=s.getTrackerVds(o),d=g.compress,p=g.requestTimeout;n.requestingNum+=1;var v={"content-type":"jdp"===u.platform?"application/json":"application/json;charset=UTF-8"},h=i([],t,!0),m=!!d&&(null===(r=null==l?void 0:l.gioCompress)||void 0===r?void 0:r.compressToUTF16);m&&(h=l.gioCompress.compressToUTF16(JSON.stringify(t)),v["X-Compress-Codec"]="1");var I=n.generateURL(o);u.request({url:"".concat(I,"?stm=").concat(Date.now(),"&compress=").concat(m?"1":"0"),header:v,method:"POST",data:h,timeout:p,fail:function(r){[200,204].includes(r.code)||(e.forEach((function(e){n.requestFailFn(e)})),D("请求失败!".concat(JSON.stringify(r)),"error"),c.emit("ON_SEND_ERROR",{eventsQueue:e,requestData:t,trackingId:o}))},complete:function(e){n.requestingNum-=1,c.emit(_e,{result:e,requestData:t,trackingId:o}),n.initiateRequest(o)}})},this.requestFailFn=function(e){if(n.retryIds[e.requestId]||(n.retryIds[e.requestId]=0),n.retryIds[e.requestId]+=1,!n.requestQueue[e.trackingId].some((function(t){return t.requestId===e.requestId})))var t=setTimeout((function(){x(n.requestQueue[e.trackingId])?(n.requestQueue[e.trackingId].push(e),n.initiateRequest(e.trackingId)):n.requestQueue[e.trackingId].push(e),clearTimeout(t),t=null}),800)},this.hoardingQueue={},this.requestQueue={},this.requestLimit=3,this.retryLimit=2,this.retryIds={},this.requestingNum=0,this.growingIO.emitter.on(Oe,(function(e){var t,r,i=e.eventsQueue,o=e.requestData,a=e.trackingId,u=n.growingIO,s=u.vdsConfig,c=u.plugins;a===n.growingIO.trackingId&&((null===(t=null==s?void 0:s.tbConfig)||void 0===t?void 0:t.cloudAppId)?null===(r=null==c?void 0:c.gioTaobaoAdapter)||void 0===r||r.tbCloudAppInvoke(i,o):n.sendEvent(i,o))}))},Me=function(e){var t=this;this.growingIO=e,this._getUidKey=function(){return t.growingIO.inPlugin?"_growing_plugin_uid_":"_growing_uid_"},this.getUid=function(){var e=t.growingIO.minipInstance;return t._uid||(t._uid=e.getStorageSync(t._getUidKey())),t._uid||t.setUid(V()),t._uid},this.setUid=function(e){var n=t._uid;t._uid=e,n!==t._uid&&(t.growingIO.minipInstance.setStorage(t._getUidKey(),t._uid),t.growingIO.emitter.emit("UID_UPDATE",{newUId:e,oldUId:n}))},this.getSessionId=function(e){var n=t.growingIO,r=n.vdsConfig.sessionExpires,i=n.dataStore.trackersExecute;return t._sessionId[e]||t.setSessionId(e),r>-1&&(Date.now()>t._sessionExpires&&i((function(e){t.setSessionId(e)})),t._sessionExpires=Date.now()+6e4*r),t._sessionId[e]},this.setSessionId=function(e,n){var r=t._sessionId[e];n||(n=V()),t._sessionId[e]=n;var i=t.growingIO.vdsConfig.sessionExpires;i>-1&&(t._sessionExpires=Date.now()+6e4*i),r!==n&&t.growingIO.emitter.emit(Te,{trackingId:e,newSessionId:n,oldSessionId:r})},this._getUserIdKey=function(e){return t.growingIO.dataStore.getStorageKey(e,"userId")},this.getUserId=function(e){var n=t.growingIO.minipInstance;return t._userId[e]||(t._userId[e]=n.getStorageSync(t._getUserIdKey(e))),t._userId[e]},this.setUserId=function(e,n){var r=t._userId[e];t._userId[e]=a(n)?"":n,r!==t._userId[e]&&(t.growingIO.minipInstance.setStorage(t._getUserIdKey(e),t._userId[e]),t.growingIO.emitter.emit("USERID_UPDATE",{newUserId:n,oldUserId:r})),n&&t.setGioId(e,n)},this._getUserKeyKey=function(e){return t.growingIO.dataStore.getStorageKey(e,"userKey")},this.getUserKey=function(e){var n=t.growingIO.minipInstance;return t._userKey[e]||(t._userKey[e]=n.getStorageSync(t._getUserKeyKey(e))),t._userKey[e]},this.setUserKey=function(e,n){var r=t._userKey[e];t._userKey[e]=a(n)?"":n,r!==t._userKey[e]&&(t.growingIO.minipInstance.setStorage(t._getUserKeyKey(e),t._userKey[e]),t.growingIO.emitter.emit("USERKEY_UPDATE",{newUserKey:n,oldUserKey:r}))},this._getGioIdKey=function(e){return t.growingIO.dataStore.getStorageKey(e,"gioId")},this.getGioId=function(e){var n=t.growingIO.minipInstance;return t._gioId[e]||(t._gioId[e]=n.getStorageSync(t._getGioIdKey(e))),t._gioId[e]},this.setGioId=function(e,n){var r=t._gioId[e];t._gioId[e]=a(n)?"":n,r!==t._gioId[e]&&(t.growingIO.minipInstance.setStorage(t._getGioIdKey(e),t._gioId[e]),t.growingIO.emitter.emit("GIOID_UPDATE",{newGioId:n,oldGioId:r}))},this.initUserInfo=function(e){var n,r=t.growingIO.minipInstance,i=[t._getUidKey(),t._getUserIdKey(e),t._getUserKeyKey(e),t._getGioIdKey(e)],o=null!==(n=ee(r,i))&&void 0!==n?n:[];["_uid","_userId","_userKey","_gioId"].forEach((function(n,r){"_uid"===n?t.getUid():t[n][e]=o[r]}))},this.saveUserInfo=function(){var e=t.growingIO,n=e.minipInstance;(0,e.dataStore.trackersExecute)((function(e){te(n,[{key:t._getUidKey(),value:t._uid},{key:t._getUserIdKey(e),value:t._userId[e]},{key:t._getUserKeyKey(e),value:t._userKey[e]},{key:t._getGioIdKey(e),value:t._gioId[e]}])}))},this._uid=void 0,this._sessionId={},this._userId={},this._userKey={},this._gioId={},this._sessionExpires=-1},Ge=new function(){var e,n=this;this.init=function(e){var t;n.emitter.emit("ON_SDK_INITIALIZE_BEFORE",{options:e});try{if(D("Gio小程序SDK 初始化中...","info"),e.trackingId&&n.dataStore.initializedTrackingIds.includes(e.trackingId))throw Error("已存在实例 ".concat(e.trackingId,",请勿重复初始化!"));if(n.trackingId&&!n.plugins.gioMultipleInstances)throw Error("您正在尝试初始化另一个实例,请集成多实例插件后重试!");var r=n.dataStore.initTrackerOptions(e);return null===(t=n.emitter)||void 0===t||t.emit(be,r),n.gioSDKInitialized=!0,n.dataStore.initTrackerHooker(r),"quickapp"!==n.gioPlatform&&n.userStore.initUserInfo(e.trackingId),n.emitter.emit(ke,r),n.trackingId&&n.trackingId!==e.trackingId||(Z().__gio__=function(){return n}),D("Gio小程序SDK 初始化完成!","success"),n.inPlugin&&"tbp"!==n.minipInstance.platform&&n.dataStore.sendVisit(r.trackingId),n.vdsConfig.forceLogin&&D("forceLogin已开启,请调用 identify 方法设置 openId 以继续上报!","info"),!0}catch(e){return D(e,"error"),!1}},this.handlerDistribute=function(e,t,r){var o=n.dataStore,a=o.initializedTrackingIds;if((0,o.getTrackerVds)(e)&&a.includes(e))return n[t].apply(n,i([e],r,!1));D("不存在实例:".concat(e,",请检查!"),"warn")},this.registerPlugins=function(e){n.plugins.pluginItems=i(i([],n.plugins.pluginItems,!0),e,!0),n.plugins.installAll(e)},this.getPlugins=function(){return n.plugins.pluginItems},this.getDeviceId=function(){return n.userStore.getUid()},this.getOption=function(e,t){return n.dataStore.getOption(e,t)},this.setOption=function(e,t,r){var i;return b(ge).includes(t)?typeof r===(null===(i=se[t])||void 0===i?void 0:i.type)?(n.dataStore.setOption(e,t,r),D("已修改".concat(ge[t],": ").concat(r),"info"),!0):(D("参数格式不正确:".concat(r,",请检查后重试!"),"error"),!1):(D("不存在可修改的配置项:".concat(t,",请检查后重试!"),"error"),!1)},this.setPageAttributes=function(e,t){if(l(t)&&!x(t)){var r=n.dataStore.eventHooks.currentPage,i=r.getPagePath();return x(r.pageProps[e])&&(r.pageProps[e]={}),x(r.pageProps[e][i])&&(r.pageProps[e][i]={}),x(t)||k(t,(function(t,n){g(r.pageProps[e][i][n])&&!g(t)||(r.pageProps[e][i][n]=t)})),!0}return K("setPageAttributes"),!1},this.clearPageAttributes=function(e,t){try{if(!x(n.dataStore.eventHooks.currentPage.pageProps[e])){var r=n.dataStore.eventHooks.currentPage,i=r.getPagePath();d(t)&&!x(t)?t.forEach((function(t){C(r.pageProps[e][i],t)})):r.pageProps[e][i]={}}}catch(e){return K("clearPageAttributes"),!1}},this.sendPage=function(e,t){n.dataStore.getTrackerVds(e).trackPage?D("仅在关闭trackPage时允许调用sendPage,请确认后修改初始化配置项!","error"):n.dataStore.sendPage(e,t)},this.identify=function(e,t){if(e===n.trackingId)if(n.vdsConfig.forceLogin){if(!ue(t))return void K("identify");var r=y(t).slice(0,1e3);n.userStore.setUid(r),n.dataStore.setOption(n.trackingId,"forceLogin",!1),n._identified=!0,n.dataStore.trackersExecute((function(e){var t=n.uploader.getHoardingQueue(e);t.forEach((function(e,n){return t[n].deviceId=r})),n.uploader.initiateRequest(e,!0)}))}else n._identified?K("identify",!1,"请勿重复调用"):K("identify",!1,"forceLogin未开启");else K("identify",!1,"子实例不允许调用identify")},this.setUserAttributes=function(e,r){var i,o,a,u;if(l(r)&&!x(r)){var s=n.dataStore,c=s.eventContextBuilder,g=s.eventInterceptor,d=s.lastVisitEvent,p=t({eventType:"LOGIN_USER_ATTRIBUTES"},c(e));p.attributes=X(t(t({},null!==(i=p.attributes)&&void 0!==i?i:{}),j(r))),p.path||(p.path=null===(o=d[e])||void 0===o?void 0:o.path,p.query=null===(a=d[e])||void 0===a?void 0:a.query,p.title=null===(u=d[e])||void 0===u?void 0:u.title),g(p)}else K("setUserAttributes")},this.setUserId=function(e,t,r){if(ue(t)){var i=n.userStore.getGioId(e);t=y(t).slice(0,1e3),r=y(r).slice(0,1e3),n.userStore.setUserId(e,t);var o=!a(r)&&y(r).length>0?y(r).slice(0,1e3):"";n.userStore.setUserKey(e,o),!n.dataStore.getTrackerVds(e).idMapping&&o&&D("您设置了 userKey ,请初始化开启 idMapping!","warn"),i&&i!==t&&n.userStore.setSessionId(e)}else K("setUserId")},this.clearUserId=function(e){n.userStore.setUserId(e,void 0),n.userStore.setUserKey(e,void 0)},this.setGeneralProps=function(e,t){return l(t)&&!x(t)?(x(n.dataStore.generalProps[e])&&(n.dataStore.generalProps[e]={}),k(t,(function(t,r){g(n.dataStore.generalProps[e][r])&&!g(t)||(n.dataStore.generalProps[e][r]=t)})),!0):(K("setGeneralProps"),!1)},this.clearGeneralProps=function(e,t){try{x(n.dataStore.generalProps[e])||(d(t)&&!x(t)?t.forEach((function(t){C(n.dataStore.generalProps[e],t)})):n.dataStore.generalProps[e]={})}catch(e){return K("clearGeneralProps"),!1}},this.track=function(e,r,i){B(r,(function(){var o,a=n.dataStore,u=a.eventContextBuilder,s=a.eventInterceptor,c=t({eventType:"CUSTOM",eventName:r},u(e));c.attributes=X(t(t({},null!==(o=c.attributes)&&void 0!==o?o:{}),j(t({},l(i)&&!x(i)?i:{})))),n.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(c["&&sendTo"]=i["&&sendTo"]),s(c)}))},this.trackTimerStart=function(e,t){return n.dataStore.getTrackerVds(e).dataCollect?B(t,(function(){var r=V();return n.dataStore.trackTimers[e]||(n.dataStore.trackTimers[e]={}),n.dataStore.trackTimers[e][r]={eventName:t,leng:0,start:+Date.now()},r})):(D("指定实例未开启数据采集,请检查!","error"),!1)},this.trackTimerPause=function(e,t){var r=n.dataStore.trackTimers[e];if(t&&r&&r[t]){var i=r[t];return i.start&&(i.leng=i.leng+(+Date.now()-i.start)),i.start=0,!0}return!1},this.trackTimerResume=function(e,t){var r=n.dataStore.trackTimers[e];if(t&&r&&r[t]){var i=r[t];return 0===i.start&&(i.start=+Date.now()),!0}return!1},this.trackTimerEnd=function(e,r,i){var o,a=n.dataStore.getTrackerVds(e).dataCollect,u=n.dataStore.trackTimers[e];if(r&&u&&u[r]){if(a){var s=u[r];if(0!==s.start){var c=+Date.now()-s.start;s.leng=c>0?s.leng+c:0}var g=n.dataStore,d=g.eventContextBuilder,p=g.eventInterceptor,f=t({eventType:"CUSTOM",eventName:s.eventName},d(e));return f.attributes=X(t(t({},null!==(o=f.attributes)&&void 0!==o?o:{}),j(t(t({},l(i)&&!x(i)?i:{}),{event_duration:s.leng>864e5?0:s.leng/1e3})))),n.plugins.gioMultipleInstances&&i&&i["&&sendTo"]&&(f["&&sendTo"]=i["&&sendTo"]),p(f),!0}return D("指定实例未开启数据采集,计时器已移除,请检查!","error"),!1}return D("未查询到指定计时器,请检查!","error"),!1},this.removeTimer=function(e,t){var r=n.dataStore.trackTimers[e];return t&&r&&r[t]?(delete r[t],!0):(D("未查询到指定计时器,请检查!","error"),!1)},this.clearTrackTimer=function(e){n.dataStore.trackTimers[e]={}},this.setLocation=function(e,t,r){x(n.dataStore.locationData[e])&&(n.dataStore.locationData[e]={});var i=n.dataStore.locationData[e],o=function(e){return e>=-180&&180>=e};o(t)&&o(r)&&(i.latitude!==t||i.longitude!==r)&&(n.dataStore.locationData[e]={latitude:t,longitude:r})},this.updateImpression=function(){D("updateImpression 错误! 请集成半自动埋点浏览插件后重试!","error")},this.getABTest=function(e,t,n){D("获取ABTest数据错误! 请集成ABTest插件后重试!","error"),R(n,{})},this.getGioInfo=function(e){var t,r,i=n.userStore,o=i.getUid,a=i.getUserId,u=i.getUserKey,s=i.getSessionId,c=n.dataStore.getTrackerVds(e),l=c.projectId,g=c.appId,d=c.dataSourceId,p=c.dataCollect,f=c.idMapping,v=c.extraParams,h=c.ignoreFields,m={gioappid:g,giocs1:a(e)||"",gioplatform:n.platformConfig.platform,gioprojectid:l,gios:s(e),giou:o()};if(m.giodatacollect=p,m.giodatasourceid=d,f&&(m.giouserkey=u(e)),x(v)||v.forEach((function(t){var r;h.includes(t)||(m["gio".concat(t)]=(null!==(r=n.dataStore.lastVisitEvent[e])&&void 0!==r?r:{})[t])})),e===n.trackingId){var I=null!==(r=null===(t=n.plugins)||void 0===t?void 0:t.gioEventAutoTracking)&&void 0!==r?r:{},y=I.circleServerUrl,S=I.circleOpen;if(y&&S){var w=re(y.split("?")[1]);w.roomId&&(m.giocircleroomid=w.roomId)}}return He.stringify(m)},this.utils=t(t(t({},U),ae),{qs:He}),this.emitter={all:e=e||new Map,on:function(t,n){var r=e.get(t);r?r.push(n):e.set(t,[n])},off:function(t,n){var r=e.get(t);r&&(n?r.splice(r.indexOf(n)>>>0,1):e.set(t,[]))},emit:function(t,n){var r=e.get(t);r&&r.slice().map((function(e){e(n)})),(r=e.get("*"))&&r.slice().map((function(e){e(t,n)}))}},this.gioPlatform="ks",this.gioFramework="native",this.sdkVersion="4.4.0";try{"quickapp"===this.gioPlatform||g(getApp)&&g(App)?this.inPlugin=!1:this.inPlugin=!0}catch(e){this.inPlugin=!0}this.inPlugin&&D("未检测到小程序实例,自动切换为插件模式!","info"),this.platformConfig=De,this.minipInstance=new Ke(this),this.dataStore=new Ne(this),this.userStore=new Me(this),this.uploader=new Fe(this),this.plugins=new Re(this),this.plugins.innerPluginInit()},Qe=function(){var e,n=arguments[0],r="g0",i=n;if(n.indexOf(".")>-1&&(r=null!==(e=n.split(".")[0])&&void 0!==e?e:"g0",i=n.split(".")[1]),u(i)&&le.includes(i)&&Ge[i]){var o=h(Array.from(arguments));if("init"===i){var a=function(e,t){var n=y(t[0]),r=y(t[1]),i=(4===t.length?t[3]:t[2])||{};return n&&r?e.dataStore.initializedTrackingIds.some((function(t,i){var o=0===i?e.vdsConfig:e.subInstance[t];return o.projectId===n&&o.dataSourceId===r}))?(D("SDK初始化失败,重复初始化,请检查初始化参数!","error"),!1):{projectId:n,dataSourceId:r,appId:y(4===t.length?t[2]:""),userOptions:i}:(D('SDK初始化失败,请使用 gdp("init", "您的GrowingIO项目 accountId", "您项目的 dataSourceId", "您的小程序 AppId(可选)", options: { host: "您的数据上报地址host" }); 进行初始化!',"error"),!1)}(Ge,o);if(a){var s=a.projectId,c=a.dataSourceId,l=a.appId,g=a.userOptions;return Ge.init(t(t({},g),{projectId:s,dataSourceId:c,appId:l,trackingId:r}))}return!1}if("registerPlugins"===i)Ge.registerPlugins(o[0]);else{if(Ge.gioSDKInitialized&&Ge.vdsConfig)return ce.includes(i)?L((function(){return Ge.handlerDistribute(r,i,o)})):L((function(){return Ge[i].apply(Ge,o)}));D("SDK未初始化!","error")}}else if(de.includes(i))D("方法 ".concat(y(i)," 已被弃用,请移除!"),"warn");else{if("canIUse"===i)return le.includes(arguments[1])&&!!Ge[arguments[1]];D("不存在名为 ".concat(y(i)," 的方法调用!"),"error")}};Z().gdp=Qe,Z().gioSDKVersion=Ge.sdkVersion;var $e=Ge.dataStore.eventHooks,ze=$e.growingApp,We=$e.growingPage,Je=$e.growingComponent,Ye=$e.growingBehavior;(0,$e.initOriginalValue)();var Ze=L((function(){return null!=ze?ze:App})),Xe=L((function(){return null!=We?We:Page})),et=L((function(){return null!=Je?Je:Component})),nt=L((function(){return null!=Ye?Ye:Behavior}));export{Ze as GioApp,nt as GioBehavior,et as GioComponent,Xe as GioPage,Qe as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t=function(e){return["undefined","null"].includes(
|
|
1
|
+
var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t=function(e){return["undefined","null"].includes(d(e))},r=function(e){return"string"===d(e)},n=function(e){return"NaN"===c(Number(e))},i=function(e){return"number"===d(e)},o=function(e){return"[object Object]"==={}.toString.call(e)&&!t(e)},a=function(e){return Array.isArray(e)&&"array"===d(e)},c=function(e){return t(e)?"":"".concat(e)},s=function(e){return o(e)?Object.keys(e):[]},u=function(e,t){if(!o(e))return!1;try{if("string"===d(t))return delete e[t];if("array"===d(t))return t.map((function(t){return delete e[t]}));"object"===d(t)&&t.constructor===RegExp&&s(e).forEach((function(r){t.test(r)&&u(e,r)}))}catch(e){return!1}},g=function(e){return a(e)?0===e.length:o(e)?0===s(e).length:!e},d=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},l=/^\d+_gdp_abt_sign$/,f=/^\d+_gdp_abtd$/,v=function(e,t){console.log("%c[GrowingIO]:".concat(e),{info:"color: #3B82F6;",error:"color: #EF4444",warn:"color: #F59E0B",success:"color: #10B981"}[t]||"")},m=function(e,t){if(["function","asyncfunction"].includes(d(e)))try{e(t)}catch(e){v("回调执行失败!".concat(e),"error")}},y=function(e){var r={};return o(e)&&(u(e,"&&sendTo"),function(e){s(e).forEach((function(n){return function(e,n){var i=c(n).slice(0,100);o(e)?r[i]=y(e):a(e)?(r[i]=function(e,t){if(void 0===t&&(t=!1),a(e)){for(var r=0,n=[],i=0,o=e;i<o.length;i++){var c=o[i];c&&!g(c)&&(n[r++]=c),t&&0===c&&(n[r++]=c)}return n}return e}(e.slice(0,100),!0),r[i]=r[i].join("||").slice(0,1e3)):function(e){return"date"===d(e)}(e)?r[i]=function(e){function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())}(e):r[i]=t(e)?"":c(e).slice(0,1e3)}(e[n],n)}))}(e)),r},I=function(e,t){void 0===t&&(t=!1);var r=0;if(g(e)||"boolean"==typeof e)return r;for(var n=0;n<e.length;)r=(r<<5)-r+e.charCodeAt(n),r|=0,n++;return t?Math.abs(r):r},p={name:"gioABTest",method:function(t,a){var d=this;this.growingIO=t,this.timeoutCheck=function(e,t){d.requestInterval=i(Number(e))&&!n(Number(e))?Number(e):5,(d.requestInterval>1440||0>d.requestInterval)&&(d.requestInterval=5),d.requestTimeout=i(Number(t))&&!n(Number(t))?Number(t):1e3,(d.requestTimeout>5e3||100>d.requestTimeout)&&(d.requestTimeout=1e3)},this.abtStorageCheck=function(){var e,t=d.growingIO.minipInstance,r=(null===(e=t.minip)||void 0===e?void 0:e.getStorageInfoSync().keys)||[];r.filter((function(e){return l.test(e)})).forEach((function(e){var r=t.getStorageSync(e);r&&r>=Date.now()||t.removeStorageSync(e)})),r.filter((function(e){return f.test(e)})).forEach((function(e){g(t.getStorageSync(e))&&t.removeStorageSync(e)}))},this.getHashKey=function(e,t){var r=d.growingIO,n=r.userStore.getUid,i=r.vdsConfig.projectId;return I("".concat(e,"#").concat(i,"#").concat(n(),"#").concat(t),!0)},this.generateUrl=function(e,t){var n,i;d.newDevice&&!d.visitSids[e]&&(d.visitSids[e]=d.growingIO.userStore.getSessionId(e)),i="http",r(n=t)||(n=c(n)),n.slice(0,4)!==i?d.url[e]="https://".concat(t,"/diversion/specified-layer-variables"):d.url[e]="".concat(t,"/diversion/specified-layer-variables")},this.getABTest=function(e,t,r){if(g(d.url[e])&&d.generateUrl(e,"https://ab.growingio.com"),!t)return v("获取ABTest数据失败! 实验层Id不合法!","error"),void m(r,{});var n=d.growingIO.minipInstance,i=n.getStorageSync("".concat(d.getHashKey(e,t),"_gdp_abt_sign"))||0,o=n.getStorageSync("".concat(d.getHashKey(e,t),"_gdp_abtd"))||{};!i||i<Date.now()?d.initiateRequest(e,t,o,r):m(r,o)},this.initiateRequest=function(t,r,n,i){var o=d.growingIO,a=o.userStore,c=a.getUid,s=a.getSessionId,u=o.dataStore,g=o.minipInstance,l=u.getTrackerVds(t),f=l.projectId,y=l.dataSourceId;g.request({url:d.url[t],header:{"Content-Type":"application/x-www-form-urlencoded"},method:"POST",data:{accountId:f,datasourceId:y,distinctId:c(),layerId:r,newDevice:d.visitSids[t]===s(t)},timeout:d.requestTimeout,success:function(o){var a=o.data;0===a.code?d.experimentVerify(t,e(e({},a),{layerId:r}),n,i):(v("获取ABTest数据失败! ".concat(a.errorMsg,"!"),"error"),m(i,{})),g.setStorageSync("".concat(d.getHashKey(t,r),"_gdp_abt_sign"),Date.now()+6e4*d.requestInterval)},fail:function(e){var o=e.errMsg;o.indexOf("timeout")>-1?(v("获取ABTest数据失败! 请求超时!","error"),m(i,{})):2>d.retryCount?(d.initiateRequest(t,r,n,i),d.retryCount+=1):(v("获取ABTest数据失败! ".concat(JSON.stringify(o).slice(0,30),"!"),"error"),m(i,{}))}})},this.experimentVerify=function(t,r,n,i){var o=r.layerId,a=r.strategyId,s=r.experimentId,g=r.layerName,l=r.experimentName,f=r.strategyName,v=r.variables,y="".concat(d.getHashKey(t,o),"_gdp_abtd"),p={layerId:c(o),strategyId:c(a),experimentId:c(s),variables:v},h=e({},n);u(h,["layerName","strategyName","experimentName"]);var S=I(JSON.stringify(p)),b=I(JSON.stringify(h)),w=e(e({},p),{layerName:g,strategyName:f,experimentName:l});d.growingIO.minipInstance.setStorageSync(y,w,new Date((new Date).getFullYear(),(new Date).getMonth(),(new Date).getDate()+1).getTime()),S!==b&&a&&s&&d.buildExperimentHitEvent(t,w),m(i,w)},this.buildExperimentHitEvent=function(t,r){var n,i=d.growingIO.dataStore,o=i.eventContextBuilder,a=i.eventConverter,c=e({eventType:"CUSTOM",eventName:"$exp_hit"},o(t)),s=r.layerId,u=r.experimentId,g=r.strategyId,l=r.layerName,f=r.experimentName,v=r.strategyName;c.attributes=y(e(e({},null!==(n=c.attributes)&&void 0!==n?n:{}),{$exp_layer_id:s,$exp_id:u,$exp_strategy_id:g,$exp_layer_name:l,$exp_name:f,$exp_strategy_name:v})),a(c)},this.pluginVersion="4.4.0";var p=null!=a?a:{},h=p.abServerUrl,S=void 0===h?"https://ab.growingio.com":h,b=p.requestInterval,w=p.requestTimeout;this.timeoutCheck(b,w);var _=this.growingIO,N=_.emitter,O=_.userStore;this.growingIO.getABTest=this.getABTest,this.visitSids={},N.on("OPTION_INITIALIZED",(function(){g(S)?v("如果您需要使用ABTest功能,请配置服务地址 abServerUrl!","warn"):(d.abtStorageCheck(),d.url={},r(S)?d.generateUrl(d.growingIO.trackingId,S):o(S)&&s(S).forEach((function(e){d.generateUrl(e,S[e])})))})),N.on("UID_UPDATE",(function(e){var t=e.newUId;if(!e.oldUId&&t)if(r(S)){var n=d.growingIO.trackingId,i=O.getSessionId(n);d.visitSids[n]=i}else o(S)&&s(S).forEach((function(e){var t=O.getSessionId(e);d.visitSids[e]=t}))})),this.retryCount=0}};export{p as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var r={name:"gioCompress",method:function(r){var o=this;this.growingIO=r,this.compressToUTF16=function(r){var e=o;return null===r?"":o._compress(r,15,(function(r){return e.f(r+32)}))+" "},this.pluginVersion="4.
|
|
1
|
+
var r={name:"gioCompress",method:function(r){var o=this;this.growingIO=r,this.compressToUTF16=function(r){var e=o;return null===r?"":o._compress(r,15,(function(r){return e.f(r+32)}))+" "},this.pluginVersion="4.4.0",this.f=String.fromCharCode,this._compress=function(r,o,e){if(null===r)return"";var s,h,t,f={},a={},p="",n="",i="",u=2,l=3,c=2,d=[],w=0,C=0;for(t=0;t<r.length;t+=1)if(p=r.charAt(t),{}.hasOwnProperty.call(f,p)||(f[p]=l++,a[p]=!0),n=i+p,{}.hasOwnProperty.call(f,n))i=n;else{if({}.hasOwnProperty.call(a,i)){if(256>i.charCodeAt(0)){for(s=0;c>s;s++)w<<=1,C===o-1?(C=0,d.push(e(w)),w=0):C++;for(h=i.charCodeAt(0),s=0;8>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1}else{for(h=1,s=0;c>s;s++)w=w<<1|h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h=0;for(h=i.charCodeAt(0),s=0;16>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1}0==--u&&(u=Math.pow(2,c),c++),delete a[i]}else for(h=f[i],s=0;c>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1;0==--u&&(u=Math.pow(2,c),c++),f[n]=l++,i=p+""}if(""!==i){if({}.hasOwnProperty.call(a,i)){if(256>i.charCodeAt(0)){for(s=0;c>s;s++)w<<=1,C===o-1?(C=0,d.push(e(w)),w=0):C++;for(h=i.charCodeAt(0),s=0;8>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1}else{for(h=1,s=0;c>s;s++)w=w<<1|h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h=0;for(h=i.charCodeAt(0),s=0;16>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1}0==--u&&(u=Math.pow(2,c),c++),delete a[i]}else for(h=f[i],s=0;c>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1;0==--u&&(u=Math.pow(2,c),c++)}for(h=2,s=0;c>s;s++)w=w<<1|1&h,C===o-1?(C=0,d.push(e(w)),w=0):C++,h>>=1;for(;;){if(w<<=1,C===o-1){d.push(e(w));break}C++}return d.join("")}}};export{r as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++)for(var i in t=arguments[n])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t,n=/^\d{1,10}$/,r=/^_[0-9a-z]+/,i=/^_n_[0-9]+$/,o=function(e){return"[object Object]"==={}.toString.call(e)&&!function(e){return["undefined","null"].includes(a(e))}(e)},a=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},l=function(e){var t;return"string"===a(e)?null!==(t=function(){try{return JSON.parse(e)}catch(e){return}}())&&void 0!==t?t:{}:null!=e?e:{}},c="ON_SEND_AFTER",u={name:"gioEventAutoTracking",method:function(u){var s=this;this.growingIO=u,this.circleOpen=!1,this.main=function(e,n){var r,i,o=s.growingIO,a=o.vdsConfig,l=o.platformConfig,c=o.plugins,u=o.emitter,d=o.trackingId;if(!(!a.autotrack||!n||t.get(e,"currentTarget.dataset.growingIgnore")||t.get(e,"target.dataset.growingIgnore")||!t.get(e,"target.dataset.growingTrack")&&"autoplay"===t.get(e,"detail.source")||e.type===(null===(r=s.prevEvent)||void 0===r?void 0:r.type)&&10>Math.abs(Number(e.timeStamp)-Number(null===(i=s.prevEvent)||void 0===i?void 0:i.timeStamp))||a.taro&&["eh"].includes(n))){s.prevEvent=e,a.uniVue&&(n=null==c?void 0:c.gioUniAppAdapter.getHandlerName(n,e)),a.debug&&console.log("Action:",e.type,Date.now()),u.emit("ON_COMPOSE_BEFORE",{event:n,params:null!=e?e:{}});var g=l.listeners.actions;g.click.includes(e.type)?s.buildClickEvent(d,e,n):g.change.includes(e.type)&&s.buildChangeEvent(d,e,n)}},this.getNodeXpath=function(e,t){var n,o,a,l=s.growingIO,c=l.gioPlatform,u=l.vdsConfig,d=(e.currentTarget||e.target).id;return(!d||"swan"===c&&r.test(d)||(o=(n=u.taro).Current,a=n.createComponent,n&&o&&!a&&i.test(d)))&&(d=""),"".concat(d,"#").concat(t)},this.buildClickEvent=function(r,i,o){var a,l,c,u,d=s.getNodeXpath(i,o);if(d){var g=s.growingIO.dataStore,v=g.eventContextBuilder,p=g.eventInterceptor,h=g.eventHooks,f=i.currentTarget||i.target,m=void 0;if(t.has(null==f?void 0:f.dataset,"index")&&""!==(null===(a=null==f?void 0:f.dataset)||void 0===a?void 0:a.index)){var I=t.toString(f.dataset.index);n.test(I)&&I-0>0&&2147483647>I-0?m=+I:(u="".concat(f.dataset.index,",index标记应为 大于 0 且小于 2147483647 的整数!"),console.log("%c[GrowingIO]:".concat(u),"color: #F59E0B"))}var C=e({eventType:"VIEW_CLICK",element:[{xpath:d,index:m,textValue:null===(l=null==f?void 0:f.dataset)||void 0===l?void 0:l.title,hyperlink:null===(c=null==f?void 0:f.dataset)||void 0===c?void 0:c.src}]},v(r));C.attributes=h.currentPage.eventSetPageProps(r,C),p(C)}},this.buildTabClickEvent=function(n,r){var i=s.growingIO.dataStore,o=i.eventContextBuilder,a=i.eventInterceptor,l=i.eventHooks,c=e({eventType:"VIEW_CLICK",element:[{xpath:"#onTabItemTap",textValue:r.text,index:r.index+1,hyperlink:t.toString(r.pagePath)}]},o(n));c.attributes=l.currentPage.eventSetPageProps(n,c),a(c)},this.buildChangeEvent=function(n,r,i){var o,a,l=s.getNodeXpath(r,i);if(l){var c=s.growingIO.dataStore,u=c.eventContextBuilder,d=c.eventInterceptor,g=c.eventHooks,v=r.currentTarget||r.target,p=e({eventType:"VIEW_CHANGE",element:{xpath:l}},u(n)),h=t.get(r,"detail.value")||t.get(r,"target.attr.value");((null===(o=null==v?void 0:v.dataset)||void 0===o?void 0:o.growingTrack)||(null===(a=null==v?void 0:v.dataset)||void 0===a?void 0:a.growingtrack))&&(t.isNil(h)||(p.element.textValue=t.toString(h))),p.element=[p.element],p.attributes=g.currentPage.eventSetPageProps(n,p),d(p)}},this.listenForLunchEvent=function(){s.growingIO.emitter.on("MINIP_LIFECYCLE",(function(e){var t=e.event,n=e.params;["App onLaunch","App onShow"].includes(t)&&s.circleInit(n)}))},this.circleInit=function(e){var t,n=s.growingIO.emitter,r=l(null===(t=e.referrerInfo)||void 0===t?void 0:t.extraData);(null==r?void 0:r.gdpCircleRoomCollectUrl)&&(s.circleServerUrl!==(null==r?void 0:r.gdpCircleRoomCollectUrl)&&(s.circleServerUrl=null==r?void 0:r.gdpCircleRoomCollectUrl,n.off(c,s.collectorSendFn),n.on(c,s.collectorSendFn),s.showPromptModal("enter")),s.circleOpen=!0)},this.collectorSendFn=function(e){var t,n=e.requestData,r=e.trackingId,i=s.growingIO.uploader;if(s.circleOpen){var l=n.filter((function(e){return"CUSTOM"!==e.eventType&&r===s.growingIO.trackingId}));if(!(function(e){return Array.isArray(e)&&"array"===a(e)}(t=l)?0===t.length:o(t)?0===function(e){return o(e)?Object.keys(e):[]}(t).length:!t))if(i.requestingNum<i.requestLimit)s.circleRequest(l);else var c=setInterval((function(){i.requestingNum<i.requestLimit&&(s.circleRequest(l),clearInterval(c),c=void 0)}),500)}},this.circleClose=function(){s.circleOpen=!1,s.circleServerUrl="",s.growingIO.emitter.off(c,s.collectorSendFn)},this.showPromptModal=function(e,t){s.growingIO.minipInstance.minip.showModal({title:"GrowingIO提示",content:"error"===e?t:"您已进入圈选模式",showCancel:!1})},this.circleRequest=function(e){s.growingIO.minipInstance.request({url:s.circleServerUrl,header:{"content-type":"application/json;charset=UTF-8"},method:"POST",data:e,complete:function(e){var t=e.statusCode,n=e.data,r=e.errMsg;[200,204].includes(t)&&(null==n?void 0:n.success)||(s.showPromptModal("error",(null==n?void 0:n.message)||n||r||"圈选请求失败,请重试!"),s.circleClose())}})},this.pluginVersion="4.4.0",t=this.growingIO.utils,this.prevEvent={},this.listenForLunchEvent()}};export{u as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t,r=/^gioTrack(.+)/,n=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,i=function(e){return["undefined","null"].includes(p(e))},o=function(e){return"string"===p(e)},s=function(e){return"[object Object]"==={}.toString.call(e)&&!i(e)},c=function(e){return Array.isArray(e)&&"array"===p(e)},a=function(e,t){if(void 0===t&&(t=!1),c(e)){for(var r=0,n=[],i=0,o=e;i<o.length;i++){var s=o[i];s&&!d(s)&&(n[r++]=s),t&&0===s&&(n[r++]=s)}return n}return e},u=function(e){return i(e)?"":"".concat(e)},l=function(e){return s(e)?Object.keys(e):[]},g=function(e,t){if(!s(e))return!1;try{if("string"===p(t))return delete e[t];if("array"===p(t))return t.map((function(t){return delete e[t]}));"object"===p(t)&&t.constructor===RegExp&&l(e).forEach((function(r){t.test(r)&&g(e,r)}))}catch(e){return!1}},d=function(e){return c(e)?0===e.length:s(e)?0===l(e).length:!e},p=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},v=function(e){try{return e()}catch(e){return}},f=function(e){var t={};return s(e)&&(g(e,"&&sendTo"),function(e){l(e).forEach((function(r){return function(e,r){var n=u(r).slice(0,100);s(e)?t[n]=f(e):c(e)?(t[n]=a(e.slice(0,100),!0),t[n]=t[n].join("||").slice(0,1e3)):function(e){return"date"===p(e)}(e)?t[n]=function(e){function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())}(e):t[n]=i(e)?"":u(e).slice(0,1e3)}(e[r],r)}))}(e)),t},m=function(e,t){void 0===t&&(t=!1);var r=0;if(d(e)||"boolean"==typeof e)return r;for(var n=0;n<e.length;)r=(r<<5)-r+e.charCodeAt(n),r|=0,n++;return t?Math.abs(r):r},I={name:"gioImpressionTracking",method:function(i){var l=this;this.growingIO=i,this.traverseListen=function(e){var r=l.growingIO.minipInstance;if(t.isFunction(null==e?void 0:e.selectAllComponents)){var n=null==e?void 0:e.selectAllComponents(".growing_collect_imp_component");t.isEmpty(n)||n.forEach((function(e){l.traverseListen(e)}))}r.initImpression(e)},this.isEqualRects=function(e,t,r){var n,i,o,s,a=(null!==(i=(null!==(n=l.rects[t])&&void 0!==n?n:{})[r])&&void 0!==i?i:[]).map((function(e){return m(JSON.stringify(e))})),u=(null!=e?e:[]).map((function(e){return m(JSON.stringify(e))}));return s=u,!(!c(o=a)||!c(s)||o.length!==s.length)&&o.every((function(e,t){return e===s[t]}))},this.getNodeId=function(e){switch(l.growingIO.gioPlatform){case"wx":case"qq":case"ks":case"jd":return e.__wxExparserNodeId__;case"my":case"tb":return e.$page?"".concat(e.$page.$id,"-").concat(e.$id):e.$id;case"swan":return e.route?u(m(e.route)):e.nodeId;case"tt":return e.route?u(m(e.route)):e.__nodeId__}},this.rectObserve=function(e,r,n){var i=l.growingIO.gioPlatform;if("tt"===i&&r.__nodeId__||"ks"===i&&r.is)return!1;var o=l.getNodeId(r),s=r.route?r:l.growingIO.minipInstance.getCurrentPage(),c=!1;if(s.route){var a=l.isEqualRects(e,s.route,o),u=t.get(l.observerIds,"".concat(s.route,".").concat(o,"._disconnected"));c=!a||!1!==u}t.isArray(e)&&!t.isEmpty(e)&&!t.isNil(e[0])&&c&&(t.isEmpty(l.rects[s.route])&&(l.rects[s.route]={}),l.rects[s.route][o]=e,l.createObserver(r,n))},this.main=function(e,r){var n,i,o=l.growingIO.gioPlatform,s=e.route?null===(n=l.growingIO.minipInstance.minip)||void 0===n?void 0:n.createSelectorQuery():null===(i=l.growingIO.minipInstance.minip)||void 0===i?void 0:i.createSelectorQuery().in(e);["ks","qq"].includes(o)?(s.selectAll(".growing_collect_imp").boundingClientRect((function(n){var i=n[0],o=void 0===i?[]:i;o=t.isArray(o)?o:[o],d(o)||l.rectObserve(o,e,r)})),s.exec()):(s.selectAll(".growing_collect_imp").boundingClientRect(),s.exec((function(t){var n=t[0];d(n)||l.rectObserve(n,e,r)})))},this.createObserver=function(e,r){var n,i,o=l.growingIO,s=o.gioPlatform,c=o.minipInstance,a=((n={thresholds:[o.vdsConfig.impressionScale||1e-13]})[r]=!0,n);["tb","my"].includes(s)&&t.compareVersion(my.SDKVersion,"2.7.0")>=-1&&(a.dataset=!0);var u=l.getNodeId(e),g=e;!e.isComponent&&e.route&&"component"!==e.mpType||(g=c.getCurrentPage()),l.observerIds[g.route]||(l.observerIds[g.route]={});var d=l.observerIds[g.route][u];d&&!d._disconnected&&d.disconnect();var p=["swan","jd"].includes(s)?null===(i=c.minip)||void 0===i?void 0:i.createIntersectionObserver(e,a):e.createIntersectionObserver(a);p=p.relativeToViewport(),l.observerIds[g.route][u]=p,l.targetObserve(p,g)},this.targetObserve=function(e,r){var n=l.growingIO.vdsConfig,i=n.taro,s=n.impressionScale||1e-13;e.observe(".growing_collect_imp",(function(e){if(!t.isEmpty(e)&&e.intersectionRatio>=s){var n=e.dataset;i&&t.isTaro3(i)&&(n=l.getTaro3Dataset(r.route,e.id));var u=l.getImpressionProperties(n),g=e.id;if(g){if("once"===n.gioImpType&&t.has(l.sentImps,g))return;l.sentImps[g]=u}if(u.eventName){var p=[];n.gioImpSendto&&(p=a(c(n.gioImpSendto)?n.gioImpSendto:v((function(){return JSON.parse(n.gioImpSendto)}))||[]),d(p)&&v((function(){return n.gioImpSendto.split(",").forEach((function(e){(e=o(e)&&e.trim().replace("[","").replace("]",""))&&p.push(e)}))}))),l.buildImpEvent(u,p)}else t.consoleText("曝光事件格式不正确,事件名只能包含数字、字母和下划线,且不以数字开头!","warn")}}))},this.getImpressionProperties=function(e){var i,s,c={eventName:void 0,properties:{}};if(!(null==e?void 0:e.gioImpTrack))return c;if(c.eventName=e.gioImpTrack,t.has(e,"gioImpAttrs"))c.properties=t.niceTry((function(){return t.isObject(e.gioImpAttrs)?e.gioImpAttrs:JSON.parse(e.gioImpAttrs)}));else for(var a in e){var u=void 0,l=a.match(r);l&&"track"!==(u=t.lowerFirst(l[1]))&&(c.properties[u]=e[a])}return c.properties=t.limitObject(c.properties),i=c.eventName,s=function(){return c},(o(i)&&!d(i)&&i.match(n)?s():(console.log("%c[GrowingIO]:事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","color: #EF4444"),!1))||(c.eventName=null,c={}),c},this.getTaro3Dataset=function(e,r){var n,i=null===(n=l.growingIO)||void 0===n?void 0:n.taro3VMs[e];if(!i)return!1;var o={},s=function(e){e.some((function(e){var n;return e.uid!==r&&e.sid!==r||-1>=(null===(n=e.props)||void 0===n?void 0:n.class.indexOf("growing_collect_imp"))||t.isEmpty(e.dataset)?!!Array.isArray(e.childNodes)&&s(e.childNodes):(o=e.dataset,!0)}))};return s(i.childNodes),o},this.buildImpEvent=function(t,r){var n,i=t.eventName,o=t.properties,c=l.growingIO,a=c.trackingId,u=c.dataStore,g=u.eventContextBuilder,p=u.eventConverter,v=c.plugins,m=e({eventType:"CUSTOM",eventName:i},g(a));m.attributes=f(e(e({},null!==(n=m.attributes)&&void 0!==n?n:{}),s(o)&&!d(o)?o:{})),v.gioMultipleInstances&&!d(r)&&(m["&&sendTo"]=r),p(m)},this.pluginVersion="4.
|
|
1
|
+
var e=function(){return e=Object.assign||function(e){for(var t,r=1,n=arguments.length;n>r;r++)for(var i in t=arguments[r])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var t,r=/^gioTrack(.+)/,n=/^[a-zA-Z_][0-9a-zA-Z_]{0,100}$/,i=function(e){return["undefined","null"].includes(p(e))},o=function(e){return"string"===p(e)},s=function(e){return"[object Object]"==={}.toString.call(e)&&!i(e)},c=function(e){return Array.isArray(e)&&"array"===p(e)},a=function(e,t){if(void 0===t&&(t=!1),c(e)){for(var r=0,n=[],i=0,o=e;i<o.length;i++){var s=o[i];s&&!d(s)&&(n[r++]=s),t&&0===s&&(n[r++]=s)}return n}return e},u=function(e){return i(e)?"":"".concat(e)},l=function(e){return s(e)?Object.keys(e):[]},g=function(e,t){if(!s(e))return!1;try{if("string"===p(t))return delete e[t];if("array"===p(t))return t.map((function(t){return delete e[t]}));"object"===p(t)&&t.constructor===RegExp&&l(e).forEach((function(r){t.test(r)&&g(e,r)}))}catch(e){return!1}},d=function(e){return c(e)?0===e.length:s(e)?0===l(e).length:!e},p=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},v=function(e){try{return e()}catch(e){return}},f=function(e){var t={};return s(e)&&(g(e,"&&sendTo"),function(e){l(e).forEach((function(r){return function(e,r){var n=u(r).slice(0,100);s(e)?t[n]=f(e):c(e)?(t[n]=a(e.slice(0,100),!0),t[n]=t[n].join("||").slice(0,1e3)):function(e){return"date"===p(e)}(e)?t[n]=function(e){function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())}(e):t[n]=i(e)?"":u(e).slice(0,1e3)}(e[r],r)}))}(e)),t},m=function(e,t){void 0===t&&(t=!1);var r=0;if(d(e)||"boolean"==typeof e)return r;for(var n=0;n<e.length;)r=(r<<5)-r+e.charCodeAt(n),r|=0,n++;return t?Math.abs(r):r},I={name:"gioImpressionTracking",method:function(i){var l=this;this.growingIO=i,this.traverseListen=function(e){var r=l.growingIO.minipInstance;if(t.isFunction(null==e?void 0:e.selectAllComponents)){var n=null==e?void 0:e.selectAllComponents(".growing_collect_imp_component");t.isEmpty(n)||n.forEach((function(e){l.traverseListen(e)}))}r.initImpression(e)},this.isEqualRects=function(e,t,r){var n,i,o,s,a=(null!==(i=(null!==(n=l.rects[t])&&void 0!==n?n:{})[r])&&void 0!==i?i:[]).map((function(e){return m(JSON.stringify(e))})),u=(null!=e?e:[]).map((function(e){return m(JSON.stringify(e))}));return s=u,!(!c(o=a)||!c(s)||o.length!==s.length)&&o.every((function(e,t){return e===s[t]}))},this.getNodeId=function(e){switch(l.growingIO.gioPlatform){case"wx":case"qq":case"ks":case"jd":return e.__wxExparserNodeId__;case"my":case"tb":return e.$page?"".concat(e.$page.$id,"-").concat(e.$id):e.$id;case"swan":return e.route?u(m(e.route)):e.nodeId;case"tt":return e.route?u(m(e.route)):e.__nodeId__;case"xhs":return e.pageId}},this.rectObserve=function(e,r,n){var i=l.growingIO.gioPlatform;if("tt"===i&&r.__nodeId__||"ks"===i&&r.is)return!1;var o=l.getNodeId(r),s=r.route?r:l.growingIO.minipInstance.getCurrentPage(),c=!1;if(s.route){var a=l.isEqualRects(e,s.route,o),u=t.get(l.observerIds,"".concat(s.route,".").concat(o,"._disconnected"));c=!a||!1!==u}t.isArray(e)&&!t.isEmpty(e)&&!t.isNil(e[0])&&c&&(t.isEmpty(l.rects[s.route])&&(l.rects[s.route]={}),l.rects[s.route][o]=e,l.createObserver(r,n))},this.main=function(e,r){var n,i,o=l.growingIO.gioPlatform,s=e.route?null===(n=l.growingIO.minipInstance.minip)||void 0===n?void 0:n.createSelectorQuery():null===(i=l.growingIO.minipInstance.minip)||void 0===i?void 0:i.createSelectorQuery().in(e);["ks","qq"].includes(o)?(s.selectAll(".growing_collect_imp").boundingClientRect((function(n){var i=n[0],o=void 0===i?[]:i;o=t.isArray(o)?o:[o],d(o)||l.rectObserve(o,e,r)})),s.exec()):(s.selectAll(".growing_collect_imp").boundingClientRect(),s.exec((function(t){var n=t[0];d(n)||l.rectObserve(n,e,r)})))},this.createObserver=function(e,r){var n,i,o=l.growingIO,s=o.gioPlatform,c=o.minipInstance,a=((n={thresholds:[o.vdsConfig.impressionScale||1e-13]})[r]=!0,n);["tb","my"].includes(s)&&t.compareVersion(my.SDKVersion,"2.7.0")>=-1&&(a.dataset=!0);var u=l.getNodeId(e),g=e;!e.isComponent&&e.route&&"component"!==e.mpType||(g=c.getCurrentPage()),l.observerIds[g.route]||(l.observerIds[g.route]={});var d=l.observerIds[g.route][u];d&&!d._disconnected&&d.disconnect();var p=["swan","jd","xhs"].includes(s)?null===(i=c.minip)||void 0===i?void 0:i.createIntersectionObserver(e,a):e.createIntersectionObserver(a);p=p.relativeToViewport(),l.observerIds[g.route][u]=p,l.targetObserve(p,g)},this.targetObserve=function(e,r){var n=l.growingIO.vdsConfig,i=n.taro,s=n.impressionScale||1e-13;e.observe(".growing_collect_imp",(function(e){if(!t.isEmpty(e)&&e.intersectionRatio>=s){var n=e.dataset;i&&t.isTaro3(i)&&(n=l.getTaro3Dataset(r.route,e.id));var u=l.getImpressionProperties(n),g=e.id;if(g){if("once"===n.gioImpType&&t.has(l.sentImps,g))return;l.sentImps[g]=u}if(u.eventName){var p=[];n.gioImpSendto&&(p=a(c(n.gioImpSendto)?n.gioImpSendto:v((function(){return JSON.parse(n.gioImpSendto)}))||[]),d(p)&&v((function(){return n.gioImpSendto.split(",").forEach((function(e){(e=o(e)&&e.trim().replace("[","").replace("]",""))&&p.push(e)}))}))),l.buildImpEvent(u,p)}else t.consoleText("曝光事件格式不正确,事件名只能包含数字、字母和下划线,且不以数字开头!","warn")}}))},this.getImpressionProperties=function(e){var i,s,c={eventName:void 0,properties:{}};if(!(null==e?void 0:e.gioImpTrack))return c;if(c.eventName=e.gioImpTrack,t.has(e,"gioImpAttrs"))c.properties=t.niceTry((function(){return t.isObject(e.gioImpAttrs)?e.gioImpAttrs:JSON.parse(e.gioImpAttrs)}));else for(var a in e){var u=void 0,l=a.match(r);l&&"track"!==(u=t.lowerFirst(l[1]))&&(c.properties[u]=e[a])}return c.properties=t.limitObject(c.properties),i=c.eventName,s=function(){return c},(o(i)&&!d(i)&&i.match(n)?s():(console.log("%c[GrowingIO]:事件名格式不正确,只能包含数字、字母和下划线,且不能以数字开头,字符总长度不能超过100!","color: #EF4444"),!1))||(c.eventName=null,c={}),c},this.getTaro3Dataset=function(e,r){var n,i=null===(n=l.growingIO)||void 0===n?void 0:n.taro3VMs[e];if(!i)return!1;var o={},s=function(e){e.some((function(e){var n;return e.uid!==r&&e.sid!==r||-1>=(null===(n=e.props)||void 0===n?void 0:n.class.indexOf("growing_collect_imp"))||t.isEmpty(e.dataset)?!!Array.isArray(e.childNodes)&&s(e.childNodes):(o=e.dataset,!0)}))};return s(i.childNodes),o},this.buildImpEvent=function(t,r){var n,i=t.eventName,o=t.properties,c=l.growingIO,a=c.trackingId,u=c.dataStore,g=u.eventContextBuilder,p=u.eventConverter,v=c.plugins,m=e({eventType:"CUSTOM",eventName:i},g(a));m.attributes=f(e(e({},null!==(n=m.attributes)&&void 0!==n?n:{}),s(o)&&!d(o)?o:{})),v.gioMultipleInstances&&!d(r)&&(m["&&sendTo"]=r),p(m)},this.pluginVersion="4.4.0",t=this.growingIO.utils,this.observerIds={},this.rects={},this.sentImps={};var g=this.growingIO,p=g.emitter,I=g.minipInstance;this.growingIO.updateImpression=function(e){e||(e=I.getCurrentPage()),I.initImpression(e)},p.on("MINIP_LIFECYCLE",(function(e){var t,r=e.event,n=e.params,i=l.growingIO.minipInstance;if("Page onShowEnd"===r){var o=i.getCurrentPage();l.traverseListen(o)}if(["Page onHide","Page onUnload"].includes(r)){var s=n.page.route;Object.values(null!==(t=l.observerIds[s])&&void 0!==t?t:{}).forEach((function(e){return e.disconnect()}))}}))}};export{I as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var n=function(){return n=Object.assign||function(n){for(var r,t=1,i=arguments.length;i>t;t++)for(var e in r=arguments[t])({}).hasOwnProperty.call(r,e)&&(n[e]=r[e]);return n},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r=function(n){return"[object Object]"==={}.toString.call(n)&&!function(n){return["undefined","null"].includes(i(n))}(n)},t=function(n,e){if(!r(n))return!1;try{if("string"===i(e))return delete n[e];if("array"===i(e))return e.map((function(r){return delete n[r]}));"object"===i(e)&&e.constructor===RegExp&&function(n){return r(n)?Object.keys(n):[]}(n).forEach((function(r){e.test(r)&&t(n,r)}))}catch(n){return!1}},i=function(n){return{}.toString.call(n).slice(8,-1).toLowerCase()},e=function(n){try{return n()}catch(n){return}},o=function(){var n;return null!==(n=e((function(){var n;return null!==(n=e((function(){var n;return null!==(n=e((function(){return $global})))&&void 0!==n?n:global})))&&void 0!==n?n:window})))&&void 0!==n?n:globalThis},a=function(r){var a=this;this.growingIO=r,this.getTrackerType=function(n,r){return r.trackingId&&r.trackingId!==n?0:1},this.rewriteDataStore=function(){a.growingIO.dataStore.getTrackerVds=function(r){if(a.growingIO.trackingId===r){var i=n({},a.growingIO.vdsConfig);return t(i,"subInstance"),a.growingIO.plugins.gioTaobaoAdapter||t(i,"tbConfig"),i}return a.growingIO.subInstance[r]?n({},a.growingIO.subInstance[r]):void 0},a.growingIO.dataStore.initTrackerOptions=function(n){var r,i=a.growingIO.dataStore.initOptions(n),e=a.getTrackerType(n.trackingId,a.growingIO);return i.trackingId=n.trackingId,e?(a.growingIO.trackingId=n.trackingId,a.growingIO.vdsConfig=i,o().vdsConfig=i):(t(i,["autotrack","debug","forceLogin","impressionScale","keepAlive","originalSource","performance","pluginMode","sessionExpires","taro","taroVue","tbConfig","uniVue"]),a.growingIO.subInstance[n.trackingId]=i,(null===(r=o().vdsConfig)||void 0===r?void 0:r.subInstance)||(o().vdsConfig.subInstance={}),o().vdsConfig.subInstance[n.trackingId]=i),i},a.growingIO.dataStore.initTrackerHooker=function(n){var r,t;if(a.getTrackerType(n.trackingId,a.growingIO)){var i=a.growingIO,e=i.platformConfig,o=i.inPlugin,g=i.minipInstance,u=i.plugins,c=i.dataStore,s=n.uniVue,d=n.taro;s||d||(e.canHook=!0),o&&!["tbp","jdp"].includes(g.platform)||c.eventHooks.initEventHooks(),s&&(null===(r=null==u?void 0:u.gioUniAppAdapter)||void 0===r||r.main()),d&&(null===(t=null==u?void 0:u.gioTaroAdapter)||void 0===t||t.main())}};var r=a.growingIO.dataStore.eventConverter,g=a;a.growingIO.dataStore.eventConverter=function(){for(var o=this,a=[],u=0;arguments.length>u;u++)a[u]=arguments[u];var c=a[0];if("CUSTOM"===c.eventType){var s=[c.trackingId];e((function(){c["&&sendTo"].forEach((function(n){"string"===i(n)&&g.growingIO.dataStore.getTrackerVds(n)&&!s.includes(n)&&s.push(n)}))})),t(c,"&&sendTo"),s.forEach((function(t){var i=g.growingIO.dataStore.eventContextBuilder,e=n(n({},c),i(t,void 0,c.trackingId!==t));e.attributes=n(n({},e.attributes),c.attributes),r.call(o,e)}))}else r.call(this,c)}},this.onSendBefore=function(n){var r=n.eventsQueue,t=n.requestData;n.trackingId!==a.growingIO.trackingId&&a.growingIO.uploader.sendEvent(r,t)},this.pluginVersion="4.
|
|
1
|
+
var n=function(){return n=Object.assign||function(n){for(var r,t=1,i=arguments.length;i>t;t++)for(var e in r=arguments[t])({}).hasOwnProperty.call(r,e)&&(n[e]=r[e]);return n},n.apply(this,arguments)};"function"==typeof SuppressedError&&SuppressedError;var r=function(n){return"[object Object]"==={}.toString.call(n)&&!function(n){return["undefined","null"].includes(i(n))}(n)},t=function(n,e){if(!r(n))return!1;try{if("string"===i(e))return delete n[e];if("array"===i(e))return e.map((function(r){return delete n[r]}));"object"===i(e)&&e.constructor===RegExp&&function(n){return r(n)?Object.keys(n):[]}(n).forEach((function(r){e.test(r)&&t(n,r)}))}catch(n){return!1}},i=function(n){return{}.toString.call(n).slice(8,-1).toLowerCase()},e=function(n){try{return n()}catch(n){return}},o=function(){var n;return null!==(n=e((function(){var n;return null!==(n=e((function(){var n;return null!==(n=e((function(){return $global})))&&void 0!==n?n:global})))&&void 0!==n?n:window})))&&void 0!==n?n:globalThis},a=function(r){var a=this;this.growingIO=r,this.getTrackerType=function(n,r){return r.trackingId&&r.trackingId!==n?0:1},this.rewriteDataStore=function(){a.growingIO.dataStore.getTrackerVds=function(r){if(a.growingIO.trackingId===r){var i=n({},a.growingIO.vdsConfig);return t(i,"subInstance"),a.growingIO.plugins.gioTaobaoAdapter||t(i,"tbConfig"),i}return a.growingIO.subInstance[r]?n({},a.growingIO.subInstance[r]):void 0},a.growingIO.dataStore.initTrackerOptions=function(n){var r,i=a.growingIO.dataStore.initOptions(n),e=a.getTrackerType(n.trackingId,a.growingIO);return i.trackingId=n.trackingId,e?(a.growingIO.trackingId=n.trackingId,a.growingIO.vdsConfig=i,o().vdsConfig=i):(t(i,["autotrack","debug","forceLogin","impressionScale","keepAlive","originalSource","performance","pluginMode","sessionExpires","taro","taroVue","tbConfig","uniVue"]),a.growingIO.subInstance[n.trackingId]=i,(null===(r=o().vdsConfig)||void 0===r?void 0:r.subInstance)||(o().vdsConfig.subInstance={}),o().vdsConfig.subInstance[n.trackingId]=i),i},a.growingIO.dataStore.initTrackerHooker=function(n){var r,t;if(a.getTrackerType(n.trackingId,a.growingIO)){var i=a.growingIO,e=i.platformConfig,o=i.inPlugin,g=i.minipInstance,u=i.plugins,c=i.dataStore,s=n.uniVue,d=n.taro;s||d||(e.canHook=!0),o&&!["tbp","jdp"].includes(g.platform)||c.eventHooks.initEventHooks(),s&&(null===(r=null==u?void 0:u.gioUniAppAdapter)||void 0===r||r.main()),d&&(null===(t=null==u?void 0:u.gioTaroAdapter)||void 0===t||t.main())}};var r=a.growingIO.dataStore.eventConverter,g=a;a.growingIO.dataStore.eventConverter=function(){for(var o=this,a=[],u=0;arguments.length>u;u++)a[u]=arguments[u];var c=a[0];if("CUSTOM"===c.eventType){var s=[c.trackingId];e((function(){c["&&sendTo"].forEach((function(n){"string"===i(n)&&g.growingIO.dataStore.getTrackerVds(n)&&!s.includes(n)&&s.push(n)}))})),t(c,"&&sendTo"),s.forEach((function(t){var i=g.growingIO.dataStore.eventContextBuilder,e=n(n({},c),i(t,void 0,c.trackingId!==t));e.attributes=n(n({},e.attributes),c.attributes),r.call(o,e)}))}else r.call(this,c)}},this.onSendBefore=function(n){var r=n.eventsQueue,t=n.requestData;n.trackingId!==a.growingIO.trackingId&&a.growingIO.uploader.sendEvent(r,t)},this.pluginVersion="4.4.0",this.subTrackingIds=[],this.growingIO.emitter.on("ON_SDK_INITIALIZE_BEFORE",(function(){a.growingIO.trackingId||a.rewriteDataStore(),a.growingIO.subInstance||(a.growingIO.subInstance={})})),this.growingIO.emitter.on("OPTION_INITIALIZED",(function(n){var r=n.trackingId;a.growingIO.trackingId&&a.growingIO.trackingId!==r&&a.subTrackingIds.push(r)}))},g={name:"gioMultipleInstances",method:a};export{a as GioMultipleInstances,g as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=function(){return e=Object.assign||function(e){for(var t,n=1,r=arguments.length;r>n;n++)for(var i in t=arguments[n])({}).hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},e.apply(this,arguments)};function t(e,t,n){if(n||2===arguments.length)for(var r,i=0,o=t.length;o>i;i++)!r&&i in t||(r||(r=[].slice.call(t,0,i)),r[i]=t[i]);return e.concat(r||[].slice.call(t))}"function"==typeof SuppressedError&&SuppressedError;var n,r=function(e){return["undefined","null"].includes(P(e))},i=function(e){return"string"===P(e)},o=function(e){return"[object Object]"==={}.toString.call(e)&&!r(e)},a=function(e){return"[object RegExp]"==={}.toString.call(e)},s=function(e){return["function","asyncfunction"].includes(P(e))},u=function(e){return Array.isArray(e)&&"array"===P(e)},c=function(e){try{return Array.from(e)[0]}catch(e){return}},l=function(e,t){if(void 0===t&&(t=!1),u(e)){for(var n=0,r=[],i=0,o=e;i<o.length;i++){var a=o[i];a&&!v(a)&&(r[n++]=a),t&&0===a&&(r[n++]=a)}return r}return e},f=function(e){return r(e)?"":"".concat(e)},d={}.hasOwnProperty,p=function(e,t){return!r(e)&&d.call(e,t)},h=function(e){return o(e)?Object.keys(e):[]},g=function(e,t){h(e).forEach((function(n){return t(e[n],n)}))},m=function(e,t){if(!o(e))return!1;try{if("string"===P(t))return delete e[t];if("array"===P(t))return t.map((function(t){return delete e[t]}));"object"===P(t)&&t.constructor===RegExp&&h(e).forEach((function(n){t.test(n)&&m(e,n)}))}catch(e){return!1}},v=function(e){return u(e)?0===e.length:o(e)?0===h(e).length:!e},P=function(e){return{}.toString.call(e).slice(8,-1).toLowerCase()},I=function(e){var t={};return o(e)&&(m(e,"&&sendTo"),g(e,(function(e,n){var i=f(n).slice(0,100);o(e)?t[i]=I(e):u(e)?(t[i]=l(e.slice(0,100),!0),t[i]=t[i].join("||").slice(0,1e3)):function(e){return"date"===P(e)}(e)?t[i]=function(e){function t(e){return 10>e?"0"+e:e}return e.getFullYear()+"-"+t(e.getMonth()+1)+"-"+t(e.getDate())+" "+t(e.getHours())+":"+t(e.getMinutes())+":"+t(e.getSeconds())+"."+t(e.getMilliseconds())}(e):t[i]=r(e)?"":f(e).slice(0,1e3)}))),t},w="SDK_INITIALIZED",E=function(t){var n,r,i,o,a=this;this.growingIO=t,this.listenerSet=!1,this.setListeners=function(){var e,t,n;a.listenerSet||(a.minipInst.canIUse("onError")&&(null===(e=a.minipInst)||void 0===e||e.onError((function(e){a.errorParse(e)}))),a.minipInst.canIUse("onUnhandledRejection")&&(null===(t=a.minipInst)||void 0===t||t.onUnhandledRejection((function(e){e.reason.stack&&a.errorParse(e.reason.stack,e.reason.message)}))),a.minipInst.canIUse("onLazyLoadError")&&(null===(n=a.minipInst)||void 0===n||n.onLazyLoadError((function(e){a.buildErrorEvent({error_type:e.errMsg,error_content:f(e.subpackage)})})))),a.listenerSet=!0},this.hookNavigate=function(){var t=a;["switchTab","reLaunch","redirectTo","navigateTo","navigateBack"].forEach((function(n){var r=a.minipInst[n];Object.defineProperty(a.minipInst,n,{writable:!0,enumerable:!0,configurable:!0,value:function(){for(var i,o=[],a=0;arguments.length>a;a++)o[a]=arguments[a];var s=null!==(i=o[0])&&void 0!==i?i:{},u=null==s?void 0:s.fail;return r.call(this,e(e({},s),{fail:function(e){var r;if(null===(r=t.growingIO.plugins.gioPerformance)||void 0===r||r.buildPerfEvent("Error",{error_type:"".concat(n," Error"),error_content:e.errMsg}),"function"==typeof u)return u(e)}}))}})}))},this.errorParse=function(e,t){var n,r,i=e.split("\n");i.length?(i.find((function(e,t){var o=e.match(/at (.*?) \((.*):(\d{1,}):(\d{1,})\)/);if(u(o))return n=i[t-1],r=e.trim(),o.length})),n||(n=i[0]),r||(r=i[1])):(n=t||"Error",r=e.substring(0,100)),a.buildErrorEvent({error_type:t||n,error_content:r})},this.minipInst=this.growingIO.minipInstance.minip,this.cacheQueue=[],this.buildErrorEvent=function(e){var t;return null===(t=a.growingIO.plugins.gioPerformance)||void 0===t?void 0:t.buildPerfEvent("apm_system_error",e)},this.setListeners(),this.hookNavigate(),s(null===(n=this.minipInst)||void 0===n?void 0:n.onAppShow)&&(null===(r=this.minipInst)||void 0===r||r.onAppShow(this.setListeners)),s(null===(i=this.minipInst)||void 0===i?void 0:i.onAppHide)&&(null===(o=this.minipInst)||void 0===o||o.onAppHide((function(){a.minipInst.canIUse("offError")&&a.minipInst.offError(),a.minipInst.canIUse("offUnhandledRejection")&&a.minipInst.offUnhandledRejection(),a.minipInst.canIUse("offLazyLoadError")&&a.minipInst.offLazyLoadError(),a.listenerSet=!1}))),this.growingIO.emitter.on(w,(function(){v(a.cacheQueue)||a.cacheQueue.forEach((function(e){a.buildErrorEvent(e)}))}))},b=function(t){var n=this;this.growingIO=t,this.lastWarm=!1,this.referrerPath="",this.lastUnloadPath="",this.initObserver=function(){var e=n.minipInst.canIUse("getPerformance")?n.minipInst.getPerformance():{},t=null==e?void 0:e.createObserver((function(e){n.handleLaunch(c(e.getEntriesByName("appLaunch"))),n.handleFCP(c(e.getEntriesByName("firstContentfulPaint"))),n.handleLCP(c(e.getEntriesByName("largestContentfulPaint"))),n.handleRoute(c(e.getEntriesByName("route")))}));null==t||t.observe({entryTypes:["render","script","navigation"]})},this.handleLaunch=function(t){v(t)||(n.appPerf=e(e({},n.appPerf),{appStartTime:t.startTime,appDuration:t.duration,firstPath:t.path}))},this.handleFCP=function(t){v(t)||(n.pagePerf[t.path]=e(e({},n.pagePerf[t.path]),{FCPStartTime:t.startTime})),n.entriesValidate(null!=t?t:{name:"firstContentfulPaint"})},this.handleLCP=function(t){v(t)||(n.pagePerf[t.path]=e(e({},n.pagePerf[t.path]),{LCPStartTime:t.startTime})),n.entriesValidate(null!=t?t:{name:"largestContentfulPaint"})},this.handleRoute=function(t){v(t)||(n.pagePerf[t.path]=e(e({},n.pagePerf[t.path]),{navigationStart:t.startTime,routeDuration:t.duration})),n.entriesValidate(null!=t?t:{name:"route"})},this.entriesValidate=function(e){var t=e.path||n.growingIO.minipInstance.getCurrentPage().route;n.pagePerf[t]||(n.pagePerf[t]={path:t}),n.pagePerf[t].entries||(n.pagePerf[t].entries=[]),n.pagePerf[t].entries.push(e.name);var r=["firstContentfulPaint","largestContentfulPaint","route"],i=!0;n.pagePerf[t].entries.length<r.length&&(i=!1),r.forEach((function(e){n.pagePerf[t].entries.includes(e)||(i=!1)})),i&&n.handleEvent(t)},this.handleEvent=function(e){var t=n.growingIO.dataStore.eventHooks.currentPage,r={title:t.getPageTitle()},i=n.appPerf.appStartTime,o=n.appPerf.onLaunch,a=n.appPerf.onShow,s=n.pagePerf[e],u=s.onLoad,c=s.onShowEnd,l=s.onReadyEnd,f=s.navigationStart,d=s.FCPStartTime,v=s.LCPStartTime,P=u,I=l||c;if(d&&(r.first_contentful_paint_duration=d>P?d-P:0),v&&(r.largest_contentful_paint_duration=v>P?v-P:0),n.referrerPath?e===n.referrerPath&&a?(r.page_launch_duration=I-a,r.reboot_duration=I-a,r.reboot_mode="warm",n.lastWarm=!1):r.page_launch_duration=I-(null!=f?f:P):"cold"===n.bootType&&(r.page_launch_duration=I-o,r.reboot_duration=I-i,r.reboot_mode="cold",n.bootType="warm"),g(r,(function(e,t){[null,"null",NaN,"NaN"].includes(e)&&m(r,t)})),r.reboot_mode&&!p(r,"reboot_duration")&&m(r,"reboot_mode"),n.appPerf={},n.pagePerf[e]={},2>=h(r).length||!p(r,"page_launch_duration"))return!1;n.buildMonitorEvent(r,{timestamp:+Date.now(),path:t.getPagePath(),query:t.getPageQuery(),title:r.title})},this.minipInst=this.growingIO.minipInstance.minip,this.appPerf={},this.pagePerf={},this.bootType="cold",this.lastWarm=!1,this.buildMonitorEvent=function(e,t){var r;return null===(r=n.growingIO.plugins.gioPerformance)||void 0===r?void 0:r.buildPerfEvent("apm_app_launch",e,t)},["MinP","bytedance"].includes(this.growingIO.minipInstance.platform)&&this.initObserver(),this.growingIO.emitter.on("MINIP_LIFECYCLE",(function(t){var r,i,o,a=t.event,s=t.timestamp,u=t.params,c=a.split(" "),l=c[0],f=c[1];switch(l){case"App":n.appPerf=e(e({},n.appPerf),((r={})[f]=s,r)),"onShowEnd"===f&&("warm"!==n.bootType||n.lastWarm||(n.lastWarm=!0));break;case"Page":var d=null===(o=u.page||u.instance)||void 0===o?void 0:o.route;n.pagePerf[d]=e(e({},n.pagePerf[d]),((i={})[f]=s,i)),"onShowEnd"===f&&n.lastWarm&&"warm"===n.bootType&&n.referrerPath===d&&n.lastUnloadPath!==d&&n.handleEvent(d),["onHide","onUnload"].includes(f)&&(n.referrerPath=d),"onUnload"===f&&(n.lastUnloadPath=d)}}))},O=function(t,n){void 0===n&&(n={});var o,s=this;this.growingIO=t,this.options=n,this.verifyUrl=function(e){if(e.indexOf(s.gdpRequestURL)>-1)return!0;if(u(s.excludeRegExp)){var t=l(s.excludeRegExp.map((function(t){return a(t)?t.test(e):i(t)?e.indexOf(t)>-1:void 0})));return!v(t)}return i(s.excludeRegExp)?e.indexOf(s.excludeRegExp)>-1:!!a(s.excludeRegExp)&&s.excludeRegExp.test(e)},this.hookRequest=function(){var t=s;["request","downloadFile","uploadFile"].forEach((function(n){var r=s.minipInst[n];Object.defineProperty(s.minipInst,n,{writable:!0,enumerable:!0,configurable:!0,value:function(){for(var i=[],o=0;arguments.length>o;o++)i[o]=arguments[o];var a=i[0],s=a.url;if(t.verifyUrl(s))return r.call(this,a);var u={header:a.header||{},url:a.url};switch(n){case"request":var c=a.method;u=e(e({},u),{method:c});break;case"downloadFile":case"uploadFile":var l=a.filePath;u=e(e({},u),{filePath:l,method:"downloadFile"===n?"GET":"POST"})}var f=a.fail,d=a.success;return u.startTime=Date.now(),r.call(this,e(e({},a),{success:function(e){if(u.endTime=Date.now(),t.networkPerfBuilder(e,u),"function"==typeof d)return d(e)},fail:function(e){var n;if(u.endTime=Date.now(),null===(n=t.growingIO.plugins.gioPerformance)||void 0===n||n.buildPerfEvent("Error",{error_type:e.errMsg,error_content:u.url}),"function"==typeof f)return f(e)}}))}})}))},this.networkPerfBuilder=function(e,t){var n=e.profile,i=void 0===n?{}:n,o=e.statusCode,a=void 0===o?0:o,u=e.errMsg,c=t.url,l=t.filePath,f=t.method,d=i.redirectStart,p=i.redirectEnd,h=i.fetchStart,P=i.domainLookUpStart,I=i.domainLookUpEnd,w=i.connectStart,E=i.connectEnd,b=i.requestStart,O=i.responseStart,y=i.responseEnd,_=!v(i),S={url:c,filePath:l,method:f,statusCode:a,message:u,redirect:_?p-d:0,cache:_?P-h:0,dns:_?I-P:0,tcp:_?E-w:0,request:_?O-b:0,response:_?y-O:0,duration:_?y-h:t.endTime-t.startTime};g(S,(function(e,t){return(""===e||r(e))&&m(S,t)})),s.buildNetworkEvent(S)},this.minipInst=this.growingIO.minipInstance.minip,this.buildNetworkEvent=function(e){var t;if(n.network){var r=e.duration,i=e.url,o=e.method,a=e.statusCode;null===(t=s.growingIO.plugins.gioPerformance)||void 0===t||t.buildPerfEvent("apm_network_request",{response_duration:r,request_address:i,request_method:o,http_code:a})}},(null===(o=this.options.network)||void 0===o?void 0:o.exclude)&&(this.excludeRegExp=this.options.network.exclude),this.hookRequest();var c=this,f=this.growingIO.uploader.generateURL;this.growingIO.uploader.generateURL=function(){var e=f.apply(this,arguments);return arguments[0]===c.growingIO.trackingId&&(c.gdpRequestURL=e),e}},y={name:"gioPerformance",method:function(r,i){void 0===i&&(i={});var o,a=this;this.growingIO=r,this.options=i,this.init=function(){var e=a.growingIO.vdsConfig.dataCollect,t=a.options,n=t.monitor,r=t.exception,i=t.network;n&&(a.monitor=new b(a.growingIO)),r&&(a.exception=new E(a.growingIO)),i&&(a.network=new O(a.growingIO,a.options)),e&&a.sendCacheQuene()},this.sendCacheQuene=function(){n.isEmpty(a.cacheQueue)||(a.cacheQueue.forEach((function(e){a.buildPerfEvent(e.eventName,e.attributes,e.extra)})),a.cacheQueue=[])},this.buildPerfEvent=function(r,i,o){var s,u=a.growingIO,c=u.dataStore,l=c.eventContextBuilder,f=c.eventConverter,d=u.gioSDKInitialized,p=u.vdsConfig;if(!d||!p.dataCollect)return a.cacheQueue=t(t([],a.cacheQueue,!0),[{eventName:r,attributes:i,extra:o}],!1),!1;n.forEach(i,(function(e,t){(Number.isNaN(e)||n.isNil(e)||0>Number(e))&&(i[t]=0),i[t]=n.fixed(e,0)}));var h=e({eventType:"CUSTOM",eventName:r,attributes:i},l(a.growingIO.trackingId));h.attributes=I(e(e({},null!==(s=h.attributes)&&void 0!==s?s:{}),i)),v(o)||(h=e(e({},h),o)),f(h)},this.pluginVersion="4.4.0",n=this.growingIO.utils,this.options=e({monitor:!0,exception:!0,network:!1},this.options),this.cacheQueue=[],this.growingIO.emitter.on(w,(function(e){if(e.trackingId===a.growingIO.trackingId){var t=e.performance,n=t.monitor,r=t.exception,i=t.network;n!==a.options.monitor&&(a.options.monitor=n),r!==a.options.exception&&(a.options.exception=r),i!==a.options.network&&(a.options.network=i),a.init()}})),null===(o=this.growingIO.emitter)||void 0===o||o.on("SESSIONID_UPDATE",(function(){var e=a.growingIO,t=e.trackingId;(0,e.getOption)(t,"dataCollect")&&a.sendCacheQuene()}))}};export{y as default};
|