diff --git a/deno.json b/deno.json index 72a9518..52bccbe 100644 --- a/deno.json +++ b/deno.json @@ -2,9 +2,9 @@ "$schema": "https://deno.land/x/deno@v1.32.3/cli/schemas/config-file.v1.json", "lock": false, "tasks": { - "start": "deno run --allow-read --allow-write=data --allow-env --allow-net src/server.ts", - "dev": "deno run --allow-read --allow-write=data --allow-env --allow-net --watch src/server.ts", - "debug": "deno run --allow-read --allow-write=data --allow-env --allow-net --inspect src/server.ts", + "start": "deno run --allow-read --allow-write=data --allow-env --allow-net --allow-sys src/server.ts", + "dev": "deno run --allow-read --allow-write=data --allow-env --allow-net --allow-sys --watch src/server.ts", + "debug": "deno run --allow-read --allow-write=data --allow-env --allow-net --allow-sys --inspect src/server.ts", "test": "DB_PATH=\":memory:\" deno test --allow-read --allow-write=data --allow-env src", "check": "deno check src/server.ts", "relays:sync": "deno run -A scripts/relays.ts sync" diff --git a/src/config.ts b/src/config.ts index ba36898..cce1ce2 100644 --- a/src/config.ts +++ b/src/config.ts @@ -144,6 +144,9 @@ const Conf = { local(path: string): string { return mergePaths(Conf.localDomain, path); }, + get sentryDsn() { + return Deno.env.get('SENTRY_DSN'); + }, }; const optionalBooleanSchema = z diff --git a/src/deps.ts b/src/deps.ts index e899f24..b0d5a63 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -72,5 +72,6 @@ export { S3Client } from 'https://deno.land/x/s3_lite_client@0.6.1/mod.ts'; export { default as IpfsHash } from 'npm:ipfs-only-hash@^4.0.0'; export { default as uuid62 } from 'npm:uuid62@^1.0.2'; export { Machina } from 'https://gitlab.com/soapbox-pub/nostr-machina/-/raw/08a157d39f2741c9a3a4364cb97db36e71d8c03a/mod.ts'; +export * as Sentry from 'npm:@sentry/node@^7.73.0'; export type * as TypeFest from 'npm:type-fest@^4.3.0'; diff --git a/src/server.ts b/src/server.ts index e3cf7ca..9dbb449 100644 --- a/src/server.ts +++ b/src/server.ts @@ -1,4 +1,15 @@ import './precheck.ts'; import app from './app.ts'; +import { Conf } from './config.ts'; +import { Sentry } from './deps.ts'; + +// Sentry +if (Conf.sentryDsn) { + console.log('Sentry enabled'); + Sentry.init({ + dsn: Conf.sentryDsn, + tracesSampleRate: 1.0, + }); +} Deno.serve(app.fetch);