getsentry / getsentry/sentry-javascript
INP metric: Too many spans with <unknown> target due to disappearing DOM elements
- Linguagem predominante
- TypeScript
- Estrelas
- 8.7k
- Forks
- 1.8k
- Merge médio
- 1d 18h
- PRs com merge (30d)
- 541
Descrição
### Problem Statement
We are seeing a large number of INP-related spans where the clicked element is reported as ``.
This happens when the user clicks UI elements that immediately disappear from the DOM right after the interaction — most commonly:
- closing buttons (e.g., closing a modal),
- clearing input with an “X” button,
- removing items from lists, cards, etc.
Because these elements are removed, by the time Sentry processes the INP event, `e.target` is already `null`, which results in spans showing `` instead of the actual clicked element.
This significantly reduces the usefulness and traceability of INP measurements.
### Solution Brainstorm
A potential fix is to capture and cache metadata about the clicked element at the moment of the click event — before the element disappears.
Example approach:
1. On click, immediately compute and store the result of `htmlTreeAsString(event.target)` (or an equivalent helper used for INP).
2. When constructing INP spans, use the cached `htmlTreeAsString` value instead of trying to read `event.target` again (which may already be null after DOM removal).
### Product Area
Unknown
Guia de contribuição
Direção de pesquisa
Comece pelo tratamento de interações de INP e pela construção de spans e, em seguida, rastreie onde e.target e htmlTreeAsString são lidos. Verifique como um clique em um elemento removido do DOM é representado e identifique os testes existentes para spans de INP ou targets que desaparecem. O trabalho estará concluído quando esses spans mantiverem os metadados do elemento clicado em vez de exibir .
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- javascript, typescript
- Domínio
- frontend, observability-sre, performance
- Tipo de issue
- Bug
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Status de atividade
- Estagnada
- Clareza
- Razoavelmente clara
- Facilidade para iniciantes
- 35/100