From c1fe9e87e0a35838b197cde78aee97172ec8d174 Mon Sep 17 00:00:00 2001 From: ereburg Date: Mon, 11 Sep 2023 13:49:20 +0300 Subject: [PATCH] add GTM analytics module --- frontend/package-lock.json | 13 +++++++++++++ frontend/package.json | 2 ++ frontend/src/index.tsx | 8 +++++++- frontend/src/reportWebVitals.js | 13 ------------- 4 files changed, 22 insertions(+), 14 deletions(-) delete mode 100644 frontend/src/reportWebVitals.js diff --git a/frontend/package-lock.json b/frontend/package-lock.json index dfe527c..89c7feb 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -30,6 +30,7 @@ "react-datepicker": "4.15.0", "react-dom": "18.2.0", "react-dropzone": "14.2.3", + "react-gtm-module": "2.0.11", "react-router": "6.15.0", "react-router-dom": "6.15.0", "react-scripts": "5.0.1", @@ -41,6 +42,7 @@ "@types/node": "18.17.14", "@types/react-datepicker": "4.11.2", "@types/react-dom": "18.2.7", + "@types/react-gtm-module": "2.0.1", "eslint-config-airbnb": "19.0.4", "eslint-config-airbnb-typescript": "17.1.0", "eslint-config-prettier": "8.8.0", @@ -4987,6 +4989,12 @@ "@types/react": "*" } }, + "node_modules/@types/react-gtm-module": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/@types/react-gtm-module/-/react-gtm-module-2.0.1.tgz", + "integrity": "sha512-T/DN9gAbCYk5wJ1nxf4pSwmXz4d1iVjM++OoG+mwMfz9STMAotGjSb65gJHOS5bPvl6vLSsJnuC+y/43OQrltg==", + "dev": true + }, "node_modules/@types/resolve": { "version": "1.17.1", "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", @@ -15761,6 +15769,11 @@ "resolved": "https://registry.npmjs.org/react-fast-compare/-/react-fast-compare-3.2.2.tgz", "integrity": "sha512-nsO+KSNgo1SbJqJEYRE9ERzo7YtYbou/OqjSQKxV7jcKox7+usiUVZOAC+XnDOABXggQTno0Y1CpVnuWEc1boQ==" }, + "node_modules/react-gtm-module": { + "version": "2.0.11", + "resolved": "https://registry.npmjs.org/react-gtm-module/-/react-gtm-module-2.0.11.tgz", + "integrity": "sha512-8gyj4TTxeP7eEyc2QKawEuQoAZdjKvMY4pgWfycGmqGByhs17fR+zEBs0JUDq4US/l+vbTl+6zvUIx27iDo/Vw==" + }, "node_modules/react-is": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", diff --git a/frontend/package.json b/frontend/package.json index f7a5733..31c4c95 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -29,6 +29,7 @@ "react-datepicker": "4.15.0", "react-dom": "18.2.0", "react-dropzone": "14.2.3", + "react-gtm-module": "2.0.11", "react-router": "6.15.0", "react-router-dom": "6.15.0", "react-scripts": "5.0.1", @@ -40,6 +41,7 @@ "@types/node": "18.17.14", "@types/react-datepicker": "4.11.2", "@types/react-dom": "18.2.7", + "@types/react-gtm-module": "2.0.1", "eslint-config-airbnb": "19.0.4", "eslint-config-airbnb-typescript": "17.1.0", "eslint-config-prettier": "8.8.0", diff --git a/frontend/src/index.tsx b/frontend/src/index.tsx index fee7922..69a1257 100644 --- a/frontend/src/index.tsx +++ b/frontend/src/index.tsx @@ -1,8 +1,14 @@ import { createRoot } from 'react-dom/client'; +import TagManager from 'react-gtm-module'; import { App } from '@/App'; - import './styles/global.scss'; +if (process.env.NODE_ENV === 'production') { + TagManager.initialize({ + gtmId: 'GTM-5H6FVXRQ', + }); +} + const container = document.getElementById('root'); const root = createRoot(container as Element); diff --git a/frontend/src/reportWebVitals.js b/frontend/src/reportWebVitals.js deleted file mode 100644 index 5253d3a..0000000 --- a/frontend/src/reportWebVitals.js +++ /dev/null @@ -1,13 +0,0 @@ -const reportWebVitals = onPerfEntry => { - if (onPerfEntry && onPerfEntry instanceof Function) { - import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { - getCLS(onPerfEntry); - getFID(onPerfEntry); - getFCP(onPerfEntry); - getLCP(onPerfEntry); - getTTFB(onPerfEntry); - }); - } -}; - -export default reportWebVitals;