feat(gtm): debug logging and consent key validation#760
feat(gtm): debug logging and consent key validation#760
Conversation
Adds an opt-in debug surface for the script registry: - New build-time constant `__NUXT_SCRIPTS_DEBUG__` injected via Vite/Nitro `define`/`replace` so debug branches DCE in production. - `useRegistryScript` traces register/load/error events through consola. - GTM warns when `consent.update()` runs before any consent default is queued, and validates GCMv2 keys in both `defaultConsent` and `consent.update()` payloads to catch typos like `analytics_storages`.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
📝 WalkthroughWalkthroughThis PR implements a build-time debug logging system for Nuxt Scripts. It introduces a Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❓ Type of change
📚 Description
Adds an opt-in debug surface for the script registry so misconfigured GTM consent setups surface clear warnings instead of failing silently. A build-time
__NUXT_SCRIPTS_DEBUG__constant is injected via Vitedefineand Nitroreplace, so debug branches DCE in production whendebug: false.When debug is enabled (or in dev),
useRegistryScripttraces register/load/error events through consola. GTM additionally:defaultConsentandconsent.update()payloads, catching typos likeanalytics_storagesorad_storag.consent.update()runs before any consent default has been queued on the dataLayer, since GTM may apply implicit defaults and create races with downstream tags.Covered by 5 new tests in
test/nuxt-runtime/consent-default.nuxt.test.ts(26 total passing).