Skip to content

Conversation

@priscilawebdev
Copy link
Member

  • Separate server-side and browser-side usage sections for clarity
  • Document openAIIntegration for Node.js platforms (auto-enabled by default)
  • Document instrumentOpenAiClient for browser and edge runtimes
  • Add special handling for Cloudflare Workers edge runtime
  • Simplify code examples by omitting import statements
  • Move configuration and supported versions to shared sections
  • Improve platform-specific visibility using PlatformSection components

closes https://linear.app/getsentry/issue/TET-1719/browser-javascript-ai-agent-onboarding

@linear
Copy link

linear bot commented Jan 16, 2026

@vercel
Copy link

vercel bot commented Jan 16, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
sentry-docs Ready Ready Preview, Comment Jan 19, 2026 10:06am
1 Skipped Deployment
Project Deployment Review Updated (UTC)
develop-docs Ignored Ignored Preview Jan 19, 2026 10:06am

Request Review

## Configuration

By default this integration adds tracing support to OpenAI API method calls including:
By default, tracing support is added to the following OpenAI API method calls:
Copy link
Member Author

Choose a reason for hiding this comment

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

updated this to be abstract as it can either be an integration or helper

Comment on lines 53 to 68
This integration is **enabled by default for Node.js-based platforms** and automatically captures spans for OpenAI API method calls. You don't need to add it to your `integrations` array in `Sentry.init` unless you want to configure input and output recording with the `recordInputs` and `recordOutputs` options:

```javascript
Sentry.init({
dsn: "____PUBLIC_DSN____",
tracesSampleRate: 1.0,
integrations: [
// This integration is enabled by default.
// Only add this if you want to configure options.
Sentry.openAIIntegration({
recordInputs: true,
recordOutputs: true,
}),
],
});
```
Copy link
Member

@shellmayr shellmayr Jan 16, 2026

Choose a reason for hiding this comment

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

If this integration is enabled by default, we should give that instruction at the base level, and only give the instructions for options under the subheading. This paragraph also doesn't really tell me what "configuring input and output recording" does for me, so it feels a bit vague right now

Copy link
Member Author

@priscilawebdev priscilawebdev Jan 16, 2026

Choose a reason for hiding this comment

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

I moved the Options and code snippet under Configuration and the a couple of other things. An image says more than a thousand words:

image

What do you think?

@priscilawebdev
Copy link
Member Author

@RulaKhaled I noticed that we do not have a separate section about Runtime for NextJS + OpenAI. should we add something? https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/integrations/openai/

@RulaKhaled
Copy link
Member

@RulaKhaled I noticed that we do not have a separate section about Runtime for NextJS + OpenAI. should we add something? https://docs.sentry.io/platforms/javascript/guides/nextjs/configuration/integrations/openai/

We don't need to, all runtimes in Next.js should use the manual instrumentation.


_Import name: `Sentry.openAIIntegration`_

The `openAIIntegration` adds instrumentation for the `openai` API to capture spans by wrapping OpenAI client calls and recording LLM interactions.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The `openAIIntegration` adds instrumentation for the `openai` API to capture spans by wrapping OpenAI client calls and recording LLM interactions.
The `openAIIntegration` adds instrumentation for the `openai` SDK to capture spans by wrapping OpenAI client calls and recording LLM interactions.

l: I'd call it an SDK, but maybe @inventarSarah has a different opinion.

<Alert>

This integration works in the Node.js, Cloudflare Workers, Vercel Edge Functions, and browser runtimes. It requires SDK version `10.2.0` or higher.
This integration is **enabled by default for Node.js-based platforms** and automatically captures spans for OpenAI API method calls. It requires SDK version `10.2.0` or higher.
Copy link
Member

Choose a reason for hiding this comment

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

q: Couldn't we just conditionally reword this and show it for environments where it's enabled by default via PlatformSelection? e.g.

This integration is enabled by default and automatically captures spans for Anthropic API method calls [..]


<PlatformSection supported={["javascript"]}>
For browser applications, you need to manually instrument the OpenAI client using the `instrumentOpenAiClient` helper:
The `instrumentOpenAiClient` helper adds instrumentation for the `openai` API to capture spans by wrapping OpenAI client calls and recording LLM interactions with configurable input/output recording. You need to manually wrap your OpenAI client instance with this helper. See example below:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
The `instrumentOpenAiClient` helper adds instrumentation for the `openai` API to capture spans by wrapping OpenAI client calls and recording LLM interactions with configurable input/output recording. You need to manually wrap your OpenAI client instance with this helper. See example below:
The `instrumentOpenAiClient` helper adds instrumentation for the `openai` SDK to capture spans by wrapping OpenAI client calls and recording LLM interactions with configurable input/output recording. You need to manually wrap your OpenAI client instance with this helper. See example below:

l: For alignment.


_Type: `boolean` (optional)_

Records outputs from OpenAI API method calls (such as generated text and responses).
Copy link
Member

Choose a reason for hiding this comment

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

l: Alignment of "OpenAI API method calls" across the PR. I think this should be "OpenAI SDK calls"

Comment on lines +148 to +150
<PlatformSection supported={["javascript", "javascript.react", "javascript.angular", "javascript.vue", "javascript.svelte", "javascript.solid", "javascript.ember", "javascript.gatsby", "javascript.nextjs", "javascript.nuxt", "javascript.solidstart", "javascript.sveltekit", "javascript.react-router", "javascript.remix", "javascript.astro", "javascript.tanstackstart-react", "javascript.electron", "javascript.cloudflare"]}>

Records outputs from OpenAI API method calls (such as generated text and responses).

Defaults to `true` if `sendDefaultPii` is `true`.
Manual Instrumentation
Copy link
Member

Choose a reason for hiding this comment

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

l: Maybe we can invert this and just use notSupported={["javascript.node"]}, as far as I can tell, that's the only SDK where we can for sure tell that users don't need to know about manual instrumentation, right?

## Supported Operations

By default this integration adds tracing support to OpenAI API method calls including:
By default, tracing support is added to the following OpenAI API method calls:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
By default, tracing support is added to the following OpenAI API method calls:
By default, tracing support is added to the following OpenAI SDK method calls:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants