summaryrefslogtreecommitdiff
path: root/packages/integrations/web-vitals/src
diff options
context:
space:
mode:
authorGravatar Chris Swithinbank <swithinbank@gmail.com> 2024-05-18 16:33:14 +0200
committerGravatar GitHub <noreply@github.com> 2024-05-18 16:33:14 +0200
commit3c7a4fabea5ebb0e8f79742731415136ae3da9a6 (patch)
tree990e7fd307222bd4f938d65c3388327438367570 /packages/integrations/web-vitals/src
parentb41cec623449e03195b3010a81abe384f80bebb5 (diff)
downloadastro-3c7a4fabea5ebb0e8f79742731415136ae3da9a6.tar.gz
astro-3c7a4fabea5ebb0e8f79742731415136ae3da9a6.tar.zst
astro-3c7a4fabea5ebb0e8f79742731415136ae3da9a6.zip
Upgrade `web-vitals` to v4 (#11094)
Diffstat (limited to 'packages/integrations/web-vitals/src')
-rw-r--r--packages/integrations/web-vitals/src/client-script.ts4
-rw-r--r--packages/integrations/web-vitals/src/schemas.ts6
2 files changed, 5 insertions, 5 deletions
diff --git a/packages/integrations/web-vitals/src/client-script.ts b/packages/integrations/web-vitals/src/client-script.ts
index b69fa6772..86591745e 100644
--- a/packages/integrations/web-vitals/src/client-script.ts
+++ b/packages/integrations/web-vitals/src/client-script.ts
@@ -1,4 +1,4 @@
-import { type Metric, onCLS, onFCP, onFID, onINP, onLCP, onTTFB } from 'web-vitals';
+import { type Metric, onCLS, onFCP, onINP, onLCP, onTTFB } from 'web-vitals';
import { WEB_VITALS_ENDPOINT_PATH } from './constants.js';
import type { ClientMetric } from './schemas.js';
@@ -26,7 +26,7 @@ function flushQueue() {
queue.clear();
}
-for (const listener of [onCLS, onLCP, onINP, onFID, onFCP, onTTFB]) {
+for (const listener of [onCLS, onLCP, onINP, onFCP, onTTFB]) {
listener(addToQueue);
}
diff --git a/packages/integrations/web-vitals/src/schemas.ts b/packages/integrations/web-vitals/src/schemas.ts
index 7a2050bd5..6dcdbe0cc 100644
--- a/packages/integrations/web-vitals/src/schemas.ts
+++ b/packages/integrations/web-vitals/src/schemas.ts
@@ -7,10 +7,10 @@ const MetricTypeSchema = z.enum(['CLS', 'INP', 'LCP', 'FCP', 'FID', 'TTFB']);
const MetricIdSchema = z
.string()
// Match https://github.com/GoogleChrome/web-vitals/blob/main/src/lib/generateUniqueID.ts
- .regex(/^v3-\d{13}-\d{13}$/)
+ .regex(/^v4-\d{13}-\d{13}$/)
// Avoid collecting higher resolution timestamp in ID.
- // Transforms `'v3-1711484350895-3748043125387'` to `'v3-17114843-3748043125387'`
- .transform((id) => id.replace(/^(v3-\d{8})\d{5}(-\d{13})$/, '$1$2'));
+ // Transforms `'v4-1711484350895-3748043125387'` to `'v4-17114843-3748043125387'`
+ .transform((id) => id.replace(/^(v4-\d{8})\d{5}(-\d{13})$/, '$1$2'));
/** Shape of the data submitted from clients to the collection API. */
const ClientMetricSchema = z.object({