From 39a0ac45cd59f091521345269f4e7323a582b303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Leo=CC=81n?= Date: Mon, 12 Feb 2024 14:50:55 +0100 Subject: [PATCH 1/4] feat(packages/sui-react-web-vitals): skip empty targets --- packages/sui-react-web-vitals/src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/sui-react-web-vitals/src/index.js b/packages/sui-react-web-vitals/src/index.js index 1baa1c103..1bdff545b 100644 --- a/packages/sui-react-web-vitals/src/index.js +++ b/packages/sui-react-web-vitals/src/index.js @@ -100,10 +100,10 @@ export default function WebVitalsReporter({ const pathname = getPathname(route) const routeid = getRouteid() const isAllowed = allowed.includes(pathname) || allowed.includes(routeid) + const target = getTarget({name, attribution}) - if (!isAllowed || !logger?.cwv || rating === RATING.GOOD) return + if (!isAllowed || !logger?.cwv || rating === RATING.GOOD || target !== '') return - const target = getTarget({name, attribution}) const {loadState, eventType} = attribution logger.cwv({ From f671e9378797525386dfcfe9399f33e6cac6fd87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Leo=CC=81n?= Date: Mon, 12 Feb 2024 14:59:54 +0100 Subject: [PATCH 2/4] feat(packages/sui-react-web-vitals): validate if the target is null --- packages/sui-react-web-vitals/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-web-vitals/src/index.js b/packages/sui-react-web-vitals/src/index.js index 1bdff545b..c6853bdef 100644 --- a/packages/sui-react-web-vitals/src/index.js +++ b/packages/sui-react-web-vitals/src/index.js @@ -102,7 +102,7 @@ export default function WebVitalsReporter({ const isAllowed = allowed.includes(pathname) || allowed.includes(routeid) const target = getTarget({name, attribution}) - if (!isAllowed || !logger?.cwv || rating === RATING.GOOD || target !== '') return + if (!isAllowed || !logger?.cwv || rating === RATING.GOOD || target !== '' || target === null) return const {loadState, eventType} = attribution From fb9e8c053bcfbaec5b665e353ae008d028db994a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Leo=CC=81n?= Date: Mon, 12 Feb 2024 15:03:22 +0100 Subject: [PATCH 3/4] refactor(packages/sui-react-web-vitals): fix the target validation --- packages/sui-react-web-vitals/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-web-vitals/src/index.js b/packages/sui-react-web-vitals/src/index.js index c6853bdef..d0923a025 100644 --- a/packages/sui-react-web-vitals/src/index.js +++ b/packages/sui-react-web-vitals/src/index.js @@ -102,7 +102,7 @@ export default function WebVitalsReporter({ const isAllowed = allowed.includes(pathname) || allowed.includes(routeid) const target = getTarget({name, attribution}) - if (!isAllowed || !logger?.cwv || rating === RATING.GOOD || target !== '' || target === null) return + if (!isAllowed || !logger?.cwv || rating === RATING.GOOD || target === '' || target === null) return const {loadState, eventType} = attribution From 0ae4b24a897309d696afc9fd578aff6487d970b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Leo=CC=81n?= Date: Mon, 12 Feb 2024 15:08:21 +0100 Subject: [PATCH 4/4] refactor(packages/sui-react-web-vitals): improve the target validation --- packages/sui-react-web-vitals/src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/sui-react-web-vitals/src/index.js b/packages/sui-react-web-vitals/src/index.js index d0923a025..a3b06d28f 100644 --- a/packages/sui-react-web-vitals/src/index.js +++ b/packages/sui-react-web-vitals/src/index.js @@ -102,7 +102,7 @@ export default function WebVitalsReporter({ const isAllowed = allowed.includes(pathname) || allowed.includes(routeid) const target = getTarget({name, attribution}) - if (!isAllowed || !logger?.cwv || rating === RATING.GOOD || target === '' || target === null) return + if (!isAllowed || !logger?.cwv || rating === RATING.GOOD || !target) return const {loadState, eventType} = attribution