Skip to content

feat: add reportMisconfiguration flag to detect 403/404 on site config#280

Open
MO-Thibault wants to merge 3 commits intoOptable:masterfrom
MO-Thibault:mo/report-misconfiguration
Open

feat: add reportMisconfiguration flag to detect 403/404 on site config#280
MO-Thibault wants to merge 3 commits intoOptable:masterfrom
MO-Thibault:mo/report-misconfiguration

Conversation

@MO-Thibault
Copy link
Copy Markdown
Contributor

Summary

  • Adds reportMisconfiguration?: boolean to InitConfig / ResolvedConfig
  • When enabled, catches 403/404 from the Site() call during SDK initialization
  • Fires a best-effort profile() to the default-sdk catch-all source with { error_403: hostname } or { error_404: hostname }
  • 403/500/other errors, or flag not set → no profile call

How it works

FetchError (new) exposes the HTTP status on thrown errors, allowing initialize() to distinguish 403/404 from generic network failures. The profile call uses { ...this.dcn, site: 'default-sdk' } — same host and node, but the guaranteed catch-all slug present in every DCN — so delivery is reliable even when the original slug is the source of the problem.

Usage

new OptableSDK({
  host: "na.edge.optable.co",
  site: window.optable.site,
  reportMisconfiguration: true,
  // ...
});

Test plan

  • reportMisconfiguration: true + 403 → profile fired with { error_403: "localhost" } to o=default-sdk
  • reportMisconfiguration: true + 404 → profile fired with { error_404: "localhost" } to o=default-sdk
  • reportMisconfiguration: false + 403 → no profile call
  • flag not set + 403 → no profile call
  • reportMisconfiguration: true + 500 → no profile call
  • All existing SDK tests pass

🤖 Generated with Claude Code

MO-Thibault and others added 3 commits May 9, 2026 17:15
When enabled, catches 403/404 errors from the Site() call during SDK
initialization and fires a best-effort profile() to the default-sdk
catch-all source with { error_403: hostname } or { error_404: hostname }.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
…rror

Network/CORS errors throw TypeError, not FetchError, so the instanceof
check was silently swallowing misconfiguration signals. Now fires on any
Site() failure: named keys for 403/404, error_config for network errors.
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