From 211fbebb11ced215f9dc0ee1714bc1f1bd0f9389 Mon Sep 17 00:00:00 2001 From: Daniel Dobkowski Date: Wed, 11 Dec 2024 22:15:56 +0100 Subject: [PATCH] feat(GoogleAnalytics): added react-ga --- package-lock.json | 11 ++++-- package.json | 1 + src/App.tsx | 31 ++++++++------- src/features/analytics/AnalyticsWrapper.tsx | 9 +++++ .../analytics/contexts/AnalyticsContext.tsx | 4 ++ src/features/analytics/hooks/index.ts | 1 + .../analytics/hooks/useGoogleAnalytics.ts | 38 +++++++++++++++++++ src/features/analytics/index.ts | 1 + src/features/analytics/types.ts | 14 +++++++ src/features/service/api/queries/models.ts | 1 + src/features/service/api/queries/queries.ts | 1 + .../service/components/ServiceHeaders.tsx | 10 ++++- src/models/service.ts | 1 + 13 files changed, 105 insertions(+), 18 deletions(-) create mode 100644 src/features/analytics/AnalyticsWrapper.tsx create mode 100644 src/features/analytics/contexts/AnalyticsContext.tsx create mode 100644 src/features/analytics/hooks/index.ts create mode 100644 src/features/analytics/hooks/useGoogleAnalytics.ts create mode 100644 src/features/analytics/index.ts create mode 100644 src/features/analytics/types.ts diff --git a/package-lock.json b/package-lock.json index 8039180..7df144c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5789,9 +5789,9 @@ } }, "caniuse-lite": { - "version": "1.0.30001680", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001680.tgz", - "integrity": "sha512-rPQy70G6AGUMnbwS1z6Xg+RkHYPAi18ihs47GH0jcxIG7wArmPgY3XbS2sRdBbxJljp3thdT8BIqv9ccCypiPA==", + "version": "1.0.30001688", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001688.tgz", + "integrity": "sha512-Nmqpru91cuABu/DTCXbM2NSRHzM2uVHfPnhJ/1zEAJx/ILBRVmz3pzH4N7DZqbdG0gWClsCC05Oj0mJ/1AWMbA==", "dev": true }, "case-sensitive-paths-webpack-plugin": { @@ -14635,6 +14635,11 @@ "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-2.0.4.tgz", "integrity": "sha512-suNP+J1VU1MWFKcyt7RtjiSWUjvidmQSlqu+eHslq+342xCbGTYmC0mEhPCOHxlW0CywylOC1u2DFAT+bv4dBw==" }, + "react-ga4": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/react-ga4/-/react-ga4-2.1.0.tgz", + "integrity": "sha512-ZKS7PGNFqqMd3PJ6+C2Jtz/o1iU9ggiy8Y8nUeksgVuvNISbmrQtJiZNvC/TjDsqD0QlU5Wkgs7i+w9+OjHhhQ==" + }, "react-helmet-async": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/react-helmet-async/-/react-helmet-async-1.3.0.tgz", diff --git a/package.json b/package.json index 1166b75..8c51519 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,7 @@ "react-dates": "^21.8.0", "react-dates-gte-react-17-21.8.0-version-fixed": "^21.8.0", "react-dom": "^18.2.0", + "react-ga4": "^2.1.0", "react-helmet-async": "^1.3.0", "react-i18next": "^11.17.2", "react-markdown": "^8.0.0", diff --git a/src/App.tsx b/src/App.tsx index 091adf1..f432461 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -2,6 +2,7 @@ import React from "react"; import { apolloClient } from "api/apolloClient"; import Footer from "components/Footer"; import Header from "components/Header"; +import { AnalyticsWrapper } from "features/analytics"; import StateModal from "features/confirmation/components/StateModal"; import "features/i18n"; import ThemeWrapper from "features/theme/components/ThemeWrapper"; @@ -15,20 +16,22 @@ import { AppLayoutWrapper } from "./components/layout/AppLayoutWrapper"; function App() { return ( - - - - - -
- - - -