From 5e1af7afd79c4d9faba025e9ab4c31dac14b70ca Mon Sep 17 00:00:00 2001 From: Andrei Borza Date: Wed, 25 Sep 2024 14:42:36 +0900 Subject: [PATCH] Document optional instrumentation file path option --- packages/solidstart/README.md | 6 +++++- packages/solidstart/src/config/types.ts | 2 +- packages/solidstart/src/config/withSentry.ts | 4 ++-- packages/solidstart/src/vite/types.ts | 6 +++--- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/packages/solidstart/README.md b/packages/solidstart/README.md index 3bf1663e6c74..080c2853564f 100644 --- a/packages/solidstart/README.md +++ b/packages/solidstart/README.md @@ -60,7 +60,7 @@ mount(() => , document.getElementById('app')); ### 3. Server-side Setup -Create an instrument file named `instrument.server.mjs` and add your initialization code for the server-side SDK. +Create an instrument file named `src/instrument.server.ts` and add your initialization code for the server-side SDK. ```javascript import * as Sentry from '@sentry/solidstart'; @@ -125,6 +125,8 @@ export default defineConfig(withSentry({ 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. +If your `instrument.server.ts` file is not located in the `src` folder, you can specify the path via the `sentrySolidStartVite` plugin. + 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. @@ -147,6 +149,8 @@ export default defineConfig(withSentry({ project: process.env.SENTRY_PROJECT, authToken: process.env.SENTRY_AUTH_TOKEN, debug: true, + // optional: if your `instrument.server.ts` file is not located inside `src` + instrumentation: './mypath/instrument.server.ts' }), ], }, diff --git a/packages/solidstart/src/config/types.ts b/packages/solidstart/src/config/types.ts index e9623313f438..2c67942c8a4d 100644 --- a/packages/solidstart/src/config/types.ts +++ b/packages/solidstart/src/config/types.ts @@ -13,7 +13,7 @@ export type Nitro = { export type SolidStartInlineConfig = Parameters[0]; -export type SolidStartInlineConfigNitroHooks = { +export type SolidStartInlineServerConfig = { hooks?: { close?: () => unknown; 'rollup:before'?: (nitro: Nitro) => unknown; diff --git a/packages/solidstart/src/config/withSentry.ts b/packages/solidstart/src/config/withSentry.ts index d27d3028fc50..3e2e631af8be 100644 --- a/packages/solidstart/src/config/withSentry.ts +++ b/packages/solidstart/src/config/withSentry.ts @@ -6,7 +6,7 @@ import type { Nitro, SentrySolidStartConfigOptions, SolidStartInlineConfig, - SolidStartInlineConfigNitroHooks, + SolidStartInlineServerConfig, } from './types'; /** @@ -22,7 +22,7 @@ export const withSentry = ( solidStartConfig: SolidStartInlineConfig = {}, sentrySolidStartConfigOptions: SentrySolidStartConfigOptions = {}, ): SolidStartInlineConfig => { - const server = (solidStartConfig.server || {}) as SolidStartInlineConfigNitroHooks; + const server = (solidStartConfig.server || {}) as SolidStartInlineServerConfig; const hooks = server.hooks || {}; let serverDir: string; diff --git a/packages/solidstart/src/vite/types.ts b/packages/solidstart/src/vite/types.ts index a725478aae7b..fdf252471de1 100644 --- a/packages/solidstart/src/vite/types.ts +++ b/packages/solidstart/src/vite/types.ts @@ -127,10 +127,10 @@ export type SentrySolidStartPluginOptions = { debug?: boolean; /** - * The path to your `instrumentation.server.ts|js` file. - * e.g. './src/instrumentation.server.ts` + * The path to your `instrument.server.ts|js` file. + * e.g. `./src/instrument.server.ts` * - * Defaults to: `./src/instrumentation.server.ts` + * Defaults to: `./src/instrument.server.ts` */ instrumentation?: string; };