From 0c1f38e3b39b512bdc3e8335e43baf55c3d3f2a9 Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Tue, 21 Apr 2026 11:27:23 +0200 Subject: [PATCH 1/2] feat(ai): Re-export AI SDK manual instrumentation helpers Adds re-exports from @sentry/core for the AI SDK manual instrumentation helpers so React Native apps can import them directly from @sentry/react-native: - instrumentOpenAiClient - instrumentAnthropicAiClient - instrumentGoogleGenAIClient - createLangChainCallbackHandler - instrumentLangGraph - instrumentStateGraphCompile Also re-exports the related types. The automatic (OpenTelemetry-based) integrations for these SDKs only work in Node.js runtimes, so React Native apps have to use the manual client wrappers. Previously users had to reach into @sentry/core to access them, which is awkward. This change aligns the React Native SDK with @sentry/browser, which already re-exports the same helpers. Refs #5297 --- CHANGELOG.md | 1 + packages/core/src/js/index.ts | 25 +++++++++++++++++++++++++ packages/core/test/aiExports.test.ts | 14 ++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 packages/core/test/aiExports.test.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index d177a44677..7db2a2c8c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### Features - Warn Expo users at Metro startup when prebuilt native projects are missing Sentry configuration ([#5984](https://github.com/getsentry/sentry-react-native/pull/5984)) +- Re-export AI SDK manual instrumentation helpers (`instrumentOpenAiClient`, `instrumentAnthropicAiClient`, `instrumentGoogleGenAIClient`, `createLangChainCallbackHandler`, `instrumentLangGraph`, `instrumentStateGraphCompile`) for use in React Native apps ([#5297](https://github.com/getsentry/sentry-react-native/issues/5297)) ### Dependencies diff --git a/packages/core/src/js/index.ts b/packages/core/src/js/index.ts index 570f8180eb..b9c3e82ece 100644 --- a/packages/core/src/js/index.ts +++ b/packages/core/src/js/index.ts @@ -48,6 +48,31 @@ export { addEventProcessor, lastEventId, consoleSandbox, + instrumentOpenAiClient, + instrumentAnthropicAiClient, + instrumentGoogleGenAIClient, + createLangChainCallbackHandler, + instrumentLangGraph, + instrumentStateGraphCompile, +} from '@sentry/core'; + +export type { + OpenAiClient, + OpenAiOptions, + InstrumentedMethod, + AnthropicAiClient, + AnthropicAiOptions, + AnthropicAiInstrumentedMethod, + AnthropicAiResponse, + GoogleGenAIClient, + GoogleGenAIChat, + GoogleGenAIOptions, + GoogleGenAIIstrumentedMethod, + LangChainOptions, + LangChainIntegration, + LangGraphOptions, + LangGraphIntegration, + CompiledGraph, } from '@sentry/core'; export { diff --git a/packages/core/test/aiExports.test.ts b/packages/core/test/aiExports.test.ts new file mode 100644 index 0000000000..559ccb6ea8 --- /dev/null +++ b/packages/core/test/aiExports.test.ts @@ -0,0 +1,14 @@ +import * as Sentry from '../src/js'; + +describe('AI SDK manual instrumentation re-exports', () => { + test.each([ + 'instrumentOpenAiClient', + 'instrumentAnthropicAiClient', + 'instrumentGoogleGenAIClient', + 'createLangChainCallbackHandler', + 'instrumentLangGraph', + 'instrumentStateGraphCompile', + ])('re-exports %s from @sentry/core', name => { + expect(typeof (Sentry as Record)[name]).toBe('function'); + }); +}); From 36a85c2ba08ad7d78eae1d252d115abb2ff1e09f Mon Sep 17 00:00:00 2001 From: Alexander Pantiukhov Date: Tue, 21 Apr 2026 11:45:30 +0200 Subject: [PATCH 2/2] Address review: fix CHANGELOG reference and drop typo'd type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - CHANGELOG entry now references the PR number (#6028) so the Danger check passes. - Drop the re-export of `GoogleGenAIIstrumentedMethod` — it is a typo in the upstream `@sentry/core` export (missing 'n'). Will be added back once the typo is fixed in sentry-javascript. --- CHANGELOG.md | 2 +- packages/core/src/js/index.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 21e2428669..b96c972082 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,7 +12,7 @@ - Expose screenshot masking options (`screenshot.maskAllText`, `screenshot.maskAllImages`, `screenshot.maskedViewClasses`, `screenshot.unmaskedViewClasses`) for error screenshots ([#6007](https://github.com/getsentry/sentry-react-native/pull/6007)) - Warn Expo users at Metro startup when prebuilt native projects are missing Sentry configuration ([#5984](https://github.com/getsentry/sentry-react-native/pull/5984)) -- Re-export AI SDK manual instrumentation helpers (`instrumentOpenAiClient`, `instrumentAnthropicAiClient`, `instrumentGoogleGenAIClient`, `createLangChainCallbackHandler`, `instrumentLangGraph`, `instrumentStateGraphCompile`) for use in React Native apps ([#5297](https://github.com/getsentry/sentry-react-native/issues/5297)) +- Re-export AI SDK manual instrumentation helpers (`instrumentOpenAiClient`, `instrumentAnthropicAiClient`, `instrumentGoogleGenAIClient`, `createLangChainCallbackHandler`, `instrumentLangGraph`, `instrumentStateGraphCompile`) for use in React Native apps ([#6028](https://github.com/getsentry/sentry-react-native/pull/6028)) - Add `Sentry.GlobalErrorBoundary` component (and `withGlobalErrorBoundary` HOC) that renders a fallback UI for fatal non-rendering JS errors routed through `ErrorUtils` in addition to the render-phase errors caught by `Sentry.ErrorBoundary`. Opt-in flags `includeNonFatalGlobalErrors` and `includeUnhandledRejections` extend the fallback to non-fatal errors and unhandled promise rejections respectively. ([#6023](https://github.com/getsentry/sentry-react-native/pull/6023)) ### Fixes diff --git a/packages/core/src/js/index.ts b/packages/core/src/js/index.ts index 7a6f812fdf..4ba7051e88 100644 --- a/packages/core/src/js/index.ts +++ b/packages/core/src/js/index.ts @@ -67,7 +67,6 @@ export type { GoogleGenAIClient, GoogleGenAIChat, GoogleGenAIOptions, - GoogleGenAIIstrumentedMethod, LangChainOptions, LangChainIntegration, LangGraphOptions,