File tree Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Expand file tree Collapse file tree 2 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -28,13 +28,15 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even
28
28
29
29
// Collect traceIds in _context regardless of `_waitForError` - if it's true,
30
30
// _context gets cleared on every checkout
31
- if ( event . type === 'transaction' ) {
32
- replay . getContext ( ) . traceIds . add ( String ( event . contexts ? .trace ? .trace_id || '' ) ) ;
31
+ if ( event . type === 'transaction' && event . contexts && event . contexts . trace && event . contexts . trace . trace_id ) {
32
+ replay . getContext ( ) . traceIds . add ( event . contexts . trace . trace_id as string ) ;
33
33
return event ;
34
34
}
35
35
36
- // XXX: Is it safe to assume that all other events are error events?
37
- replay . getContext ( ) . errorIds . add ( event . event_id as string ) ;
36
+ // no event type means error
37
+ if ( ! event . type ) {
38
+ replay . getContext ( ) . errorIds . add ( event . event_id as string ) ;
39
+ }
38
40
39
41
const exc = event . exception ?. values ?. [ 0 ] ;
40
42
addInternalBreadcrumb ( {
Original file line number Diff line number Diff line change @@ -7,14 +7,13 @@ import { createPerformanceSpans } from './createPerformanceSpans';
7
7
* (including v8 internal objects).
8
8
*/
9
9
export function addMemoryEntry ( replay : ReplayContainer ) : Promise < void [ ] > | undefined {
10
- // window.performance.memory is a non-standard API and doesn't work on all browsers
11
- // so we check before creating the event.
12
- if ( ! ( 'memory' in WINDOW . performance ) ) {
10
+ // window.performance.memory is a non-standard API and doesn't work on all browsers, so we try-catch this
11
+ try {
12
+ return createPerformanceSpans ( replay , [
13
+ // @ts -ignore memory doesn't exist on type Performance as the API is non-standard (we check that it exists above)
14
+ createMemoryEntry ( WINDOW . performance . memory ) ,
15
+ ] ) ;
16
+ } catch ( error ) {
13
17
return ;
14
18
}
15
-
16
- return createPerformanceSpans ( replay , [
17
- // @ts -ignore memory doesn't exist on type Performance as the API is non-standard (we check that it exists above)
18
- createMemoryEntry ( WINDOW . performance . memory ) ,
19
- ] ) ;
20
19
}
You can’t perform that action at this time.
0 commit comments