Repository navigation
feat: name hosted collectors, allow reporting-only beacons - #1
Merged
Merged
Conversation
Beacon is a protocol client, but the endpoint default only ever named
SnowSEO, so pointing it at any other collector meant spelling out a full
URL — and getting that URL subtly wrong (a bare origin, or the wrong
mount path) fails as an opaque 401 rather than a 404.
`analytics.collector` now takes a name from the exported COLLECTORS map
("snow-analytics" or "snowseo") and fills the endpoint in. `endpoint`
still wins, for self-hosted collectors.
A pure analytics install also had to carry three options whose only job
was to switch off features it never asked for: `siteUrl`, a
`resolve: () => null` that existed to satisfy a constructor check, and
`strictNegotiation: false` to stop the beacon answering 406 for the
site's own JSON endpoints. All three are gone:
createBeacon({ analytics: { key, collector: "snow-analytics" } })
- `createBeacon` with `analytics` and no `dir`/`resolve` is now a valid
reporting-only install instead of a thrown error.
- `strictNegotiation` defaults to false for reporting-only beacons and
stays true when twins are served. Explicit values override both.
- `siteUrl` is optional, and required only by the methods that mint
absolute URLs, which throw an error naming it.
- `host` is optional on the wire: a key belongs to one site, so the
collector resolves it. The client omits it only when given neither
`siteUrl` nor `analytics.host`; beacon-server falls back to the key's
host when the key names exactly one, and answers 400 when it names
several, where guessing would file hits under the wrong site. A
present-but-empty host is still rejected.
Existing installs are unaffected: anything passing siteUrl sends host
exactly as before, and the endpoint default is still SnowSEO.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Beacon is a protocol client, but the endpoint default only ever named SnowSEO, so pointing it at any other collector meant spelling out a full URL — and getting that URL subtly wrong (a bare origin, or the wrong mount path) fails as an opaque
401rather than a 404.A pure analytics install also carried three options whose only job was to switch off features it never asked for:
siteUrl, aresolve: () => nullthat existed to satisfy a constructor check, andstrictNegotiation: falseto stop the beacon answering406for the site's own JSON endpoints.After
Changes
analytics.collectortakes a name from the new exportedCOLLECTORSmap ("snow-analytics"|"snowseo") and fills in the ingest URL.endpointstill wins, for self-hosted collectors.createBeacon({ analytics })with nodir/resolveis a valid install instead of a thrown error.strictNegotiationdefaults tofalsefor reporting-only beacons, staystruewhen twins are served. Explicit values override both.siteUrlis optional, required only by the methods that mint absolute URLs, which throw an error naming it.hostis optional on the wire. A key belongs to one site, so a collector can resolve it. The client omits it only when given neithersiteUrlnoranalytics.host;beacon-serverfalls back to the key's host when the key names exactly one, and answers400when it names several, where guessing would file hits under the wrong site. A present-but-emptyhostis still rejected.Compatibility
Existing installs are unaffected: anything passing
siteUrlsendshostexactly as before, and the endpoint default is still SnowSEO. Both packages bumped to 0.1.8.Verification
pnpm check,build,type-check,test— 282 tests pass (198 beacon + 84 beacon-server), plusexamples:type-checkandexamples:build, i.e. every gate CI runs.siteUrland nohostposted a GPTBot hit and got200, and the server resolved the site from the key (verified by the crawler-detected milestone landing on the right site).🤖 Generated with Claude Code