Title: Vite auto-instrumentation renames wrapped classes, mangling span names · Issue #24696 · getsentry/sentry-javascript · GitHub
Open Graph Title: Vite auto-instrumentation renames wrapped classes, mangling span names · Issue #24696 · getsentry/sentry-javascript
X Title: Vite auto-instrumentation renames wrapped classes, mangling span names · Issue #24696 · getsentry/sentry-javascript
Description: Summary Under zero config (sentryCloudflareVitePlugin()), a wrapped class reports its name as __SENTRY_ORIGINAL_
Open Graph Description: Summary Under zero config (sentryCloudflareVitePlugin()), a wrapped class reports its name as __SENTRY_ORIGINAL_
X Description: Summary Under zero config (sentryCloudflareVitePlugin()), a wrapped class reports its name as __SENTRY_ORIGINAL_<Name>__ at runtime. Anything that reads Class.name shows that placeholder: a @...
Opengraph URL: https://github.com/getsentry/sentry-javascript/issues/24696
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Vite auto-instrumentation renames wrapped classes, mangling span names","articleBody":"## Summary\n\nUnder zero config (`sentryCloudflareVitePlugin()`), a wrapped class reports its name as `__SENTRY_ORIGINAL_\u003cName>__` at runtime. Anything that reads `Class.name` shows that placeholder: a `@cloudflare/think` agent span reads `invoke_agent __SENTRY_ORIGINAL_ThinkAgent__` with `gen_ai.function_id` to match, and `agents` puts it in `gen_ai.agent.name`. Applies to every class the plugin wraps (Durable Objects, Agents, Workflows, WorkerEntrypoints). Manual `instrument*WithSentry` is unaffected.\n\n## Root cause\n\n`packages/cloudflare/src/vite/transform.ts` frees the export binding for the wrapper by renaming the user's class declaration:\n\n```js\nclass __SENTRY_ORIGINAL_ThinkAgent__ extends Think {}\nexport const ThinkAgent = instrumentAgentWithSentry(opts, __SENTRY_ORIGINAL_ThinkAgent__);\n```\n\nRenaming a declaration changes `Function.prototype.name`. Think passes `this.constructor.name` to the AI SDK as `functionId`, which the vercel-ai subscriber uses as the span name.\n\nFix: leave the declaration alone and alias the export instead, the shape the plugin already emits for cross-module re-exports and the docs show for manual wrapping:\n\n```js\nclass ThinkAgent extends Think {}\nconst __SENTRY_WRAPPED_ThinkAgent__ = instrumentAgentWithSentry(opts, ThinkAgent);\nexport { __SENTRY_WRAPPED_ThinkAgent__ as ThinkAgent };\n```\n\n## Environment\n\n- `@sentry/cloudflare` 10.67.0, `@cloudflare/vite-plugin` 1.57.2\n- `@cloudflare/think` 0.19.0, `ai` 7, `agents` 0.24\n- Reproduced on a local worker with the `cloudflare-think` e2e app\n","author":{"url":"https://github.com/RulaKhaled","@type":"Person","name":"RulaKhaled"},"datePublished":"2026-09-24T12:03:34Z","url":"https://github.com/getsentry/sentry-javascript/issues/24696"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:fd31025e-07db-d4ab-34f5-d91eefa118a8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C9AC:B3B7B:447AD62:5B6D5E6:6B0412A4 |
| html-safe-nonce | b9f95d66f836d593e000eba0419882230f6f4904c59eef9006690d1a668f0157 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDOUFDOkIzQjdCOjQ0N0FENjI6NUI2RDVFNjo2QjA0MTJBNCIsInZpc2l0b3JfaWQiOiIzMjA0OTg0NjE3NjA2MzIwODA0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 291badb8b33bfb9d323a82112049fcad5c1163b0a43caa0743e28e20da97af1a |
| hovercard-subject-tag | issue:5568001341 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/getsentry/sentry-javascript/24696/issue_layout |
| twitter:image | https://opengraph.githubassets.com/b8e05fc5c6f709466f7539de01668382aa1eaac3f00df6dcffdc28caab3e2092/getsentry/sentry-javascript/issues/24696 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/b8e05fc5c6f709466f7539de01668382aa1eaac3f00df6dcffdc28caab3e2092/getsentry/sentry-javascript/issues/24696 |
| og:image:alt | Summary Under zero config (sentryCloudflareVitePlugin()), a wrapped class reports its name as __SENTRY_ORIGINAL_ |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RulaKhaled |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| turbo-cache-control | no-preview |
| go-import | github.com/getsentry/sentry-javascript git https://github.com/getsentry/sentry-javascript.git |
| octolytics-dimension-user_id | 1396951 |
| octolytics-dimension-user_login | getsentry |
| octolytics-dimension-repository_id | 3328572 |
| octolytics-dimension-repository_nwo | getsentry/sentry-javascript |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3328572 |
| octolytics-dimension-repository_network_root_nwo | getsentry/sentry-javascript |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width