Skip to content

feat(node): Migrate Node AI provider to dataCollection option - #21247

Merged
s1gr1d merged 1 commit into
developfrom
sig/node-ai-provider-data-collection
Jun 1, 2026
Merged

feat(node): Migrate Node AI provider to dataCollection option#21247
s1gr1d merged 1 commit into
developfrom
sig/node-ai-provider-data-collection

Conversation

@s1gr1d

Copy link
Copy Markdown
Member

Closes#20930

@s1gr1d
s1gr1d requested a review from a team as a code ownerMay 29, 2026 12:32
@s1gr1d
s1gr1d requested review from JPeer264, andreiborza, chargome and nicohrubec and removed request for a teamMay 29, 2026 12:32
*/
private _patch(exports: PatchedModuleExports): PatchedModuleExports | void {
const client = getClient();
const genAI = client?.getDataCollectionOptions().genAI;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: The code client?.getDataCollectionOptions().genAI may throw a TypeError. If client is undefined, accessing .genAI on the resulting undefined will cause a crash.
Severity: HIGH

Suggested Fix

Add optional chaining to the .genAI property access to prevent the TypeError. The corrected code should be client?.getDataCollectionOptions()?.genAI.

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent. Verify if this is a real issue. If it is, propose a fix; if not, explain why it's
not valid.
Location: packages/node/src/integrations/tracing/langgraph/instrumentation.ts#L94
Potential issue: The code at
`packages/node/src/integrations/tracing/langgraph/instrumentation.ts:94` uses optional
chaining for `client` but not for the subsequent property access. If `getClient()`
returns `undefined`, which can happen if a module using `@langchain/langgraph` is loaded
before `Sentry.init()` is called, the expression `client?.getDataCollectionOptions()`
evaluates to `undefined`. The following access to `.genAI` on `undefined` will then
throw a `TypeError: Cannot read properties of undefined (reading 'genAI')`, causing a
crash.

Also affects:

  • packages/core/src/tracing/ai/utils.ts:52~52

Did we get this right? 👍 / 👎 to inform future reviews.

@github-actions

Copy link
Copy Markdown
Contributor

size-limit report 📦

PathSize% ChangeChange
@sentry/browser27.17 kB--
@sentry/browser - with treeshaking flags25.62 kB--
@sentry/browser (incl. Tracing)45.25 kB--
@sentry/browser (incl. Tracing + Span Streaming)47.47 kB--
@sentry/browser (incl. Tracing, Profiling)50.22 kB--
@sentry/browser (incl. Tracing, Replay)84.83 kB--
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags74.39 kB--
@sentry/browser (incl. Tracing, Replay with Canvas)89.53 kB--
@sentry/browser (incl. Tracing, Replay, Feedback)102.15 kB--
@sentry/browser (incl. Feedback)44.34 kB--
@sentry/browser (incl. sendFeedback)31.98 kB--
@sentry/browser (incl. FeedbackAsync)37.08 kB--
@sentry/browser (incl. Metrics)28.25 kB--
@sentry/browser (incl. Logs)28.48 kB--
@sentry/browser (incl. Metrics & Logs)29.19 kB--
@sentry/react28.99 kB--
@sentry/react (incl. Tracing)47.51 kB--
@sentry/vue32.2 kB--
@sentry/vue (incl. Tracing)47.16 kB--
@sentry/svelte27.19 kB--
CDN Bundle29.55 kB--
CDN Bundle (incl. Tracing)47.81 kB--
CDN Bundle (incl. Logs, Metrics)31.05 kB--
CDN Bundle (incl. Tracing, Logs, Metrics)49.04 kB--
CDN Bundle (incl. Replay, Logs, Metrics)70.31 kB--
CDN Bundle (incl. Tracing, Replay)85.18 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics)86.35 kB--
CDN Bundle (incl. Tracing, Replay, Feedback)91.05 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics)92.21 kB--
CDN Bundle - uncompressed87.59 kB--
CDN Bundle (incl. Tracing) - uncompressed144.09 kB--
CDN Bundle (incl. Logs, Metrics) - uncompressed92.08 kB--
CDN Bundle (incl. Tracing, Logs, Metrics) - uncompressed147.85 kB--
CDN Bundle (incl. Replay, Logs, Metrics) - uncompressed216.81 kB--
CDN Bundle (incl. Tracing, Replay) - uncompressed262.87 kB--
CDN Bundle (incl. Tracing, Replay, Logs, Metrics) - uncompressed266.61 kB--
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed276.57 kB--
CDN Bundle (incl. Tracing, Replay, Feedback, Logs, Metrics) - uncompressed280.3 kB--
@sentry/nextjs (client)50.03 kB--
@sentry/sveltekit (client)45.68 kB--
@sentry/core/server75.93 kB+0.01%+2 B 🔺
@sentry/core/browser63.09 kB+0.01%+4 B 🔺
@sentry/node-core61.69 kB--
@sentry/node130.45 kB+0.04%+52 B 🔺
@sentry/node - without tracing74.1 kB--
@sentry/aws-serverless86.29 kB--
@sentry/cloudflare (withSentry) - minified171.5 kB--
@sentry/cloudflare (withSentry)429.29 kB--

View base workflow run

@s1gr1d
s1gr1d merged commit a144453 into developJun 1, 2026
265 of 266 checks passed
@s1gr1d
s1gr1d deleted the sig/node-ai-provider-data-collection branch June 1, 2026 11:31
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

(node): Migrate Node.js AI provider integrations to dataCollection

2 participants

@s1gr1d@JPeer264