From d10eb94ed989ff249f2829fc0c5b779edffd32cf Mon Sep 17 00:00:00 2001 From: Alexander Date: Thu, 26 Oct 2023 13:43:42 +0400 Subject: [PATCH] refactor: remove `Sentry` util (#489) relates-to: #458 --- src/Config/CliBuilder.ts | 9 +++++---- src/Utils/Sentry.ts | 3 --- src/Utils/index.ts | 1 - 3 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 src/Utils/Sentry.ts diff --git a/src/Config/CliBuilder.ts b/src/Config/CliBuilder.ts index 2caa9b11..b6e8f686 100644 --- a/src/Config/CliBuilder.ts +++ b/src/Config/CliBuilder.ts @@ -1,8 +1,9 @@ import { CliConfig, ConfigReader } from './ConfigReader'; -import { ClusterArgs, Helpers, logger, LogLevel, Sentry } from '../Utils'; +import { ClusterArgs, Helpers, logger, LogLevel } from '../Utils'; import { SystemConfigManager } from './SystemConfigManager'; import { CliInfo } from './CliInfo'; import { Arguments, Argv, CommandModule } from 'yargs'; +import { init, runWithAsyncContext, setContext } from '@sentry/node'; export interface CliBuilderOptions { info: CliInfo; @@ -108,9 +109,9 @@ export class CliBuilder { const systemConfigManager = new SystemConfigManager(args.api as string); const systemConfig = await systemConfigManager.read(); - return Sentry.runWithAsyncContext(() => { + return runWithAsyncContext(() => { this.initSentry(systemConfig.sentryDsn); - Sentry.setContext('args', args); + setContext('args', args); systemConfigManager.enableBackgroundRotation((rotatedSystemConfig) => { this.initSentry(rotatedSystemConfig.sentryDsn); @@ -124,7 +125,7 @@ export class CliBuilder { } private initSentry(dsn: string) { - Sentry.init({ + init({ attachStacktrace: true, dsn, release: process.env.VERSION, diff --git a/src/Utils/Sentry.ts b/src/Utils/Sentry.ts deleted file mode 100644 index e3a504ad..00000000 --- a/src/Utils/Sentry.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { init, setContext, runWithAsyncContext } from '@sentry/node'; - -export default { init, setContext, runWithAsyncContext }; diff --git a/src/Utils/index.ts b/src/Utils/index.ts index 8b1cce64..332df095 100644 --- a/src/Utils/index.ts +++ b/src/Utils/index.ts @@ -3,4 +3,3 @@ export * from './Helpers'; export * from './Logger'; export * from './Backoff'; export * from './Traceroute'; -export { default as Sentry } from './Sentry';