Skip to content

feat: add Bing UET (Microsoft Advertising) registry script#650

Merged
harlan-zw merged 3 commits intomainfrom
feat/bing-uet
Mar 18, 2026
Merged

feat: add Bing UET (Microsoft Advertising) registry script#650
harlan-zw merged 3 commits intomainfrom
feat/bing-uet

Conversation

@harlan-zw
Copy link
Collaborator

@harlan-zw harlan-zw commented Mar 18, 2026

🔗 Linked issue

N/A — community requested feature (Bing Analytics / Microsoft Advertising UET)

❓ Type of change

  • 📖 Documentation
  • 🐞 Bug fix
  • 👌 Enhancement
  • ✨ New feature
  • 🧹 Chore
  • ⚠️ Breaking change

📚 Description

Adds useScriptBingUet() composable for integrating Microsoft Advertising Universal Event Tracking. Includes method queueing so calls to uetq.push() work before the script loads, with automatic new UET({ ti, enableAutoSpaTracking }) initialization and pageLoad event on script load.

Based on the vendor snippet from Microsoft UET docs.

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.
@vercel
Copy link
Contributor

vercel bot commented Mar 18, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
scripts-playground Ready Ready Preview, Comment Mar 18, 2026 4:06pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 18, 2026

Open in StackBlitz

npm i https://pkg.pr.new/@nuxt/scripts@650

commit: 45edb19

@coderabbitai
Copy link

coderabbitai bot commented Mar 18, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1fbeff18-8c6c-4a2d-8495-2d9ec76508ff

📥 Commits

Reviewing files that changed from the base of the PR and between 45edb19 and 537bdfd.

📒 Files selected for processing (3)
  • src/module.ts
  • src/registry.ts
  • src/runtime/registry/bing-uet.ts

📝 Walkthrough

Walkthrough

Adds Bing UET integration across the Nuxt Scripts codebase: new runtime composable useScriptBingUet() with types and schema (BingUetOptions, BingUetApi), registry entry and metadata, logo asset, Partytown forward and registry default, script-size benchmark data and generated HTML bootstraps (including a small Mixpanel bootstrap), documentation page (docs/content/scripts/bing-uet.md), and a playground example (playground/pages/third-parties/bing-uet.vue).

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The pull request title accurately describes the main feature being added: a new Bing UET registry script integration for the Nuxt Scripts library.
Description check ✅ Passed The pull request description follows the required template with all major sections completed, including linked issue, type of change selection, and detailed description of the feature.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/bing-uet
📝 Coding Plan
  • Generate coding plan for human review comments

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 sets mp.__SV and mp._i, while the runtime wraps these assignments in if (!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

📥 Commits

Reviewing files that changed from the base of the PR and between a597de9 and 8d3fa67.

📒 Files selected for processing (12)
  • docs/content/scripts/bing-uet.md
  • playground/pages/third-parties/bing-uet.vue
  • scripts/generate-sizes.ts
  • src/module.ts
  • src/registry-logos.ts
  • src/registry-types.json
  • src/registry.ts
  • src/runtime/registry/bing-uet.ts
  • src/runtime/registry/schemas.ts
  • src/runtime/types.ts
  • src/script-meta.ts
  • src/script-sizes.json

- Forward only `uetq.push` for Partytown (not root object)
- Use explicit HTTPS URL instead of protocol-relative `//`
@harlan-zw harlan-zw merged commit 696afe8 into main Mar 18, 2026
5 checks passed
@harlan-zw harlan-zw deleted the feat/bing-uet branch March 18, 2026 16:03
@harlan-zw harlan-zw restored the feat/bing-uet branch March 18, 2026 16:07
@harlan-zw harlan-zw mentioned this pull request Mar 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant