Skip to content

Commit

Permalink
Merge pull request #152 from adobe/report-all
Browse files Browse the repository at this point in the history
  • Loading branch information
trieloff authored May 7, 2024
2 parents 8892435 + 0e295ff commit 4b342f5
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,14 @@ sampleRUM.drain('cwv', (() => {
sampleRUM('cwv', data);
};

const featureToggle = () => ['blog.adobe.com', 'www.revolt.tv'].includes(window.location.hostname);
const isEager = (metric) => ['CLS', 'LCP'].includes(metric);

// When loading `web-vitals` using a classic script, all the public
// methods can be found on the `webVitals` global namespace.
['FID', 'INP', 'TTFB', 'CLS', 'LCP'].forEach((metric) => {
const metricFn = window.webVitals[`on${metric}`];
if (typeof metricFn === 'function') {
const opts = isEager(metric) ? { reportAllChanges: featureToggle() } : undefined;
const opts = isEager(metric) ? { reportAllChanges: true } : undefined;
metricFn(storeCWV, opts);
}
});
Expand Down

0 comments on commit 4b342f5

Please sign in to comment.