Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ref(deno): Update deno integrations to avoid setupOnce #9812

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
9 changes: 7 additions & 2 deletions packages/deno/src/integrations/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ export class DenoContext implements Integration {
public name: string = DenoContext.id;

/** @inheritDoc */
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void {
addGlobalEventProcessor(async (event: Event) => denoRuntime(event));
public setupOnce(_addGlobalEventProcessor: (callback: EventProcessor) => void): void {
// noop
}

/** @inheritDoc */
public processEvent(event: Event): Promise<Event> {
return denoRuntime(event);
}
}
9 changes: 7 additions & 2 deletions packages/deno/src/integrations/contextlines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,13 @@ export class ContextLines implements Integration {
/**
* @inheritDoc
*/
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void {
addGlobalEventProcessor(event => this.addSourceContext(event));
public setupOnce(_addGlobalEventProcessor: (callback: EventProcessor) => void): void {
// noop
}

/** @inheritDoc */
public processEvent(event: Event): Promise<Event> {
return this.addSourceContext(event);
}

/** Processes an event and adds context lines */
Expand Down
31 changes: 17 additions & 14 deletions packages/deno/src/integrations/normalizepaths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,29 +72,32 @@ export class NormalizePaths implements Integration {
public name: string = NormalizePaths.id;

/** @inheritDoc */
public setupOnce(addGlobalEventProcessor: (callback: EventProcessor) => void): void {
public setupOnce(_addGlobalEventProcessor: (callback: EventProcessor) => void): void {
// noop
}

/** @inheritDoc */
public processEvent(event: Event): Event | null {
// This error.stack hopefully contains paths that traverse the app cwd
const error = new Error();

addGlobalEventProcessor((event: Event): Event | null => {
const appRoot = getAppRoot(error);
const appRoot = getAppRoot(error);

if (appRoot) {
for (const exception of event.exception?.values || []) {
for (const frame of exception.stacktrace?.frames || []) {
if (frame.filename && frame.in_app) {
const startIndex = frame.filename.indexOf(appRoot);
if (appRoot) {
for (const exception of event.exception?.values || []) {
for (const frame of exception.stacktrace?.frames || []) {
if (frame.filename && frame.in_app) {
const startIndex = frame.filename.indexOf(appRoot);

if (startIndex > -1) {
const endIndex = startIndex + appRoot.length;
frame.filename = `app://${frame.filename.substring(endIndex)}`;
}
if (startIndex > -1) {
const endIndex = startIndex + appRoot.length;
frame.filename = `app://${frame.filename.substring(endIndex)}`;
}
}
}
}
}

return event;
});
return event;
}
}