Skip to content

Commit

Permalink
Update README
Browse files Browse the repository at this point in the history
  • Loading branch information
andreiborza committed Sep 25, 2024
1 parent 242cee0 commit 14a749a
Showing 1 changed file with 97 additions and 36 deletions.
133 changes: 97 additions & 36 deletions packages/solidstart/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,16 +101,109 @@ 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.

### 5. Run your application
### 5. Configure your application

For Sentry to work properly, SolidStart's `app.config.ts` has to be modified.

#### 5.1 Wrapping the config with `withSentry`

Add `withSentry` from `@sentry/solidstart` and wrap SolidStart's config inside `app.config.ts`.

```typescript
import { defineConfig } from '@solidjs/start/config'
import { withSentry } from "@sentry/solidstart";

export default defineConfig(withSentry({
// ...
middleware: './src/middleware.ts',
}))

```

#### 5.2 Generate source maps and build `instrument.server.ts`

Sentry relies on running `instrument.server.ts` as early as possible. Add the `sentrySolidStartVite` plugin
from `@sentry/solidstart` to your `app.config.ts`. This takes care of building `instrument.server.ts` and placing it alongside the server entry file.

To upload source maps, configure an auth token. Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a
`SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when
building your project. We recommend you add the auth token to your CI/CD environment as an environment variable.

Learn more about configuring the plugin in our
[Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).

```typescript
// app.config.ts
import { defineConfig } from '@solidjs/start/config';
import { sentrySolidStartVite, withSentry } from '@sentry/solidstart';

export default defineConfig(withSentry({
// ...
middleware: './src/middleware.ts',
vite: {
plugins: [
sentrySolidStartVite({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
debug: true,
}),
],
},
// ...
}));
```

### 6. Run your application

Then run your app

```bash
NODE_OPTIONS='--import=./instrument.server.mjs' yarn start
# or
NODE_OPTIONS='--require=./instrument.server.js' yarn start
NODE_OPTIONS='--import=./.output/server/instrument.server.mjs' yarn start
```

⚠️ **Note build presets** ⚠️
Depending on [build preset](https://nitro.unjs.io/deploy), the location of `instrument.server.mjs` differs.
To find out where `instrument.server.mjs` is located, monitor the build log output for

```bash
[Sentry SolidStart withSentry] Successfully created /my/project/path/.output/server/instrument.server.mjs.
```


⚠️ **Note for platforms without the ability to modify `NODE_OPTIONS` or use `--import`** ⚠️
Depending on where the application is deployed to, it might not be possible to modify or use `NODE_OPTIONS` to
import `instrument.server.mjs`.

For such platforms, we offer the `experimental_basicServerTracing` flag to add a top
level import of `instrument.server.mjs` to the server entry file.

```typescript
// app.config.ts
import { defineConfig } from '@solidjs/start/config';
import { sentrySolidStartVite, withSentry } from '@sentry/solidstart';

export default defineConfig(withSentry({
// ...
middleware: './src/middleware.ts',
vite: {
plugins: [
sentrySolidStartVite({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
debug: true,
}),
],
},
// ...
}, { experimental_basicServerTracing: true }));
```

This has a **fundamental restriction**: It only supports limited performance instrumentation.
**Only basic http instrumentation** will work, and no DB or framework-specific instrumentation will be available.


# Solid Router

The Solid Router instrumentation uses the Solid Router library to create navigation spans to ensure you collect
Expand Down Expand Up @@ -156,35 +249,3 @@ render(
document.getElementById('root'),
);
```

## Uploading Source Maps

To upload source maps, add the `sentrySolidStartVite` plugin from `@sentry/solidstart` to your `app.config.ts` and
configure an auth token. Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a
`SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when
building your project. We recommend you add the auth token to your CI/CD environment as an environment variable.

Learn more about configuring the plugin in our
[Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).

```typescript
// app.config.ts
import { defineConfig } from '@solidjs/start/config';
import { sentrySolidStartVite } from '@sentry/solidstart';

export default defineConfig({
// ...

vite: {
plugins: [
sentrySolidStartVite({
org: process.env.SENTRY_ORG,
project: process.env.SENTRY_PROJECT,
authToken: process.env.SENTRY_AUTH_TOKEN,
debug: true,
}),
],
},
// ...
});
```

0 comments on commit 14a749a

Please sign in to comment.