Skip to content

docs: document the web SDK first-party collection domain - #195

Open
tashviks wants to merge 3 commits into
mainfrom
tashvik/web-sdk-domain-routing
Open

docs: document the web SDK first-party collection domain#195
tashviks wants to merge 3 commits into
mainfrom
tashvik/web-sdk-domain-routing

Conversation

@tashviks

@tashviks tashviks commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Companion to linkrunner-labs/web-sdk#10, which adds the data-domain attribute.

What

A new First-party collection domain (recommended) section on /sdk/web, under Configuration. Four steps: register the subdomain in Settings → Manage Domains, CNAME it to api.linkrunner.io, add data-domain to the script tag, verify.

Shown for all three surfaces the SDK supports: the script tag, <LinkrunnerScript domain="…" />, and window.LinkrunnerConfig.

Why

Ad blockers match a request by its domain, so events sent to api.linkrunner.io are dropped in the browser for roughly a quarter of desktop visitors. Collecting from a subdomain of the customer's own site is what survives that, and until now the only way to set one up was for us to ship a mapping inside the bundle, keyed to their token. This documents the self-serve path.

Details worth a look in review

  • Hostname, not a URL. Called out in a <Note>, because the collection path belongs to us and can change; naming only the host means their page keeps working without an edit.
  • A verification step. The curl -i -X OPTIONS preflight check, expecting 204 with access-control-allow-origin. A CNAME and a certificate alone are not enough, and anything they put in front of the subdomain (WAF, bot filter, auth proxy) sits in the path too.
  • The two-requests-per-event symptom, in a <Warning> with what it means and what to check.

Follows the repo writing rules: no em-dashes, second person, <Steps>/<Note>/<Warning> components, bold for UI labels and backticks for code identifiers.

Not addressed here

The rest of sdk/web.mdx is stale against the shipped SDK — it documents sdk.linkrunner.io/latest/linkrunner-sdk.min.js, a bare token= attribute, and @linkrunner/web-sdk / useLinkrunner, where the package is @linkrunner/web served from cdn.linkrunner.io/web/v1/lr.js with data-token. My section uses the real names, so it now sits beside snippets that contradict it. Left out of this PR to keep the diff reviewable; happy to bring the page in line in a follow-up if you want it.

No screenshots: every step here is a DNS record, a script tag, or a terminal command. The Settings → Manage Domains step is the only UI touch and could take one if you'd prefer.

🤖 Generated with Claude Code

Adds the data-domain section to /sdk/web: register the subdomain, CNAME it,
name it in the script tag, verify.

Ad blockers match a request by its domain, so events sent to api.linkrunner.io
are dropped in the browser for roughly a quarter of desktop visitors. Collecting
from a subdomain of the customer's own site is what survives that, and until now
the only way to set one up was for us to ship a mapping inside the bundle.

Covers the hostname-not-a-URL rule (the collection path can change, and naming
only the host means their page follows it), the OPTIONS preflight check so they
can confirm the subdomain actually serves the collector before relying on it,
and the two-requests-per-event symptom with what it means.

Companion to linkrunner-labs/web-sdk#10.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@tashviks
tashviks requested a review from RathodDarshil August 25, 2026 05:14
tashviks and others added 2 commits August 25, 2026 18:39
Integrators had no way to know what is validated before an event is accepted,
which is the thing that tells them where each event belongs. A token is required
(400 without one, 401 if unknown), an event_type or event_name is required,
requests over 64 KB are rejected, and string fields truncate at 2048 characters.

The part worth spelling out is that the token is public by design. It is in the
page source of every site running the SDK, so it identifies a project rather than
authenticating a sender, and a 401 says a token is unknown rather than saying who
sent the request. Without that stated, the 401 reads as an access control and
browser events look more trustworthy than they are.

Ends with the practical rule: behavioral analytics from the browser, anything
that grants access or moves money from the backend.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
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