Skip to content

Commit

Permalink
refactor: reexport Sentry from utils
Browse files Browse the repository at this point in the history
  • Loading branch information
lsndr committed Oct 5, 2023
1 parent 8f962ff commit eeed3de
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
13 changes: 4 additions & 9 deletions src/Config/CliBuilder.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import { CliConfig, ConfigReader } from './ConfigReader';
import { ClusterArgs, Helpers, logger, LogLevel } from '../Utils';
import { ClusterArgs, Helpers, logger, LogLevel, Sentry } from '../Utils';
import { SystemConfigReader } from './SystemConfigReader';
import { CliInfo } from './CliInfo';
import { Arguments, Argv, CommandModule } from 'yargs';
import {
init as initSentry,
runWithAsyncContext as runSentryWithAsyncContext,
setContext as setSentryContext
} from '@sentry/node';

export interface CliBuilderOptions {
info: CliInfo;
Expand Down Expand Up @@ -98,7 +93,7 @@ export class CliBuilder {
const systemConfigReader = new SystemConfigReader(args.api as string);
const systemConfig = await systemConfigReader.read();

initSentry({
Sentry.init({
attachStacktrace: true,
dsn: systemConfig.sentryDsn,
release: process.env.VERSION,
Expand All @@ -115,8 +110,8 @@ export class CliBuilder {
}
});

return runSentryWithAsyncContext(() => {
setSentryContext('args', args);
return Sentry.runWithAsyncContext(() => {
Sentry.setContext('args', args);

return handler(args);
});
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/Sentry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { init, setContext, runWithAsyncContext } from '@sentry/node';

export default { init, setContext, runWithAsyncContext };
1 change: 1 addition & 0 deletions src/Utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@ export * from './Helpers';
export * from './Logger';
export * from './Backoff';
export * from './Traceroute';
export { default as Sentry } from './Sentry';

0 comments on commit eeed3de

Please sign in to comment.