Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ const WebVitals = () => {
normalizePerformanceScore(updatedEvent, PERFORMANCE_SCORE_PROFILES);
return updatedEvent as unknown as SentryEventWithPerformanceData;
})
.filter(event => event.measurements["score.total"] != null)
Comment on lines 56 to +58
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Direct navigation to a non-pageload event detail page in WebVitalsDetail.tsx causes a crash due to unguarded access to score measurements which are not populated.
Severity: HIGH | Confidence: High

🔍 Detailed Analysis

The WebVitalsDetail.tsx component can crash if a user navigates directly to a detail page for an event that is not a 'pageload' event or lacks a measurements object. The list view in index.tsx correctly filters for event?.contexts?.trace?.op === 'pageload', but the detail page does not. When an invalid event is loaded directly via URL, normalizePerformanceScore is called but fails to add the expected score.* measurements. The component then attempts to access properties like measurements['score.fcp'].value, resulting in a TypeError because the score object is undefined.

💡 Suggested Fix

In WebVitalsDetail.tsx, before rendering the details, add checks to ensure that the loaded event is a 'pageload' event and that the necessary measurements and score.* properties exist after normalization. This will prevent the component from attempting to access properties on undefined objects.

🤖 Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location:
packages/spotlight/src/ui/telemetry/components/insights/webVitals/index.tsx#L56-L58

Potential issue: The `WebVitalsDetail.tsx` component can crash if a user navigates
directly to a detail page for an event that is not a 'pageload' event or lacks a
`measurements` object. The list view in `index.tsx` correctly filters for
`event?.contexts?.trace?.op === 'pageload'`, but the detail page does not. When an
invalid event is loaded directly via URL, `normalizePerformanceScore` is called but
fails to add the expected `score.*` measurements. The component then attempts to access
properties like `measurements['score.fcp'].value`, resulting in a `TypeError` because
the score object is undefined.

Did we get this right? 👍 / 👎 to inform future reviews.
Reference ID: 8311977

.sort((a, b) => (sort.asc ? compareEvents(a, b) : compareEvents(b, a)))
);
}, [events, sort]);
Expand Down
Loading