Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ _Import name: `Sentry.vercelAIIntegration`_

The `vercelAIIntegration` adds instrumentation for the [`ai`](https://www.npmjs.com/package/ai) SDK by Vercel to capture spans using the [`AI SDK's built-in Telemetry`](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry).

<PlatformSection notSupported={["javascript.cloudflare", "javascript.nextjs"]}>
<PlatformSection notSupported={["javascript.cloudflare", "javascript.deno", "javascript.nextjs"]}>
It is enabled by default and will automatically capture spans for all `ai`
function calls. You can opt-in to capture inputs and outputs by setting `recordInputs` and `recordOutputs` in the integration config:

Expand All @@ -63,7 +63,7 @@ Sentry.init({

</PlatformSection>

<PlatformSection supported={['javascript.cloudflare']}>
<PlatformSection supported={['javascript.cloudflare', 'javascript.deno']}>
This integration is not enabled by default. You need to manually enable it by passing `Sentry.vercelAIIntegration()` to `Sentry.init`:

```javascript
Expand All @@ -89,7 +89,7 @@ Sentry.init({

</PlatformSection>

<PlatformSection supported={['javascript.cloudflare', 'javascript.nextjs']}>
<PlatformSection supported={['javascript.cloudflare', 'javascript.deno', 'javascript.nextjs']}>
To correctly capture spans, pass the `experimental_telemetry` object with `isEnabled: true` to every `generateText`, `generateObject`, `streamText`, and `ToolLoopAgent` call. For more details, see the [AI SDK Telemetry Metadata docs](https://sdk.vercel.ai/docs/ai-sdk-core/telemetry#telemetry-metadata).

```javascript
Expand All @@ -105,9 +105,23 @@ const result = await generateText({

</PlatformSection>

<PlatformSection notSupported={['javascript.cloudflare']}>
## Options

### `enableTruncation`

_Type: `boolean`_

Enables or disables truncation of recorded input messages. Truncation keeps large payloads within span size limits.

Defaults to `true`.

```javascript
Sentry.init({
integrations: [Sentry.vercelAIIntegration({ enableTruncation: false })],
});
```

<PlatformSection notSupported={['javascript.cloudflare', 'javascript.deno']}>
### `force`

Requires SDK version `9.29.0` or higher.
Expand All @@ -129,7 +143,9 @@ Sentry.init({
forced when it is enabled.
</PlatformSection>

<PlatformSection notSupported={['javascript.nextjs']}>
</PlatformSection>

<PlatformSection notSupported={['javascript.cloudflare', 'javascript.nextjs']}>

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 documentation for recordInputs incorrectly implies support for Deno, breaking the pattern where Deno and Cloudflare have parallel feature support.
Severity: LOW

Suggested Fix

To ensure consistency, add 'javascript.deno' to the notSupported array for the recordInputs section in vercelai.mdx. This will align its documented support with that of Cloudflare, as is done for other options in the file.

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: docs/platforms/javascript/common/configuration/integrations/vercelai.mdx#L148

Potential issue: The documentation for the Vercel AI integration is inconsistent
regarding feature support for Deno. Throughout the file, `javascript.deno` and
`javascript.cloudflare` are treated as having identical support limitations. However,
for the `recordInputs` option, `javascript.deno` is omitted from the `notSupported` list
at line 148, while `javascript.cloudflare` is included. This incorrectly suggests to
Deno users that this feature is supported, which contradicts the established pattern in
the rest of the document. This will likely lead to user confusion.

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

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: Documentation for the Vercel AI integration incorrectly shows Deno users the recordInputs and recordOutputs options, which are not supported for their platform at the integration level.
Severity: MEDIUM

Suggested Fix

Add javascript.deno to the notSupported list on line 148 to hide the section documenting the recordInputs and recordOutputs options. Alternatively, add a Deno-specific section explaining that these options are not supported at the integration level and that experimental_telemetry must be used instead.

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: docs/platforms/javascript/common/configuration/integrations/vercelai.mdx#L148

Potential issue: The documentation for the Vercel AI integration is inconsistent for the
Deno runtime. The PR correctly groups Deno with Cloudflare for initialization behavior,
which requires `experimental_telemetry` on each function call. However, it fails to
update the options documentation completely. As a result, Deno users are shown
documentation for the `recordInputs` and `recordOutputs` configuration options at the
integration level. These options do not work for Deno in the same way as other
platforms. Unlike the Cloudflare documentation, there is no specific note explaining
this limitation for Deno, which will likely cause developers to implement a
configuration that fails or behaves unexpectedly.

### `recordInputs`

Requires SDK version `9.27.0` or higher.
Expand Down Expand Up @@ -164,19 +180,35 @@ Sentry.init({

</PlatformSection>

<PlatformSection supported={['javascript.cloudflare']}>
### `recordInputs` and `recordOutputs`

Setting `recordInputs` and `recordOutputs` on the integration is only supported with AI SDK v7 or higher through the <PlatformLink to="/features/nodejs-compat">`@sentry/cloudflare/nodejs_compat`</PlatformLink> entrypoint. On the default entrypoint, Sentry only post-processes spans the AI SDK already emitted and can't decide whether inputs and outputs are recorded.

To control input and output recording on the default entrypoint, set `experimental_telemetry.recordInputs` and `experimental_telemetry.recordOutputs` directly on each `ai` function call (for example, `generateText`), not on the Sentry integration (see [Configuration](#configuration)).

```javascript
// Only in the `@sentry/cloudflare/nodejs_compat` entrypoint (AI SDK v7+)
Sentry.init({
integrations: [
Sentry.vercelAIIntegration({ recordInputs: true, recordOutputs: true }),
],
});
```

</PlatformSection>

## ToolLoopAgent

The integration also captures spans for the [`ToolLoopAgent`](https://ai-sdk.dev/docs/agents/overview#toolloopagent-class) class. Each call to `generate()` or `stream()` creates an agent span with individual LLM requests and tool executions as child spans.

<PlatformSection notSupported={["javascript.cloudflare", "javascript.nextjs"]}>
<PlatformSection notSupported={["javascript.cloudflare", "javascript.deno", "javascript.nextjs"]}>

No additional configuration is needed — `ToolLoopAgent` spans are captured automatically.

</PlatformSection>

<PlatformSection supported={['javascript.cloudflare', 'javascript.nextjs']}>
<PlatformSection supported={['javascript.cloudflare', 'javascript.deno', 'javascript.nextjs']}>

Pass `experimental_telemetry` with `isEnabled: true` to the `ToolLoopAgent` constructor to correctly capture spans:

Expand Down
Loading