From 7f163092b1da3a80393aaa40fd6431215420459c Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Fri, 16 Aug 2024 17:15:59 +0200 Subject: [PATCH] Add middleware description and update how to run snippet --- .../javascript.solidstart.mdx | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/platform-includes/getting-started-config/javascript.solidstart.mdx b/platform-includes/getting-started-config/javascript.solidstart.mdx index 4e3aae7407b3c..66368ab22d2a9 100644 --- a/platform-includes/getting-started-config/javascript.solidstart.mdx +++ b/platform-includes/getting-started-config/javascript.solidstart.mdx @@ -50,7 +50,9 @@ Sentry.init({ ### Instrumentation -Complete the setup by adding the Sentry middleware to your `src/middleware.ts` file. If you don't have a `src/middleware.ts` file yet, create one: +The Sentry SDK provides [middleware lifecycle](https://docs.solidjs.com/solid-start/advanced/middleware) handlers to enhance data collected by Sentry on the server side by enabling distributed tracing between the client and server. + +Complete the setup by adding `sentryBeforeResponseMiddleware` to your `src/middleware.ts` file. If you don't have a `src/middleware.ts` file yet, create one: ```typescript {filename:src/middleware.ts} import { sentryBeforeResponseMiddleware } from '@sentry/solidstart/middleware'; @@ -75,9 +77,7 @@ export default defineConfig({ }); ``` -The Sentry middleware enhances the data collected by Sentry on the server side by enabling distributed tracing between the client and server. - -If you previously added the `solidRouterBrowserTracingIntegration` integration in `src/entry-client.tsx`, wrap your Solid Router with `withSentryRouterRouting`. +If you previously added the `solidRouterBrowserTracingIntegration` integration to `Sentry.init` in `src/entry-client.tsx`, wrap your Solid Router with `withSentryRouterRouting`. This creates a higher order component, which will enable Sentry to collect navigation spans. ```tsx {filename:app.tsx} @@ -98,16 +98,13 @@ export default function App() { ### Run your application -Add an `--import` flag to the `NODE_OPTIONS` environment variable wherever you run your application. +Add an `--import` flag to the `NODE_OPTIONS` environment variable wherever you run your application to import `public/instrument.server.mjs`. -```bash {tabTitle: npm} -NODE_OPTIONS='--import=./public/instrument.server.mjs npm start -``` +For example, update your scripts in `package.json`. -```bash {tabTitle: yarn} -NODE_OPTIONS='--import=./public/instrument.server.mjs yarn start -``` - -```bash {tabTitle: pnpm} -NODE_OPTIONS='--import=./public/instrument.server.mjs pnpm start -``` +```json {filename:package.json} +{ + "scripts": { + "start": "NODE_OPTIONS='--import ./public/instrument.server.mjs' vinxi start", + } +}