Fix Google Analytics tag injection (#9819)

I missed injecting the Google Analytics tag from the environment at build time...

# Important Notes
None
This commit is contained in:
somebody1234 2024-05-01 21:32:50 +10:00 committed by GitHub
parent 6b0361c33c
commit d995d17dcb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 6 deletions

View File

@ -97,6 +97,9 @@ export function getDefines(serverPort = 8080) {
),
'process.env.ENSO_CLOUD_COGNITO_DOMAIN': stringify(process.env.ENSO_CLOUD_COGNITO_DOMAIN),
'process.env.ENSO_CLOUD_COGNITO_REGION': stringify(process.env.ENSO_CLOUD_COGNITO_REGION),
'process.env.ENSO_CLOUD_GOOGLE_ANALYTICS_TAG': stringify(
process.env.ENSO_CLOUD_GOOGLE_ANALYTICS_TAG
),
/* eslint-enable @typescript-eslint/naming-convention */
}
}

View File

@ -1,10 +1,10 @@
/** @file Google Analytics tag. */
import * as load from './load'
if (process.env.ENSO_CLOUD_GOOGLE_ANALYTICS_TAG != null) {
void load.loadScript(
`https://www.googletagmanager.com/gtag/js?id=${process.env.ENSO_CLOUD_GOOGLE_ANALYTICS_TAG}`
)
const GOOGLE_ANALYTICS_TAG = process.env.ENSO_CLOUD_GOOGLE_ANALYTICS_TAG
if (GOOGLE_ANALYTICS_TAG != null) {
void load.loadScript(`https://www.googletagmanager.com/gtag/js?id=${GOOGLE_ANALYTICS_TAG}`)
}
// @ts-expect-error This is explicitly not given types as it is a mistake to acess this
@ -29,5 +29,7 @@ export function event(name: string, params?: object) {
gtag('js', new Date())
// eslint-disable-next-line @typescript-eslint/naming-convention
gtag('set', 'linker', { accept_incoming: true })
gtag('config', 'G-CLTBJ37MDM')
gtag('config', GOOGLE_ANALYTICS_TAG)
if (GOOGLE_ANALYTICS_TAG === 'G-CLTBJ37MDM') {
gtag('config', 'G-DH47F649JC')
}