Skip to content

Commit

Permalink
Re-export Sentry from init (DX) and call init from error endpoint to …
Browse files Browse the repository at this point in the history
…see if it fixes the issue with flush() timeout
  • Loading branch information
Vadorequest committed Jun 25, 2021
1 parent 15da42f commit d8ca4fd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/modules/core/sentry/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ if (process.env.SENTRY_DSN) {
release: process.env.NEXT_PUBLIC_APP_VERSION_RELEASE,
});

if (!process.env.SENTRY_DSN && process.env.NODE_ENV !== 'test') {
// eslint-disable-next-line no-console
console.error('Sentry DSN not defined');
}

// Scope configured by default, subsequent calls to "configureScope" will add additional data
Sentry.configureScope((scope) => { // See https://www.npmjs.com/package/@sentry/node
scope.setTag('customerRef', process.env.NEXT_PUBLIC_CUSTOMER_REF);
Expand All @@ -40,4 +35,11 @@ if (process.env.SENTRY_DSN) {
scope.setTag('memory', process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || null); // Optional - Available on production environment only
scope.setTag('runtimeEngine', isBrowser() ? 'browser' : 'server');
});
} else {
if (process.env.NODE_ENV !== 'test') {
// eslint-disable-next-line no-console
console.error('Sentry DSN not defined');
}
}

export default Sentry;
2 changes: 1 addition & 1 deletion src/pages/api/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { createLogger } from '@/modules/core/logging/logger';
import { configureReq } from '@/modules/core/sentry/server';
import { flushSafe } from '@/modules/core/sentry/universal';
import * as Sentry from '@sentry/node';
import Sentry from '@/modules/core/sentry/init';
import {
NextApiRequest,
NextApiResponse,
Expand Down

1 comment on commit d8ca4fd

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.