Skip to content

Commit 14a749a

Browse files
committed
Update README
1 parent 242cee0 commit 14a749a

File tree

1 file changed

+97
-36
lines changed

1 file changed

+97
-36
lines changed

packages/solidstart/README.md

Lines changed: 97 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,109 @@ export default defineConfig({
101101
The Sentry middleware enhances the data collected by Sentry on the server side by enabling distributed tracing between
102102
the client and server.
103103

104-
### 5. Run your application
104+
### 5. Configure your application
105+
106+
For Sentry to work properly, SolidStart's `app.config.ts` has to be modified.
107+
108+
#### 5.1 Wrapping the config with `withSentry`
109+
110+
Add `withSentry` from `@sentry/solidstart` and wrap SolidStart's config inside `app.config.ts`.
111+
112+
```typescript
113+
import { defineConfig } from '@solidjs/start/config'
114+
import { withSentry } from "@sentry/solidstart";
115+
116+
export default defineConfig(withSentry({
117+
// ...
118+
middleware: './src/middleware.ts',
119+
}))
120+
121+
```
122+
123+
#### 5.2 Generate source maps and build `instrument.server.ts`
124+
125+
Sentry relies on running `instrument.server.ts` as early as possible. Add the `sentrySolidStartVite` plugin
126+
from `@sentry/solidstart` to your `app.config.ts`. This takes care of building `instrument.server.ts` and placing it alongside the server entry file.
127+
128+
To upload source maps, configure an auth token. Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a
129+
`SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when
130+
building your project. We recommend you add the auth token to your CI/CD environment as an environment variable.
131+
132+
Learn more about configuring the plugin in our
133+
[Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).
134+
135+
```typescript
136+
// app.config.ts
137+
import { defineConfig } from '@solidjs/start/config';
138+
import { sentrySolidStartVite, withSentry } from '@sentry/solidstart';
139+
140+
export default defineConfig(withSentry({
141+
// ...
142+
middleware: './src/middleware.ts',
143+
vite: {
144+
plugins: [
145+
sentrySolidStartVite({
146+
org: process.env.SENTRY_ORG,
147+
project: process.env.SENTRY_PROJECT,
148+
authToken: process.env.SENTRY_AUTH_TOKEN,
149+
debug: true,
150+
}),
151+
],
152+
},
153+
// ...
154+
}));
155+
```
156+
157+
### 6. Run your application
105158

106159
Then run your app
107160

108161
```bash
109-
NODE_OPTIONS='--import=./instrument.server.mjs' yarn start
110-
# or
111-
NODE_OPTIONS='--require=./instrument.server.js' yarn start
162+
NODE_OPTIONS='--import=./.output/server/instrument.server.mjs' yarn start
163+
```
164+
165+
⚠️ **Note build presets** ⚠️
166+
Depending on [build preset](https://nitro.unjs.io/deploy), the location of `instrument.server.mjs` differs.
167+
To find out where `instrument.server.mjs` is located, monitor the build log output for
168+
169+
```bash
170+
[Sentry SolidStart withSentry] Successfully created /my/project/path/.output/server/instrument.server.mjs.
171+
```
172+
173+
174+
⚠️ **Note for platforms without the ability to modify `NODE_OPTIONS` or use `--import`** ⚠️
175+
Depending on where the application is deployed to, it might not be possible to modify or use `NODE_OPTIONS` to
176+
import `instrument.server.mjs`.
177+
178+
For such platforms, we offer the `experimental_basicServerTracing` flag to add a top
179+
level import of `instrument.server.mjs` to the server entry file.
180+
181+
```typescript
182+
// app.config.ts
183+
import { defineConfig } from '@solidjs/start/config';
184+
import { sentrySolidStartVite, withSentry } from '@sentry/solidstart';
185+
186+
export default defineConfig(withSentry({
187+
// ...
188+
middleware: './src/middleware.ts',
189+
vite: {
190+
plugins: [
191+
sentrySolidStartVite({
192+
org: process.env.SENTRY_ORG,
193+
project: process.env.SENTRY_PROJECT,
194+
authToken: process.env.SENTRY_AUTH_TOKEN,
195+
debug: true,
196+
}),
197+
],
198+
},
199+
// ...
200+
}, { experimental_basicServerTracing: true }));
112201
```
113202

203+
This has a **fundamental restriction**: It only supports limited performance instrumentation.
204+
**Only basic http instrumentation** will work, and no DB or framework-specific instrumentation will be available.
205+
206+
114207
# Solid Router
115208

116209
The Solid Router instrumentation uses the Solid Router library to create navigation spans to ensure you collect
@@ -156,35 +249,3 @@ render(
156249
document.getElementById('root'),
157250
);
158251
```
159-
160-
## Uploading Source Maps
161-
162-
To upload source maps, add the `sentrySolidStartVite` plugin from `@sentry/solidstart` to your `app.config.ts` and
163-
configure an auth token. Auth tokens can be passed to the plugin explicitly with the `authToken` option, with a
164-
`SENTRY_AUTH_TOKEN` environment variable, or with an `.env.sentry-build-plugin` file in the working directory when
165-
building your project. We recommend you add the auth token to your CI/CD environment as an environment variable.
166-
167-
Learn more about configuring the plugin in our
168-
[Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).
169-
170-
```typescript
171-
// app.config.ts
172-
import { defineConfig } from '@solidjs/start/config';
173-
import { sentrySolidStartVite } from '@sentry/solidstart';
174-
175-
export default defineConfig({
176-
// ...
177-
178-
vite: {
179-
plugins: [
180-
sentrySolidStartVite({
181-
org: process.env.SENTRY_ORG,
182-
project: process.env.SENTRY_PROJECT,
183-
authToken: process.env.SENTRY_AUTH_TOKEN,
184-
debug: true,
185-
}),
186-
],
187-
},
188-
// ...
189-
});
190-
```

0 commit comments

Comments
 (0)