trang mạng:RobloxNội dung
Roblox{"@context":"schema.org","@type":"Organization","name":"Roblox","url":"/","ime":"imes.rbxcdn.com/fc3f3e3158fc20ebb5cccebfe6.png","logo":"imes.rbxcdn.com/fc3f3e3158fc20ebb5cccebfe6.png","email":"info@roblox.com","sameAs":["/roblox/","twitter.com/roblox","/company/","/roblox/","/user/roblox","/roblox"]}varRoblox=Roblox||{};Roblox.BundleVerifierConstants={isMetricsApiEnabled:true,eventStreamUrl:"//ecsv2.roblox.com/pe?t=dinostic",deviceType:"Computer",cdnLoggingEnabled:JSON.parse("true")};varRoblox=Roblox||{};Roblox.BundleDetector=(function(){varisMetricsApiEnabled=Roblox.BundleVerifierConstants&&Roblox.BundleVerifierConstants.isMetricsApiEnabled;varloadStates={loadSuccess:"loadSuccess",loadFailure:"loadFailure",executionFailure:"executionFailure"};varbundleContentTypes={jascript:"jascript",css:"css"};varephemeralCounterNames={cdnPrefix:"CDNBundleError_",unknown:"CDNBundleError_unknown",cssError:"CssBundleError",jsError:"JascriptBundleError",jsFileError:"JsFileExecutionError",resourceError:"ResourcePerformance_Error",resourceLoaded:"ResourcePerformance_Loaded"};return{jsBundlesLoaded:{},bundlesReported:{},counterNames:ephemeralCounterNames,loadStates:loadStates,bundleContentTypes:bundleContentTypes,timing:undefined,setTiming:function(windowTiming){this.timing=windowTiming;},getLoadTime:function(){if(this.timing&&this.timing.domComplete){returnthis.getCurrentTime()-this.timing.domComplete;}},getCurrentTime:function(){returnnewDate().getTime();},getCdnProviderName:function(bundleUrl,callBack){if(Roblox.BundleVerifierConstants.cdnLoggingEnabled){varxhr=newXML();xhr.open('GET',bundleUrl,true);xhr.onreadystatechange=function(){if(xhr.readyState===xhr.HEADERS_RECEIVED){try{varheaderValue=xhr.getResponseHeader("rbx-cdn-provider");if(headerValue){callBack(headerValue);}else{callBack();}}catch(e){callBack();}}};xhr.onerror=function(){callBack();};xhr.send();}else{callBack();}},getCdnProviderAndReportMetrics:function(bundleUrl,bundleName,loadState,bundleContentType){this.getCdnProviderName(bundleUrl,function(cdnProviderName){Roblox.BundleDetector.reportMetrics(bundleUrl,bundleName,loadState,bundleContentType,cdnProviderName);});},reportMetrics:function(bundleUrl,bundleName,loadState,bundleContentType,cdnProviderName){if(!isMetricsApiEnabled||!bundleUrl||!loadState||!loadStates.hasOwnProperty(loadState)||!bundleContentType||!bundleContentTypes.hasOwnProperty(bundleContentType)){return;}varxhr=newXML();varmetricsApiUrl=(Roblox.EnvironmentUrls&&Roblox.EnvironmentUrls.metricsApi)||"metrics.roblox.com";xhr.open("POST",metricsApiUrl+"/v1/bundle-metrics/report",true);xhr.setRequestHeader("Content-Type","application/json");xhr.withCredentials=true;xhr.send(JSON.stringify({bundleUrl:bundleUrl,bundleName:bundleName||"",bundleContentType:bundleContentType,loadState:loadState,cdnProviderName:cdnProviderName,loadTimeInMilliseconds:this.getLoadTime()||0}));},logToEphemeralStatistics:function(sequenceName,value){vardeviceType=Roblox.BundleVerifierConstants.deviceType;sequenceName+="_"+deviceType;varxhr=newXML();xhr.open('POST','/game/report-stats?name='+sequenceName+"&value="+value,true);xhr.withCredentials=true;xhr.send();},logToEphemeralCounter:function(ephemeralCounterName){vardeviceType=Roblox.BundleVerifierConstants.deviceType;ephemeralCounterName+="_"+deviceType;//logtoephemeralcounters-takenfromET.jsvarxhr=newXML();xhr.open('POST','/game/report-event?name='+ephemeralCounterName,true);xhr.withCredentials=true;xhr.send();},logToEventStream:function(failedBundle,ctx,cdnProvider,status){varurlUnencoded=window.location.href;if(Roblox.Endpoints&&Roblox.Endpoints.supportLocalizedUrls){//RemoveurlLocalefromeventstreRobloxamtopreventbreakingchangeurlUnencoded=Roblox.Endpoints.removeUrlLocale(urlUnencoded);}varesUrl=Roblox.BundleVerifierConstants.eventStreamUrl,currentPeUrl=encodeURIComponent(urlUnencoded);vardeviceType=Roblox.BundleVerifierConstants.deviceType;ctx+="_"+deviceType;//tryandgrabperformancedata.//Notethatthisistheperformanceofthexmlratherthantheoriginalresourceload.varduration=0;if(window.performance){varperfTiming=window.performance.getEntriesByName(failedBundle);if(perfTiming.length>0){vardata=perfTiming[0];duration=data.duration||0;}}//logtoeventstream(dinostic)varparams="&evt=webBundleError&url="+currentPeUrl+"&ctx="+ctx+"&fileSourceUrl="+encodeURIComponent(failedBundle)+"&cdnName="+(cdnProvider||"unknown")+"&statusCode="+(status||"unknown")+"&loadDuration="+Math.floor(duration);varimg=newIme();img.src=esUrl+params;},getCdnInfo:function(failedBundle,ctx,fileType){if(Roblox.BundleVerifierConstants.cdnLoggingEnabled){varxhr=newXML();varcounter=this.counterNames;xhr.open('GET',failedBundle,true);varcdnProvider;//succesfulrequestxhr.onreadystatechange=function(){if(xhr.readyState===xhr.HEADERS_RECEIVED){cdnProvider=xhr.getResponseHeader("rbx-cdn-provider");if(cdnProvider&&cdnProvider.length>0){Roblox.BundleDetector.logToEphemeralCounter(counter.cdnPrefix+cdnProvider+"_"+fileType);}else{Roblox.BundleDetector.logToEphemeralCounter(counter.unknown+"_"+fileType);}}elseif(xhr.readyState===xhr.DONE){//appendstatustocdnprovidersoweknowitsnotrelatedtonetworkerror.Roblox.BundleDetector.logToEventStream(failedBundle,ctx,cdnProvider,xhr.status);}};//attachtopossiblethingsthatcangowrongwiththerequest.//additionallyanetworkerrorwilltriggerthiscallbackxhr.onerror=function(){Roblox.BundleDetector.logToEphemeralCounter(counter.unknown+"_"+fileType);Roblox.BundleDetector.logToEventStream(failedBundle,ctx,counter.unknown);};xhr.send();}else{this.logToEventStream(failedBundle,ctx);}},reportResourceError:function(resourceName){varephemeralCounterName=this.counterNames.resourceError+"_"+resourceName;this.logToEphemeralCounter(ephemeralCounterName);},reportResourceLoaded:function(resourceName){varloadTimeInMs=this.getLoadTime();if(loadTimeInMs){varsequenceName=this.counterNames.resourceLoaded+"_"+resourceName;this.logToEphemeralStatistics(sequenceName,loadTimeInMs);}},reportBundleError:function(bundleT){varephemeralCounterName,failedBundle,ctx,contentType;if(bundleT.rel&&bundleT.rel==="stylesheet"){ephemeralCounterName=this.counterNames.cssError;failedBundle=bundleT.href;ctx="css";contentType=bundleContentTypes.css;}else{ephemeralCounterName=this.counterNames.jsError;failedBundle=bundleT.src;ctx="js";contentType=bundleContentTypes.jascript;}//markthatweloggedthisbundlethis.bundlesReported[failedBundle]=true;//e.g.jascriptBundleError_Computerthis.logToEphemeralCounter(ephemeralCounterName);//thiswillalsologtoeventstreamthis.getCdnInfo(failedBundle,ctx,ctx);varbundleName;if(bundleT.dataset){bundleName=bundleT.dataset.bundlename;}else{bundleName=bundleT.getAttribute('data-bundlename');}this.getCdnPrRobloxoviderAndReportMetrics(failedBundle,bundleName,loadStates.loadFailure,contentType);},bundleDetected:function(bundleName){this.jsBundlesLoaded[bundleName]=true;},verifyBundles:function(documenRobloxt){varephemeralCounterName=this.counterNames.jsFileError,eventContext=ephemeralCounterName;//graballrobloxscripttsinthepe.varscripts=(document&&document.scripts)||window.document.scripts;varerrorsList=[];varbundleName;varmonitor;for(vari=0;i0){for(varj=0;j