Skip to content

Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.

move move ErrorBoundeary to the root, work around withSentryRouteTracing type

Oleg Isonen9cd0d80188ec
diff --git a/app/entry.client.tsx b/app/entry.client.tsx
index f8bae5b356..0a870b7dab 100644
--- a/app/entry.client.tsx
+++ b/app/entry.client.tsx
@@ -3,13 +3,13 @@ import { RemixBrowser } from "@remix-run/react";
import { initSentry } from "./shared/sentry";
import { useLocation, useMatches } from "@remix-run/react";
-import * as Sentry from "@sentry/remix";
+import { BrowserTracing, remixRouterInstrumentation } from "@sentry/remix";
import { useEffect } from "react";
initSentry({
integrations: [
- new Sentry.BrowserTracing({
- routingInstrumentation: Sentry.remixRouterInstrumentation(
+ new BrowserTracing({
+ routingInstrumentation: remixRouterInstrumentation(
useEffect,
useLocation,
useMatches
diff --git a/app/root.tsx b/app/root.tsx
index 057b688987..44c8df873f 100644
--- a/app/root.tsx
+++ b/app/root.tsx
@@ -1,2 +1,16 @@
// Our root outlet doesn't contain a layout because we have 2 types of documents: canvas and designer and we need to decide down the line which one to render, thre is no single root document.
-export { Outlet as default } from "@remix-run/react";
+import { Outlet } from "@remix-run/react";
+import { withSentryRouteTracing } from "@sentry/remix";
+import { ErrorBoundary } from "@sentry/remix";
+import { OutletProps } from "react-router-dom";
+
+const RootWithErrorBoundary = (props: OutletProps) => (
+ <ErrorBoundary>
+ <Outlet {...props} />
+ </ErrorBoundary>
+);
+
+export default withSentryRouteTracing(
+ // withSentryRouteTracing() expects a type from component that is not necessary true.
+ RootWithErrorBoundary as () => JSX.Element
+);
diff --git a/app/shared/documents/canvas.tsx b/app/shared/documents/canvas.tsx
index 0358e081f0..084f5ac598 100644
--- a/app/shared/documents/canvas.tsx
+++ b/app/shared/documents/canvas.tsx
@@ -6,40 +6,35 @@ import {
Scripts,
ScrollRestoration,
} from "@remix-run/react";
-import { ErrorBoundary, withSentryRouteTracing } from "@sentry/remix";
import { CriticalCss } from "@webstudio-is/sdk";
import { Env } from "~/shared/env";
/**
* We are using Outlet prop from index layout when user renders site from a subdomain.
*/
-const CanvasRoot = ({
+export const Canvas = ({
Outlet = DefaultOutlet,
}: {
Outlet: typeof DefaultOutlet;
}) => {
return (
- <ErrorBoundary>
- <html lang="en">
- <head>
- <meta charSet="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <link rel="icon" href="/favicon.ico" type="image/x-icon" />
- <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
- <Meta />
- <Links />
- <CriticalCss />
- </head>
- <body>
- <Outlet />
- <ScrollRestoration />
- <Env />
- <Scripts />
- {process.env.NODE_ENV === "development" && <LiveReload />}
- </body>
- </html>
- </ErrorBoundary>
+ <html lang="en">
+ <head>
+ <meta charSet="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <link rel="icon" href="/favicon.ico" type="image/x-icon" />
+ <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
+ <Meta />
+ <Links />
+ <CriticalCss />
+ </head>
+ <body>
+ <Outlet />
+ <ScrollRestoration />
+ <Env />
+ <Scripts />
+ {process.env.NODE_ENV === "development" && <LiveReload />}
+ </body>
+ </html>
);
};
-
-export const Canvas = withSentryRouteTracing(CanvasRoot);
diff --git a/app/shared/documents/designer.tsx b/app/shared/documents/designer.tsx
index e4566c99c6..46ba3018f1 100644
--- a/app/shared/documents/designer.tsx
+++ b/app/shared/documents/designer.tsx
@@ -1,29 +1,24 @@
import { Links, LiveReload, Meta, Outlet, Scripts } from "@remix-run/react";
-import { ErrorBoundary, withSentryRouteTracing } from "@sentry/remix";
import { CriticalCss } from "@webstudio-is/sdk";
import { darkTheme } from "~/shared/design-system";
import { Env } from "~/shared/env";
-const DesignerRoot = () => {
+export const Designer = () => {
return (
- <ErrorBoundary>
- <html lang="en">
- <head>
- <meta charSet="utf-8" />
- <meta name="viewport" content="width=device-width,initial-scale=1" />
- <Meta />
- <Links />
- <CriticalCss />
- </head>
- <body className={darkTheme}>
- <Outlet />
- <Env />
- <Scripts />
- {process.env.NODE_ENV === "development" && <LiveReload />}
- </body>
- </html>
- </ErrorBoundary>
+ <html lang="en">
+ <head>
+ <meta charSet="utf-8" />
+ <meta name="viewport" content="width=device-width,initial-scale=1" />
+ <Meta />
+ <Links />
+ <CriticalCss />
+ </head>
+ <body className={darkTheme}>
+ <Outlet />
+ <Env />
+ <Scripts />
+ {process.env.NODE_ENV === "development" && <LiveReload />}
+ </body>
+ </html>
);
};
-
-export const Designer = withSentryRouteTracing(DesignerRoot);