Skip to content

Commit a1343b3

Browse files
committed
ref(replay): PR feedback
1 parent 339c05d commit a1343b3

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

packages/replay/src/coreHandlers/handleGlobalEvent.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,15 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even
2828

2929
// Collect traceIds in _context regardless of `_waitForError` - if it's true,
3030
// _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);
3333
return event;
3434
}
3535

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+
}
3840

3941
const exc = event.exception?.values?.[0];
4042
addInternalBreadcrumb({

packages/replay/src/util/addMemoryEntry.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ import { createPerformanceSpans } from './createPerformanceSpans';
77
* (including v8 internal objects).
88
*/
99
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) {
1317
return;
1418
}
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-
]);
2019
}

0 commit comments

Comments
 (0)