From b559840584e63b9d1b61bdd04bd2f0ff853c49f4 Mon Sep 17 00:00:00 2001 From: moiz-sgtradex Date: Fri, 12 Sep 2025 09:42:32 +0530 Subject: [PATCH 1/6] feat: gtm setup for ga analytics --- .github/workflows/ci.yml | 2 ++ .gitignore | 2 ++ package-lock.json | 14 ++++++++++++++ package.json | 2 ++ src/components/content/DocumentPreview.tsx | 9 ++++++++- src/components/content/DocumentStatus.tsx | 11 ++++++++++- src/lib/gtmService.ts | 13 +++++++++++++ src/main.tsx | 2 +- src/types/types.ts | 4 ++++ tsconfig.json | 3 ++- 10 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 src/lib/gtmService.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 091eb44..69b2284 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,3 +21,5 @@ jobs: run: npm run lint - name: Build run: npm run build + env: + VITE_GTM_ID: ${{ secrets.VITE_GTM_ID }} diff --git a/.gitignore b/.gitignore index 07ed592..492770e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ Thumbs.db eslintcache .prettiercache .netlify/ +.env +.env.local \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 3a20b33..e5157ed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,12 +16,14 @@ "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-tabs": "^1.1.1", + "@types/react-gtm-module": "^2.0.4", "class-variance-authority": "^0.7.0", "clsx": "2.1.1", "lucide-react": "^0.453.0", "qrcode.react": "^4.2.0", "react": "^19.1.0", "react-dom": "^19.1.0", + "react-gtm-module": "^2.0.11", "react-router-dom": "^7.6.1", "tailwind-merge": "2.5.4", "vite-plugin-node-polyfills": "^0.23.0" @@ -2352,6 +2354,12 @@ "@types/react": "^19.0.0" } }, + "node_modules/@types/react-gtm-module": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/@types/react-gtm-module/-/react-gtm-module-2.0.4.tgz", + "integrity": "sha512-5wPMWsUE5AI6O0B0K1/zbs0rFHBKu+7NWXQwDXhqvA12ooLD6W1AYiWZqR4UiOd7ixZDV1H5Ys301zEsqyIfNg==", + "license": "MIT" + }, "node_modules/@typescript-eslint/eslint-plugin": { "version": "8.33.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/eslint-plugin/-/eslint-plugin-8.33.0.tgz", @@ -6359,6 +6367,12 @@ "react": "^19.1.0" } }, + "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==", + "license": "MIT" + }, "node_modules/react-is": { "version": "16.13.1", "resolved": "https://registry.npmjs.org/react-is/-/react-is-16.13.1.tgz", diff --git a/package.json b/package.json index 5ff0e92..b0cedf8 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,14 @@ "@radix-ui/react-separator": "^1.1.0", "@radix-ui/react-slot": "^1.1.0", "@radix-ui/react-tabs": "^1.1.1", + "@types/react-gtm-module": "^2.0.4", "class-variance-authority": "^0.7.0", "clsx": "2.1.1", "lucide-react": "^0.453.0", "qrcode.react": "^4.2.0", "react": "^19.1.0", "react-dom": "^19.1.0", + "react-gtm-module": "^2.0.11", "react-router-dom": "^7.6.1", "tailwind-merge": "2.5.4", "vite-plugin-node-polyfills": "^0.23.0" diff --git a/src/components/content/DocumentPreview.tsx b/src/components/content/DocumentPreview.tsx index 51e8971..d37025b 100644 --- a/src/components/content/DocumentPreview.tsx +++ b/src/components/content/DocumentPreview.tsx @@ -2,6 +2,7 @@ import React, { useState } from 'react'; import { Button } from '@/button'; import { ExpandIcon } from 'lucide-react'; import { ExpandPreview } from './ExpandPreview'; +import { sendGAEvent } from '../../lib/gtmService'; export const DocumentPreview = ({ image, name, imageAlt }: { image: string; name: string; imageAlt: string }) => { const [expandPreview, setExpandPreview] = useState(false); @@ -17,7 +18,13 @@ export const DocumentPreview = ({ image, name, imageAlt }: { image: string; name