Beautiful Open-Source Form Builder
refactor: Remove obsolete GTM configuration and integrate new GTM package
JhumanJ1a51989ef0e1
diff --git a/client/gtm.js b/client/gtm.jsdeleted file mode 100644index 8dce65173..000000000--- a/client/gtm.js+++ /dev/null@@ -1,6 +0,0 @@-export default {- id: process.env.NUXT_PUBLIC_GTM_CODE, // Your GTM single container ID, array of container ids ['GTM-xxxxxx', 'GTM-yyyyyy'] or array of objects [{id: 'GTM-xxxxxx', queryParams: { gtm_auth: 'abc123', gtm_preview: 'env-4', gtm_cookies_win: 'x'}}, {id: 'GTM-yyyyyy', queryParams: {gtm_auth: 'abc234', gtm_preview: 'env-5', gtm_cookies_win: 'x'}}], // Your GTM single container ID or array of container ids ['GTM-xxxxxx', 'GTM-yyyyyy']- debug: false, // Whether or not display console logs debugs (optional)- devtools: false, // (optional),- enabled: false, // Disabled by default, will be enabled conditionally by our plugin-}diff --git a/client/nuxt.config.ts b/client/nuxt.config.tsindex cc31b9d4a..a17164e92 100644--- a/client/nuxt.config.ts+++ b/client/nuxt.config.ts@@ -1,7 +1,6 @@// https://nuxt.com/docs/api/configuration/nuxt-configimport runtimeConfig from "./runtimeConfig"import sitemap from "./sitemap"-import gtm from "./gtm"export default defineNuxtConfig({loglevel: process.env.NUXT_LOG_LEVEL || 'info',@@ -139,6 +138,5 @@ export default defineNuxtConfig({sitemap,runtimeConfig,- gtm,compatibilityDate: '2024-10-30'})diff --git a/client/package-lock.json b/client/package-lock.jsonindex 412cb4ef2..24a974e4c 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -21,6 +21,7 @@"@vueuse/integrations": "^11.2.0","@vueuse/motion": "^2.2.6","@vueuse/nuxt": "^11.2.0",+ "@zadigetvoltaire/nuxt-gtm": "^0.0.13","@zxing/library": "^0.21.3","amplitude-js": "^8.21.9","chart.js": "^4.4.5",@@ -62,7 +63,6 @@"@nuxt/icon": "^1.12.0","@nuxtjs/i18n": "^9.0.0","@nuxtjs/sitemap": "^7.2.0",- "@zadigetvoltaire/nuxt-gtm": "^0.0.13","autoprefixer": "^10.4.20","eslint": "^9.0.0","eslint-config-prettier": "^9.1.0",@@ -1448,6 +1448,32 @@"integrity": "sha512-5DGmA8FTdB2XbDeEwc/5ZXBl6UbBAyBOOLlPuBnZ/N1SwdH9Ii+cOX3tBROlDgcTXxjOYnLMVoKk9+FXAw0CJw==","license": "MIT"},+ "node_modules/@gtm-support/core": {+ "version": "2.3.1",+ "resolved": "https://registry.npmjs.org/@gtm-support/core/-/core-2.3.1.tgz",+ "integrity": "sha512-eD0hndQjhgKm5f/7IA9fZYujmHiVMY+fnYv4mdZSmz5XJQlS4TiTmpdZx2l7I2A9rI9J6Ysz8LpXYYNo/Xq4LQ==",+ "license": "MIT"+ },+ "node_modules/@gtm-support/vue-gtm": {+ "version": "2.2.0",+ "resolved": "https://registry.npmjs.org/@gtm-support/vue-gtm/-/vue-gtm-2.2.0.tgz",+ "integrity": "sha512-7nhBTRkTG0mD+7r7JvNalJz++YwszZk0oP1HIY6fCgz6wNKxT6LuiXCqdPrZmNPe/WbPIKuqxGZN5s+i6NZqow==",+ "license": "MIT",+ "dependencies": {+ "@gtm-support/core": "^2.0.0"+ },+ "optionalDependencies": {+ "vue-router": ">= 4.1.0 < 5.0.0"+ },+ "peerDependencies": {+ "vue": ">= 3.2.0 < 4.0.0"+ },+ "peerDependenciesMeta": {+ "vue-router": {+ "optional": true+ }+ }+ },"node_modules/@headlessui/tailwindcss": {"version": "0.2.2","resolved": "https://registry.npmjs.org/@headlessui/tailwindcss/-/tailwindcss-0.2.2.tgz",@@ -9087,7 +9113,6 @@"version": "0.0.13","resolved": "https://registry.npmjs.org/@zadigetvoltaire/nuxt-gtm/-/nuxt-gtm-0.0.13.tgz","integrity": "sha512-7SgXtIB8uLdLGJaoUAQSGCSbRnNzplNkNVFKIHaVI4We0vqghstBoVPlJCJ9VdwsfdNyk3/C+Lh1uKpzTrtEuw==",- "dev": true,"license": "MIT","dependencies": {"@gtm-support/vue-gtm": "^2.0.0",@@ -9099,39 +9124,10 @@"nuxt": "^3.0.0"}},- "node_modules/@zadigetvoltaire/nuxt-gtm/node_modules/@gtm-support/core": {- "version": "2.3.1",- "resolved": "https://registry.npmjs.org/@gtm-support/core/-/core-2.3.1.tgz",- "integrity": "sha512-eD0hndQjhgKm5f/7IA9fZYujmHiVMY+fnYv4mdZSmz5XJQlS4TiTmpdZx2l7I2A9rI9J6Ysz8LpXYYNo/Xq4LQ==",- "dev": true,- "license": "MIT"- },- "node_modules/@zadigetvoltaire/nuxt-gtm/node_modules/@gtm-support/vue-gtm": {- "version": "2.2.0",- "resolved": "https://registry.npmjs.org/@gtm-support/vue-gtm/-/vue-gtm-2.2.0.tgz",- "integrity": "sha512-7nhBTRkTG0mD+7r7JvNalJz++YwszZk0oP1HIY6fCgz6wNKxT6LuiXCqdPrZmNPe/WbPIKuqxGZN5s+i6NZqow==",- "dev": true,- "license": "MIT",- "dependencies": {- "@gtm-support/core": "^2.0.0"- },- "optionalDependencies": {- "vue-router": ">= 4.1.0 < 5.0.0"- },- "peerDependencies": {- "vue": ">= 3.2.0 < 4.0.0"- },- "peerDependenciesMeta": {- "vue-router": {- "optional": true- }- }- },"node_modules/@zadigetvoltaire/nuxt-gtm/node_modules/sirv": {"version": "2.0.4","resolved": "https://registry.npmjs.org/sirv/-/sirv-2.0.4.tgz","integrity": "sha512-94Bdh3cC2PKrbgSOUqTiGPWVZeSiXfKOVZNJniWoqrWrRkB1CJzBU3NEbiTsPcYy1lDsANA/THzS+9WBiy5nfQ==",- "dev": true,"license": "MIT","dependencies": {"@polka/url": "^1.0.0-next.24",diff --git a/client/package.json b/client/package.jsonindex b48287660..5cb855b80 100644--- a/client/package.json+++ b/client/package.json@@ -21,7 +21,6 @@"@nuxt/icon": "^1.12.0","@nuxtjs/i18n": "^9.0.0","@nuxtjs/sitemap": "^7.2.0",- "@zadigetvoltaire/nuxt-gtm": "^0.0.13","autoprefixer": "^10.4.20","eslint": "^9.0.0","eslint-config-prettier": "^9.1.0",@@ -50,6 +49,7 @@"@vueuse/integrations": "^11.2.0","@vueuse/motion": "^2.2.6","@vueuse/nuxt": "^11.2.0",+ "@zadigetvoltaire/nuxt-gtm": "^0.0.13","@zxing/library": "^0.21.3","amplitude-js": "^8.21.9","chart.js": "^4.4.5",diff --git a/client/plugins/gtm.client.js b/client/plugins/gtm.client.jsindex d236f8441..206eaa20c 100644--- a/client/plugins/gtm.client.js+++ b/client/plugins/gtm.client.js@@ -1,12 +1,15 @@export default defineNuxtPlugin(() => {+ const config = useRuntimeConfig()+ const gtmId = config.public.gtmCode+const route = useRoute()const isIframe = useIsIframe()const isPublicFormPage = route.name === 'forms-slug'+ const gtm = useGtm()+// Only enable GTM if not in a form page (for respondents) and not in an iframe- if (!isPublicFormPage && !isIframe) {- // Initialize GTM manually only when needed- const gtm = useGtm()+ if (gtmId && gtm && !isPublicFormPage && !isIframe) {// Override the enabled setting to true for this sessiongtm.enable(true)diff --git a/client/runtimeConfig.js b/client/runtimeConfig.jsindex 357af2cca..3b8a902b8 100644--- a/client/runtimeConfig.js+++ b/client/runtimeConfig.js@@ -6,12 +6,15 @@ function parseNumber(value, defaultValue = 0) {export default {// Keys within public, will be also exposed to the client-sidepublic: {+ gtm: {+ id: process.env.NUXT_PUBLIC_GTM_CODE || null,+ enabled: false,+ },apiBase: process.env.NUXT_PUBLIC_API_BASE || '',appUrl: process.env.NUXT_PUBLIC_APP_URL || '',env: process.env.NUXT_PUBLIC_ENV || 'local',hCaptchaSiteKey: process.env.NUXT_PUBLIC_H_CAPTCHA_SITE_KEY || null,reCaptchaSiteKey: process.env.NUXT_PUBLIC_RE_CAPTCHA_SITE_KEY || null,- gtmCode: process.env.NUXT_PUBLIC_GTM_CODE || null,amplitudeCode: process.env.NUXT_PUBLIC_AMPLITUDE_CODE || null,crispWebsiteId: process.env.NUXT_PUBLIC_CRISP_WEBSITE_ID || null,rootRedirectUrl: process.env.NUXT_PUBLIC_ROOT_REDIRECT_URL || null,