![dependabot[bot]](/assets/img/avatar_default.png) 5768cb5858
			
		
	
	5768cb5858
	
	
	
		
			
			* web: bump @sentry/browser in /web in the sentry group across 1 directory Bumps the sentry group with 1 update in the /web directory: [@sentry/browser](https://github.com/getsentry/sentry-javascript). Updates `@sentry/browser` from 7.114.0 to 8.2.1 - [Release notes](https://github.com/getsentry/sentry-javascript/releases) - [Changelog](https://github.com/getsentry/sentry-javascript/blob/develop/CHANGELOG.md) - [Commits](https://github.com/getsentry/sentry-javascript/compare/7.114.0...8.2.1) --- updated-dependencies: - dependency-name: "@sentry/browser" dependency-type: direct:production update-type: version-update:semver-major dependency-group: sentry ... Signed-off-by: dependabot[bot] <support@github.com> * fix sentry beforeSend Signed-off-by: Jens Langhammer <jens@goauthentik.io> --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Jens Langhammer <jens@goauthentik.io> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Jens Langhammer <jens@goauthentik.io>
		
			
				
	
	
		
			94 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
			
		
		
	
	
			94 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			TypeScript
		
	
	
	
	
	
| import { config } from "@goauthentik/common/api/config";
 | |
| import { VERSION } from "@goauthentik/common/constants";
 | |
| import { SentryIgnoredError } from "@goauthentik/common/errors";
 | |
| import { me } from "@goauthentik/common/users";
 | |
| import {
 | |
|     ErrorEvent,
 | |
|     EventHint,
 | |
|     browserTracingIntegration,
 | |
|     init,
 | |
|     setTag,
 | |
|     setUser,
 | |
| } from "@sentry/browser";
 | |
| 
 | |
| import { CapabilitiesEnum, Config, ResponseError } from "@goauthentik/api";
 | |
| 
 | |
| export const TAG_SENTRY_COMPONENT = "authentik.component";
 | |
| export const TAG_SENTRY_CAPABILITIES = "authentik.capabilities";
 | |
| 
 | |
| export async function configureSentry(canDoPpi = false): Promise<Config> {
 | |
|     const cfg = await config();
 | |
|     if (cfg.errorReporting.enabled) {
 | |
|         init({
 | |
|             dsn: cfg.errorReporting.sentryDsn,
 | |
|             ignoreErrors: [
 | |
|                 /network/gi,
 | |
|                 /fetch/gi,
 | |
|                 /module/gi,
 | |
|                 // Error on edge on ios,
 | |
|                 // https://stackoverflow.com/questions/69261499/what-is-instantsearchsdkjsbridgeclearhighlight
 | |
|                 /instantSearchSDKJSBridgeClearHighlight/gi,
 | |
|                 // Seems to be an issue in Safari and Firefox
 | |
|                 /MutationObserver.observe/gi,
 | |
|                 /NS_ERROR_FAILURE/gi,
 | |
|             ],
 | |
|             release: `authentik@${VERSION}`,
 | |
|             integrations: [
 | |
|                 browserTracingIntegration({
 | |
|                     shouldCreateSpanForRequest: (url: string) => {
 | |
|                         return url.startsWith(window.location.host);
 | |
|                     },
 | |
|                 }),
 | |
|             ],
 | |
|             tracesSampleRate: cfg.errorReporting.tracesSampleRate,
 | |
|             environment: cfg.errorReporting.environment,
 | |
|             beforeSend: (
 | |
|                 event: ErrorEvent,
 | |
|                 hint: EventHint,
 | |
|             ): ErrorEvent | PromiseLike<ErrorEvent | null> | null => {
 | |
|                 if (!hint) {
 | |
|                     return event;
 | |
|                 }
 | |
|                 if (hint.originalException instanceof SentryIgnoredError) {
 | |
|                     return null;
 | |
|                 }
 | |
|                 if (
 | |
|                     hint.originalException instanceof ResponseError ||
 | |
|                     hint.originalException instanceof DOMException
 | |
|                 ) {
 | |
|                     return null;
 | |
|                 }
 | |
|                 return event;
 | |
|             },
 | |
|         });
 | |
|         setTag(TAG_SENTRY_CAPABILITIES, cfg.capabilities.join(","));
 | |
|         if (window.location.pathname.includes("if/")) {
 | |
|             setTag(TAG_SENTRY_COMPONENT, `web/${currentInterface()}`);
 | |
|         }
 | |
|         if (cfg.capabilities.includes(CapabilitiesEnum.CanDebug)) {
 | |
|             const Spotlight = await import("@spotlightjs/spotlight");
 | |
| 
 | |
|             Spotlight.init({ injectImmediately: true });
 | |
|         }
 | |
|         if (cfg.errorReporting.sendPii && canDoPpi) {
 | |
|             me().then((user) => {
 | |
|                 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
 | |
| export function currentInterface(): string {
 | |
|     const pathMatches = window.location.pathname.match(/.+if\/(\w+)\//);
 | |
|     let currentInterface = "unknown";
 | |
|     if (pathMatches && pathMatches.length >= 2) {
 | |
|         currentInterface = pathMatches[1];
 | |
|     }
 | |
|     return currentInterface.toLowerCase();
 | |
| }
 |