web: send sentry-trace header in API requests
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
29241cc287
commit
141481df3a
|
@ -3,6 +3,7 @@ import { getCookie } from "../utils";
|
||||||
import { APIMiddleware } from "../elements/notifications/APIDrawer";
|
import { APIMiddleware } from "../elements/notifications/APIDrawer";
|
||||||
import { MessageMiddleware } from "../elements/messages/Middleware";
|
import { MessageMiddleware } from "../elements/messages/Middleware";
|
||||||
import { VERSION } from "../constants";
|
import { VERSION } from "../constants";
|
||||||
|
import { getMetaContent } from "@sentry/tracing/dist/browser/browsertracing";
|
||||||
|
|
||||||
export class LoggingMiddleware implements Middleware {
|
export class LoggingMiddleware implements Middleware {
|
||||||
|
|
||||||
|
@ -53,6 +54,7 @@ export const DEFAULT_CONFIG = new Configuration({
|
||||||
basePath: process.env.AK_API_BASE_PATH + "/api/v3",
|
basePath: process.env.AK_API_BASE_PATH + "/api/v3",
|
||||||
headers: {
|
headers: {
|
||||||
"X-CSRFToken": getCookie("authentik_csrf"),
|
"X-CSRFToken": getCookie("authentik_csrf"),
|
||||||
|
"sentry-trace": getMetaContent("sentry-trace") || "",
|
||||||
},
|
},
|
||||||
middleware: [
|
middleware: [
|
||||||
new APIMiddleware(),
|
new APIMiddleware(),
|
||||||
|
|
|
@ -27,7 +27,10 @@ export function configureSentry(canDoPpi: boolean = false): Promise<Config> {
|
||||||
],
|
],
|
||||||
tracesSampleRate: config.errorReporting.tracesSampleRate,
|
tracesSampleRate: config.errorReporting.tracesSampleRate,
|
||||||
environment: config.errorReporting.environment,
|
environment: config.errorReporting.environment,
|
||||||
beforeSend: async (event: Sentry.Event, hint: Sentry.EventHint): Promise<Sentry.Event | null> => {
|
beforeSend: async (event: Sentry.Event, hint: Sentry.EventHint | undefined): Promise<Sentry.Event | null> => {
|
||||||
|
if (!hint) {
|
||||||
|
return event;
|
||||||
|
}
|
||||||
if (hint.originalException instanceof SentryIgnoredError) {
|
if (hint.originalException instanceof SentryIgnoredError) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue