|
1 |
| -import { Links, Meta, Outlet, Scripts, ScrollRestoration } from '@remix-run/react'; |
2 |
| - |
| 1 | +import { cssBundleHref } from '@remix-run/css-bundle'; |
| 2 | +import { LinksFunction, MetaFunction, json } from '@remix-run/node'; |
| 3 | +import { |
| 4 | + Links, |
| 5 | + LiveReload, |
| 6 | + Meta, |
| 7 | + Outlet, |
| 8 | + Scripts, |
| 9 | + ScrollRestoration, |
| 10 | + useLoaderData, |
| 11 | + useRouteError, |
| 12 | +} from '@remix-run/react'; |
3 | 13 | import { captureRemixErrorBoundaryError, withSentry } from '@sentry/remix';
|
| 14 | +import type { SentryMetaArgs } from '@sentry/remix'; |
| 15 | + |
| 16 | +export const links: LinksFunction = () => [...(cssBundleHref ? [{ rel: 'stylesheet', href: cssBundleHref }] : [])]; |
| 17 | + |
| 18 | +export const loader = () => { |
| 19 | + return json({ |
| 20 | + ENV: { |
| 21 | + SENTRY_DSN: process.env.E2E_TEST_DSN, |
| 22 | + }, |
| 23 | + }); |
| 24 | +}; |
| 25 | + |
| 26 | +export const meta = ({ data }: SentryMetaArgs<MetaFunction<typeof loader>>) => { |
| 27 | + return [ |
| 28 | + { |
| 29 | + env: data.ENV, |
| 30 | + }, |
| 31 | + { |
| 32 | + name: 'sentry-trace', |
| 33 | + content: data.sentryTrace, |
| 34 | + }, |
| 35 | + { |
| 36 | + name: 'baggage', |
| 37 | + content: data.sentryBaggage, |
| 38 | + }, |
| 39 | + ]; |
| 40 | +}; |
| 41 | + |
| 42 | +export function ErrorBoundary() { |
| 43 | + const error = useRouteError(); |
| 44 | + const eventId = captureRemixErrorBoundaryError(error); |
| 45 | + |
| 46 | + return ( |
| 47 | + <div> |
| 48 | + <span>ErrorBoundary Error</span> |
| 49 | + <span id="event-id">{eventId}</span> |
| 50 | + </div> |
| 51 | + ); |
| 52 | +} |
| 53 | + |
| 54 | +function App() { |
| 55 | + const { ENV } = useLoaderData(); |
4 | 56 |
|
5 |
| -export function Layout({ children }: { children: React.ReactNode }) { |
6 | 57 | return (
|
7 | 58 | <html lang="en">
|
8 | 59 | <head>
|
9 | 60 | <meta charSet="utf-8" />
|
10 |
| - <meta name="viewport" content="width=device-width, initial-scale=1" /> |
| 61 | + <meta name="viewport" content="width=device-width,initial-scale=1" /> |
| 62 | + <script |
| 63 | + dangerouslySetInnerHTML={{ |
| 64 | + __html: `window.ENV = ${JSON.stringify(ENV)}`, |
| 65 | + }} |
| 66 | + /> |
11 | 67 | <Meta />
|
12 | 68 | <Links />
|
13 | 69 | </head>
|
14 | 70 | <body>
|
15 |
| - {children} |
| 71 | + <Outlet /> |
16 | 72 | <ScrollRestoration />
|
17 | 73 | <Scripts />
|
| 74 | + <LiveReload /> |
18 | 75 | </body>
|
19 | 76 | </html>
|
20 | 77 | );
|
21 | 78 | }
|
22 | 79 |
|
23 |
| -function App() { |
24 |
| - return <Outlet />; |
25 |
| -} |
26 |
| - |
27 | 80 | export default withSentry(App);
|
0 commit comments