Skip to content

Commit 672f8de

Browse files
BYKdcramer
authored andcommitted
fix: Don't crash when score.total is missing (#682)
Fixes #681.
1 parent 98fd47b commit 672f8de

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

.changeset/rude-tomatoes-brush.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@spotlightjs/spotlight': patch
3+
'@spotlightjs/electron': patch
4+
'@spotlightjs/overlay': patch
5+
'@spotlightjs/astro': patch
6+
---
7+
8+
Fix rare error when `score.total` is missing from `measurements`

packages/overlay/src/integrations/sentry/utils/webVitals.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { SentryEvent } from '~/integrations/sentry/types';
2-
import { WebVitals } from '../constants';
1+
import type { SentryEvent } from '~/integrations/sentry/types';
2+
import type { WebVitals } from '../constants';
33

44
const SQRT_2 = Math.sqrt(2);
55

@@ -155,7 +155,7 @@ export function normalizePerformanceScore(
155155
};
156156
}
157157

158-
if (shouldAddTotal) {
158+
if (shouldAddTotal && !Object.prototype.hasOwnProperty.call(measurements, 'score.total')) {
159159
measurements['score.total'] = {
160160
value: scoreTotal,
161161
unit: 'ratio',

0 commit comments

Comments
 (0)