From 11f3d44bb02e6bbd2fd9bd6e7acea61e029a8794 Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Wed, 7 Oct 2026 15:33:40 +0000 Subject: [PATCH] docs(js): Fix Cloudflare AI integration snippets and duplicate agent setup links @sentry/cloudflare does not export init() or most AI integration factories, so the shared AI integration pages showed Cloudflare users code that cannot work. Show the Vite plugin setup and instrument.server.ts options on Cloudflare instead, and drop the duplicate Eve and Flue entries on the agent Set Up page. Co-Authored-By: Ognjen Bostjancic --- .../configuration/integrations/anthropic.mdx | 48 +++++++++++++++++++ .../integrations/google-genai.mdx | 48 +++++++++++++++++++ .../configuration/integrations/langchain.mdx | 48 +++++++++++++++++++ .../configuration/integrations/langgraph.mdx | 48 +++++++++++++++++++ .../configuration/integrations/mistral.mdx | 30 ++++++++++++ .../configuration/integrations/openai.mdx | 48 +++++++++++++++++++ .../integrations/together-ai.mdx | 48 +++++++++++++++++++ .../configuration/integrations/vercelai.mdx | 47 ++++++++++++++++++ docs/product/agents/getting-started.mdx | 2 - 9 files changed, 365 insertions(+), 2 deletions(-) diff --git a/docs/platforms/javascript/common/configuration/integrations/anthropic.mdx b/docs/platforms/javascript/common/configuration/integrations/anthropic.mdx index 07f72854ebe78..b3188c70446a4 100644 --- a/docs/platforms/javascript/common/configuration/integrations/anthropic.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/anthropic.mdx @@ -14,12 +14,18 @@ Requires SDK version `11.0.0` or higher. On earlier versions, see the [Agent Tra + + _Import name: `Sentry.anthropicAIIntegration`_ + + This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read [this](./../#modifying-default-integrations). The `anthropicAIIntegration` adds instrumentation for the [`@anthropic-ai/sdk`](https://www.npmjs.com/package/@anthropic-ai/sdk) SDK to capture agent tracing `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -29,6 +35,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, there is no `Sentry.init()`. Add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled Anthropic SDK is instrumented: + +```typescript {filename:vite.config.mts} +import { cloudflare } from "@cloudflare/vite-plugin"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); +``` + +Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the Vite plugin page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, wrap your client with `Sentry.instrumentAnthropicAiClient()`. + + + ## Supported Operations By default, tracing support is added to the following Anthropic SDK calls: @@ -62,6 +88,8 @@ Records outputs from Anthropic SDK calls (such as generated text and responses). Defaults to `true` if `dataCollection.genAI.outputs` is `true`, which is the default. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -74,3 +102,23 @@ Sentry.init({ ], }); ``` + + + + + +On Cloudflare, `@sentry/cloudflare` doesn't export `anthropicAIIntegration`, so set these through the `dataCollection` option in your `instrument.server.ts` file instead. This applies to all AI integrations: + +```typescript {filename:src/instrument.server.ts} +import * as Sentry from "@sentry/cloudflare"; + +export default Sentry.defineCloudflareOptions((env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + dataCollection: { + genAI: { inputs: false, outputs: false }, + }, +})); +``` + + diff --git a/docs/platforms/javascript/common/configuration/integrations/google-genai.mdx b/docs/platforms/javascript/common/configuration/integrations/google-genai.mdx index 12c687fe90609..18e819d8a0c1f 100644 --- a/docs/platforms/javascript/common/configuration/integrations/google-genai.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/google-genai.mdx @@ -14,12 +14,18 @@ Requires SDK version `11.0.0` or higher. On earlier versions, see the [Agent Tra + + _Import name: `Sentry.googleGenAIIntegration`_ + + This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read [this](./../#modifying-default-integrations). The `googleGenAIIntegration` adds instrumentation for the [`@google/genai`](https://www.npmjs.com/package/@google/genai) SDK to capture agent tracing `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -29,6 +35,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, there is no `Sentry.init()`. Add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled Google Gen AI SDK is instrumented: + +```typescript {filename:vite.config.mts} +import { cloudflare } from "@cloudflare/vite-plugin"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); +``` + +Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the Vite plugin page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, wrap your client with `Sentry.instrumentGoogleGenAIClient()`. + + + ## Supported Operations By default, tracing support is added to the following Google Gen AI SDK calls: @@ -64,6 +90,8 @@ Records outputs from Google Gen AI SDK calls (such as generated text and respons Defaults to `true` if `dataCollection.genAI.outputs` is `true`, which is the default. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -76,3 +104,23 @@ Sentry.init({ ], }); ``` + + + + + +On Cloudflare, `@sentry/cloudflare` doesn't export `googleGenAIIntegration`, so set these through the `dataCollection` option in your `instrument.server.ts` file instead. This applies to all AI integrations: + +```typescript {filename:src/instrument.server.ts} +import * as Sentry from "@sentry/cloudflare"; + +export default Sentry.defineCloudflareOptions((env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + dataCollection: { + genAI: { inputs: false, outputs: false }, + }, +})); +``` + + diff --git a/docs/platforms/javascript/common/configuration/integrations/langchain.mdx b/docs/platforms/javascript/common/configuration/integrations/langchain.mdx index 2affbeabd9428..fca3acb31bcef 100644 --- a/docs/platforms/javascript/common/configuration/integrations/langchain.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/langchain.mdx @@ -14,12 +14,18 @@ Requires SDK version `11.0.0` or higher. On earlier versions, see the [Agent Tra + + _Import name: `Sentry.langChainIntegration`_ + + This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read [this](./../#modifying-default-integrations). The `langChainIntegration` adds instrumentation for [`langchain`](https://www.npmjs.com/package/langchain) to capture agent tracing `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -29,6 +35,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, there is no `Sentry.init()`. Add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled LangChain is instrumented: + +```typescript {filename:vite.config.mts} +import { cloudflare } from "@cloudflare/vite-plugin"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); +``` + +Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the Vite plugin page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, pass a handler from `Sentry.createLangChainCallbackHandler()` in your LangChain `callbacks`. + + + ## Supported Operations By default, tracing support is added to the following LangChain operations: @@ -89,6 +115,8 @@ Records outputs from LangChain operations (such as generated text and responses) Defaults to `true` if `dataCollection.genAI.outputs` is `true`, which is the default. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -101,3 +129,23 @@ Sentry.init({ ], }); ``` + + + + + +On Cloudflare, `@sentry/cloudflare` doesn't export `langChainIntegration`, so set these through the `dataCollection` option in your `instrument.server.ts` file instead. This applies to all AI integrations: + +```typescript {filename:src/instrument.server.ts} +import * as Sentry from "@sentry/cloudflare"; + +export default Sentry.defineCloudflareOptions((env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + dataCollection: { + genAI: { inputs: false, outputs: false }, + }, +})); +``` + + diff --git a/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx b/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx index 63331cfbbdafe..51c8dcb96a09d 100644 --- a/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/langgraph.mdx @@ -14,12 +14,18 @@ Requires SDK version `11.0.0` or higher. On earlier versions, see the [Agent Tra + + _Import name: `Sentry.langGraphIntegration`_ + + This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read [this](./../#modifying-default-integrations). The `langGraphIntegration` adds instrumentation for [`@langchain/langgraph`](https://www.npmjs.com/package/@langchain/langgraph) to capture agent tracing `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -29,6 +35,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, there is no `Sentry.init()`. Add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled LangGraph is instrumented: + +```typescript {filename:vite.config.mts} +import { cloudflare } from "@cloudflare/vite-plugin"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); +``` + +Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the Vite plugin page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, use [Manual Instrumentation](#manual-instrumentation). + + + ## Supported Operations By default, tracing support is added to the following LangGraph operations: @@ -58,6 +84,8 @@ Records outputs from LangGraph operations (such as generated responses, agent ou Defaults to `true` if `dataCollection.genAI.outputs` is `true`, which is the default. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -71,6 +99,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, `@sentry/cloudflare` doesn't export `langGraphIntegration`, so set these through the `dataCollection` option in your `instrument.server.ts` file instead. This applies to all AI integrations: + +```typescript {filename:src/instrument.server.ts} +import * as Sentry from "@sentry/cloudflare"; + +export default Sentry.defineCloudflareOptions((env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + dataCollection: { + genAI: { inputs: false, outputs: false }, + }, +})); +``` + + + ## Manual Instrumentation _Import names: `Sentry.instrumentStateGraph`, `Sentry.instrumentCreateReactAgent`_ diff --git a/docs/platforms/javascript/common/configuration/integrations/mistral.mdx b/docs/platforms/javascript/common/configuration/integrations/mistral.mdx index a7c4abfc77a2d..26981b41299aa 100644 --- a/docs/platforms/javascript/common/configuration/integrations/mistral.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/mistral.mdx @@ -14,12 +14,18 @@ Requires SDK version `11.0.0` or higher. + + _Import name: `Sentry.mistralAIIntegration`_ + + This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read [this](./../#modifying-default-integrations). The `mistralAIIntegration` adds instrumentation for the [`@mistralai/mistralai`](https://www.npmjs.com/package/@mistralai/mistralai) SDK to capture agent tracing `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -29,6 +35,8 @@ Sentry.init({ }); ``` + + On Deno, preload Sentry's import hook so the Mistral SDK can be instrumented: @@ -122,6 +130,8 @@ Records outputs from Mistral AI SDK calls (such as generated text and responses) Defaults to `true` if `dataCollection.genAI.outputs` is `true`, which is the default. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -135,6 +145,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, `@sentry/cloudflare` doesn't export `mistralAIIntegration`, so set these through the `dataCollection` option in your `instrument.server.ts` file instead. This applies to all AI integrations: + +```typescript {filename:src/instrument.server.ts} +import * as Sentry from "@sentry/cloudflare"; + +export default Sentry.defineCloudflareOptions((env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + dataCollection: { + genAI: { inputs: false, outputs: false }, + }, +})); +``` + + + ## Manual Instrumentation diff --git a/docs/platforms/javascript/common/configuration/integrations/openai.mdx b/docs/platforms/javascript/common/configuration/integrations/openai.mdx index 97b2c93ecabcc..aa01dabd4ba35 100644 --- a/docs/platforms/javascript/common/configuration/integrations/openai.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/openai.mdx @@ -14,12 +14,18 @@ Requires SDK version `11.0.0` or higher. On earlier versions, see the [Agent Tra + + _Import name: `Sentry.openAIIntegration`_ + + This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read [this](./../#modifying-default-integrations). The `openAIIntegration` adds instrumentation for the [`openai`](https://www.npmjs.com/package/openai) SDK to capture agent tracing `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -29,6 +35,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, there is no `Sentry.init()`. Add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled OpenAI SDK is instrumented: + +```typescript {filename:vite.config.mts} +import { cloudflare } from "@cloudflare/vite-plugin"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); +``` + +Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the Vite plugin page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, wrap your client with `Sentry.instrumentOpenAiClient()`. + + + ## Supported Operations By default, tracing support is added to the following OpenAI SDK calls: @@ -62,6 +88,8 @@ Records outputs from OpenAI SDK calls (such as generated text and responses). Defaults to `true` if `dataCollection.genAI.outputs` is `true`, which is the default. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -74,3 +102,23 @@ Sentry.init({ ], }); ``` + + + + + +On Cloudflare, `@sentry/cloudflare` doesn't export `openAIIntegration`, so set these through the `dataCollection` option in your `instrument.server.ts` file instead. This applies to all AI integrations: + +```typescript {filename:src/instrument.server.ts} +import * as Sentry from "@sentry/cloudflare"; + +export default Sentry.defineCloudflareOptions((env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + dataCollection: { + genAI: { inputs: false, outputs: false }, + }, +})); +``` + + diff --git a/docs/platforms/javascript/common/configuration/integrations/together-ai.mdx b/docs/platforms/javascript/common/configuration/integrations/together-ai.mdx index 9ea04af045012..69d48fca13d22 100644 --- a/docs/platforms/javascript/common/configuration/integrations/together-ai.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/together-ai.mdx @@ -14,12 +14,18 @@ Requires SDK version `11.0.0` or higher. + + _Import name: `Sentry.togetherAIIntegration`_ + + This integration is enabled by default when tracing is enabled. If you'd like to modify your default integrations, read [this](./../#modifying-default-integrations). The `togetherAIIntegration` adds instrumentation for the [`together-ai`](https://www.npmjs.com/package/together-ai) SDK to capture agent tracing `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs. Together AI speaks the OpenAI wire format, so it reuses the same span and streaming logic as the OpenAI integration. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -29,6 +35,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, there is no `Sentry.init()`. Add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled Together AI SDK is instrumented: + +```typescript {filename:vite.config.mts} +import { cloudflare } from "@cloudflare/vite-plugin"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); +``` + +Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the Vite plugin page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, see manual instrumentation. + + + ## Supported Operations By default, tracing support is added to the following Together AI SDK calls: @@ -60,6 +86,8 @@ Records outputs from Together AI SDK calls (such as generated text and responses Defaults to `true` if `dataCollection.genAI.outputs` is `true`, which is the default. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -72,3 +100,23 @@ Sentry.init({ ], }); ``` + + + + + +On Cloudflare, `@sentry/cloudflare` doesn't export `togetherAIIntegration`, so set these through the `dataCollection` option in your `instrument.server.ts` file instead. This applies to all AI integrations: + +```typescript {filename:src/instrument.server.ts} +import * as Sentry from "@sentry/cloudflare"; + +export default Sentry.defineCloudflareOptions((env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + dataCollection: { + genAI: { inputs: false, outputs: false }, + }, +})); +``` + + diff --git a/docs/platforms/javascript/common/configuration/integrations/vercelai.mdx b/docs/platforms/javascript/common/configuration/integrations/vercelai.mdx index a7fd32fe3c693..6495e9340dfcb 100644 --- a/docs/platforms/javascript/common/configuration/integrations/vercelai.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/vercelai.mdx @@ -20,6 +20,8 @@ This integration is enabled by default when tracing is enabled. If you'd like to The `vercelAIIntegration` adds instrumentation for the [`ai`](https://www.npmjs.com/package/ai) SDK by Vercel to capture agent tracing `gen_ai` spans, recording model, token usage, latency, and (when enabled) inputs and outputs. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -29,6 +31,26 @@ Sentry.init({ }); ``` + + + + +On Cloudflare, there is no `Sentry.init()`. Add `sentryCloudflareVitePlugin()` alongside Cloudflare's Vite plugin so the bundled AI SDK is instrumented: + +```typescript {filename:vite.config.mts} +import { cloudflare } from "@cloudflare/vite-plugin"; +import { sentryCloudflareVitePlugin } from "@sentry/cloudflare/vite"; +import { defineConfig } from "vite"; + +export default defineConfig({ + plugins: [cloudflare(), sentryCloudflareVitePlugin()], +}); +``` + +Build-time instrumentation is enabled by default, and the plugin registers the integration in both `vite dev` and `vite build`. Keep the `nodejs_compat` flag enabled in your Wrangler configuration, and see the Vite plugin page for the full setup. Without the plugin, or with `buildTimeInstrumentation: false`, see manual instrumentation. + + + @@ -115,6 +137,8 @@ Records outputs from `ai` function calls (such as generated text and responses). Defaults to `true` if `dataCollection.genAI.outputs` is `true`, which is the default. + + ```javascript Sentry.init({ dsn: "___PUBLIC_DSN___", @@ -127,3 +151,26 @@ Sentry.init({ ], }); ``` + + + + + +On Cloudflare, pass the options from your `instrument.server.ts` file: + +```typescript {filename:src/instrument.server.ts} +import * as Sentry from "@sentry/cloudflare"; + +export default Sentry.defineCloudflareOptions((env) => ({ + dsn: "___PUBLIC_DSN___", + tracesSampleRate: 1.0, + integrations: [ + Sentry.vercelAIIntegration({ + recordInputs: false, + recordOutputs: false, + }), + ], +})); +``` + + diff --git a/docs/product/agents/getting-started.mdx b/docs/product/agents/getting-started.mdx index b7d705ac33cdf..6ccdcc95b1923 100644 --- a/docs/product/agents/getting-started.mdx +++ b/docs/product/agents/getting-started.mdx @@ -31,8 +31,6 @@ To start sending agent data to Sentry, make sure you've created a Sentry project - [Flue](/platforms/javascript/guides/flue/) - [Laravel](/platforms/php/guides/laravel/agent-tracing/) - [Mastra](/platforms/javascript/guides/mastra/) -- [Flue](/platforms/javascript/guides/flue/) -- [Eve](/platforms/javascript/guides/eve/) - [Next.js](/platforms/javascript/guides/nextjs/agent-tracing/) - [Node.js](/platforms/javascript/guides/node/agent-tracing/) - [Python](/platforms/python/agent-tracing/)