Skip to content

Commit 8a28b4e

Browse files
committed
fix(cloudflare,vercel-edge): Add configuration options to vercelAIIntegration
- Add VercelAiOptions interface with recordInputs and recordOutputs options - Update vercelAIIntegration to accept optional configuration parameters - Export VercelAiOptions and VercelAiIntegration types - Align API with Node.js SDK to support documented configuration - Fix issue where Cloudflare and Vercel Edge SDKs couldn't use integration options Fixes compatibility with Sentry documentation that shows vercelAIIntegration accepting configuration options like recordInputs and recordOutputs.
1 parent f3f0ba3 commit 8a28b4e

File tree

6 files changed

+96
-4
lines changed

6 files changed

+96
-4
lines changed

packages/cloudflare/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type {
1919
} from '@sentry/core';
2020

2121
export type { CloudflareOptions } from './client';
22+
export type { VercelAiOptions, VercelAiIntegration } from './integrations/tracing/vercelai-types';
2223

2324
export {
2425
addEventProcessor,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Integration } from '@sentry/core';
2+
3+
/**
4+
* Options for the Vercel AI integration.
5+
*/
6+
export interface VercelAiOptions {
7+
/**
8+
* Enable or disable input recording. Enabled if `sendDefaultPii` is `true`
9+
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
10+
*/
11+
recordInputs?: boolean;
12+
/**
13+
* Enable or disable output recording. Enabled if `sendDefaultPii` is `true`
14+
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
15+
*/
16+
recordOutputs?: boolean;
17+
}
18+
19+
export interface VercelAiIntegration extends Integration {
20+
options: VercelAiOptions;
21+
}

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
import type { IntegrationFn } from '@sentry/core';
1212
import { addVercelAiProcessors, defineIntegration } from '@sentry/core';
13+
import type { VercelAiOptions } from './vercelai-types';
1314

1415
const INTEGRATION_NAME = 'VercelAI';
1516

16-
const _vercelAIIntegration = (() => {
17+
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
1718
return {
1819
name: INTEGRATION_NAME,
20+
options,
1921
setup(client) {
2022
addVercelAiProcessors(client);
2123
},
@@ -28,7 +30,29 @@ const _vercelAIIntegration = (() => {
2830
*
2931
* For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
3032
*
31-
* You need to enable collecting spans for a specific call by setting
33+
* @example
34+
* ```javascript
35+
* const Sentry = require('@sentry/cloudflare');
36+
*
37+
* Sentry.init({
38+
* integrations: [Sentry.vercelAIIntegration()],
39+
* });
40+
* ```
41+
*
42+
* You can configure the integration with options to set default recording preferences:
43+
*
44+
* ```javascript
45+
* Sentry.init({
46+
* integrations: [
47+
* Sentry.vercelAIIntegration({
48+
* recordInputs: true,
49+
* recordOutputs: true,
50+
* }),
51+
* ],
52+
* });
53+
* ```
54+
*
55+
* You need to enable collecting spans for a specific call by setting
3256
* `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
3357
*
3458
* ```javascript

packages/vercel-edge/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ export type {
1919
} from '@sentry/core';
2020

2121
export type { VercelEdgeOptions } from './types';
22+
export type { VercelAiOptions, VercelAiIntegration } from './integrations/tracing/vercelai-types';
2223

2324
export {
2425
addEventProcessor,
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import type { Integration } from '@sentry/core';
2+
3+
/**
4+
* Options for the Vercel AI integration.
5+
*/
6+
export interface VercelAiOptions {
7+
/**
8+
* Enable or disable input recording. Enabled if `sendDefaultPii` is `true`
9+
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
10+
*/
11+
recordInputs?: boolean;
12+
/**
13+
* Enable or disable output recording. Enabled if `sendDefaultPii` is `true`
14+
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
15+
*/
16+
recordOutputs?: boolean;
17+
}
18+
19+
export interface VercelAiIntegration extends Integration {
20+
options: VercelAiOptions;
21+
}

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

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@
1010

1111
import type { IntegrationFn } from '@sentry/core';
1212
import { addVercelAiProcessors, defineIntegration } from '@sentry/core';
13+
import type { VercelAiOptions } from './vercelai-types';
1314

1415
const INTEGRATION_NAME = 'VercelAI';
1516

16-
const _vercelAIIntegration = (() => {
17+
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
1718
return {
1819
name: INTEGRATION_NAME,
20+
options,
1921
setup(client) {
2022
addVercelAiProcessors(client);
2123
},
@@ -28,7 +30,29 @@ const _vercelAIIntegration = (() => {
2830
*
2931
* For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
3032
*
31-
* You need to enable collecting spans for a specific call by setting
33+
* @example
34+
* ```javascript
35+
* const Sentry = require('@sentry/vercel-edge');
36+
*
37+
* Sentry.init({
38+
* integrations: [Sentry.vercelAIIntegration()],
39+
* });
40+
* ```
41+
*
42+
* You can configure the integration with options to set default recording preferences:
43+
*
44+
* ```javascript
45+
* Sentry.init({
46+
* integrations: [
47+
* Sentry.vercelAIIntegration({
48+
* recordInputs: true,
49+
* recordOutputs: true,
50+
* }),
51+
* ],
52+
* });
53+
* ```
54+
*
55+
* You need to enable collecting spans for a specific call by setting
3256
* `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
3357
*
3458
* ```javascript

0 commit comments

Comments
 (0)