Browser init() bundles all default integrations

未關閉
#26,126 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
54/100
Issue 類型
功能
描述清晰度
基本清楚
活躍度
活躍

研究方向

Read the @sentry/browser init implementation in build/npm/esm/prod/sdk.js and compare it with the initWithoutDefaultIntegrations exports in @sentry/node and @sentry/bun. Check whether a browser entry point can avoid referencing getDefaultIntegrations while preserving the browser setup steps named in the issue. Done means the new path is tree-shakeable and the reported bundle excludes unused default integrations.

由索引模型根據 Issue 內容生成。

描述

Browser Feature

init() in @sentry/browser 11.10.0 picks the default integrations at runtime (options.defaultIntegrations == null ? getDefaultIntegrations() : ... in build/npm/esm/prod/sdk.js). A bundler can't drop that branch, so all 12 default integrations ship even when the app passes defaultIntegrations: false.

init({ dsn, defaultIntegrations: false, integrations: [browserTracingIntegration()] });
  • Bundled alone with esbuild 0.27 (minified, ESM, browser): 161,358 B raw / 49,098 B br-11.
  • The same setup with new BrowserClient({ ..., stackParser: defaultStackParser, transport: makeFetchTransport }), setCurrentClient(client) and client.init() comes to 137,636 B raw / 42,099 B br-11. That's about 24 KB raw of integration code that never runs (breadcrumbs, globalHandlers, browserApiErrors, browserSession, linkedErrors, dedupe, httpContext, cultureContext, console, eventFilters, functionToString, conversationId).
  • The manual setup skips the other things init() does (resolveBrowserTunnelOption, the browser-extension check, setNormalizeStringifier), so it isn't a full replacement.
  • @sentry/node and @sentry/bun already export initWithoutDefaultIntegrations. @sentry/browser has no equivalent.

Proposal from the reporter: give @sentry/browser a tree-shakeable init path that doesn't reference getDefaultIntegrations. One example is a browser initWithoutDefaultIntegrations.

Seen in getsentry/junior's dashboard, which now builds the client by hand to avoid this.

via @BYK.

--

View Session in Sentry

主要語言
TypeScript
星號
8.8k
分支
1.9k
平均合併
1 天 8 小時
30 天內合併 PR
744

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

getsentry/sentry-javascript 的其他 Issue

查看 getsentry/sentry-javascript 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。