Skip to content

Commit cc78ede

Browse files
committed
Document optional instrumentation file path option
1 parent 14a749a commit cc78ede

File tree

4 files changed

+72
-59
lines changed

4 files changed

+72
-59
lines changed

packages/solidstart/README.md

Lines changed: 66 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ mount(() => <StartClient />, document.getElementById('app'));
6060

6161
### 3. Server-side Setup
6262

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.
6464

6565
```javascript
6666
import * as Sentry from '@sentry/solidstart';
@@ -110,24 +110,30 @@ For Sentry to work properly, SolidStart's `app.config.ts` has to be modified.
110110
Add `withSentry` from `@sentry/solidstart` and wrap SolidStart's config inside `app.config.ts`.
111111

112112
```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';
120115

116+
export default defineConfig(
117+
withSentry({
118+
// ...
119+
middleware: './src/middleware.ts',
120+
}),
121+
);
121122
```
122123

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

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.
127129

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.
131137

132138
Learn more about configuring the plugin in our
133139
[Sentry Vite Plugin documentation](https://www.npmjs.com/package/@sentry/vite-plugin).
@@ -137,21 +143,25 @@ Learn more about configuring the plugin in our
137143
import { defineConfig } from '@solidjs/start/config';
138144
import { sentrySolidStartVite, withSentry } from '@sentry/solidstart';
139145

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+
);
155165
```
156166

157167
### 6. Run your application
@@ -163,46 +173,49 @@ NODE_OPTIONS='--import=./.output/server/instrument.server.mjs' yarn start
163173
```
164174

165175
⚠️ **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
168178

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

173-
174183
⚠️ **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`.
177186

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.
180189

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

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+
);
201215
```
202216

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.
206219

207220
# Solid Router
208221

packages/solidstart/src/config/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type Nitro = {
1313

1414
export type SolidStartInlineConfig = Parameters<typeof defineConfig>[0];
1515

16-
export type SolidStartInlineConfigNitroHooks = {
16+
export type SolidStartInlineServerConfig = {
1717
hooks?: {
1818
close?: () => unknown;
1919
'rollup:before'?: (nitro: Nitro) => unknown;

packages/solidstart/src/config/withSentry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type {
66
Nitro,
77
SentrySolidStartConfigOptions,
88
SolidStartInlineConfig,
9-
SolidStartInlineConfigNitroHooks,
9+
SolidStartInlineServerConfig,
1010
} from './types';
1111

1212
/**
@@ -22,7 +22,7 @@ export const withSentry = (
2222
solidStartConfig: SolidStartInlineConfig = {},
2323
sentrySolidStartConfigOptions: SentrySolidStartConfigOptions = {},
2424
): SolidStartInlineConfig => {
25-
const server = (solidStartConfig.server || {}) as SolidStartInlineConfigNitroHooks;
25+
const server = (solidStartConfig.server || {}) as SolidStartInlineServerConfig;
2626
const hooks = server.hooks || {};
2727

2828
let serverDir: string;

packages/solidstart/src/vite/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,10 @@ export type SentrySolidStartPluginOptions = {
127127
debug?: boolean;
128128

129129
/**
130-
* The path to your `instrumentation.server.ts|js` file.
131-
* e.g. './src/instrumentation.server.ts`
130+
* The path to your `instrument.server.ts|js` file.
131+
* e.g. `./src/instrument.server.ts`
132132
*
133-
* Defaults to: `./src/instrumentation.server.ts`
133+
* Defaults to: `./src/instrument.server.ts`
134134
*/
135135
instrumentation?: string;
136136
};

0 commit comments

Comments
 (0)