sentry.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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 REACT_APP_DISABLE_SENTRY =
  8. process.env.REACT_APP_DISABLE_SENTRY === "true";
  9. // Disable Sentry locally or inside the Docker to avoid noise/respect privacy
  10. const onlineEnv =
  11. !REACT_APP_DISABLE_SENTRY &&
  12. Object.keys(SentryEnvHostnameMap).find(
  13. (item) => window.location.hostname.indexOf(item) >= 0,
  14. );
  15. Sentry.init({
  16. dsn: onlineEnv
  17. ? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260"
  18. : undefined,
  19. environment: onlineEnv ? SentryEnvHostnameMap[onlineEnv] : undefined,
  20. release: process.env.REACT_APP_GIT_SHA,
  21. ignoreErrors: [
  22. "undefined is not an object (evaluating 'window.__pad.performLoop')", // Only happens on Safari, but spams our servers. Doesn't break anything
  23. ],
  24. integrations: [
  25. new SentryIntegrations.CaptureConsole({
  26. levels: ["error"],
  27. }),
  28. ],
  29. beforeSend(event) {
  30. if (event.request?.url) {
  31. event.request.url = event.request.url.replace(/#.*$/, "");
  32. }
  33. return event;
  34. },
  35. });