Skip to content

Commit dbb354e

Browse files
♻️ Replace longTaskRegistry by longTaskContexts (#4013)
1 parent ea920e6 commit dbb354e

17 files changed

+304
-444
lines changed

packages/rum-core/src/boot/rumPublicApi.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ const noopStartRum = (): ReturnType<StartRum> => ({
2323
getInternalContext: () => undefined,
2424
lifeCycle: {} as any,
2525
viewHistory: {} as any,
26+
longTaskContexts: {} as any,
2627
session: {} as any,
2728
stopSession: () => undefined,
2829
startDurationVital: () => ({}) as DurationVitalReference,

packages/rum-core/src/boot/rumPublicApi.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ import { createCustomVitalsState } from '../domain/vital/vitalCollection'
5252
import { callPluginsMethod } from '../domain/plugins'
5353
import type { Hooks } from '../domain/hooks'
5454
import type { SdkName } from '../domain/contexts/defaultContext'
55+
import type { LongTaskContexts } from '../domain/longTask/longTaskCollection'
5556
import { createPreStartStrategy } from './preStartRum'
5657
import type { StartRum, StartRumResult } from './startRum'
5758

@@ -484,6 +485,7 @@ export interface ProfilerApi {
484485
configuration: RumConfiguration,
485486
sessionManager: RumSessionManager,
486487
viewHistory: ViewHistory,
488+
longTaskContexts: LongTaskContexts,
487489
createEncoder: (streamId: DeflateEncoderStreamId) => Encoder
488490
) => void
489491
}
@@ -576,6 +578,7 @@ export function makeRumPublicApi(
576578
configuration,
577579
startRumResult.session,
578580
startRumResult.viewHistory,
581+
startRumResult.longTaskContexts,
579582
createEncoder
580583
)
581584

packages/rum-core/src/boot/startRum.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,6 @@ import { startDisplayContext } from '../domain/contexts/displayContext'
4343
import type { CustomVitalsState } from '../domain/vital/vitalCollection'
4444
import { startVitalCollection } from '../domain/vital/vitalCollection'
4545
import { startCiVisibilityContext } from '../domain/contexts/ciVisibilityContext'
46-
import { startLongAnimationFrameCollection } from '../domain/longAnimationFrame/longAnimationFrameCollection'
47-
import { RumPerformanceEntryType, supportPerformanceTimingEvent } from '../browser/performanceObservable'
4846
import { startLongTaskCollection } from '../domain/longTask/longTaskCollection'
4947
import { startSyntheticsContext } from '../domain/contexts/syntheticsContext'
5048
import { startRumAssembly } from '../domain/assembly'
@@ -237,14 +235,8 @@ export function startRumEventCollection(
237235
const { stop: stopResourceCollection } = startResourceCollection(lifeCycle, configuration, pageStateHistory)
238236
cleanupTasks.push(stopResourceCollection)
239237

240-
if (configuration.trackLongTasks) {
241-
if (supportPerformanceTimingEvent(RumPerformanceEntryType.LONG_ANIMATION_FRAME)) {
242-
const { stop: stopLongAnimationFrameCollection } = startLongAnimationFrameCollection(lifeCycle, configuration)
243-
cleanupTasks.push(stopLongAnimationFrameCollection)
244-
} else {
245-
startLongTaskCollection(lifeCycle, configuration)
246-
}
247-
}
238+
const { stop: stopLongTaskCollection, longTaskContexts } = startLongTaskCollection(lifeCycle, configuration)
239+
cleanupTasks.push(stopLongTaskCollection)
248240

249241
const { addError } = startErrorCollection(lifeCycle, configuration, bufferedDataObservable)
250242

@@ -280,6 +272,7 @@ export function startRumEventCollection(
280272
globalContext,
281273
userContext,
282274
accountContext,
275+
longTaskContexts,
283276
stop: () => cleanupTasks.forEach((task) => task()),
284277
}
285278
}

packages/rum-core/src/domain/longAnimationFrame/longAnimationFrameCollection.spec.ts

Lines changed: 0 additions & 78 deletions
This file was deleted.

packages/rum-core/src/domain/longAnimationFrame/longAnimationFrameCollection.ts

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)