Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -1260,6 +1260,18 @@ Affected SDKs: `@sentry/react-router`.
+ import { sentryOnBuildEnd } from '@sentry/react-router/vite';
```

### Remix: Vite plugin moved to `@sentry/remix/vite`

Affected SDKs: `@sentry/remix`.

`sentryRemixVitePlugin` is no longer available from the main `@sentry/remix` entry point. Import it from the dedicated subpath instead:

```diff
// vite.config.ts
- import { sentryRemixVitePlugin } from '@sentry/remix';
+ import { sentryRemixVitePlugin } from '@sentry/remix/vite';
```

## 3. Removed APIs

### `@sentry/core` / All SDKs
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { installGlobals } from '@remix-run/node';
import { vitePlugin as remix } from '@remix-run/dev';
import { sentryRemixVitePlugin } from '@sentry/remix';
import { sentryRemixVitePlugin } from '@sentry/remix/vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { installGlobals } from '@remix-run/node';
import { vitePlugin as remix } from '@remix-run/dev';
import { sentryRemixVitePlugin } from '@sentry/remix';
import { sentryRemixVitePlugin } from '@sentry/remix/vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vitePlugin as remix } from '@remix-run/dev';
import { sentryRemixVitePlugin } from '@sentry/remix';
import { sentryRemixVitePlugin } from '@sentry/remix/vite';
import { sentryOrchestrionPlugin } from '@sentry/server-utils/orchestrion/vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vitePlugin as remix } from '@remix-run/dev';
import { sentryRemixVitePlugin } from '@sentry/remix';
import { sentryRemixVitePlugin } from '@sentry/remix/vite';
import { hydrogen } from '@shopify/hydrogen/vite';
import { oxygen } from '@shopify/mini-oxygen/vite';
import { defineConfig } from 'vite';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { vitePlugin as remix } from '@remix-run/dev';
import { sentryRemixVitePlugin } from '@sentry/remix';
import { sentryRemixVitePlugin } from '@sentry/remix/vite';
import { defineConfig } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';

Expand Down
5 changes: 5 additions & 0 deletions packages/remix/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
"types": "./build/types/cloudflare/index.d.ts",
"default": "./build/esm/cloudflare/index.js"
},
"./vite": {
"types": "./build/types/vite/index.d.ts",
"import": "./build/esm/vite/index.js",
"require": "./build/cjs/vite/index.js"
},
"./import": {
"import": {
"default": "./build/import-hook.mjs"
Expand Down
1 change: 1 addition & 0 deletions packages/remix/rollup.npm.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default [
'src/client/index.ts',
'src/server/index.ts',
'src/cloudflare/index.ts',
'src/vite/index.ts',
],
packageSpecificConfig: {
external: ['react-router', 'react-router-dom', 'react', 'react/jsx-runtime'],
Expand Down
1 change: 0 additions & 1 deletion packages/remix/src/index.server.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export * from './server';
export { captureRemixErrorBoundaryError, withSentry, ErrorBoundary, browserTracingIntegration } from './client';

export { sentryRemixVitePlugin } from './config/vite';
export { createRemixRouteManifest } from './config/createRemixRouteManifest';
export type { CreateRemixRouteManifestOptions } from './config/createRemixRouteManifest';

Expand Down
32 changes: 32 additions & 0 deletions packages/remix/src/vite/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { Plugin } from 'vite';
import { makeRouteManifestPlugin } from './routeManifestPlugin';
import type { SentryRemixVitePluginOptions } from './types';

export type { SentryRemixVitePluginOptions };

/**
* Sentry Vite plugins for Remix.
*
* Add these to your Vite configuration to inject the Remix route manifest, so client-side
* transactions are parameterized.
*
* @example
* ```typescript
* // vite.config.ts
* import { vitePlugin as remix } from '@remix-run/dev';
* import { sentryRemixVitePlugin } from '@sentry/remix/vite';
* import { defineConfig } from 'vite';
*
* export default defineConfig({
* plugins: [
* remix(),
* sentryRemixVitePlugin({
* appDirPath: './app',
* }),
* ],
* });
* ```
*/
export function sentryRemixVitePlugin(options: SentryRemixVitePluginOptions = {}): Plugin[] {
return [makeRouteManifestPlugin(options)];
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as path from 'path';
import type { Plugin } from 'vite';
import { createRemixRouteManifest } from './createRemixRouteManifest';
import { createRemixRouteManifest } from '../config/createRemixRouteManifest';
import type { SentryRemixVitePluginOptions } from './types';

/**
* Escapes a JSON string for safe embedding in HTML script tags.
Expand All @@ -12,45 +13,13 @@ function escapeJsonForHtml(jsonString: string): string {
.replace(/<!--/g, '<\\!--'); // Escape <!-- to prevent HTML comment injection
}

export type SentryRemixVitePluginOptions = {
/**
* Path to the app directory (where routes folder is located).
* Can be relative to project root or absolute.
* Defaults to 'app' in the project root.
*
* @example './app'
* @example '/absolute/path/to/app'
*/
appDirPath?: string;
};

// Global variable key used to store the route manifest
const MANIFEST_GLOBAL_KEY = '_sentryRemixRouteManifest' as const;

/**
* Vite plugin to inject Remix route manifest for Sentry client-side route parameterization.
*
* @param options - Plugin configuration options
* @returns Vite plugin
*
* @example
* ```typescript
* // vite.config.ts
* import { defineConfig } from 'vite';
* import { vitePlugin as remix } from '@remix-run/dev';
* import { sentryRemixVitePlugin } from '@sentry/remix';
*
* export default defineConfig({
* plugins: [
* remix(),
* sentryRemixVitePlugin({
* appDirPath: './app',
* }),
* ],
* });
* ```
*/
export function sentryRemixVitePlugin(options: SentryRemixVitePluginOptions = {}): Plugin {
export function makeRouteManifestPlugin(options: Pick<SentryRemixVitePluginOptions, 'appDirPath'> = {}): Plugin {
let routeManifestJson: string = '';
let isDevMode = false;

Expand Down
11 changes: 11 additions & 0 deletions packages/remix/src/vite/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export type SentryRemixVitePluginOptions = {
/**
* Path to the app directory (where routes folder is located).
* Can be relative to project root or absolute.
* Defaults to 'app' in the project root.
*
* @example './app'
* @example '/absolute/path/to/app'
*/
appDirPath?: string;
};
Loading
Loading