Skip to content

Integrate Vercel AI into nextjs-15 #16539

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

Closed

Conversation

AbhiPrasad
Copy link
Member

@AbhiPrasad AbhiPrasad commented Jun 10, 2025

ref #16538

Vercel AI integration was added to the nextjs-15 test application.

  • sentry.server.config.ts was updated to include Sentry.vercelAIIntegration().
  • ai and zod dependencies were added to package.json.

A new test page, app/ai-test/page.tsx, was created to demonstrate various AI SDK features, including automatic telemetry, explicit telemetry configuration, tool calls, and disabled telemetry. AI operations are wrapped in a Sentry span for tracing.

A corresponding Playwright test, tests/ai-test.test.ts, was implemented to verify:

  • AI spans are created with expected operations (ai.pipeline.generate_text, gen_ai.generate_text, gen_ai.execute_tool).
  • Span attributes, including model info, tokens, prompts, and responses, are correct.
  • Input/output recording respects sendDefaultPii: true.
  • Tool calls are properly traced.
  • Disabled telemetry prevents span creation.

Finally, a fix was applied to packages/node/src/integrations/tracing/vercelai/instrumentation.ts. The generatePatch function was adjusted to correctly preserve the this context by changing it from an arrow function to a regular function, ensuring proper method binding for patched AI SDK methods.

@AbhiPrasad AbhiPrasad changed the base branch from master to develop June 10, 2025 21:27
Copy link
Contributor

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.99 kB added added
@sentry/browser - with treeshaking flags 23.76 kB added added
@sentry/browser (incl. Tracing) 38.36 kB added added
@sentry/browser (incl. Tracing, Replay) 76.47 kB added added
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 69.57 kB added added
@sentry/browser (incl. Tracing, Replay with Canvas) 81.23 kB added added
@sentry/browser (incl. Tracing, Replay, Feedback) 93.31 kB added added
@sentry/browser (incl. Feedback) 40.73 kB added added
@sentry/browser (incl. sendFeedback) 28.7 kB added added
@sentry/browser (incl. FeedbackAsync) 33.59 kB added added
@sentry/react 25.76 kB added added
@sentry/react (incl. Tracing) 40.35 kB added added
@sentry/vue 28.36 kB added added
@sentry/vue (incl. Tracing) 40.21 kB added added
@sentry/svelte 24.01 kB added added
CDN Bundle 25.48 kB added added
CDN Bundle (incl. Tracing) 38.53 kB added added
CDN Bundle (incl. Tracing, Replay) 74.41 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) 79.86 kB added added
CDN Bundle - uncompressed 74.41 kB added added
CDN Bundle (incl. Tracing) - uncompressed 114.1 kB added added
CDN Bundle (incl. Tracing, Replay) - uncompressed 228.07 kB added added
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 240.89 kB added added
@sentry/nextjs (client) 42.01 kB added added
@sentry/sveltekit (client) 38.84 kB added added
@sentry/node 150.42 kB added added
@sentry/node - without tracing 98.34 kB added added
@sentry/aws-serverless 124.1 kB added added

@getsentry getsentry deleted a comment from github-actions bot Jun 11, 2025
@AbhiPrasad AbhiPrasad closed this Jun 11, 2025
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.

2 participants