-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
100 additions
and
191 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,56 @@ | ||
import { PrismaInstrumentation } from "@prisma/instrumentation"; | ||
import "./polyfills"; | ||
|
||
import * as Sentry from "@sentry/nextjs"; | ||
import { getEnvVariable, getNodeEnvironment } from "@stackframe/stack-shared/dist/utils/env"; | ||
import { nicify } from "@stackframe/stack-shared/dist/utils/strings"; | ||
import { registerOTel } from '@vercel/otel'; | ||
import "./polyfills"; | ||
|
||
export function register() { | ||
registerOTel({ | ||
serviceName: 'stack-backend', | ||
instrumentations: [new PrismaInstrumentation()], | ||
}); | ||
|
||
if (getEnvVariable("NEXT_RUNTIME") === "nodejs" || getEnvVariable("NEXT_RUNTIME") === "edge") { | ||
Sentry.init({ | ||
dsn: getEnvVariable("NEXT_PUBLIC_SENTRY_DSN"), | ||
|
||
ignoreErrors: [ | ||
// React throws these errors when used with some browser extensions (eg. Google Translate) | ||
"NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.", | ||
"NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.", | ||
], | ||
|
||
// Adjust this value in production, or use tracesSampler for greater control | ||
tracesSampleRate: 1, | ||
|
||
// Setting this option to true will print useful information to the console while you're setting up Sentry. | ||
debug: true, | ||
|
||
enabled: getNodeEnvironment() !== "development" && !getEnvVariable("CI"), | ||
|
||
// Add exception metadata to the event | ||
beforeSend(event, hint) { | ||
const error = hint.originalException; | ||
let nicified; | ||
try { | ||
nicified = nicify(error, { maxDepth: 8 }); | ||
} catch (e) { | ||
nicified = `Error occurred during nicification: ${e}`; | ||
} | ||
if (error instanceof Error) { | ||
event.extra = { | ||
...event.extra, | ||
cause: error.cause, | ||
errorProps: { | ||
...error, | ||
}, | ||
nicifiedError: nicified, | ||
}; | ||
} | ||
return event; | ||
}, | ||
}); | ||
|
||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as Sentry from "@sentry/nextjs"; | ||
import { getEnvVariable, getNodeEnvironment } from "@stackframe/stack-shared/dist/utils/env"; | ||
import { nicify } from "@stackframe/stack-shared/dist/utils/strings"; | ||
import "./polyfills"; | ||
|
||
export function register() { | ||
if (getEnvVariable("NEXT_RUNTIME") === "nodejs" || getEnvVariable("NEXT_RUNTIME") === "edge") { | ||
Sentry.init({ | ||
dsn: getEnvVariable("NEXT_PUBLIC_SENTRY_DSN"), | ||
|
||
ignoreErrors: [ | ||
// React throws these errors when used with some browser extensions (eg. Google Translate) | ||
"NotFoundError: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.", | ||
"NotFoundError: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.", | ||
], | ||
|
||
// Adjust this value in production, or use tracesSampler for greater control | ||
tracesSampleRate: 1, | ||
|
||
// Setting this option to true will print useful information to the console while you're setting up Sentry. | ||
debug: false, | ||
|
||
enabled: getNodeEnvironment() !== "development" && !getEnvVariable("CI"), | ||
|
||
// Add exception metadata to the event | ||
beforeSend(event, hint) { | ||
const error = hint.originalException; | ||
let nicified; | ||
try { | ||
nicified = nicify(error, { maxDepth: 8 }); | ||
} catch (e) { | ||
nicified = `Error occurred during nicification: ${e}`; | ||
} | ||
if (error instanceof Error) { | ||
event.extra = { | ||
...event.extra, | ||
cause: error.cause, | ||
errorProps: { | ||
...error, | ||
}, | ||
nicifiedError: nicified, | ||
}; | ||
} | ||
return event; | ||
}, | ||
}); | ||
|
||
} | ||
} |