index.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import React from "react";
  2. import ReactDOM from "react-dom";
  3. import * as Sentry from "@sentry/browser";
  4. import * as SentryIntegrations from "@sentry/integrations";
  5. import { TopErrorBoundary } from "./components/TopErrorBoundary";
  6. import { IsMobileProvider } from "./is-mobile";
  7. import App from "./components/App";
  8. import "./styles.scss";
  9. const SentryEnvHostnameMap: { [key: string]: string } = {
  10. "excalidraw.com": "production",
  11. "now.sh": "staging",
  12. };
  13. const onlineEnv = Object.keys(SentryEnvHostnameMap).find(
  14. (item) => window.location.hostname.indexOf(item) >= 0,
  15. );
  16. Sentry.init({
  17. // Disable Sentry locally to avoid noise
  18. dsn: onlineEnv
  19. ? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260"
  20. : undefined,
  21. environment: onlineEnv ? SentryEnvHostnameMap[onlineEnv] : undefined,
  22. release: process.env.REACT_APP_GIT_SHA,
  23. integrations: [
  24. new SentryIntegrations.CaptureConsole({
  25. levels: ["error"],
  26. }),
  27. ],
  28. });
  29. // Block pinch-zooming on iOS outside of the content area
  30. document.addEventListener(
  31. "touchmove",
  32. function (event) {
  33. // @ts-ignore
  34. if (event.scale !== 1) {
  35. event.preventDefault();
  36. }
  37. },
  38. { passive: false },
  39. );
  40. const rootElement = document.getElementById("root");
  41. ReactDOM.render(
  42. <TopErrorBoundary>
  43. <IsMobileProvider>
  44. <App />
  45. </IsMobileProvider>
  46. </TopErrorBoundary>,
  47. rootElement,
  48. );