From a7f4a2bf210f8c8064b6b98322486ec02d7cf351 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 +++++++ .../BookingCardBottom/BackToServiceButton.tsx | 12 ++++++ .../service/components/ServiceHeaders.tsx | 8 +++- 11 files changed, 112 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..44edbf1 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.30001687", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001687.tgz", + "integrity": "sha512-0S/FDhf4ZiqrTUiQ39dKeUjYRjkv7lOZU1Dgif2rIqrTzX/1wV2hfKu9TOm1IHkdSijfLswxTFzl/cvir+SLSQ==", "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 ( - - - - - -
- - - -