Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/cloudflare/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type {
} from '@sentry/core';

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

export {
addEventProcessor,
Expand Down
21 changes: 21 additions & 0 deletions packages/cloudflare/src/integrations/tracing/vercelai-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Integration } from '@sentry/core';

/**
* Options for the Vercel AI integration.
*/
export interface VercelAiOptions {
/**
* Enable or disable input recording. Enabled if `sendDefaultPii` is `true`
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
*/
recordInputs?: boolean;
/**
* Enable or disable output recording. Enabled if `sendDefaultPii` is `true`
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
*/
recordOutputs?: boolean;
}

export interface VercelAiIntegration extends Integration {
options: VercelAiOptions;
}
28 changes: 26 additions & 2 deletions packages/cloudflare/src/integrations/tracing/vercelai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

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

const INTEGRATION_NAME = 'VercelAI';

const _vercelAIIntegration = (() => {
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
return {
name: INTEGRATION_NAME,
options,
setup(client) {
addVercelAiProcessors(client);
},
Expand All @@ -28,7 +30,29 @@ const _vercelAIIntegration = (() => {
*
* For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
*
* You need to enable collecting spans for a specific call by setting
* @example
* ```javascript
* const Sentry = require('@sentry/cloudflare');
*
* Sentry.init({
* integrations: [Sentry.vercelAIIntegration()],
* });
* ```
*
* You can configure the integration with options to set default recording preferences:
*
* ```javascript
* Sentry.init({
* integrations: [
* Sentry.vercelAIIntegration({
* recordInputs: true,
* recordOutputs: true,
* }),
* ],
* });
* ```
*
* You need to enable collecting spans for a specific call by setting
* `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
*
* ```javascript
Expand Down
1 change: 1 addition & 0 deletions packages/vercel-edge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type {
} from '@sentry/core';

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

export {
addEventProcessor,
Expand Down
21 changes: 21 additions & 0 deletions packages/vercel-edge/src/integrations/tracing/vercelai-types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import type { Integration } from '@sentry/core';

/**
* Options for the Vercel AI integration.
*/
export interface VercelAiOptions {
/**
* Enable or disable input recording. Enabled if `sendDefaultPii` is `true`
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
*/
recordInputs?: boolean;
/**
* Enable or disable output recording. Enabled if `sendDefaultPii` is `true`
* or if you set `isEnabled` to `true` in your ai SDK method telemetry settings
*/
recordOutputs?: boolean;
}

export interface VercelAiIntegration extends Integration {
options: VercelAiOptions;
}
28 changes: 26 additions & 2 deletions packages/vercel-edge/src/integrations/tracing/vercelai.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@

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

const INTEGRATION_NAME = 'VercelAI';

const _vercelAIIntegration = (() => {
const _vercelAIIntegration = ((options: VercelAiOptions = {}) => {
return {
name: INTEGRATION_NAME,
options,
setup(client) {
addVercelAiProcessors(client);
},
Expand All @@ -28,7 +30,29 @@ const _vercelAIIntegration = (() => {
*
* For more information, see the [`ai` documentation](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).
*
* You need to enable collecting spans for a specific call by setting
* @example
* ```javascript
* const Sentry = require('@sentry/vercel-edge');
*
* Sentry.init({
* integrations: [Sentry.vercelAIIntegration()],
* });
* ```
*
* You can configure the integration with options to set default recording preferences:
*
* ```javascript
* Sentry.init({
* integrations: [
* Sentry.vercelAIIntegration({
* recordInputs: true,
* recordOutputs: true,
* }),
* ],
* });
* ```
*
* You need to enable collecting spans for a specific call by setting
* `experimental_telemetry.isEnabled` to `true` in the first argument of the function call.
*
* ```javascript
Expand Down
Loading