Suprt666

Untitled

Feb 10th, 2020
619
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. if (self.CavalryLogger) { CavalryLogger.start_js(["FEt5G"]); }
  2.  
  3. __d("CavalryLoggerImpl",["Arbiter","Banzai","Bootloader","ImageTimingHelper","ISB","KillabyteProfilerConfig","NavigationTimingHelper","PageEvents","PageletEventConstsJS","PageletEventsHelper","PerfXLogger","ResourceTimingBootloaderHelper","ScriptPath","performance","performanceAbsoluteNow","__getTotalFactories","__getCompileTime","__getFactoryTime"],(function(a,b,c,d,e,f){__p&&__p();var g,h,i=b("KillabyteProfilerConfig").htmlProfilerModule,j=b("KillabyteProfilerConfig").profilerModule,k="cavalry",l=["t_start","t_paint","t_cstart"],m=window.CavalryLogger;Object.assign(m.prototype,{initializeInstrumentation:function(){__p&&__p();if(this.instrumentation_started)return;var c=this;b("Arbiter").subscribe("BigPipe/init",function(a,b){b.lid==c.lid&&b.arbiter&&(c._recordTTIEvent(b.arbiter,"tti_bigpipe"),c._recordDisplayedEvent(b.arbiter,"all_pagelets_displayed"),c._recordLoadedEvent(b.arbiter,"all_pagelets_loaded"),c._recordPageletEventsTime(b.arbiter))});b("Arbiter").subscribe("MRenderingScheduler/init",function(a,b){b.lid==c.lid&&(c._recordTTIEvent(b.arbiter,"MRenderingScheduler/tti"),c._recordDisplayedEvent(b.arbiter,"MRenderingScheduler/dd"),c._recordLoadedEvent(b.arbiter,"MRenderingScheduler/e2e"),c._recordPageletEventsTime(b.arbiter))});b("Arbiter").subscribe(b("PageEvents").BIGPIPE_ONLOAD,function(d,e){a.bigPipe&&c.lid===a.bigPipe.lid&&c.addPiggyback("cjs_factory_count_e2e",b("__getTotalFactories")()).addPiggyback("cjs_compile_time_e2e",b("__getCompileTime")()).addPiggyback("cjs_factory_time_e2e",b("__getFactoryTime")())});c.addPiggyback("script_path",b("ScriptPath").getScriptPath());this.is_detailed_profiler&&b("PageletEventsHelper").init();this.instrumentation_started=!0},_recordTTIEvent:function(a,b){__p&&__p();var c=this;a.subscribe(b,function(a,b){if(b.lid==c.lid){if(b.metrics)for(var d in b.metrics)c.addPiggyback(d,b.metrics[d]);b.usageSnapshot&&(c.ttiUsageSnapshot=b.usageSnapshot);c._setTTIPhase(b.phase).measurePageLoad(!0,b.ts);c.setAbsTimeStamp("t_bigpipe_tti",b.ts,!0)}})},_recordDisplayedEvent:function(a,b){var c=this;a.subscribe(b,function(a,b){b.lid===c.lid&&(b.usageSnapshot&&(c.ddUsageSnapshot=b.usageSnapshot),c.setAbsTimeStamp("t_marker_all_pagelets_displayed",b.ts,!0))})},_recordLoadedEvent:function(a,b){var c=this;a.subscribe(b,function(a,b){b.lid===c.lid&&c.setAbsTimeStamp("t_marker_bigpipe_e2e",b.ts,!0)})},_recordPageletEventsTime:function(a){__p&&__p();if(this.is_detailed_profiler){var c=this;a.subscribe("pagelet_event",function(a,d){if(d.lid==c.lid){a=d.id;c.events[a]=c.events[a]||{};c.events[a][d.event]=d.ts-window._cstart;d.event===b("PageletEventConstsJS").ARRIVE_END&&(c.events[a].phase=d.phase)}})}},_setTTIPhase:function(a){this.addPiggyback("tti_phase",a);return this},setTimeStamp:function(a,c,d,e){this.mark(a);var f=this.values.t_cstart||this.values.t_start;f=e?f+e:(g||(g=b("performanceAbsoluteNow")))();this.setValue(a,f,c,d);this.tti_event&&a==this.tti_event&&this.measurePageLoad(c);return this},setAbsTimeStamp:function(a,b,c,d){this.setValue(a,b,c,d);this.tti_event&&a==this.tti_event&&this.measurePageLoad(c,b);return this},log:function(){__p&&__p();var a={lid:this.lid};b("ISB").token&&(a.fb_isb=b("ISB").token);this.addPiggyback("pagelet_events",b("PageletEventsHelper").getMetrics(this.lid));this.setValue("client_pixel_ratio_10x",parseInt((window.devicePixelRatio||1)*10,10));this._moveBootloaderData();a=babelHelpers["extends"]({t_creport:(g||(g=b("performanceAbsoluteNow")))()},a,this.values,this.piggy_values);var c=window.__bodyWrapper;if(c.getCodeUsage&&j){if(!this.start||!this.e2e||!this.dd)throw new Error("Timestamps are missing in Cavalry. Please report this to the Web Speed team");var d=j.findUsedCSSSelectors(document,j.getDocumentStylesheets(document));d={js_calls:JSON.stringify(c.getCodeUsage()),css_selectors:JSON.stringify(d),bootloads:JSON.stringify(this._getBootloadsUntil(this.e2e))};i&&(d.html=JSON.stringify(i.getKillabyteHTMLData()));var e=babelHelpers["extends"]({},j.getDataForSnapshot(this.ddUsageSnapshot),{bootloads:JSON.stringify(this._getBootloadsUntil(this.dd))});d={e2e:d,dd:e};if(this.ttiUsageSnapshot){if(!this.tti)throw new Error("tti timestamp should always be present if we have usage data");d.tti=babelHelpers["extends"]({},j.getDataForSnapshot(this.ttiUsageSnapshot),{bootloads:JSON.stringify(this._getBootloadsUntil(this.tti))})}b("Arbiter").inform("cavalry_usage_data_collected",{usageData:d,lid:this.lid},"state");c.clearCodeUsage()}e=b("PerfXLogger").getPayload(a.lid);e&&this._logPerfXPiggybacks(a,e);b("Banzai").post(k,a,b("Banzai").VITAL);d=this.values;this.values={};this.piggy_values={};for(var c=0;c<l.length;c++)this.values[l[c]]=d[l[c]];b("Arbiter").inform("cavalry_log_sent",a,"state")},_logPerfXPiggybacks:function(a,b){a.perfx_page=b.perfx_page,a.perfx_page_type=b.perfx_page_type,a.perfx_tti=b.tti,a.perfx_e2e=b.e2e},_moveBootloaderData:function(){this.log_resources&&this.addPiggyback("resource_timing_bootloader",b("ResourceTimingBootloaderHelper").mergeBootloaderMetricsAndResourceTimings(this.piggy_values.resource_timing_bootloader,this.bootloader_metrics,!1,{}))},_collectMetrics:function(a){(!this.metric_collected||a)&&(this.metric_collected=!0,this.addPiggyback("tag",document.getElementsByTagName("*").length))},_getBootloadsUntil:function(a){var c=this;return Array.from(b("Bootloader").getBootloadedComponents()).filter(function(b){b[0];b=b[1];return
Add Comment
Please, Sign In to add comment