From 4b4d9adad75494db44ce0ef3563d3602d9e93114 Mon Sep 17 00:00:00 2001 From: Bryan Atkinson Date: Tue, 26 Nov 2024 19:50:53 +0000 Subject: [PATCH] Remove FID wait timeout on OOB trace send. This gets sent at first unload now, so no need to add additional timeouts. --- .../services/oob_resources_service.test.ts | 24 --------------- .../src/services/oob_resources_service.ts | 30 +++++-------------- 2 files changed, 7 insertions(+), 47 deletions(-) diff --git a/packages/performance/src/services/oob_resources_service.test.ts b/packages/performance/src/services/oob_resources_service.test.ts index 57de44a19e4..13b844512d1 100644 --- a/packages/performance/src/services/oob_resources_service.test.ts +++ b/packages/performance/src/services/oob_resources_service.test.ts @@ -250,30 +250,6 @@ describe('Firebase Performance > oob_resources_service', () => { ); }); - it('waits for first input delay if polyfill is available', () => { - getIidStub.returns(MOCK_ID); - const api = Api.getInstance(); - //@ts-ignore Assignment to read-only property. - api.onFirstInputDelay = stub(); - setupOobResources(performanceController); - clock.tick(1); - - // Force the page load event to be sent - stub(mockWindow.document, 'visibilityState').value('hidden'); - callEventListener('visibilitychange'); - - expect(api.onFirstInputDelay).to.be.called; - expect(createOobTraceStub).not.to.be.called; - clock.tick(5000); - expect(createOobTraceStub).to.be.calledWithExactly( - performanceController, - [NAVIGATION_PERFORMANCE_ENTRY], - [PAINT_PERFORMANCE_ENTRY], - {}, - undefined - ); - }); - it('logs first input delay if polyfill is available and callback is called', () => { getIidStub.returns(MOCK_ID); const api = Api.getInstance(); diff --git a/packages/performance/src/services/oob_resources_service.ts b/packages/performance/src/services/oob_resources_service.ts index 4747b3aa72a..16bc096d1fb 100644 --- a/packages/performance/src/services/oob_resources_service.ts +++ b/packages/performance/src/services/oob_resources_service.ts @@ -30,8 +30,6 @@ import { WebVitalMetrics } from '../resources/web_vitals'; import { Api } from './api_service'; import { getIid } from './iid_service'; -const FID_WAIT_TIME_MS = 5000; - let webVitalMetrics: WebVitalMetrics = {}; let sentPageLoadTrace: boolean = false; let firstInputDelay: number | undefined; @@ -147,27 +145,13 @@ function sendOobTrace(performanceController: PerformanceController): void { 'navigation' ) as PerformanceNavigationTiming[]; const paintTimings = api.getEntriesByType('paint'); - // If First Input Delay polyfill is added to the page, report the fid value. - // https://github.com/GoogleChromeLabs/first-input-delay - if (api.onFirstInputDelay && !firstInputDelay) { - setTimeout(() => { - Trace.createOobTrace( - performanceController, - navigationTimings, - paintTimings, - webVitalMetrics, - firstInputDelay - ); - }, FID_WAIT_TIME_MS); - } else { - Trace.createOobTrace( - performanceController, - navigationTimings, - paintTimings, - webVitalMetrics, - firstInputDelay - ); - } + Trace.createOobTrace( + performanceController, + navigationTimings, + paintTimings, + webVitalMetrics, + firstInputDelay + ); } }