web: ignore module load errors
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
90e3ae9457
commit
e758c434ea
|
@ -74,7 +74,7 @@ class ConfigView(APIView):
|
||||||
config = ConfigSerializer(
|
config = ConfigSerializer(
|
||||||
{
|
{
|
||||||
"error_reporting": {
|
"error_reporting": {
|
||||||
"enabled": CONFIG.y("error_reporting.enabled") and not settings.DEBUG,
|
"enabled": CONFIG.y("error_reporting.enabled"),
|
||||||
"environment": CONFIG.y("error_reporting.environment"),
|
"environment": CONFIG.y("error_reporting.environment"),
|
||||||
"send_pii": CONFIG.y("error_reporting.send_pii"),
|
"send_pii": CONFIG.y("error_reporting.send_pii"),
|
||||||
"traces_sample_rate": float(CONFIG.y("error_reporting.sample_rate", 0.4)),
|
"traces_sample_rate": float(CONFIG.y("error_reporting.sample_rate", 0.4)),
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { VERSION } from "@goauthentik/web/constants";
|
||||||
import * as Sentry from "@sentry/browser";
|
import * as Sentry from "@sentry/browser";
|
||||||
import { Integrations } from "@sentry/tracing";
|
import { Integrations } from "@sentry/tracing";
|
||||||
|
|
||||||
import { Config } from "@goauthentik/api";
|
import { Config, ResponseError } from "@goauthentik/api";
|
||||||
|
|
||||||
import { config } from "./Config";
|
import { config } from "./Config";
|
||||||
import { me } from "./Users";
|
import { me } from "./Users";
|
||||||
|
@ -11,66 +11,66 @@ import { me } from "./Users";
|
||||||
export const TAG_SENTRY_COMPONENT = "authentik.component";
|
export const TAG_SENTRY_COMPONENT = "authentik.component";
|
||||||
export const TAG_SENTRY_CAPABILITIES = "authentik.capabilities";
|
export const TAG_SENTRY_CAPABILITIES = "authentik.capabilities";
|
||||||
|
|
||||||
export function configureSentry(canDoPpi = false): Promise<Config> {
|
export async function configureSentry(canDoPpi = false): Promise<Config> {
|
||||||
return config().then((config) => {
|
const cfg = await config();
|
||||||
if (config.errorReporting.enabled) {
|
if (cfg.errorReporting.enabled) {
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
|
dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
|
||||||
ignoreErrors: [
|
ignoreErrors: [
|
||||||
/network/gi,
|
/network/gi,
|
||||||
/fetch/gi,
|
/fetch/gi,
|
||||||
// Error on edge on ios,
|
/module/gi,
|
||||||
// https://stackoverflow.com/questions/69261499/what-is-instantsearchsdkjsbridgeclearhighlight
|
// Error on edge on ios,
|
||||||
/instantSearchSDKJSBridgeClearHighlight/gi,
|
// https://stackoverflow.com/questions/69261499/what-is-instantsearchsdkjsbridgeclearhighlight
|
||||||
// Seems to be an issue in Safari and Firefox
|
/instantSearchSDKJSBridgeClearHighlight/gi,
|
||||||
/MutationObserver.observe/gi,
|
// Seems to be an issue in Safari and Firefox
|
||||||
],
|
/MutationObserver.observe/gi,
|
||||||
release: `authentik@${VERSION}`,
|
],
|
||||||
tunnel: "/api/v3/sentry/",
|
release: `authentik@${VERSION}`,
|
||||||
integrations: [
|
tunnel: "/api/v3/sentry/",
|
||||||
new Integrations.BrowserTracing({
|
integrations: [
|
||||||
tracingOrigins: [window.location.host, "localhost"],
|
new Integrations.BrowserTracing({
|
||||||
}),
|
tracingOrigins: [window.location.host, "localhost"],
|
||||||
],
|
}),
|
||||||
tracesSampleRate: config.errorReporting.tracesSampleRate,
|
],
|
||||||
environment: config.errorReporting.environment,
|
tracesSampleRate: cfg.errorReporting.tracesSampleRate,
|
||||||
beforeSend: async (
|
environment: cfg.errorReporting.environment,
|
||||||
event: Sentry.Event,
|
beforeSend: async (
|
||||||
hint: Sentry.EventHint | undefined,
|
event: Sentry.Event,
|
||||||
): Promise<Sentry.Event | null> => {
|
hint: Sentry.EventHint | undefined,
|
||||||
if (!hint) {
|
): Promise<Sentry.Event | null> => {
|
||||||
return event;
|
if (!hint) {
|
||||||
}
|
|
||||||
if (hint.originalException instanceof SentryIgnoredError) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
hint.originalException instanceof Response ||
|
|
||||||
hint.originalException instanceof DOMException
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return event;
|
return event;
|
||||||
},
|
}
|
||||||
});
|
if (hint.originalException instanceof SentryIgnoredError) {
|
||||||
Sentry.setTag(TAG_SENTRY_CAPABILITIES, config.capabilities.join(","));
|
return null;
|
||||||
if (window.location.pathname.includes("if/")) {
|
}
|
||||||
Sentry.setTag(TAG_SENTRY_COMPONENT, `web/${currentInterface()}`);
|
if (
|
||||||
Sentry.configureScope((scope) =>
|
hint.originalException instanceof ResponseError ||
|
||||||
scope.setTransactionName(`authentik.web.if.${currentInterface()}`),
|
hint.originalException instanceof DOMException
|
||||||
);
|
) {
|
||||||
}
|
return null;
|
||||||
if (config.errorReporting.sendPii && canDoPpi) {
|
}
|
||||||
me().then((user) => {
|
return event;
|
||||||
Sentry.setUser({ email: user.user.email });
|
},
|
||||||
console.debug("authentik/config: Sentry with PII enabled.");
|
});
|
||||||
});
|
Sentry.setTag(TAG_SENTRY_CAPABILITIES, cfg.capabilities.join(","));
|
||||||
} else {
|
if (window.location.pathname.includes("if/")) {
|
||||||
console.debug("authentik/config: Sentry enabled.");
|
Sentry.setTag(TAG_SENTRY_COMPONENT, `web/${currentInterface()}`);
|
||||||
}
|
Sentry.configureScope((scope) =>
|
||||||
|
scope.setTransactionName(`authentik.web.if.${currentInterface()}`),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
return config;
|
if (cfg.errorReporting.sendPii && canDoPpi) {
|
||||||
});
|
me().then((user) => {
|
||||||
|
Sentry.setUser({ email: user.user.email });
|
||||||
|
console.debug("authentik/config: Sentry with PII enabled.");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.debug("authentik/config: Sentry enabled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get the interface name from URL
|
// Get the interface name from URL
|
||||||
|
|
Reference in New Issue