Skip to content

feat(js): Update docs for vercelAiIntegration #14168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jul 1, 2025
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ supported:
- javascript.express
- javascript.fastify
- javascript.gcp-functions
- javascript.cloudflare
- javascript.hapi
- javascript.hono
- javascript.koa
Expand All @@ -27,22 +28,21 @@ supported:

<Alert>

This integration only works in the Node.js and Bun runtimes. Requires SDK version `9.30.0` or higher.
This integration only works in the Node.js, Cloudflare Workers, Vercel Edge Functions and Bun runtimes. Requires SDK version `9.33.0` or higher.

</Alert>

<PlatformSection supported={["javascript.nextjs"]}>

<Include name="nextjs-server-only" />

</PlatformSection>

_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). Get started with the following snippet:
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).
Copy link
Member

Choose a reason for hiding this comment

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

You can now remove <Include name="nextjs-server-only" /> a bit earlier in this file.
CleanShot 2025-06-30 at 17 15 31


<PlatformSection notSupported={["javascript.cloudflare", "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:

```javascript
Sentry.init({
dsn: "____PUBLIC_DSN____"
tracesSampleRate: 1.0,
integrations: [
Sentry.vercelAIIntegration({
Expand All @@ -53,17 +53,51 @@ Sentry.init({
});
```

</PlatformSection>

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

```javascript
Sentry.init({
dsn: "____PUBLIC_DSN____"
tracesSampleRate: 1.0,
integrations: [Sentry.vercelAIIntegration()],
});
```

</PlatformSection>

<PlatformSection supported={['javascript.nextjs']}>
This integration is enabled by default in the Node runtime, but not in the Edge runtime. You need to manually enable it by passing `Sentry.vercelAIIntegration()` to `Sentry.init` in your `sentry.edge.config.js` file:

```javascript {filename: 'sentry.edge.config.(js|ts)'}
Sentry.init({
dsn: "____PUBLIC_DSN____"
tracesSampleRate: 1.0,
integrations: [Sentry.vercelAIIntegration()],
});
```

</PlatformSection>

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

Choose a reason for hiding this comment

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

Should we also call out recordInputs and recordOutputs in the copy?


```javascript
const result = await generateText({
model: openai("gpt-4o"),
experimental_telemetry: {
isEnabled: true,
recordInputs: true,
recordOutputs: true,
},
});
```

</PlatformSection>

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

### `force`
Expand All @@ -82,6 +116,12 @@ Sentry.init({
});
```

<PlatformSection supported={["javascript.nextjs"]}>
This option is not available in the Edge runtime. There, the integration is
forced when it is enabled.
</PlatformSection>

<PlatformSection notSupported={['javascript.nextjs']}>
### `recordInputs`

Requires SDK version `9.27.0` or higher.
Expand Down Expand Up @@ -114,6 +154,10 @@ Sentry.init({
});
```

</PlatformSection>

</PlatformSection>

## Identifying functions

In order to make it easier to correlate captured spans with the function calls we recommend setting `functionId` in `experimental_telemetry` in all generation function calls:
Expand Down
7 changes: 5 additions & 2 deletions docs/product/insights/agents/getting-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ The Sentry JavaScript SDK supports AI agent monitoring through the Vercel AI int
label="Connect"
url="/platforms/javascript/guides/connect/configuration/integrations/vercelai/"
/>
- <LinkWithPlatformIcon
platform="javascript.cloudflare"
label="Cloudflare"
url="/platforms/javascript/guides/cloudflare/configuration/integrations/vercelai/"
/>
- <LinkWithPlatformIcon
platform="javascript.hono"
label="Hono"
Expand Down Expand Up @@ -114,8 +119,6 @@ The Sentry JavaScript SDK supports AI agent monitoring through the Vercel AI int

#### Quick Start with Vercel AI SDK

<Include name="nextjs-server-only" />

```javascript
import { Sentry } from "@sentry/node";

Expand Down
5 changes: 0 additions & 5 deletions includes/nextjs-server-only.mdx

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Depending on whether an integration enhances the functionality of a particular r
### Browser Integrations

| | **Auto Enabled** | **Errors** | **Tracing** | **Replay** | **Additional Context** |
|-------------------------------------------------------|:----------------:|:----------:|:-----------:|:----------:|:----------------------:|
| ----------------------------------------------------- | :--------------: | :--------: | :---------: | :--------: | :--------------------: |
| [`breadcrumbsIntegration`](./breadcrumbs) | ✓ | | | | ✓ |
| [`browserApiErrorsIntegration`](./browserapierrors) | ✓ | ✓ | | | |
| [`browserSessionIntegration`](./browsersession) | ✓ | | | | ✓ |
Expand Down Expand Up @@ -72,6 +72,7 @@ Depending on whether an integration enhances the functionality of a particular r
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`dataloaderIntegration`](./dataloader) | ✓ | | ✓ | |
| [`prismaIntegration`](./prisma) | ✓ | | ✓ | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`extraErrorDataIntegration`](./extraerrordata) | | | | ✓ |
| [`fsIntegration`](./fs) | | | ✓ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
| [`onUncaughtExceptionIntegration`](./onuncaughtexception) | ✓ | ✓ | | |
| [`onUnhandledRejectionIntegration`](./unhandledrejection) | ✓ | ✓ | | |
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`amqplibIntegration`](./amqplib) | | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`captureConsoleIntegration`](./captureconsole) | | | | ✓ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
| [`requestDataIntegration`](./requestdata) | ✓ | | ✓ | |
| [`tediousIntegration`](./tedious) | ✓ | | ✓ | |
| [`prismaIntegration`](./prisma) | ✓ | | ✓ | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`captureConsoleIntegration`](./captureconsole) | | | | ✓ |
| [`dataloaderIntegration`](./dataloader) | | | ✓ | |
| [`extraErrorDataIntegration`](./extraerrordata) | | | | ✓ |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| [`tediousIntegration`](./tedious) | ✓ | | ✓ | |
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`rewriteFramesIntegration`](./rewriteframes) | ✓ | ✓ | | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`captureConsoleIntegration`](./captureconsole) | | | | ✓ |
| [`dataloaderIntegration`](./dataloader) | | | ✓ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| [`tediousIntegration`](./tedious) | ✓ | | ✓ | |
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`prismaIntegration`](./prisma) | ✓ | | ✓ | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`captureConsoleIntegration`](./captureconsole) | | | | ✓ |
| [`dataloaderIntegration`](./dataloader) | | | ✓ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
| [`onUncaughtExceptionIntegration`](./onuncaughtexception) | ✓ | ✓ | | |
| [`onUnhandledRejectionIntegration`](./unhandledrejection) | ✓ | ✓ | | |
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`amqplibIntegration`](./amqplib) | | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`captureConsoleIntegration`](./captureconsole) | | | | ✓ |
Expand All @@ -40,4 +41,4 @@
| [`requestDataIntegration`](./requestdata) | | | ✓ | |
| [`rewriteFramesIntegration`](./rewriteframes) | | ✓ | | |
| [`tediousIntegration`](./tedious) | | | ✓ | |
| [`trpcMiddleware`](./trpc) | | ✓ | ✓ | ✓ |
| [`trpcMiddleware`](./trpc) | | ✓ | ✓ | ✓ |
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| [`tediousIntegration`](./tedious) | ✓ | | ✓ | |
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`prismaIntegration`](./prisma) | ✓ | | ✓ | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`captureConsoleIntegration`](./captureconsole) | | | | ✓ |
| [`dataloaderIntegration`](./dataloader) | | | ✓ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
| [`tediousIntegration`](./tedious) | ✓ | | ✓ | |
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`prismaIntegration`](./prisma) | ✓ | | ✓ | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`captureConsoleIntegration`](./captureconsole) | | | | ✓ |
| [`dataloaderIntegration`](./dataloader) | | | ✓ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Depending on whether an integration enhances the functionality of a particular r
### Browser Integrations

| | **Auto Enabled** | **Errors** | **Tracing** | **Replay** | **Additional Context** |
|-------------------------------------------------------|:----------------:|:----------:|:-----------:|:----------:|:----------------------:|
| ----------------------------------------------------- | :--------------: | :--------: | :---------: | :--------: | :--------------------: |
| [`breadcrumbsIntegration`](./breadcrumbs) | ✓ | | | | ✓ |
| [`browserApiErrorsIntegration`](./browserapierrors) | ✓ | ✓ | | | |
| [`browserSessionIntegration`](./browsersession) | ✓ | | | | ✓ |
Expand Down Expand Up @@ -85,9 +85,11 @@ Depending on whether an integration enhances the functionality of a particular r
| [`localVariablesIntegration`](./localvariables) | | ✓ | | |
| [`nodeProfilingIntegration`](./nodeprofiling) | | | ✓ | |
| [`trpcMiddleware`](./trpc) | | ✓ | ✓ | ✓ |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | ✓ |

### Edge Integrations

| | **Auto Enabled** | **Errors** | **Tracing** | **Additional Context** |
| --------------------------------------------- | :--------------: | :--------: | :---------: | :--------------------: |
| [`winterCGFetchIntegration`](./wintercgfetch) | ✓ | | ✓ | ✓ |
| [`vercelAiIntegration`](./vercelai) | | | ✓ | |
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
| [`prismaIntegration`](./prisma) | ✓ | | ✓ | |
| [`redisIntegration`](./redis) | ✓ | | ✓ | |
| [`requestDataIntegration`](./requestdata) | ✓ | | ✓ | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`rewriteFramesIntegration`](./rewriteframes) | | ✓ | | |
| [`supabaseIntegration`](./supabase) | | ✓ | ✓ | |
| [`tediousIntegration`](./tedious) | ✓ | | ✓ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Depending on whether an integration enhances the functionality of a particular r
| [`dataloaderIntegration`](./dataloader) | ✓ | | ✓ | |
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`prismaIntegration`](./prisma) | ✓ | | ✓ | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`extraErrorDataIntegration`](./extraerrordata) | | | | ✓ |
| [`fsIntegration`](./fs) | | | ✓ | |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Depending on whether an integration enhances the functionality of a particular r
| [`dataloaderIntegration`](./dataloader) | ✓ | | ✓ | |
| [`childProcessIntegration`](./childProcess) | ✓ | | | ✓ |
| [`prismaIntegration`](./prisma) | ✓ | | ✓ | |
| [`vercelAiIntegration`](./vercelai) | ✓ | | ✓ | |
| [`anrIntegration`](./anr) | | ✓ | | |
| [`extraErrorDataIntegration`](./extraerrordata) | | | | ✓ |
| [`fsIntegration`](./fs) | | | ✓ | |
Expand Down
Loading