Skip to content

Commit

Permalink
ref(wasm): Refactor Wasm integration to use processEvent (#9019)
Browse files Browse the repository at this point in the history
This refactors Wasm integration to use `processEvent`.
  • Loading branch information
mydea committed Sep 27, 2023
1 parent e448247 commit affa527
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/wasm/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Event, EventProcessor, Hub, Integration, StackFrame } from '@sentry/types';
import type { Event, Integration, StackFrame } from '@sentry/types';

import { patchWebAssembly } from './patchWebAssembly';
import { getImage, getImages } from './registry';
Expand Down Expand Up @@ -49,26 +49,27 @@ export class Wasm implements Integration {
/**
* @inheritDoc
*/
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void, _getCurrentHub: () => Hub): void {
public setupOnce(_addGlobaleventProcessor: unknown, _getCurrentHub: unknown): void {
patchWebAssembly();
}

addGlobalEventProcessor((event: Event) => {
let haveWasm = false;
/** @inheritDoc */
public processEvent(event: Event): Event {
let haveWasm = false;

if (event.exception && event.exception.values) {
event.exception.values.forEach(exception => {
if (exception?.stacktrace?.frames) {
haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);
}
});
}
if (event.exception && event.exception.values) {
event.exception.values.forEach(exception => {
if (exception?.stacktrace?.frames) {
haveWasm = haveWasm || patchFrames(exception.stacktrace.frames);
}
});
}

if (haveWasm) {
event.debug_meta = event.debug_meta || {};
event.debug_meta.images = [...(event.debug_meta.images || []), ...getImages()];
}
if (haveWasm) {
event.debug_meta = event.debug_meta || {};
event.debug_meta.images = [...(event.debug_meta.images || []), ...getImages()];
}

return event;
});
return event;
}
}

0 comments on commit affa527

Please sign in to comment.