feat: add Bing UET (Microsoft Advertising) registry script#650
feat: add Bing UET (Microsoft Advertising) registry script#650
Conversation
Adds `useScriptBingUet()` composable for integrating Microsoft Advertising Universal Event Tracking. Includes queue setup before script load and automatic `new UET()` initialization after bat.js loads, with `pageLoad` event push. Also adds mixpanel CLIENT_INIT to the size generator.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
commit: |
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds Bing UET integration across the Nuxt Scripts codebase: new runtime composable Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
📝 Coding Plan
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 |
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
scripts/generate-sizes.ts (1)
405-415: Keep Mixpanel size-bootstrap in sync with runtime bootstrap.Lines 405-415 diverge from
src/runtime/registry/mixpanel-analytics.ts. The size-bootstrap unconditionally setsmp.__SVandmp._i, while the runtime wraps these assignments inif (!mp.__SV)to prevent re-initialization. This can skew benchmark comparability against real runtime behavior.Wrap the property initialization in an
if (!mp.__SV)guard to match the runtime implementation:Suggested fix
- var mp = window.mixpanel = window.mixpanel || []; - mp.__SV = 1.2; mp._i = mp._i || []; + var mp = window.mixpanel = window.mixpanel || []; + if (!mp.__SV) { + mp.__SV = 1.2; mp._i = mp._i || [];🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@scripts/generate-sizes.ts` around lines 405 - 415, The size-bootstrap mixpanel snippet inside the mixpanelAnalytics string unconditionally sets mp.__SV and mp._i which diverges from runtime; update the mixpanelAnalytics template so the assignments to mp.__SV and mp._i (and the initialization of mp._i and mp._i.push) are executed only when !mp.__SV, mirroring the runtime guard used in src/runtime/registry/mixpanel-analytics.ts and leaving mp.init, mp.track, and people methods behavior unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/module.ts`:
- Line 142: The bingUet forwarding currently includes both 'uetq' and
'uetq.push', which breaks Partytown's array-queue semantics; update the bingUet
forwarding configuration (the bingUet symbol) to forward only 'uetq.push' and
remove the plain 'uetq' entry so only the method path is proxied (this preserves
Array.isArray(window.uetq) behavior and proper queue initialization).
In `@src/registry.ts`:
- Line 157: The registry entry using a protocol-relative URL (src:
'//bat.bing.com/bat.js') should be changed to an explicit HTTPS absolute URL;
update the src value to 'https://bat.bing.com/bat.js' in the object defined in
src/registry.ts (the registry entry with src) and search for any other
protocol-relative URLs in the same file to replace with HTTPS equivalents to
ensure server-side fetch/bundling works.
In `@src/runtime/registry/bing-uet.ts`:
- Around line 33-38: The uetOptions is currently typed as Record<string, any>
but must match the shape expected by window.UET; change its type to an explicit
interface or inline type like { ti: string; enableAutoSpaTracking?: boolean; q?:
any[] } and construct it with ti: options.id, enableAutoSpaTracking:
options.enableAutoSpaTracking ?? true, and q: window.uetq (cast to any[] if
needed), then pass that object to new window.UET; update references to
uetOptions.q and window.uetq accordingly so the types line up with the
window.UET constructor.
---
Nitpick comments:
In `@scripts/generate-sizes.ts`:
- Around line 405-415: The size-bootstrap mixpanel snippet inside the
mixpanelAnalytics string unconditionally sets mp.__SV and mp._i which diverges
from runtime; update the mixpanelAnalytics template so the assignments to
mp.__SV and mp._i (and the initialization of mp._i and mp._i.push) are executed
only when !mp.__SV, mirroring the runtime guard used in
src/runtime/registry/mixpanel-analytics.ts and leaving mp.init, mp.track, and
people methods behavior unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 44f10b79-e398-491d-b8c4-ff7d4591c263
📒 Files selected for processing (12)
docs/content/scripts/bing-uet.mdplayground/pages/third-parties/bing-uet.vuescripts/generate-sizes.tssrc/module.tssrc/registry-logos.tssrc/registry-types.jsonsrc/registry.tssrc/runtime/registry/bing-uet.tssrc/runtime/registry/schemas.tssrc/runtime/types.tssrc/script-meta.tssrc/script-sizes.json
- Forward only `uetq.push` for Partytown (not root object) - Use explicit HTTPS URL instead of protocol-relative `//`
🔗 Linked issue
N/A — community requested feature (Bing Analytics / Microsoft Advertising UET)
❓ Type of change
📚 Description
Adds
useScriptBingUet()composable for integrating Microsoft Advertising Universal Event Tracking. Includes method queueing so calls touetq.push()work before the script loads, with automaticnew UET({ ti, enableAutoSpaTracking })initialization andpageLoadevent on script load.Based on the vendor snippet from Microsoft UET docs.