Webseite:SPX Tracking WebsiteInhalt
//历史逻辑,处理shopeexpress->spx的跳转consthostname=window.location.hostname;if(hostname.indexOf('shopeexpress')!==-1||hostname.indexOf('spx')!==-1){window.region=hostname.substr(-2).toUpperCase();}//BR市场由于只有shopeexpress,不作跳转处理if(window.region!=='BR'&&window.location.origin.indexOf('shopeexpress')!==-1){constorigin=window.location.origin.replace('shopeexpress','spx');window.location.href=`${origin}/${window.location.hash}`;}window.__APP_VERSION__='v-2015-VN-LIVE';!function(t,e){"object"==typeofexports&&"undefined"!=typeofmodule?e(exports):"function"==typeofdefine&&define.amd?define(["exports"],e):e((t="undefined"!=typeofglobalThis?globalThis:t||self)["tracing-entrance-tracker"]={})}(this,(function(t){"usestrict";conste=t=>localStore.getItem(t);consta="entrance_tracker_invalid_case";classi{_reporter;_endSte="js_init_end";_reported=!1;_logger=!1;_currentSte="html_init_start";_maxWaitTimer=null;_xhrOptions={};_beforeSend;_maxWait=13e3;_visiblechangeCount=0;_startTime=performance.now();_prevStartedTime=performance.now();_prevSteTime=performance.now();_contextData={data:{invalid_case:0,visible_tab:1}};constructor(t,e){this._reporter=t;consta=e||{};this._logger=!!a.logger,this._xhrOptions=a.xhrOptions||{},this._beforeSend=a.beforeSend,this._maxWait=a.maxWait&&a.maxWait>0?a.maxWait:this._maxWait}_logInfo(...t){conste=this._logger;if(!e)return;consta="string"==typeofe&&"function"==typeofwindow.console[e]?e:"info";window.console[a](...t)}_getDuration(t){return+(performance.now()-t).toFixed(2)}entrySteReport(t){if(this._reported)this._logInfo("[初始化成功率上报]alreadyreported!t:",performance.now()-this._startTime);elsetry{const{data:e={},...a}=this._contextData,i={type:"numeric",key:"app_init_ste",value:this._getDuration(this._startTime),...a,data:{ste:this._currentSte,visiblechange_count:this._visiblechangeCount,...e,...t}},r=this._beforeSend?this._beforeSend(i,this.getBaseData()):i;if(!1===r)return;this._reporter.sendData(r,this._xhrOptions),this._reported=!0,this._logInfo(`[初始化成功率上报]reported!is_success:"${t.is_success}".t:`,performance.now()-thisSPX Tracking Website._startTime),this._logInfo("[初始化成功率上报]reported!data:time:",performance.now()-this._startTime,r)}catch(t){console.error("[初始化成功率上报]Error:",t)}}getNigationType(){try{constt=window.performance.getEntriesByType("nigation"),e=Array.isArray(t)&&t.length?t[0].type:"unknown";returnthis._logInfo("[初始化成功率上报]nigationType:",e),e}catch(t){returnconsole.error("[初始化成功率上报]getnigation_typeerror:",t),"unknown"}}clearMaxWaitTimer(){null!==this._maxWaitTimer&&(clearTimeout(this._maxWaitTimer),this._maxWaitTimer=null)}pauseMaxWaitTimer(){this.clearMaxWaitTimer(),this._maxWait-=+(performance.now()-this._prevStartedTime).toFixed(0)}startMaxWaitTimer(){this.clearMaxWaitTimer(),this._logInfo("[初始化成功率上报]max_waittimerstarted.t:",performance.now()-this._startTime);constt=()=>{this._logInfo("[初始化成功率上报]max_waitreached.t:",performance.now()-this._startTime),this._contextData.data&&this._contextData.data.invalid_case||this._reported||this.entrySteReport({is_success:0})};this._maxWait>0?(this._prevStartedTime=performance.now(),this._maxWaitTimer=setTimeout(t,this._maxWait)):t()}maxWaitHandler(t=!1){if(t&&this._visiblechangeCount++,document.hidden)this.addContextData({data:{visible_tab:0}}),this.pauseMaxWaitTimer();else{if(this._reported)returnthis._logInfo("[初始化成功率上报]alreadyreported!Noneedformaxwait.t:",performance.now()-this._startTime),voidthis.clearVisibilitychange();this.startMaxWaitTimer()}}clearVisibilitychange(){document.removeEventListener("visibilitychange",this.maxWaitHandler.bind(this,!0))}checkMaxWait(){document.addEventListener("visibilitychange",this.maxWaitHandler.bind(this,!0)),this.maxWaitHandler()}getContextData(){returnthis._contextData}addContextData(t){conste=t||{},{data:a={},...i}=this._contextData,{data:r={},...n}=e;Object.assign(this._contextData,{...i,...n,data:{...a,...r}})}changeInitSte(t,e={}){this._currentSte=t,this._logInfo(`[初始化成功率上报]changeInitSte:${this._currentSte}.t:`,performance.now()-this._startTime),this.addContextData({data:{...e,[`to_${this._currentSte}_duration`]:this._getDuration(this._prevSteTime)}}),t!==this._endSte||this._contextData.data.invalid_case||this.entrySteReport({is_success:1}),this._prevSteTime=performance.now()}start(t){conste=t||{};this._logger=!!e.logger||this._logger,this._xhrOptions=e.xhrOptions||this._xhrOptions,this._beforeSend=e.beforeSend||this._beforeSend,null!==this._maxWaitTimer&&(this._logInfo("[初始化成功率上报]maxWaitalreadystarted,resetting."),this.clearMaxWaitTimer(),this.clearVisibilitychange()),this._maxWait=e.maxWait&&e.maxWait>0?e.maxWait:this._maxWait,this.addContextData({data:{nigation_type:this.getNigationType(),referrer:document.referrer||""}}),this.checkMaxWait()}getReporter(){returnthis._reporter}getBaseData(){returnthis._reporter.getBaseData()}setBaseData(t){returnthis._reporter.setBaseData(t)}getInvalidCaseState(){returne(a)}setAsInvalidCaseState(t=!1){!function(t,e){try{consta="string"==typeofe?e:JSON.stringify(e);localStore.setItem(t,a)}catch(t){console.error("[初始化成功率]ErrorwhensetlocalStore:",t)}}(a,"1"),this.addContextData({data:{invalid_case:1}}),t&&window.addEventListener("unload",(()=>{this.resetInvalidCaseState()}))}resetInvalidCaseState(){vart;t=a,localStore.reSPX Tracking WebsitemoveItem(t),this.addContextData({data:{invalid_case:0}})}}classr{_reportContext;_env;constructor(t){consta="xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(t=>{conste=16*Math.random()|0;return("x"===t?e:3&e|8).toString(16)})),i=(()=>{constt=window.location.hostname;returnt.includes("systems")?"XX":t.substr(-2)})(),r=i.toUpperCase();this._env=(t=>{conste=t.match(/.+\.(dev|stable|test|uat|sting)\..+$/);returne?e[1]:"live"})(window.location.hostname),this._reportContext={a:r,ct:Math.floor(Date.now()/1e3),env:this._env,na:i,pf:"pc",r:1,s:location.href,sid:a,uid:e("useremail")||e("username")||"-",ut:e("stationName")||"-",nt:nigator?.connection?.effectiveType||"unknown",...t}}getBaseData(){returnthis._reportContext}setBaseData(t){this._reportContext={...this._reportContext,...t}}sendData(t,e){const{type:a,...i}=t||{},r=[{...this._reportContext,dt:a||this._reportContext.dt,d:{type:a,...i}}],n=newXML,s=JSON.stringify(r),o="live"===this._env?"autobahn.ssc.shopeemobile.com/data/":"autobahn.ssc.test.shopeemobile.com/data/",{withCredentials:h=!0,timeout:c=1e5}=e||{};n.withCredentials=h,n.timeout=c,n.open("POST",o,!0),n.setRequestHeader("Content-type","application/json;charset=utf-8"),n.send(s)}}t.AutobahnXhrReporter=r,t.EntranceTracker=i,t.startTracker=(t,e)=>{consta=newr(t),n=newi(a,e);returnn.start(),n},Object.defineProperty(t,"__esModule",{value:!0})}));window.__EntryTracker=window['tracing-entrance-tracker'].startTracker({bt:'SLS',sbt:'NSS',a:'VN',env:'live',v:window.__APP_VERSION__,},{beforeSend(reportData,baseData){constheadlessUA=nigator.userent.toLowerCase().includes('headless');constvalidStrValueRule=/^([\w-.]+)+$/;constvalidUrlRule=/^?:\/\/([.\w]+)(\/)?([#\w/?=&%-.]+)?/;const{d,v,sid,pf,nt,s}=baseData;const{data,key,type}=reportData;const{nigation_type,ste,referrer}=data;constisValidStr=[v,sid,pf,nt,key,type,nigation_type,ste].every(v=>validStrValueRule.test(v));constisValidUrl=[s,referrer].every(v=>validUrlRule.test(v)||!v);letvisit_type='valid_visit';if(headlessUA)visit_type='crawl_visit';if(!isValidStr||!isValidUrl)visit_type='xss_visit';reportData.data.visit_type=visit_type;returnreportData;}});!function(){var_;if(!(null===(_=window.__MDAP_PREV_RESOURCE__)||void0===_?void0:_.init)){window.__MDAP_PREV_RESOURCE__={data:[],init:!0};varn=function(_){varn;null===(n=window.__MDAP_PREV_RESOURCE__.data)||void0===n||n.push(_)};window.addEventListener("error",n,!0),window.__MDAP_PREV_RESOURCE__.removePrevListener=function(){window.removeEventListener("error",n)}}}();constWIDTH=1400;//设计稿宽constmobileAdapter=()=>{constscale=screen.width/WIDTH;constcontent=`width=${WIDTH},initial-scale=${scale},maximum-scale=${scale},minimum-scale=${scale},user-scalable=yes`;letmeta=document.querySelector('meta[name=viewport]');if(!meta){meta=document.createElement('meta');meta.setAttribute('name','viewport');document.head.appendChild(meta);}meta.setAttribute('content',content);}mobileAdapter();//执行函数window.onorientationchange=mobileAdapter;//旋转屏幕重新校正SPXTrackingWebsitevar__initMap__;functionmapReady(cb){__initMap__=cb;}functioninitMap(){__initMap__?__initMap__():(window.__mapScriptLoaded__=true);}html,body,#root{height:100%;margin:0;padding:0;}(function(w,d,s,l,i){if(window.region!=='BR'){w[l]=w[l]||[];w[l].push({'gtm.start':newDate().getTime(),event:'gtm.js'});varf=d.getElementsByTName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);vargtScriSPX Tracking Websitept=document.createElement('script');gtScript.async=true;gtScript.src='/gt/js?id=UA--14';f.parentNode.insertBefore(gtScript,f);}})(window,document,'script','dataLayer','GTM-5B2TZNC');document.addEventListener('DOMContentLoaded',function(){if(window.region!=='BR'){varnoScript=document.createElement('noscript');variframe=document.createElement('iframe');iframe.src="/ns.html?id=GTM-5B2TZNC";iframe.height="0";iframe.width="0";iframe.style.display="none";iframe.style.visibility="hidden";noScript.appendChild(iframe);varbody=document.body;body.insertBefore(noScript,body.firstChild);}});if(window.region==='TH'){window.dataLayer=window.dataLayer||[];functiongt(){dataLayer.push(arguments);}gt('js',newDate());try{if(!JSON.parse(localStore.getItem('open-spx-cookiesTypeList')||'[]').includes('performance')){gt('consent','default',{'ad_store':'denied','analytics_store':'denied'});dataLayer.push({'event':'default_consent'});}}catch(error){console.error(error)}}YouneedtoenableJaScripttorunthisapp.//BR市场使用Shopeexpresslogoif(window.region!='BR'){constclassList=document.querySelector('#spx-loading-logo').classList;classList.add('spx-loading-logo-2305');}if(location.search.includes('preview=')){constscriptT=document.createElement('script');constversion=newURLSearchParams(location.search).get('preview');scriptT.setAttribute('src','sls.sp-cdn.shopee.com/api/v4//pgmgmt/spx-vn-pc-conf.js'.replace('.js',`-draft-${version}.js`));document.head.appendChild(scriptT);}//googlemapapiconstmapKey=['test','uat','sting'].indexOf('live')!==-1?'AIzaSyDg98eJ55wAsflSlkBk0iUXcKnKHP8GpSY':'AIzaSyB0a3pTo-HIk4bWQp5-ZDRqRXoicpS-oOk';constgoogleMapApiScript=document.createElement('script');googleMapApiScript.src='maps.googleapis.com/maps/api/js?libraries=places&callback=initMap&key='+mapKey;googleMapApiScript.defer=true;document.body.append(googleMapApiScript);constprefix='ssc-numeric';const_separator_='-:-';const{pathname}=location;constqmsFcpTIDName=`FCP_${pathname.replace(/\/|-/g,'_')}`;constqmsLcpTIDName=`LCP_${pathname.replace(/\/|-/g,'_')}`;window.qmsFcpTID=`${qmsFcpTIDName}${_separator_}${Date.now()}`;window.qmsLcpTID=`${qmsLcpTIDName}${_separator_}${Date.now()}`;performance.mark(`${prefix}-${qmsFcpTID}:start`);performance.mark(`${prefix}-${qmsLcpTID}:start`);