From a99be258c330150c5bcb035f0eaccd3417708c89 Mon Sep 17 00:00:00 2001 From: Miriam Budayr <35577323+miriambudayr@users.noreply.github.com> Date: Mon, 8 Jul 2024 19:51:30 -0500 Subject: [PATCH] inline exports, remove unused method, and consolidate initialization methods --- packages/shared/src/sentry.ts | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/packages/shared/src/sentry.ts b/packages/shared/src/sentry.ts index 9c197470..98c2f644 100644 --- a/packages/shared/src/sentry.ts +++ b/packages/shared/src/sentry.ts @@ -24,11 +24,6 @@ class SentryAPI { console.warn(`Logger already initialized.`); } - this.initSentry(app, version); - this.initialized = true; - } - - private initSentry(app: string, version: string | undefined) { Sentry.init({ dsn: SENTRY_DSN, integrations: [nodeProfilingIntegration()], @@ -38,6 +33,8 @@ class SentryAPI { app, version, }); + + this.initialized = true; } identify(authInfo: AuthInfo) { @@ -52,14 +49,6 @@ class SentryAPI { await Sentry.close(); } - async flush() { - if (process.env.REPLAY_TELEMETRY_DISABLED) { - return; - } - - await Sentry.flush(); - } - captureException(error: Error, tags?: Tags) { if (process.env.REPLAY_TELEMETRY_DISABLED) { return; @@ -94,11 +83,11 @@ export const sentry = new SentryAPI(); // This should be called with the name once at the entry point. // For example, with the Playwright plugin, it is called in the Reporter interface constructor. -function initSentry(app: string, version: string | undefined) { +export function initSentry(app: string, version: string | undefined) { sentry.initialize(app, version); } -async function withSentry( +export async function withSentry( methodName: string, fn: () => T | Promise, tags?: Tags @@ -113,7 +102,7 @@ async function withSentry( } } -function withSentrySync(methodName: string, fn: () => T): T { +export function withSentrySync(methodName: string, fn: () => T): T { try { return fn(); } catch (error: any) { @@ -122,5 +111,3 @@ function withSentrySync(methodName: string, fn: () => T): T { throw error; } } - -export { initSentry, withSentry, withSentrySync };