Files
supabase/apps/www/pages/_app.tsx
T
Ivan VasilovandAlaister Young 37e44bec9c feat: Add GTM (#35567)
* Add third-parties dependency for GTM. Reexport the GTM from the common package.

* Add the TelemetryTagManager to four of the production apps.

* Add the GOOGLE_TAG_MANAGER_ID env var as a turbo dependency to the 4 apps.

* Skip rendering the tag manager if the env var is not set or not running on the platform.

* Fix the prop type to be extracted from the component.

* Add default values for consent to GTM.

* Another try to mimic gtag function.

* Fix a link in www.

* Try another approach.

* try.

* Remove the data-redaction flag.

* Remove extra code.

* Send a sign-up event if GTM is enabled.

* Send only the email to GTM.

* Minor fixes.

* Remove third-parties from pnpm lockfile.

* Lets try to make studio work again.

* Add CSP rules for img loading for GTM.

* Add event for testing.

* Add www.googletagmanager.com to the CSP rules.

* Add Stape to CSP rules.

* Fix stape CSP.

* Clean up the code.

* Remove extra console.log.

* Fix the stape urls for CORS.

* Fix the wrong category for Stape URL.

* Add google ads urls.

* Bump the timeout.

* Add google.com to the img-src for google ads.

* update csp

* remove comment

* update to use google analytics without signals

* add stape to default-src in csp

* move csp to middleware

* add google ads support and fix middleware base path

* remove google tag manager / google ads references from csp. load via stape proxy instead

* add double click url to image src

* add Google Tag Manager URL to CSP configuration

* add ga4 urls to csp

* remove google urls from CSP

---------

Co-authored-by: Alaister Young <a@alaisteryoung.com>
2025-06-30 10:35:47 +00:00

115 lines
3.3 KiB
TypeScript

import '@code-hike/mdx/styles'
import 'config/code-hike.scss'
import '../styles/index.css'
import {
AuthProvider,
FeatureFlagProvider,
IS_PLATFORM,
PageTelemetry,
ThemeProvider,
useThemeSandbox,
TelemetryTagManager,
} from 'common'
import { DefaultSeo } from 'next-seo'
import { AppProps } from 'next/app'
import Head from 'next/head'
import { useRouter } from 'next/router'
import { SonnerToaster, themes, TooltipProvider } from 'ui'
import { CommandProvider } from 'ui-patterns/CommandMenu'
import { useConsentToast } from 'ui-patterns/consent'
import MetaFaviconsPagesRouter, {
DEFAULT_FAVICON_ROUTE,
DEFAULT_FAVICON_THEME_COLOR,
} from 'common/MetaFavicons/pages-router'
import { WwwCommandMenu } from '~/components/CommandMenu'
import { API_URL, APP_NAME, DEFAULT_META_DESCRIPTION } from '~/lib/constants'
import useDarkLaunchWeeks from '../hooks/useDarkLaunchWeeks'
export default function App({ Component, pageProps }: AppProps) {
const router = useRouter()
const { hasAcceptedConsent } = useConsentToast()
useThemeSandbox()
const site_title = `${APP_NAME} | The Postgres Development Platform.`
const { basePath } = useRouter()
const isDarkLaunchWeek = useDarkLaunchWeeks()
const forceDarkMode = isDarkLaunchWeek
let applicationName = 'Supabase'
let faviconRoute = DEFAULT_FAVICON_ROUTE
let themeColor = DEFAULT_FAVICON_THEME_COLOR
if (router.asPath && router.asPath.includes('/launch-week/x')) {
applicationName = 'Supabase LWX'
faviconRoute = 'images/launchweek/lwx/favicon'
themeColor = 'FFFFFF'
}
return (
<>
<Head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
</Head>
<MetaFaviconsPagesRouter
applicationName={applicationName}
route={faviconRoute}
themeColor={themeColor}
includeManifest
includeMsApplicationConfig
includeRssXmlFeed
/>
<DefaultSeo
title={site_title}
description={DEFAULT_META_DESCRIPTION}
openGraph={{
type: 'website',
url: 'https://supabase.com/',
site_name: 'Supabase',
images: [
{
url: `https://supabase.com${basePath}/images/og/supabase-og.png`,
width: 800,
height: 600,
alt: 'Supabase Og Image',
},
],
}}
twitter={{
handle: '@supabase',
site: '@supabase',
cardType: 'summary_large_image',
}}
/>
<AuthProvider>
<FeatureFlagProvider API_URL={API_URL} enabled={IS_PLATFORM}>
<ThemeProvider
themes={themes.map((theme) => theme.value)}
enableSystem
disableTransitionOnChange
forcedTheme={forceDarkMode ? 'dark' : undefined}
>
<TooltipProvider delayDuration={0}>
<CommandProvider>
<SonnerToaster position="top-right" />
<Component {...pageProps} />
<WwwCommandMenu />
<PageTelemetry
API_URL={API_URL}
hasAcceptedConsent={hasAcceptedConsent}
enabled={IS_PLATFORM}
/>
</CommandProvider>
</TooltipProvider>
</ThemeProvider>
</FeatureFlagProvider>
</AuthProvider>
<TelemetryTagManager />
</>
)
}