Skip to content
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
4 changes: 2 additions & 2 deletions packages/deno/test/__snapshots__/mod.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ snapshot[`captureException 1`] = `
filename: "app:///test/mod.test.ts",
function: "<anonymous>",
in_app: true,
lineno: 43,
lineno: 42,
post_context: [
"",
" await delay(200);",
Expand All @@ -108,7 +108,7 @@ snapshot[`captureException 1`] = `
filename: "app:///test/mod.test.ts",
function: "something",
in_app: true,
lineno: 40,
lineno: 39,
post_context: [
" }",
"",
Expand Down
7 changes: 3 additions & 4 deletions packages/deno/test/mod.test.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
import { assertEquals } from 'https://deno.land/[email protected]/assert/assert_equals.ts';
import { assertSnapshot } from 'https://deno.land/[email protected]/testing/snapshot.ts';
import type { Event, Integration } from 'npm:@sentry/types';
import { createStackParser, nodeStackLineParser } from 'npm:@sentry/utils';

import { createStackParser, nodeStackLineParser } from '../../utils/build/esm/index.js';
import { defaultIntegrations, DenoClient, Hub, Scope } from '../build/index.js';
import { getNormalizedEvent } from './normalize.ts';
import { makeTestTransport } from './transport.ts';

function getTestClient(callback: (event?: Event) => void, integrations: Integration[] = []): [Hub, DenoClient] {
function getTestClient(callback: (event?: Event) => void, integrations: any[] = []): [Hub, DenoClient] {
const client = new DenoClient({
dsn: 'https://[email protected]/5650507',
debug: true,
integrations: [...defaultIntegrations, ...integrations],
stackParser: createStackParser(nodeStackLineParser()),
transport: makeTestTransport(envelope => {
callback(getNormalizedEvent(envelope));
}),
}) as any,
});

const scope = new Scope();
Expand Down
27 changes: 13 additions & 14 deletions packages/deno/test/normalize.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@
/* eslint-disable complexity */
import type { Envelope, Event, Session, Transaction } from 'npm:@sentry/types';
import { forEachEnvelopeItem } from 'npm:@sentry/utils';
import { forEachEnvelopeItem } from '../../utils/build/esm/index.js';

type EventOrSession = Event | Transaction | Session;
type EventOrSession = any;

export function getNormalizedEvent(envelope: Envelope): Event | undefined {
let event: Event | undefined;
export function getNormalizedEvent(envelope: any): any | undefined {
let event: any | undefined;

forEachEnvelopeItem(envelope, item => {
forEachEnvelopeItem(envelope, (item: any) => {
const [headers, body] = item;

if (headers.type === 'event') {
event = body as Event;
event = body;
}
});

return normalize(event) as Event | undefined;
return normalize(event) as any | undefined;
}

export function normalize(event: EventOrSession | undefined): EventOrSession | undefined {
Expand All @@ -24,14 +23,14 @@ export function normalize(event: EventOrSession | undefined): EventOrSession | u
}

if (eventIsSession(event)) {
return normalizeSession(event as Session);
return normalizeSession(event);
} else {
return normalizeEvent(event as Event);
return normalizeEvent(event);
}
}

export function eventIsSession(data: EventOrSession): boolean {
return !!(data as Session)?.sid;
return !!data?.sid;
}

/**
Expand All @@ -40,7 +39,7 @@ export function eventIsSession(data: EventOrSession): boolean {
* All properties that are timestamps, versions, ids or variables that may vary
* by platform are replaced with placeholder strings
*/
function normalizeSession(session: Session): Session {
function normalizeSession(session: any): any {
if (session.sid) {
session.sid = '{{id}}';
}
Expand All @@ -66,7 +65,7 @@ function normalizeSession(session: Session): Session {
* All properties that are timestamps, versions, ids or variables that may vary
* by platform are replaced with placeholder strings
*/
function normalizeEvent(event: Event): Event {
function normalizeEvent(event: any): any {
if (event.sdk?.version) {
event.sdk.version = '{{version}}';
}
Expand Down Expand Up @@ -157,7 +156,7 @@ function normalizeEvent(event: Event): Event {
if (event.exception?.values?.[0].stacktrace?.frames) {
// Exlcude Deno frames since these may change between versions
event.exception.values[0].stacktrace.frames = event.exception.values[0].stacktrace.frames.filter(
frame => !frame.filename?.includes('deno:'),
(frame: any) => !frame.filename?.includes('deno:'),
);
}

Expand Down