Skip to content

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

Open
mosherBT wants to merge 1 commit into
masterfrom
source-check-addon
Open

sourceCheck: add addon verifying the site slug has a configured source#336
mosherBT wants to merge 1 commit 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
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