diff --git a/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.spec.ts b/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.spec.ts index bfcbd91f17..b54554b99d 100644 --- a/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.spec.ts +++ b/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.spec.ts @@ -1,4 +1,4 @@ -import { DOM_EVENT, Duration, RelativeTime } from '@datadog/browser-core' +import { DOM_EVENT, Duration, ONE_MINUTE, RelativeTime } from '@datadog/browser-core' import { createNewEvent, restorePageVisibility, setPageVisibility } from '../../../../../core/test/specHelper' import { setup, TestSetupBuilder } from '../../../../test/specHelper' import { @@ -136,6 +136,16 @@ describe('trackFirstContentfulPaint', () => { lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, FAKE_PAINT_ENTRY) expect(fcpCallback).not.toHaveBeenCalled() }) + + it('should not be present if it happens after 10 minutes', () => { + const { lifeCycle } = setupBuilder.build() + + lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, { + ...FAKE_PAINT_ENTRY, + startTime: (10 * ONE_MINUTE) as RelativeTime, + }) + expect(fcpCallback).not.toHaveBeenCalled() + }) }) describe('largestContentfulPaint', () => { @@ -181,6 +191,16 @@ describe('largestContentfulPaint', () => { expect(lcpCallback).not.toHaveBeenCalled() }) + + it('should not be present if it happens after 10 minutes', () => { + const { lifeCycle } = setupBuilder.build() + + lifeCycle.notify(LifeCycleEventType.PERFORMANCE_ENTRY_COLLECTED, { + ...FAKE_LARGEST_CONTENTFUL_PAINT_ENTRY, + startTime: (10 * ONE_MINUTE) as RelativeTime, + }) + expect(lcpCallback).not.toHaveBeenCalled() + }) }) describe('firstInputTimings', () => { diff --git a/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts b/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts index 8c3fdec121..afc19e8ade 100644 --- a/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts +++ b/packages/rum-core/src/domain/rumEventsCollection/view/trackInitialViewTimings.ts @@ -7,6 +7,7 @@ import { RelativeTime, timeStampNow, TimeStamp, + ONE_MINUTE, } from '@datadog/browser-core' import { LifeCycle, LifeCycleEventType } from '../../lifeCycle' import { trackFirstHidden } from './trackFirstHidden' @@ -76,7 +77,8 @@ export function trackFirstContentfulPaint(lifeCycle: LifeCycle, callback: (fcp: if ( entry.entryType === 'paint' && entry.name === 'first-contentful-paint' && - entry.startTime < firstHidden.timeStamp + entry.startTime < firstHidden.timeStamp && + entry.startTime < 10 * ONE_MINUTE ) { callback(entry.startTime) } @@ -118,7 +120,8 @@ export function trackLargestContentfulPaint( if ( entry.entryType === 'largest-contentful-paint' && entry.startTime < firstInteractionTimestamp && - entry.startTime < firstHidden.timeStamp + entry.startTime < firstHidden.timeStamp && + entry.startTime < 10 * ONE_MINUTE ) { lcpSizes.push({ timeStamp: timeStampNow(), startTime: entry.startTime, size: entry.size }) callback(entry.startTime)