Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 18 additions & 9 deletions web/src/common/sentry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function beforeSend(
if (!hint) {
return event;
}

if (hint.originalException instanceof SentryIgnoredError) {
return null;
}
Expand All @@ -40,6 +41,7 @@ function beforeSend(
) {
return null;
}

return event;
}

Expand All @@ -53,21 +55,25 @@ export function configureSentry(): void {

const logger = ConsoleLogger.prefix("sentry");

const integrations: Integration[] = [
browserTracingIntegration({
// https://docs.sentry.io/platforms/javascript/tracing/instrumentation/automatic-instrumentation/#custom-routing
instrumentNavigation: false,
instrumentPageLoad: false,
traceFetch: false,
}),
];
const integrations: Integration[] =
process.env.NODE_ENV === "production"
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note that the repetition of process.env.NODE_ENV is how we hint to ESBuild that the value is a constant and the browserTracingIntegration import eligible for tree-shaking.

? [
browserTracingIntegration({
// https://docs.sentry.io/platforms/javascript/tracing/instrumentation/automatic-instrumentation/#custom-routing
instrumentNavigation: false,
instrumentPageLoad: false,
traceFetch: false,
}),
]
: [];

if (debug) {
logger.debug("Enabled Spotlight");
integrations.push(spotlightBrowserIntegration());
}

init({
enabled: process.env.NODE_ENV !== "production",
dsn: cfg.errorReporting.sentryDsn,
ignoreErrors: [
/network/gi,
Expand All @@ -80,7 +86,10 @@ export function configureSentry(): void {
/MutationObserver.observe/gi,
/NS_ERROR_FAILURE/gi,
],
release: `authentik@${import.meta.env.AK_VERSION}`,
release:
process.env.NODE_ENV === "production"
? `authentik@${import.meta.env.AK_VERSION}`
: undefined,
integrations,
tracePropagationTargets: [window.location.origin],
tracesSampleRate: debug ? 1.0 : cfg.errorReporting.tracesSampleRate,
Expand Down
2 changes: 1 addition & 1 deletion web/src/elements/router/RouterOutlet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class RouterOutlet extends AKElement {

window.addEventListener("hashchange", this.navigate);

if (this.#sentryClient) {
if (process.env.NODE_ENV !== "production" && this.#sentryClient) {
this.#pageLoadSpan =
startBrowserTracingPageLoadSpan(this.#sentryClient, {
name: window.location.pathname,
Expand Down
Loading