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

refactor: make sentry cloud agnostic #1079

Merged
merged 1 commit into from
May 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 7 additions & 5 deletions packages/backend/src/helpers/sentry.ee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import * as Tracing from '@sentry/tracing';

import appConfig from '../config/app';

const isSentryEnabled = !!appConfig.sentryDsn;

export function init(app?: Express) {
if (!appConfig.isCloud) return;
if (!isSentryEnabled) return;

return Sentry.init({
enabled: !!appConfig.sentryDsn,
Expand All @@ -22,19 +24,19 @@ export function init(app?: Express) {


export function attachRequestHandler(app: Express) {
if (!appConfig.isCloud) return;
if (!isSentryEnabled) return;

app.use(Sentry.Handlers.requestHandler());
}

export function attachTracingHandler(app: Express) {
if (!appConfig.isCloud) return;
if (!isSentryEnabled) return;

app.use(Sentry.Handlers.tracingHandler());
}

export function attachErrorHandler(app: Express) {
if (!appConfig.isCloud) return;
if (!isSentryEnabled) return;

app.use(Sentry.Handlers.errorHandler({
shouldHandleError() {
Expand All @@ -45,7 +47,7 @@ export function attachErrorHandler(app: Express) {
}

export function captureException(exception: any, captureContext?: CaptureContext) {
if (!appConfig.isCloud) return;
if (!isSentryEnabled) return;

return Sentry.captureException(exception, captureContext);
}