@@ -44,22 +44,26 @@ export function startTrackingWebVitals(reportAllChanges: boolean = false): void
44
44
* Start tracking long tasks.
45
45
*/
46
46
export 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
+ } ;
61
62
62
- observe ( 'longtask' , entryHandler ) ;
63
+ observe ( 'longtask' , entryHandler ) ;
64
+ } catch ( _ ) {
65
+ // Do nothing
66
+ }
63
67
}
64
68
65
69
/** Starts tracking the Cumulative Layout Shift on the current page. */
0 commit comments