From c767345e90bc252b47c15b762541d58621353f32 Mon Sep 17 00:00:00 2001 From: "Brian J. Geiger" Date: Tue, 8 Aug 2023 17:05:04 -0400 Subject: [PATCH] Try initializing GTM in a way that works runtime (#1921) ## Purpose You can't just pull something into the index.html from runtime, it has to happen build time. So we'll try doing this the way raven works instead. ## Summary of Changes 1. Initialize GTM in a way that works runtime. 2. Add environment variable for the gtm id 3. Types --- config/environment.d.ts | 2 +- config/environment.js | 2 +- ember-cli-build.js | 13 ++++++++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/config/environment.d.ts b/config/environment.d.ts index 42bb974a20..a04a23a875 100644 --- a/config/environment.d.ts +++ b/config/environment.d.ts @@ -28,6 +28,7 @@ declare const config: { rootURL: string; assetsPrefix: string; sentryDSN: string | null; + googleTagManagerId: string | null; sentryOptions: { release?: string; ignoreErrors: string[]; @@ -195,7 +196,6 @@ declare const config: { pageTitle: { prepend: boolean; }; - gtm: string; }; export default config; diff --git a/config/environment.js b/config/environment.js index 8d443dfa91..1d74a7b19d 100644 --- a/config/environment.js +++ b/config/environment.js @@ -77,6 +77,7 @@ module.exports = function(environment) { assetsPrefix, locationType: 'auto', sentryDSN: null, + googleTagManagerId: null, sentryOptions: { release, ignoreErrors: [ @@ -303,7 +304,6 @@ module.exports = function(environment) { pageTitle: { prepend: false, }, - gtm: '', }; if (environment === 'development') { diff --git a/ember-cli-build.js b/ember-cli-build.js index a31a63b2e2..f304cdb629 100644 --- a/ember-cli-build.js +++ b/ember-cli-build.js @@ -108,7 +108,18 @@ module.exports = function(defaults) { }, gtm: { enabled: IS_PROD, - content: config.gtm, + content: ` + `, postProcess, }, },