@@ -44,22 +44,26 @@ export function startTrackingWebVitals(reportAllChanges: boolean = false): void
4444 * Start tracking long tasks.
4545 */
4646export function startTrackingLongTasks ( ) : void {
47- const entryHandler : PerformanceEntryHandler = ( entry : PerformanceEntry ) : void => {
48- const transaction = getActiveTransaction ( ) as IdleTransaction | undefined ;
49- if ( ! transaction ) {
50- return ;
51- }
52- const startTime = msToSec ( entry . startTime ) ;
53- const duration = msToSec ( entry . duration ) ;
54- transaction . startChild ( {
55- description : 'Long Task' ,
56- op : 'ui.long-task' ,
57- startTimestamp : startTime ,
58- endTimestamp : startTime + duration ,
59- } ) ;
60- } ;
47+ try {
48+ const entryHandler : PerformanceEntryHandler = ( entry : PerformanceEntry ) : void => {
49+ const transaction = getActiveTransaction ( ) as IdleTransaction | undefined ;
50+ if ( ! transaction ) {
51+ return ;
52+ }
53+ const startTime = msToSec ( entry . startTime ) ;
54+ const duration = msToSec ( entry . duration ) ;
55+ transaction . startChild ( {
56+ description : 'Long Task' ,
57+ op : 'ui.long-task' ,
58+ startTimestamp : startTime ,
59+ endTimestamp : startTime + duration ,
60+ } ) ;
61+ } ;
6162
62- observe ( 'longtask' , entryHandler ) ;
63+ observe ( 'longtask' , entryHandler ) ;
64+ } catch ( _ ) {
65+ // Do nothing
66+ }
6367}
6468
6569/** Starts tracking the Cumulative Layout Shift on the current page. */
0 commit comments