Skip to content

Commit fc5cad6

Browse files
JPeer264chargome
andauthored
fix(cloudflare,deno,node): Align types of vercelai (#22343)
`recordInput` and `recordOuput` types were missing for integrations that were using the `vercelAiIntegration` from the `server-utils` package. By exporting them this is now aligned. Only `node` had also `force` in it, so it is only extended there. Cloudflare (the older entrypoint) and Vercel Edge only have `enableTrucation` --------- Co-authored-by: Charly Gomez <charly.gomez1310@gmail.com>
1 parent bd6c0e3 commit fc5cad6

7 files changed

Lines changed: 17 additions & 41 deletions

File tree

packages/cloudflare/src/integrations/tracing/vercelai.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ interface VercelAiOptions {
1919
* Defaults to `true`.
2020
*/
2121
enableTruncation?: boolean;
22+
23+
// `recordInputs`/`recordOutputs` are intentionally omitted: this entrypoint only post-processes
24+
// spans the AI SDK already emitted, so it cannot decide whether inputs/outputs are recorded.
25+
// Control this per call via `experimental_telemetry.recordInputs`/`recordOutputs`, or use the
26+
// `@sentry/cloudflare/nodejs_compat` entrypoint for integration-level control on ai >= 7.
2227
}
2328

2429
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {

packages/cloudflare/src/nodejs_compat/integrations/tracing/vercelai.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,9 @@
77

88
import type { IntegrationFn } from '@sentry/core';
99
import { defineIntegration } from '@sentry/core';
10-
import { vercelAiIntegration as serverUtilsVercelAiIntegration } from '@sentry/server-utils';
10+
import { vercelAiIntegration as serverUtilsVercelAiIntegration, type VercelAiOptions } from '@sentry/server-utils';
1111
import { vercelAIIntegration as cloudflareVercelAIIntegration } from '../../../integrations/tracing/vercelai';
1212

13-
interface VercelAiOptions {
14-
/**
15-
* Enable or disable truncation of recorded input messages.
16-
* Defaults to `true`.
17-
*/
18-
enableTruncation?: boolean;
19-
}
20-
2113
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
2214
const inner = serverUtilsVercelAiIntegration(options);
2315
const instrumentation = cloudflareVercelAIIntegration(options);

packages/deno/src/integrations/tracing/vercelai.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,7 @@
44

55
import type { IntegrationFn } from '@sentry/core';
66
import { addVercelAiProcessors, defineIntegration, extendIntegration } from '@sentry/core';
7-
import { vercelAiIntegration as serverUtilsVercelAiIntegration } from '@sentry/server-utils';
8-
9-
interface VercelAiOptions {
10-
/**
11-
* Enable or disable truncation of recorded input messages.
12-
* Defaults to `true`.
13-
*/
14-
enableTruncation?: boolean;
15-
}
7+
import { vercelAiIntegration as serverUtilsVercelAiIntegration, type VercelAiOptions } from '@sentry/server-utils';
168

179
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
1810
const inner = serverUtilsVercelAiIntegration(options);

packages/node/src/integrations/tracing/vercelai/types.ts

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Integration } from '@sentry/core';
2+
import type { VercelAiOptions as VercelAiBaseOptions } from '@sentry/server-utils';
23

34
/**
45
* Telemetry configuration.
@@ -45,31 +46,12 @@ export declare type AttributeValue =
4546
| Array<null | undefined | number>
4647
| Array<null | undefined | boolean>;
4748

48-
export interface VercelAiOptions {
49-
/**
50-
* Enable or disable input recording. Enabled if `dataCollection.genAI.inputs` (or the deprecated `sendDefaultPii` option) is `true`
51-
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings.
52-
* Integration-level options take precedence over global `dataCollection` config.
53-
*/
54-
recordInputs?: boolean;
55-
/**
56-
* Enable or disable output recording. Enabled if `dataCollection.genAI.outputs` (or the deprecated `sendDefaultPii` option) is `true`
57-
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings.
58-
* Integration-level options take precedence over global `dataCollection` config.
59-
*/
60-
recordOutputs?: boolean;
61-
49+
export interface VercelAiOptions extends VercelAiBaseOptions {
6250
/**
6351
* By default, the instrumentation will register span processors only when the ai package is used.
6452
* If you want to register the span processors even when the ai package usage cannot be detected, you can set `force` to `true`.
6553
*/
6654
force?: boolean;
67-
68-
/**
69-
* Enable or disable truncation of recorded input messages.
70-
* Defaults to `true`.
71-
*/
72-
enableTruncation?: boolean;
7355
}
7456

7557
export interface VercelAiIntegration extends Integration {

packages/server-utils/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export type {
2727
TracingChannelBindingHandle,
2828
TracingChannelPayloadWithSpan,
2929
} from './tracing-channel';
30-
export { vercelAiIntegration } from './vercel-ai';
3130
export type { InstrumentationConfig } from './orchestrion';
31+
export { vercelAiIntegration, type VercelAiOptions } from './vercel-ai';
3232
export {
3333
fastifyIntegration,
3434
// oxlint-disable-next-line typescript/no-deprecated

packages/server-utils/src/vercel-ai/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { defineIntegration, waitForTracingChannelBinding, type IntegrationFn } f
22
import { subscribeVercelAiTracingChannel } from './vercel-ai-dc-subscriber';
33
import * as dc from 'node:diagnostics_channel';
44

5-
type VercelAiOptions = {
5+
export interface VercelAiOptions {
66
/**
77
* Enable or disable input recording. Enabled if `dataCollection.genAI.inputs` (or the deprecated `sendDefaultPii` option) is `true`
88
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings.
@@ -22,7 +22,7 @@ type VercelAiOptions = {
2222
* Defaults to `true`.
2323
*/
2424
enableTruncation?: boolean;
25-
};
25+
}
2626

2727
const _vercelAiIntegration = ((options: VercelAiOptions = {}) => {
2828
return {

packages/vercel-edge/src/integrations/tracing/vercelai.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ interface VercelAiOptions {
1919
* Defaults to `true`.
2020
*/
2121
enableTruncation?: boolean;
22+
23+
// `recordInputs`/`recordOutputs` are intentionally omitted: this entrypoint only post-processes
24+
// spans the AI SDK already emitted (no OTel patch or tracing channel in the edge runtime), so it
25+
// cannot decide whether inputs/outputs are recorded. Control this per call via
26+
// `experimental_telemetry.recordInputs`/`recordOutputs`.
2227
}
2328

2429
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {

0 commit comments

Comments
 (0)