Skip to content

Commit

Permalink
fix: Don't crash when score.total is missing (#682)
Browse files Browse the repository at this point in the history
Fixes #681.
  • Loading branch information
BYK authored Jan 29, 2025
1 parent 0da237f commit 52ceec5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 8 additions & 0 deletions .changeset/rude-tomatoes-brush.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
'@spotlightjs/spotlight': patch
'@spotlightjs/electron': patch
'@spotlightjs/overlay': patch
'@spotlightjs/astro': patch
---

Fix rare error when `score.total` is missing from `measurements`
6 changes: 3 additions & 3 deletions packages/overlay/src/integrations/sentry/utils/webVitals.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SentryEvent } from '~/integrations/sentry/types';
import { WebVitals } from '../constants';
import type { SentryEvent } from '~/integrations/sentry/types';
import type { WebVitals } from '../constants';

const SQRT_2 = Math.sqrt(2);

Expand Down Expand Up @@ -155,7 +155,7 @@ export function normalizePerformanceScore(
};
}

if (shouldAddTotal) {
if (shouldAddTotal && !Object.prototype.hasOwnProperty.call(measurements, 'score.total')) {
measurements['score.total'] = {
value: scoreTotal,
unit: 'ratio',
Expand Down

0 comments on commit 52ceec5

Please sign in to comment.