Browser init() bundles all default integrations

オープン
#26,126 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
54/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
javascript, node.js, typescript

調査の方向性

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時間
マージ済み PR(30日)
744

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

getsentry/sentry-javascript のほかの issue

getsentry/sentry-javascript の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。