@@ -18,7 +18,6 @@ import {
1818 getClient ,
1919 getCurrentScope ,
2020 getDynamicSamplingContextFromSpan ,
21- GLOBAL_OBJ ,
2221 hasSpansEnabled ,
2322 hasSpanStreamingEnabled ,
2423 NAVIGATION_SPAN_NAME_FALLBACK ,
@@ -36,11 +35,10 @@ import {
3635import { _INTERNAL_ensureBrowserSpanStreaming , startIdleSpan , startInactiveSpan } from '@sentry/core/browser' ;
3736import {
3837 addHistoryInstrumentationHandler ,
38+ longTasksIntegration ,
3939 addPerformanceEntries ,
4040 getLocationHref ,
4141 isBotUserAgent ,
42- startTrackingLongAnimationFrames ,
43- startTrackingLongTasks ,
4442} from '@sentry/browser-utils' ;
4543import { BROWSER_NAVIGATION_TYPE } from '@sentry/conventions/attributes' ;
4644import { DEBUG_BUILD } from '../debug-build' ;
@@ -286,16 +284,17 @@ export interface BrowserTracingOptions {
286284 * Options for `browserTracingCoreIntegration`: the options of `browserTracingIntegration`, minus the ones
287285 * for features that `browserTracingIntegration` registers as standalone integrations.
288286 */
289- export type BrowserTracingCoreOptions = Omit < BrowserTracingOptions , 'enableInp' | 'webVitals' | 'enableElementTiming' > ;
287+ export type BrowserTracingCoreOptions = Omit <
288+ BrowserTracingOptions ,
289+ 'enableInp' | 'webVitals' | 'enableElementTiming' | 'enableLongTask' | 'enableLongAnimationFrame'
290+ > ;
290291
291292const DEFAULT_BROWSER_TRACING_OPTIONS : BrowserTracingCoreOptions = {
292293 ...TRACING_DEFAULTS ,
293294 instrumentNavigation : true ,
294295 instrumentBfcacheRestore : true ,
295296 instrumentPageLoad : true ,
296297 markBackgroundSpan : true ,
297- enableLongTask : true ,
298- enableLongAnimationFrame : true ,
299298 ignoreResourceSpans : [ ] ,
300299 detectRedirects : true ,
301300 linkPreviousTrace : 'in-memory' ,
@@ -324,7 +323,7 @@ export const browserTracingIntegration = ((options: Partial<BrowserTracingOption
324323 }
325324
326325 // oxlint-disable-next-line typescript/no-deprecated -- still honoured until it is removed
327- const { enableInp = true , webVitals } = options ;
326+ const { enableInp = true , webVitals, enableLongTask = true , enableLongAnimationFrame = true } = options ;
328327
329328 return _browserTracingIntegration ( options , client => {
330329 const ignore = webVitals ?. ignore ?? [ ] ;
@@ -334,6 +333,10 @@ export const browserTracingIntegration = ((options: Partial<BrowserTracingOption
334333 ignore : enableInp || ignore . includes ( 'inp' ) ? ignore : [ ...ignore , 'inp' ] ,
335334 } ) ,
336335 ) ;
336+
337+ if ( enableLongTask || enableLongAnimationFrame ) {
338+ client . addIntegration ( longTasksIntegration ( { enableLongTask, enableLongAnimationFrame } ) ) ;
339+ }
337340 } ) ;
338341} ) satisfies IntegrationFn ;
339342
@@ -358,8 +361,6 @@ function _browserTracingIntegration(
358361 const optionalWindowDocument = WINDOW . document as ( typeof WINDOW ) [ 'document' ] | undefined ;
359362
360363 const {
361- enableLongTask,
362- enableLongAnimationFrame,
363364 beforeStartSpan,
364365 idleTimeout,
365366 finalTimeout,
@@ -470,16 +471,6 @@ function _browserTracingIntegration(
470471
471472 registerSpanErrorInstrumentation ( ) ;
472473
473- if (
474- enableLongAnimationFrame &&
475- GLOBAL_OBJ . PerformanceObserver &&
476- PerformanceObserver . supportedEntryTypes ?. includes ( 'long-animation-frame' )
477- ) {
478- startTrackingLongAnimationFrames ( ) ;
479- } else if ( enableLongTask ) {
480- startTrackingLongTasks ( ) ;
481- }
482-
483474 if ( detectRedirects && optionalWindowDocument ) {
484475 const interactionHandler = ( ) : void => {
485476 lastInteractionTimestamp = timestampInSeconds ( ) ;
0 commit comments