Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion app/entry.client.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@ import { hydrate } from "react-dom";
import { RemixBrowser } from "@remix-run/react";
import { initSentry } from "./shared/sentry";

initSentry();
import { useLocation, useMatches } from "@remix-run/react";
import { BrowserTracing, remixRouterInstrumentation } from "@sentry/remix";
import { useEffect } from "react";

initSentry({
integrations: [
new BrowserTracing({
routingInstrumentation: remixRouterInstrumentation(
useEffect,
useLocation,
useMatches
),
}),
],
});

hydrate(<RemixBrowser />, document);
7 changes: 7 additions & 0 deletions app/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ import { renderToString } from "react-dom/server";
import { RemixServer } from "@remix-run/react";
import { insertCriticalCss } from "./critical-css";
import type { EntryContext } from "@remix-run/node";
import * as Sentry from "@sentry/remix";
import { initSentry } from "./shared/sentry";
import { prisma } from "./shared/db/prisma.server";

initSentry({
integrations: [new Sentry.Integrations.Prisma({ client: prisma })],
});

export default function handleRequest(
request: Request,
Expand Down
16 changes: 15 additions & 1 deletion app/root.tsx
Original file line number Diff line number Diff line change
@@ -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
);
3 changes: 1 addition & 2 deletions app/shared/env/env-getter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,8 @@ export default new Proxy(
{},
{
get(_target, prop) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
if (typeof window === "undefined") {
return process.env;
return prop in process.env ? process.env[prop as keyof Env] : undefined;
}
const env = (window[namespace as never] ?? {}) as unknown as Env;
return prop in env ? env[prop as keyof Env] : undefined;
Expand Down
11 changes: 6 additions & 5 deletions app/shared/sentry.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
import * as Sentry from "@sentry/browser";
import { Extras } from "@sentry/types";
import { BrowserTracing } from "@sentry/tracing";
import * as Sentry from "@sentry/remix";
import { Extras, Integration } from "@sentry/types";
import env from "~/shared/env";

export const initSentry = () =>
export const initSentry = ({
integrations = [],
}: { integrations?: Integration[] } = {}) =>
env.SENTRY_DSN
? Sentry.init({
dsn: env.SENTRY_DSN,
integrations: [new BrowserTracing()],
tracesSampleRate: 1.0,
environment: env.VERCEL_ENV || "development",
integrations: integrations,
})
: () => null;

Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
"@remix-run/node": "^1.5.1",
"@remix-run/react": "^1.5.1",
"@remix-run/serve": "^1.5.1",
"@sentry/browser": "^7.3.0",
"@sentry/tracing": "^7.3.0",
"@sentry/remix": "^7.5.0",
"@stitches/react": "^1.2.7",
"@webstudio-is/sdk": "0.4.0",
"bson-objectid": "^2.0.2",
Expand Down
Loading