fix(meta-pixel): let a pre-load consent call replace the queued default - #930
Conversation
|
@felixgabler is attempting to deploy a commit to the Nuxt Team on Vercel. A member of the Team first needs to authorize it. |
🤖 MERGED
GitHub merged this pull request.
The pull request closed. |
commit: |
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughThe Meta Pixel stub now removes queued consent calls before adding a new consent call at the front of the queue. It continues to append other commands normally. Tests cover consent calls made before loading, replacement of the default denied call, and forwarding to Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to No concrete unresolved issue has been established; the change is mergeable after normal checks. Architecture SummaryArchitecture risk: 🔵 Low · up to The change affects 2 systems. Changed systems: Architecture concerns Review detailsSystems and components
Before / after behavior
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1🛠️ Fix failing CI checks 💡
🧪 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 |
📦 Package Size📚 22 runtime dependencies (no change)
All tracked output (25)
Runtime dependencies (22)
Baseline: main_@_4bb52cc4___2026-09-22 · gzip is the comparison metric · changes below 16 B gzip are ignored |
|
Thanks for merging this, @harlan-zw! We're still on 1.3.9 in production and carry this fix as a local patch for now. Is a 1.x backport planned, like #897? If it helps, I'm happy to open a PR against the |
|
No problem, thanks for the PR. I'll arrange that shortly :) |
🔗 Linked issue
resolves #928
📚 Description
With
defaultConsent: 'denied',clientInitqueues['consent', 'revoke']ahead ofinitandPageView. Aconsent.grant()made before fbevents.js loads is appended behind it. fbevents replays the queue in order and stops at the revoke, so the grant never runs and nothing is sent. More detail and a trace are in the issue.This change touches only the stub. Before fbevents has loaded, a
consentcall removes any queued consent command and puts the new one at the head of the queue. Consent is a state rather than an event, so the latest decision made before load is the one that applies beforeinit. OncecallMethodexists, calls go straight to fbevents as before.That matches how fbevents behaves after load: commands held while consent is revoked are sent on grant, and a revoke holds everything queued after it.
Before, in the playground repro from the issue (Chrome,
window.fbq.queuetraced):After:
We also run the same change as a local patch on 1.3.9 in production builds. It sends events for visitors who had already consented, sends nothing while consent is undecided, and sends nothing when consent is withdrawn before the pixel finishes loading.
Tests in
test/nuxt-runtime/consent-default.nuxt.test.ts:grant()thenrevoke()to both be appended. It now expects only the latest consent, at the head of the queue.grant()before load replacesdefaultConsent: 'denied'.callMethodexists, consent calls go straight to it.Both new tests fail on
mainwithout the change. The file passes (30 tests) with it, and eslint is clean.One thing we are unsure about: this only reorders
consentcommands in the pre-load queue. If there is a reason to keep strict call order there that we have not thought of, we are happy to adjust.Thanks for the module and for looking at this.
I investigated this with help from an AI coding assistant (Claude Code), which also drafted this text. I reviewed it, and the results above come from real runs.