2020-11-29 17:10:12 +00:00
|
|
|
import * as Sentry from "@sentry/browser";
|
|
|
|
import { Integrations } from "@sentry/tracing";
|
|
|
|
import { VERSION } from "../constants";
|
2020-12-12 22:32:55 +00:00
|
|
|
import { SentryIgnoredError } from "../common/errors";
|
2021-03-16 20:32:39 +00:00
|
|
|
import { Config, Configuration, RootApi } from "authentik-api";
|
2021-03-08 10:14:00 +00:00
|
|
|
import { getCookie } from "../utils";
|
2020-11-26 21:37:41 +00:00
|
|
|
|
2021-03-08 10:14:00 +00:00
|
|
|
export const DEFAULT_CONFIG = new Configuration({
|
|
|
|
basePath: "/api/v2beta",
|
|
|
|
headers: {
|
|
|
|
"X-CSRFToken": getCookie("authentik_csrf"),
|
2020-12-01 12:59:59 +00:00
|
|
|
}
|
2021-03-08 10:14:00 +00:00
|
|
|
});
|
2020-11-29 17:10:12 +00:00
|
|
|
|
2021-03-08 10:14:00 +00:00
|
|
|
export function configureSentry(): Promise<Config> {
|
|
|
|
return new RootApi(DEFAULT_CONFIG).rootConfigList().then((config) => {
|
|
|
|
if (config.errorReportingEnabled) {
|
|
|
|
Sentry.init({
|
|
|
|
dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
|
|
|
|
release: `authentik@${VERSION}`,
|
|
|
|
integrations: [
|
|
|
|
new Integrations.BrowserTracing(),
|
|
|
|
],
|
|
|
|
tracesSampleRate: 0.6,
|
|
|
|
environment: config.errorReportingEnvironment,
|
|
|
|
beforeSend(event: Sentry.Event, hint: Sentry.EventHint) {
|
|
|
|
if (hint.originalException instanceof SentryIgnoredError) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return event;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
console.debug("authentik/config: Sentry enabled.");
|
|
|
|
}
|
|
|
|
return config;
|
|
|
|
});
|
2020-11-23 10:50:38 +00:00
|
|
|
}
|