@@ -60,7 +60,7 @@ mount(() => <StartClient />, document.getElementById('app'));
60
60
61
61
### 3. Server-side Setup
62
62
63
- Create an instrument file named ` instrument.server.mjs ` and add your initialization code for the server-side SDK.
63
+ Create an instrument file named ` src/ instrument.server.ts ` and add your initialization code for the server-side SDK.
64
64
65
65
``` javascript
66
66
import * as Sentry from ' @sentry/solidstart' ;
@@ -110,24 +110,30 @@ For Sentry to work properly, SolidStart's `app.config.ts` has to be modified.
110
110
Add ` withSentry ` from ` @sentry/solidstart ` and wrap SolidStart's config inside ` app.config.ts ` .
111
111
112
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
- }))
113
+ import { defineConfig } from ' @solidjs/start/config' ;
114
+ import { withSentry } from ' @sentry/solidstart' ;
120
115
116
+ export default defineConfig (
117
+ withSentry ({
118
+ // ...
119
+ middleware: ' ./src/middleware.ts' ,
120
+ }),
121
+ );
121
122
```
122
123
123
124
#### 5.2 Generate source maps and build ` instrument.server.ts `
124
125
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.
126
+ Sentry relies on running ` instrument.server.ts ` as early as possible. Add the ` sentrySolidStartVite ` plugin from
127
+ ` @sentry/solidstart ` to your ` app.config.ts ` . This takes care of building ` instrument.server.ts ` and placing it
128
+ alongside the server entry file.
127
129
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.
130
+ If your ` instrument.server.ts ` file is not located in the ` src ` folder, you can specify the path via the
131
+ ` sentrySolidStartVite ` plugin.
132
+
133
+ To upload source maps, configure an auth token. Auth tokens can be passed to the plugin explicitly with the ` authToken `
134
+ option, with a ` SENTRY_AUTH_TOKEN ` environment variable, or with an ` .env.sentry-build-plugin ` file in the working
135
+ directory when building your project. We recommend you add the auth token to your CI/CD environment as an environment
136
+ variable.
131
137
132
138
Learn more about configuring the plugin in our
133
139
[ Sentry Vite Plugin documentation] ( https://www.npmjs.com/package/@sentry/vite-plugin ) .
@@ -137,21 +143,25 @@ Learn more about configuring the plugin in our
137
143
import { defineConfig } from ' @solidjs/start/config' ;
138
144
import { sentrySolidStartVite , withSentry } from ' @sentry/solidstart' ;
139
145
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
- }));
146
+ export default defineConfig (
147
+ withSentry ({
148
+ // ...
149
+ middleware: ' ./src/middleware.ts' ,
150
+ vite: {
151
+ plugins: [
152
+ sentrySolidStartVite ({
153
+ org: process .env .SENTRY_ORG ,
154
+ project: process .env .SENTRY_PROJECT ,
155
+ authToken: process .env .SENTRY_AUTH_TOKEN ,
156
+ debug: true ,
157
+ // optional: if your `instrument.server.ts` file is not located inside `src`
158
+ instrumentation: ' ./mypath/instrument.server.ts' ,
159
+ }),
160
+ ],
161
+ },
162
+ // ...
163
+ }),
164
+ );
155
165
```
156
166
157
167
### 6. Run your application
@@ -163,46 +173,49 @@ NODE_OPTIONS='--import=./.output/server/instrument.server.mjs' yarn start
163
173
```
164
174
165
175
⚠️ ** 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
176
+ Depending on [ build preset] ( https://nitro.unjs.io/deploy ) , the location of ` instrument.server.mjs ` differs. To find out
177
+ where ` instrument.server.mjs ` is located, monitor the build log output for
168
178
169
179
``` bash
170
180
[Sentry SolidStart withSentry] Successfully created /my/project/path/.output/server/instrument.server.mjs.
171
181
```
172
182
173
-
174
183
⚠️ ** 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 ` .
184
+ Depending on where the application is deployed to, it might not be possible to modify or use ` NODE_OPTIONS ` to import
185
+ ` instrument.server.mjs ` .
177
186
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.
187
+ For such platforms, we offer the ` experimental_basicServerTracing ` flag to add a top level import of
188
+ ` instrument.server.mjs ` to the server entry file.
180
189
181
190
``` typescript
182
191
// app.config.ts
183
192
import { defineConfig } from ' @solidjs/start/config' ;
184
193
import { sentrySolidStartVite , withSentry } from ' @sentry/solidstart' ;
185
194
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 }));
195
+ export default defineConfig (
196
+ withSentry (
197
+ {
198
+ // ...
199
+ middleware: ' ./src/middleware.ts' ,
200
+ vite: {
201
+ plugins: [
202
+ sentrySolidStartVite ({
203
+ org: process .env .SENTRY_ORG ,
204
+ project: process .env .SENTRY_PROJECT ,
205
+ authToken: process .env .SENTRY_AUTH_TOKEN ,
206
+ debug: true ,
207
+ }),
208
+ ],
209
+ },
210
+ // ...
211
+ },
212
+ { experimental_basicServerTracing: true },
213
+ ),
214
+ );
201
215
```
202
216
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
-
217
+ This has a ** fundamental restriction** : It only supports limited performance instrumentation. ** Only basic http
218
+ instrumentation** will work, and no DB or framework-specific instrumentation will be available.
206
219
207
220
# Solid Router
208
221
0 commit comments