Skip to content

Commit

Permalink
Add middleware description and update how to run snippet
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiborza committed Aug 26, 2024
1 parent 1006915 commit 8b71354
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions platform-includes/getting-started-config/javascript.solidstart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -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}
Expand All @@ -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",
}
}

0 comments on commit 8b71354

Please sign in to comment.