Skip to content
Open
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@
// → sentry.message.template: "Hello {} {}"
```

- **feat(react-router): Stabilize the instrumentation API**

React Router's instrumentation API is now stable — the `@experimental` markers have been removed from `createSentryServerInstrumentation`, `createSentryClientInstrumentation`, and the related helpers and types.
The manual server wrappers `wrapServerLoader` and `wrapServerAction` are now deprecated in favor of it. Export `instrumentations = [Sentry.createSentryServerInstrumentation()]` from your `entry.server.tsx` to instrument all loaders and actions without wrapping them individually.

Work in this release was contributed by @archievi, @AyaanFaisal21, and @itosa-kazu. Thank you for your contributions!

## 10.57.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ export interface CreateSentryClientInstrumentationOptions {

/**
* Creates a Sentry client instrumentation for React Router's instrumentation API.
* @experimental
*/
export function createSentryClientInstrumentation(
options: CreateSentryClientInstrumentationOptions = {},
Expand Down Expand Up @@ -330,15 +329,13 @@ export function createSentryClientInstrumentation(

/**
* Check if React Router's instrumentation API is being used on the client.
* @experimental
*/
export function isClientInstrumentationApiUsed(): boolean {
return !!GLOBAL_WITH_FLAGS[SENTRY_CLIENT_INSTRUMENTATION_FLAG];
}

/**
* Check if React Router's instrumentation API's navigate hook was invoked.
* @experimental
*/
export function isNavigateHookInvoked(): boolean {
return !!GLOBAL_WITH_FLAGS[SENTRY_NAVIGATE_HOOK_INVOKED_FLAG];
Expand Down
2 changes: 0 additions & 2 deletions packages/react-router/src/client/tracingIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import { instrumentHydratedRouter } from './hydratedRouter';
export interface ReactRouterTracingIntegrationOptions {
/**
* Options for React Router's instrumentation API.
* @experimental
*/
instrumentationOptions?: CreateSentryClientInstrumentationOptions;

Expand All @@ -27,7 +26,6 @@ export interface ReactRouterTracingIntegrationOptions {
export interface ReactRouterTracingIntegration extends Integration {
/**
* Client instrumentation to pass to `HydratedRouter`'s `instrumentations` prop.
* @experimental
*/
readonly clientInstrumentation: ClientInstrumentation;
}
Expand Down
1 change: 0 additions & 1 deletion packages/react-router/src/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* If React Router changes these types, this file must be updated.
*
* @see https://reactrouter.com/how-to/instrumentation
* @experimental
*/

export type InstrumentationResult = { status: 'success'; error: undefined } | { status: 'error'; error: unknown };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export interface CreateSentryServerInstrumentationOptions {

/**
* Creates a Sentry server instrumentation for React Router's instrumentation API.
* @experimental
*/
export function createSentryServerInstrumentation(
options: CreateSentryServerInstrumentationOptions = {},
Expand Down
2 changes: 2 additions & 0 deletions packages/react-router/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ export { init } from './sdk';
// eslint-disable-next-line deprecation/deprecation
export { wrapSentryHandleRequest, sentryHandleRequest } from './wrapSentryHandleRequest';
export { createSentryHandleRequest, type SentryHandleRequestOptions } from './createSentryHandleRequest';
// eslint-disable-next-line deprecation/deprecation
export { wrapServerAction } from './wrapServerAction';
// eslint-disable-next-line deprecation/deprecation
export { wrapServerLoader } from './wrapServerLoader';
export { createSentryHandleError, type SentryHandleErrorOptions } from './createSentryHandleError';
export { getMetaTagTransformer } from './getMetaTagTransformer';
Expand Down
1 change: 0 additions & 1 deletion packages/react-router/src/server/serverGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export function markInstrumentationApiUsed(): void {

/**
* Check if React Router's instrumentation API is being used on the server.
* @experimental
*/
export function isInstrumentationApiUsed(): boolean {
return !!(GLOBAL_OBJ as GlobalObjWithFlag)[SENTRY_SERVER_INSTRUMENTATION_FLAG];
Expand Down
6 changes: 6 additions & 0 deletions packages/react-router/src/server/wrapServerAction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ type SpanOptions = {
// Track if we've already warned about duplicate instrumentation
let hasWarnedAboutDuplicateActionInstrumentation = false;

// todo(v11): Remove this deprecated wrapper in favor of the instrumentation API (`createSentryServerInstrumentation`).
/**
* Wraps a React Router server action function with Sentry performance monitoring.
*
* @deprecated Use React Router's instrumentation API instead: export
* `instrumentations = [createSentryServerInstrumentation()]` from your `entry.server.tsx` to instrument all server
* actions without wrapping them individually. This manual wrapper will be removed in a future major.
*
* @param options - Optional span configuration options including name, operation, description and attributes
* @param actionFn - The server action function to wrap
*
Expand Down
6 changes: 6 additions & 0 deletions packages/react-router/src/server/wrapServerLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ type SpanOptions = {
// Track if we've already warned about duplicate instrumentation
let hasWarnedAboutDuplicateLoaderInstrumentation = false;

// todo(v11): Remove this deprecated wrapper in favor of the instrumentation API (`createSentryServerInstrumentation`).
/**
* Wraps a React Router server loader function with Sentry performance monitoring.
*
* @deprecated Use React Router's instrumentation API instead: export
* `instrumentations = [createSentryServerInstrumentation()]` from your `entry.server.tsx` to instrument all server
* loaders without wrapping them individually. This manual wrapper will be removed in a future major.
*
* @param options - Optional span configuration options including name, operation, description and attributes
* @param loaderFn - The server loader function to wrap
*
Expand Down
Loading