Skip to content

Commit f42a971

Browse files
committed
switch ga to use beacon
1 parent c8503bc commit f42a971

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

frontend/src/reportWebVitals.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Metric } from 'web-vitals'
22
import ReactGA from 'react-ga4'
3+
import { UaEventOptions } from 'react-ga4/types/ga4'
34

45
const getAnalyticsId = () => process.env.GOOGLE_ANALYTICS_TRACKING_ID
56
const isDev = () => process.env.NODE_ENV && process.env.NODE_ENV === 'development'
@@ -12,12 +13,13 @@ const getEventValueFromMetric = (metric: Metric) => {
1213
}
1314

1415
const reportHandler = (metric: Metric) => {
15-
const event = {
16+
const event: UaEventOptions = {
1617
category: 'Web Vitals',
1718
action: metric.name,
1819
value: getEventValueFromMetric(metric),
1920
label: metric.id,
20-
nonInteraction: true
21+
nonInteraction: true,
22+
transport: 'beacon'
2123
}
2224

2325
if (isDev()) {

0 commit comments

Comments
 (0)