aboutsummaryrefslogtreecommitdiff
path: root/lib/common/Sentry.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/common/Sentry.ts')
-rw-r--r--lib/common/Sentry.ts24
1 files changed, 24 insertions, 0 deletions
diff --git a/lib/common/Sentry.ts b/lib/common/Sentry.ts
new file mode 100644
index 0000000..446ec27
--- /dev/null
+++ b/lib/common/Sentry.ts
@@ -0,0 +1,24 @@
+import { RewriteFrames } from '@sentry/integrations';
+import * as SentryNode from '@sentry/node';
+import { Integrations } from '@sentry/node';
+import type { Config } from '../../config/Config.js';
+
+export class Sentry {
+ public constructor(rootdir: string, config: Config) {
+ if (config.credentials.sentryDsn === null) throw TypeError('sentryDsn cannot be null');
+
+ SentryNode.init({
+ dsn: config.credentials.sentryDsn,
+ environment: config.environment,
+ tracesSampleRate: 1.0,
+ integrations: [
+ new RewriteFrames({
+ root: rootdir
+ }),
+ new Integrations.OnUnhandledRejection({
+ mode: 'none'
+ })
+ ]
+ });
+ }
+}