web: make most client/network errors ignored by sentry
This commit is contained in:
parent
d2862ddc93
commit
434922f702
|
@ -2,6 +2,7 @@ import { DefaultClient } from "./client";
|
|||
import * as Sentry from "@sentry/browser";
|
||||
import { Integrations } from "@sentry/tracing";
|
||||
import { VERSION } from "../constants";
|
||||
import { SentryIgnoredError } from "../common/errors";
|
||||
|
||||
export class Config {
|
||||
branding_logo: string;
|
||||
|
@ -24,6 +25,12 @@ export class Config {
|
|||
integrations: [new Integrations.BrowserTracing()],
|
||||
tracesSampleRate: 1.0,
|
||||
environment: config.error_reporting_environment,
|
||||
beforeSend(event: Sentry.Event, hint: Sentry.EventHint) {
|
||||
if (hint.originalException instanceof SentryIgnoredError) {
|
||||
return null;
|
||||
}
|
||||
return event;
|
||||
},
|
||||
});
|
||||
console.debug("authentik/config: Sentry enabled.");
|
||||
}
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
export class SentryIgnoredError extends Error {}
|
|
@ -1,5 +1,6 @@
|
|||
import { css, CSSResult, customElement, html, LitElement, property, TemplateResult } from "lit-element";
|
||||
import Chart from "chart.js";
|
||||
import { showMessage } from "./messages/MessageContainer";
|
||||
|
||||
interface TickValue {
|
||||
value: number;
|
||||
|
@ -41,7 +42,13 @@ export class AdminLoginsChart extends LitElement {
|
|||
firstUpdated(): void {
|
||||
fetch(this.url)
|
||||
.then((r) => r.json())
|
||||
.catch((e) => console.error(e))
|
||||
.catch((e) => {
|
||||
showMessage({
|
||||
level_tag: "error",
|
||||
message: "Unexpected error"
|
||||
});
|
||||
console.log(e);
|
||||
})
|
||||
.then((r) => {
|
||||
const canvas = <HTMLCanvasElement>this.shadowRoot?.querySelector("canvas");
|
||||
if (!canvas) {
|
||||
|
|
|
@ -13,6 +13,7 @@ import fa from "@fortawesome/fontawesome-free/css/solid.css";
|
|||
import { convertToSlug } from "../../utils";
|
||||
import { SpinnerButton } from "./SpinnerButton";
|
||||
import { PRIMARY_CLASS } from "../../constants";
|
||||
import { showMessage } from "../messages/MessageContainer";
|
||||
|
||||
@customElement("ak-modal-button")
|
||||
export class ModalButton extends LitElement {
|
||||
|
@ -110,7 +111,11 @@ export class ModalButton extends LitElement {
|
|||
}
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
showMessage({
|
||||
level_tag: "error",
|
||||
message: "Unexpected error"
|
||||
});
|
||||
console.log(e);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -139,7 +144,11 @@ export class ModalButton extends LitElement {
|
|||
});
|
||||
})
|
||||
.catch((e) => {
|
||||
console.error(e);
|
||||
showMessage({
|
||||
level_tag: "error",
|
||||
message: "Unexpected error"
|
||||
});
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import { LitElement, html, customElement, property, TemplateResult } from "lit-element";
|
||||
import { SentryIgnoredError } from "../../common/errors";
|
||||
|
||||
enum ResponseType {
|
||||
redirect = "redirect",
|
||||
|
@ -30,7 +31,7 @@ export class FlowShellCard extends LitElement {
|
|||
// Fallback when the flow does not exist, just redirect to the root
|
||||
window.location.pathname = "/";
|
||||
} else if (!r.ok) {
|
||||
throw Error(r.statusText);
|
||||
throw new SentryIgnoredError(r.statusText);
|
||||
}
|
||||
return r;
|
||||
})
|
||||
|
|
|
@ -8,6 +8,7 @@ import BackdropStyle from "@patternfly/patternfly/components/Backdrop/backdrop.c
|
|||
import { SpinnerSize } from "../../elements/Spinner";
|
||||
import { showMessage } from "../../elements/messages/MessageContainer";
|
||||
import { gettext } from "django";
|
||||
import { SentryIgnoredError } from "../../common/errors";
|
||||
|
||||
@customElement("ak-site-shell")
|
||||
export class SiteShell extends LitElement {
|
||||
|
@ -70,7 +71,7 @@ export class SiteShell extends LitElement {
|
|||
level_tag: "error",
|
||||
message: gettext(`Request failed: ${r.statusText}`),
|
||||
});
|
||||
throw new Error("Request failed");
|
||||
throw new SentryIgnoredError("Request failed");
|
||||
})
|
||||
.then((r) => r.text())
|
||||
.then((t) => {
|
||||
|
|
Reference in New Issue