Skip to content

Commit 0c1f38e

Browse files
committed
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
1 parent 52d789a commit 0c1f38e

3 files changed

Lines changed: 40 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
### Features
1212

1313
- Warn Expo users at Metro startup when prebuilt native projects are missing Sentry configuration ([#5984](https://github.com/getsentry/sentry-react-native/pull/5984))
14+
- 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))
1415

1516
### Dependencies
1617

packages/core/src/js/index.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,31 @@ 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+
GoogleGenAIIstrumentedMethod,
71+
LangChainOptions,
72+
LangChainIntegration,
73+
LangGraphOptions,
74+
LangGraphIntegration,
75+
CompiledGraph,
5176
} from '@sentry/core';
5277

5378
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)