Browser init() bundles all default integrations

Aberta
#26,126 1 comentário 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 1 dia

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
54/100
Tipo de issue
Funcionalidade
Clareza
Razoavelmente clara
Status de atividade
Ativa
Stack de tecnologia
javascript, node.js, typescript

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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

Linguagem predominante
TypeScript
Estrelas
8.8k
Forks
1.9k
Merge médio
1d 8h
PRs com merge (30d)
744

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de getsentry/sentry-javascript

Todas as issues de getsentry/sentry-javascript

Issues semelhantes

Mais issues de TypeScript

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.