Browser init() bundles all default integrations

Offen
#26,126 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Anfängerfreundlichkeit
54/100
Issue-Typ
Feature
Klarheit
Größtenteils klar
Aktivitätsstatus
Aktiv

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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

Vorherrschende Sprache
TypeScript
Sterne
8.8k
Forks
1.9k
Ø Merge
1 T. 8 Std.
Gemergte PRs (30 T.)
744

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus getsentry/sentry-javascript

Alle Issues in getsentry/sentry-javascript

Ähnliche Issues

Weitere Issues zu TypeScript

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.