2020-12-16 22:02:43 +00:00
|
|
|
import { DefaultClient } from "./Client";
|
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";
|
2020-11-26 21:37:41 +00:00
|
|
|
|
|
|
|
export class Config {
|
2020-12-01 12:59:59 +00:00
|
|
|
branding_logo: string;
|
|
|
|
branding_title: string;
|
2020-11-23 10:50:38 +00:00
|
|
|
|
2020-12-01 12:59:59 +00:00
|
|
|
error_reporting_enabled: boolean;
|
|
|
|
error_reporting_environment: string;
|
|
|
|
error_reporting_send_pii: boolean;
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
throw Error();
|
|
|
|
}
|
2020-11-29 17:10:12 +00:00
|
|
|
|
2020-11-26 21:37:41 +00:00
|
|
|
static get(): Promise<Config> {
|
2020-11-29 21:14:48 +00:00
|
|
|
return DefaultClient.fetch<Config>(["root", "config"]).then((config) => {
|
|
|
|
if (config.error_reporting_enabled) {
|
|
|
|
Sentry.init({
|
2020-12-05 21:08:42 +00:00
|
|
|
dsn: "https://a579bb09306d4f8b8d8847c052d3a1d3@sentry.beryju.org/8",
|
|
|
|
release: `authentik@${VERSION}`,
|
2021-02-27 16:18:42 +00:00
|
|
|
integrations: [
|
|
|
|
new Integrations.BrowserTracing(),
|
|
|
|
],
|
2021-02-02 14:50:29 +00:00
|
|
|
tracesSampleRate: 0.6,
|
2020-11-29 21:14:48 +00:00
|
|
|
environment: config.error_reporting_environment,
|
2020-12-12 22:32:55 +00:00
|
|
|
beforeSend(event: Sentry.Event, hint: Sentry.EventHint) {
|
|
|
|
if (hint.originalException instanceof SentryIgnoredError) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
return event;
|
|
|
|
},
|
2020-11-29 21:14:48 +00:00
|
|
|
});
|
2020-12-05 21:08:42 +00:00
|
|
|
console.debug("authentik/config: Sentry enabled.");
|
2020-11-29 21:14:48 +00:00
|
|
|
}
|
|
|
|
return config;
|
|
|
|
});
|
2020-11-26 21:37:41 +00:00
|
|
|
}
|
2020-11-23 10:50:38 +00:00
|
|
|
}
|