diff --git a/src/App.tsx b/src/App.tsx index 05a899cf0..be26909ad 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,6 +1,7 @@ import { AppRouted } from '@/AppRouted'; import { Toaster } from '@/components/ui/sonner'; import { useDatadog } from '@/integrations/datadog/datadog'; +import { useGTM } from '@/integrations/google/gtm'; import { useReo } from '@/integrations/reo/reo'; import { queryClient } from '@/react-query/queryClient'; import { QueryClientProvider } from '@tanstack/react-query'; @@ -9,6 +10,7 @@ import { ReactQueryDevtools } from '@tanstack/react-query-devtools'; export function App() { useReo(); useDatadog(); + useGTM(); return ( <> diff --git a/src/features/cluster/Scaling.tsx b/src/features/cluster/Scaling.tsx index c76057e37..1df534ca2 100644 --- a/src/features/cluster/Scaling.tsx +++ b/src/features/cluster/Scaling.tsx @@ -47,8 +47,7 @@ export function Scaling() {

Here we go!

Your cluster is updating with the latest changes. This includes waiting several minutes to let - traffic drain safely. - + traffic drain safely. We will let you know when we are ready for you to connect! In the meantime, join us on Discord! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric. diff --git a/src/features/cluster/StartingUp.tsx b/src/features/cluster/StartingUp.tsx index d83d2beab..f220c7f5c 100644 --- a/src/features/cluster/StartingUp.tsx +++ b/src/features/cluster/StartingUp.tsx @@ -91,8 +91,7 @@ export function StartingUp() {

Here we go!

Your cluster is spinning up with the latest changes, including your own DNS records and private - connections. Please wait while we get everything going. - + connections. Please wait while we get everything going. We will let you know when we are ready for you to connect! In the meantime, join us on Discord! Get real-time help from our engineers, see feature drops early, and connect with others building on Fabric. diff --git a/src/integrations/google/gtm.ts b/src/integrations/google/gtm.ts new file mode 100644 index 000000000..5b5c6f3ea --- /dev/null +++ b/src/integrations/google/gtm.ts @@ -0,0 +1,30 @@ +import { isLocalStudio } from '@/config/constants'; +import { useEffect } from 'react'; + +let initialized = false; +const enabled = !import.meta.env.DEV && !isLocalStudio; + +export function useGTM() { + useEffect(() => { + if (initialized) { + return; + } + initialized = true; + if (enabled) { + // eslint-disable-next-line @typescript-eslint/no-explicit-any + (function(w: any, d: any, s, l, i) { + w[l] = w[l] || []; + w[l].push({ + 'gtm.start': + new Date().getTime(), event: 'gtm.js', + }); + const f = d.getElementsByTagName(s)[0]; + const j = d.createElement(s); + const dl = l !== 'dataLayer' ? `&l=${l}` : ''; + j.async = true; + j.src = 'https://www.googletagmanager.com/gtm.js?id=' + i + dl; + f.parentNode.insertBefore(j, f); + })(window, document, 'script', 'dataLayer', 'GTM-5QQX432'); + } + }, []); + }