@@ -3,7 +3,6 @@ import { addGlobalEventProcessor, getCurrentHub, Scope, setContext } from '@sent
3
3
import { Breadcrumb , Client , Event } from '@sentry/types' ;
4
4
import { addInstrumentationHandler , createEnvelope , logger } from '@sentry/utils' ;
5
5
import debounce from 'lodash.debounce' ;
6
- import { PerformanceObserverEntryList } from 'perf_hooks' ;
7
6
import { EventType , record } from 'rrweb' ;
8
7
9
8
import {
@@ -19,6 +18,7 @@ import { handleFetchSpanListener } from './coreHandlers/handleFetch';
19
18
import { handleGlobalEventListener } from './coreHandlers/handleGlobalEvent' ;
20
19
import { handleHistorySpanListener } from './coreHandlers/handleHistory' ;
21
20
import { handleXhrSpanListener } from './coreHandlers/handleXhr' ;
21
+ import { setupPerformanceObserver } from './coreHandlers/performanceObserver' ;
22
22
import { createMemoryEntry , createPerformanceEntries , ReplayPerformanceEntry } from './createPerformanceEntry' ;
23
23
import { createEventBuffer , EventBuffer } from './eventBuffer' ;
24
24
import { deleteSession } from './session/deleteSession' ;
@@ -38,7 +38,6 @@ import type {
38
38
import { captureInternalException } from './util/captureInternalException' ;
39
39
import { createBreadcrumb } from './util/createBreadcrumb' ;
40
40
import { createPayload } from './util/createPayload' ;
41
- import { dedupePerformanceEntries } from './util/dedupePerformanceEntries' ;
42
41
import { isExpired } from './util/isExpired' ;
43
42
import { isSessionExpired } from './util/isSessionExpired' ;
44
43
import { overwriteRecordDroppedEvent , restoreRecordDroppedEvent } from './util/monkeyPatchRecordDroppedEvent' ;
@@ -335,30 +334,7 @@ export class ReplayContainer {
335
334
return ;
336
335
}
337
336
338
- this . _performanceObserver = new PerformanceObserver ( this . handlePerformanceObserver ) ;
339
-
340
- // Observe almost everything for now (no mark/measure)
341
- [
342
- 'element' ,
343
- 'event' ,
344
- 'first-input' ,
345
- 'largest-contentful-paint' ,
346
- 'layout-shift' ,
347
- 'longtask' ,
348
- 'navigation' ,
349
- 'paint' ,
350
- 'resource' ,
351
- ] . forEach ( type => {
352
- try {
353
- this . _performanceObserver ?. observe ( {
354
- type,
355
- buffered : true ,
356
- } ) ;
357
- } catch {
358
- // This can throw if an entry type is not supported in the browser.
359
- // Ignore these errors.
360
- }
361
- } ) ;
337
+ this . _performanceObserver = setupPerformanceObserver ( this ) ;
362
338
}
363
339
364
340
/**
@@ -570,19 +546,6 @@ export class ReplayContainer {
570
546
} ) ;
571
547
} ;
572
548
573
- /**
574
- * Keep a list of performance entries that will be sent with a replay
575
- */
576
- handlePerformanceObserver : ( list : PerformanceObserverEntryList ) => void = ( list : PerformanceObserverEntryList ) => {
577
- // For whatever reason the observer was returning duplicate navigation
578
- // entries (the other entry types were not duplicated).
579
- const newPerformanceEntries = dedupePerformanceEntries (
580
- this . performanceEvents ,
581
- list . getEntries ( ) as AllPerformanceEntry [ ] ,
582
- ) ;
583
- this . performanceEvents = newPerformanceEntries ;
584
- } ;
585
-
586
549
/**
587
550
* Tasks to run when we consider a page to be hidden (via blurring and/or visibility)
588
551
*/
0 commit comments