sentry.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. import * as Sentry from "@sentry/browser";
  2. import * as SentryIntegrations from "@sentry/integrations";
  3. const SentryEnvHostnameMap: { [key: string]: string } = {
  4. "excalidraw.com": "production",
  5. "vercel.app": "staging",
  6. };
  7. const SENTRY_DISABLED = import.meta.env.VITE_APP_DISABLE_SENTRY === "true";
  8. // Disable Sentry locally or inside the Docker to avoid noise/respect privacy
  9. const onlineEnv =
  10. !SENTRY_DISABLED &&
  11. Object.keys(SentryEnvHostnameMap).find(
  12. (item) => window.location.hostname.indexOf(item) >= 0,
  13. );
  14. Sentry.init({
  15. dsn: onlineEnv
  16. ? "https://[email protected]/5179260"
  17. : undefined,
  18. environment: onlineEnv ? SentryEnvHostnameMap[onlineEnv] : undefined,
  19. release: import.meta.env.VITE_APP_GIT_SHA,
  20. ignoreErrors: [
  21. "undefined is not an object (evaluating 'window.__pad.performLoop')", // Only happens on Safari, but spams our servers. Doesn't break anything
  22. ],
  23. integrations: [
  24. new SentryIntegrations.CaptureConsole({
  25. levels: ["error"],
  26. }),
  27. ],
  28. beforeSend(event) {
  29. if (event.request?.url) {
  30. event.request.url = event.request.url.replace(/#.*$/, "");
  31. }
  32. return event;
  33. },
  34. });