Skip to content

fix(audience): bundle core subpath + support X/Google dedup - #2933

Merged
JCSanPedro merged 2 commits into
mainfrom
sdk-audience-fix-internal-bundle-add-x-google
Jul 29, 2026
Merged

fix(audience): bundle core subpath + support X/Google dedup#2933
JCSanPedro merged 2 commits into
mainfrom
sdk-audience-fix-internal-bundle-add-x-google

Conversation

@JCSanPedro

@JCSanPedro JCSanPedro commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Two related audience-SDK changes.

1. fix: bundle workspace-dep subpaths into the published package

Regression from #2928 (tsup → tsdown build migration, 2026-07-28). The audience build previously used tsup, whose noExternal (fed the bare-name BUNDLED_WORKSPACE_DEPS list) inlined @imtbl/audience-core and its subpaths. #2928 migrated the build to tsdown, moving the same bare-name list to deps.alwaysBundle — but tsdown's matcher only matches the bare package name, not subpaths. So the @imtbl/audience-core/internal import (added harmlessly back in #2881, 2026-06-09) started leaking out as an external import.

Because @imtbl/audience-core is private: true (never published) and prepack strips it from dependencies, the published package throws MODULE_NOT_FOUND for @imtbl/audience-core/internal at runtime (jest, bundlers, any npm consumer).

Affected releases: only 2.24.0 and the 2.23.1-0 alpha (both published 2026-07-29, after the migration). 2.23.0 and earlier — built with tsup — resolve fine, which is why Play main (pinned to 2.23.0) is green and this only surfaced on the branch that bumped past the migration.

Fix: derive alwaysBundle matchers from the dep list as regexes that also match subpaths (^@imtbl/audience-core(/.*)?$), restoring the tsup behavior. tsdown accepts regex matchers (the CDN build already uses alwaysBundle: [/.*/]).

2. feat: support X and Google in trackConversion dedup

Add x and google to DEDUP_CAPABLE_NETWORKS so trackConversion mints and stamps a shared conversion id for those visits. X dedups on conversion_id, Google on transaction_id/order_id, both keyed on the same client-minted value the postbacks builders reuse server-side. This lets Game Page add X/Google pixels later with no further SDK coordination.

Note: Google server-side dedup also depends on the postbacks upload sending the id as order_id (separate platform-services migration PR).

Test plan

  • CI build + @imtbl/audience tests pass
  • Packed tarball's dist/{browser,node}/index.js has no external @imtbl/audience-core/internal import (inlined)
  • After release, Play bumps to the new version and CI goes green

The tsdown alwaysBundle list matched bare package names only, so the
`@imtbl/audience-core/internal` subpath import leaked out as an external
dependency in the published bundle. Because `@imtbl/audience-core` is
private and never published (and prepack strips it from dependencies),
`npm install @imtbl/audience` produced a package that fails to resolve
`@imtbl/audience-core/internal` at runtime. Match subpaths too so the
whole workspace dep is inlined.
Add x and google to DEDUP_CAPABLE_NETWORKS so trackConversion mints and
stamps a shared conversion id for those visits. X dedups on conversion_id
and Google on transaction_id/order_id, both keyed on the same client-minted
value the postbacks builders reuse server-side.
@nx-cloud

nx-cloud Bot commented Jul 29, 2026

Copy link
Copy Markdown

View your CI Pipeline Execution ↗ for commit 2670531

Command Status Duration Result
nx release publish --tag alpha ✅ Succeeded 39s View ↗
nx run-many -p @imtbl/sdk,@imtbl/checkout-widge... ✅ Succeeded 1m 14s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-07-29 03:18:52 UTC

@github-actions

Copy link
Copy Markdown

✅ Audience Bundle Size — @imtbl/audience

Metric Size Delta vs main (416cfe2)
Gzipped 11641 bytes (11.36 KB) +5 bytes
Raw (minified) 32663 bytes +13 bytes

Budget: 24.00 KB gzipped (warn at 20.00 KB)

@JCSanPedro
JCSanPedro marked this pull request as ready for review July 29, 2026 03:21
@JCSanPedro
JCSanPedro requested a review from a team as a code owner July 29, 2026 03:21
@JCSanPedro
JCSanPedro added this pull request to the merge queue Jul 29, 2026
Merged via the queue into main with commit d3ff259 Jul 29, 2026
10 checks passed
@JCSanPedro
JCSanPedro deleted the sdk-audience-fix-internal-bundle-add-x-google branch July 29, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants