Skip to content

Commit

Permalink
ref(replay): PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea committed Dec 7, 2022
1 parent 339c05d commit a1343b3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
10 changes: 6 additions & 4 deletions packages/replay/src/coreHandlers/handleGlobalEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ export function handleGlobalEventListener(replay: ReplayContainer): (event: Even

// Collect traceIds in _context regardless of `_waitForError` - if it's true,
// _context gets cleared on every checkout
if (event.type === 'transaction') {
replay.getContext().traceIds.add(String(event.contexts?.trace?.trace_id || ''));
if (event.type === 'transaction' && event.contexts && event.contexts.trace && event.contexts.trace.trace_id) {
replay.getContext().traceIds.add(event.contexts.trace.trace_id as string);
return event;
}

// XXX: Is it safe to assume that all other events are error events?
replay.getContext().errorIds.add(event.event_id as string);
// no event type means error
if (!event.type) {
replay.getContext().errorIds.add(event.event_id as string);
}

const exc = event.exception?.values?.[0];
addInternalBreadcrumb({
Expand Down
15 changes: 7 additions & 8 deletions packages/replay/src/util/addMemoryEntry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import { createPerformanceSpans } from './createPerformanceSpans';
* (including v8 internal objects).
*/
export function addMemoryEntry(replay: ReplayContainer): Promise<void[]> | undefined {
// window.performance.memory is a non-standard API and doesn't work on all browsers
// so we check before creating the event.
if (!('memory' in WINDOW.performance)) {
// window.performance.memory is a non-standard API and doesn't work on all browsers, so we try-catch this
try {
return createPerformanceSpans(replay, [
// @ts-ignore memory doesn't exist on type Performance as the API is non-standard (we check that it exists above)
createMemoryEntry(WINDOW.performance.memory),
]);
} catch (error) {
return;
}

return createPerformanceSpans(replay, [
// @ts-ignore memory doesn't exist on type Performance as the API is non-standard (we check that it exists above)
createMemoryEntry(WINDOW.performance.memory),
]);
}

0 comments on commit a1343b3

Please sign in to comment.