diff --git a/packages/sui-react-web-vitals/src/index.js b/packages/sui-react-web-vitals/src/index.js index c4d3a2dd4..1baa1c103 100644 --- a/packages/sui-react-web-vitals/src/index.js +++ b/packages/sui-react-web-vitals/src/index.js @@ -57,11 +57,7 @@ export default function WebVitalsReporter({ }, [onReport]) useMount(() => { - const { - deviceMemory, - connection: {effectiveType}, - hardwareConcurrency - } = window.navigator + const {deviceMemory, connection: {effectiveType} = {}, hardwareConcurrency} = window.navigator || {} const getRouteid = () => { return route?.id diff --git a/packages/sui-react-web-vitals/test/browser/indexSpec.js b/packages/sui-react-web-vitals/test/browser/indexSpec.js index 63218b5dc..2ad572f88 100644 --- a/packages/sui-react-web-vitals/test/browser/indexSpec.js +++ b/packages/sui-react-web-vitals/test/browser/indexSpec.js @@ -279,7 +279,7 @@ describe('WebVitalsReporter', () => { ]) }) - it.skip('should track inp with deviceMemory, networkConnection, and hardwareConcurrency using logger cwv', async () => { + it('should track inp with deviceMemory, networkConnection, and hardwareConcurrency using logger cwv', async () => { const logger = { cwv: sinon.spy() } @@ -302,15 +302,15 @@ describe('WebVitalsReporter', () => { await waitFor(() => [ expect( logger.cwv.calledWith({ - amount: 304, - deviceMemory: 8, - effectiveType: '4g', - eventType: 'body', - hardwareConcurrency: 10, name: 'cwv.inp', + amount: 304, path: '/', target: undefined, - visibilityState: 'hidden' + visibilityState: document.visibilityState, + eventType: 'body', + deviceMemory: 8, + effectiveType: '4g', + hardwareConcurrency: 10 }) ).to.be.true ])