Skip to content

Commit ed2f9be

Browse files
authored
fix(tracing): Fix missing page load metrics in Electron renderer (#5187)
Electron renderers can have a combined Chrome and node.js context which can cause it to be detected as node.js when in fact it has full browser features. This PR simplifies the detection of the browser performance API so that it doesn't fail to record page load metrics when running in an Electron renderer with mixed context.
1 parent 571d661 commit ed2f9be

File tree

1 file changed

+3
-3
lines changed
  • packages/tracing/src/browser/metrics

1 file changed

+3
-3
lines changed

packages/tracing/src/browser/metrics/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* eslint-disable max-lines */
22
import { Measurements } from '@sentry/types';
3-
import { browserPerformanceTimeOrigin, getGlobalObject, htmlTreeAsString, isNodeEnv, logger } from '@sentry/utils';
3+
import { browserPerformanceTimeOrigin, getGlobalObject, htmlTreeAsString, logger } from '@sentry/utils';
44

55
import { IS_DEBUG_BUILD } from '../../flags';
66
import { Transaction } from '../../transaction';
@@ -14,8 +14,8 @@ import { _startChild, isMeasurementValue } from './utils';
1414

1515
const global = getGlobalObject<Window>();
1616

17-
function getBrowserPerformanceAPI(): false | Performance {
18-
return !isNodeEnv() && global && global.document && global.performance;
17+
function getBrowserPerformanceAPI(): Performance | undefined {
18+
return global && global.addEventListener && global.performance;
1919
}
2020

2121
let _performanceCursor: number = 0;

0 commit comments

Comments
 (0)