Skip to content

feat: add addon verifying the site slug has a configured source - #336

Merged
mosherBT merged 6 commits into
masterfrom
source-check-addon
Oct 5, 2026
Merged

mosherBT merged 6 commits into
masterfrom
source-check-addon

Conversation

@mosherBT

@mosherBT mosherBT commented Sep 9, 2026 •

Copy link
Copy Markdown
Contributor

Why

Multi-site publishers run pages on domains that were never provisioned as sources. Wrappers verify the site slug against the DCN before constructing the SDK and fall back to a default source so targeting still works with default enrichment; that check is copied per bundle.

What Changed

  • addons: checkSourceExists({ site, defaultSite, node?, host? }) in lib/addons/sourceCheck.ts — probes /config?purpose=check-source-exists on the edge and returns the site to use: site when the source exists, defaultSite (or default-sdk) when it does not. Verdict cached in sessionStorage, one probe per session. Any HTTP response counts as existing; only a network-level rejection marks a source missing, matching the wrapper behaviour.
  • Returns the site instead of mutating window.optable; the caller assigns it.

How to Test

Unit tests cover: probe URL and caching on success, network-failure fallback, empty-defaultSite fallback, cached hit/miss short-circuits, custom host.

  • Tested
  • Docs updated

Notes

  • Breaking change
  • Requires release

@mosherBT
mosherBT requested review from a team as code owners September 9, 2026 16:16
@mosherBT mosherBT self-assigned this Sep 9, 2026
@mosherBT
mosherBT requested review from etiennelatendresse-optable and removed request for nyssaoptable September 10, 2026 13:46
@mosherBT mosherBT changed the title sourceCheck: add addon verifying the site slug has a configured source feat: add addon verifying the site slug has a configured source Sep 10, 2026
@mosherBT
mosherBT requested a review from a team as a code owner September 28, 2026 17:22
Comment thread lib/addons/sourceCheck.ts
Comment thread lib/addons/sourceCheck.ts
Comment thread lib/addons/sourceCheck.ts Outdated
@mosherBT
mosherBT force-pushed the source-check-addon branch 2 times, most recently from f1b9419 to 812179c Compare October 1, 2026 19:32
mosherBT and others added 6 commits October 5, 2026 15:04
msw settles an aborted request with a 500 response rather than rejecting
it, so the hanging handler never reached the timeout branch: fetch
resolved, the verdict was cached as a hit and the call returned the
probed site. Stub fetch so the request rejects with an AbortError when
its signal fires, matching browser behaviour.
@mosherBT
mosherBT force-pushed the source-check-addon branch from 0121957 to 3dcd40c Compare October 5, 2026 19:04
@mosherBT
mosherBT merged commit 01e561e into master Oct 5, 2026
7 checks passed
@mosherBT
mosherBT deleted the source-check-addon branch October 5, 2026 20:09
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.

2 participants