index.tsx 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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 { register as registerServiceWorker } from "./serviceWorker";
  9. import "./css/styles.scss";
  10. // On Apple mobile devices add the proprietary app icon and splashscreen markup.
  11. // No one should have to do this manually, and eventually this annoyance will
  12. // go away once https://bugs.webkit.org/show_bug.cgi?id=183937 is fixed.
  13. if (/\b(iPad|iPhone|iPod)\b/.test(navigator.userAgent)) {
  14. import("pwacompat");
  15. }
  16. const SentryEnvHostnameMap: { [key: string]: string } = {
  17. "excalidraw.com": "production",
  18. "now.sh": "staging",
  19. };
  20. const onlineEnv = Object.keys(SentryEnvHostnameMap).find(
  21. (item) => window.location.hostname.indexOf(item) >= 0,
  22. );
  23. Sentry.init({
  24. // Disable Sentry locally to avoid noise
  25. dsn: onlineEnv
  26. ? "https://7bfc596a5bf945eda6b660d3015a5460@sentry.io/5179260"
  27. : undefined,
  28. environment: onlineEnv ? SentryEnvHostnameMap[onlineEnv] : undefined,
  29. release: process.env.REACT_APP_GIT_SHA,
  30. ignoreErrors: [
  31. "undefined is not an object (evaluating 'window.__pad.performLoop')", // Only happens on Safari, but spams our servers. Doesn't break anything
  32. ],
  33. integrations: [
  34. new SentryIntegrations.CaptureConsole({
  35. levels: ["error"],
  36. }),
  37. ],
  38. });
  39. // Block pinch-zooming on iOS outside of the content area
  40. document.addEventListener(
  41. "touchmove",
  42. function (event) {
  43. // @ts-ignore
  44. if (event.scale !== 1) {
  45. event.preventDefault();
  46. }
  47. },
  48. { passive: false },
  49. );
  50. const rootElement = document.getElementById("root");
  51. ReactDOM.render(
  52. <TopErrorBoundary>
  53. <IsMobileProvider>
  54. <App />
  55. </IsMobileProvider>
  56. </TopErrorBoundary>,
  57. rootElement,
  58. );
  59. registerServiceWorker();