File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
packages/browser-utils/src/metrics Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -127,6 +127,32 @@ export function startTrackingLongAnimationFrames(): void {
127127 // NOTE: the current web-vitals version (3.5.2) does not support long-animation-frame, so
128128 // we should directly observe `long-animation-frame` events here instead of through the web-vitals
129129 // `observe` helper function.
130+ if ( PerformanceObserver . supportedEntryTypes . includes ( 'long-animation-frame' ) ) {
131+ const observer = new PerformanceObserver ( list => {
132+ for ( const entry of list . getEntries ( ) ) {
133+ if ( ! getActiveSpan ( ) ) {
134+ return ;
135+ }
136+ const startTime = msToSec ( ( browserPerformanceTimeOrigin as number ) + entry . startTime ) ;
137+ const duration = msToSec ( entry . duration ) ;
138+
139+ const span = startInactiveSpan ( {
140+ name : 'Main UI thread blocked' ,
141+ op : 'ui.long-animation-frame' ,
142+ startTime,
143+ attributes : {
144+ [ SEMANTIC_ATTRIBUTE_SENTRY_ORIGIN ] : 'auto.ui.browser.metrics' ,
145+ } ,
146+ } ) ;
147+ if ( span ) {
148+ span . end ( startTime + duration ) ;
149+ }
150+ }
151+ } ) ;
152+
153+ observer . observe ( { type : 'long-animation-frame' , buffered : true } ) ;
154+ }
155+
130156 // addPerformanceInstrumentationHandler('long-animation-frame', ({ entries }) => {
131157 // for (const entry of entries) {
132158 // if (!getActiveSpan()) {
You can’t perform that action at this time.
0 commit comments