Skip to content

Commit 50212fd

Browse files
authored
feat(ai): Re-export AI SDK manual instrumentation helpers (#6028)
* 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 * Address review: fix CHANGELOG reference and drop typo'd type - 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.
1 parent d145143 commit 50212fd

3 files changed

Lines changed: 39 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
- Expose scope-level attributes API (`setAttribute`, `setAttributes`, `removeAttribute`) bridging to native SDKs ([#6009](https://github.com/getsentry/sentry-react-native/pull/6009))
1414
- 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))
1515
- Warn Expo users at Metro startup when prebuilt native projects are missing Sentry configuration ([#5984](https://github.com/getsentry/sentry-react-native/pull/5984))
16+
- 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))
1617
- 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))
1718

1819
### Fixes

packages/core/src/js/index.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,30 @@ export {
4848
addEventProcessor,
4949
lastEventId,
5050
consoleSandbox,
51+
instrumentOpenAiClient,
52+
instrumentAnthropicAiClient,
53+
instrumentGoogleGenAIClient,
54+
createLangChainCallbackHandler,
55+
instrumentLangGraph,
56+
instrumentStateGraphCompile,
57+
} from '@sentry/core';
58+
59+
export type {
60+
OpenAiClient,
61+
OpenAiOptions,
62+
InstrumentedMethod,
63+
AnthropicAiClient,
64+
AnthropicAiOptions,
65+
AnthropicAiInstrumentedMethod,
66+
AnthropicAiResponse,
67+
GoogleGenAIClient,
68+
GoogleGenAIChat,
69+
GoogleGenAIOptions,
70+
LangChainOptions,
71+
LangChainIntegration,
72+
LangGraphOptions,
73+
LangGraphIntegration,
74+
CompiledGraph,
5175
} from '@sentry/core';
5276

5377
export {
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import * as Sentry from '../src/js';
2+
3+
describe('AI SDK manual instrumentation re-exports', () => {
4+
test.each([
5+
'instrumentOpenAiClient',
6+
'instrumentAnthropicAiClient',
7+
'instrumentGoogleGenAIClient',
8+
'createLangChainCallbackHandler',
9+
'instrumentLangGraph',
10+
'instrumentStateGraphCompile',
11+
])('re-exports %s from @sentry/core', name => {
12+
expect(typeof (Sentry as Record<string, unknown>)[name]).toBe('function');
13+
});
14+
});

0 commit comments

Comments
 (0)