Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ref(replay): PR feedback
  • Loading branch information
mydea committed Dec 9, 2022
commit 432da151e3b3b76251c570c4bf123044319055ef
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 {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

l: can we change the func signature here to just be void? Then we don't need the return statements and we can also just void createPerformanceSpans

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good finding, there is actually nothing async about this 😅 so should be good to clean up. done!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addEvent should be async

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addEvent was also sync before, and we are not really waiting for it anywhere?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 , it may have been a bug -- eventbuffer's addevent is async, looks like replay.addEvent was not returning the promise.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I think you're right - but I'll make a separate PR to fix that 👍

// 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),
]);
}