From e5111c40a1289d27b67945bcd7380e999e03324f Mon Sep 17 00:00:00 2001 From: Daniel McCoy Stephenson Date: Thu, 12 Nov 2026 20:21:40 -0700 Subject: [PATCH] Say the tag cap counts version, and what untyped version/installId do The 32-tag count that stops the install tag includes the version tag the client adds, so an event passing 31 tags of its own goes without install; the README and MAX_TAGS doc comment read as if only the event's own tags counted. The README and TSDoc also now say a non-string version throws and a non-string installId counts as none, as the code and tests already do. No behavior changed. Co-Authored-By: Claude Opus 5.5 --- CHANGELOG.md | 5 +++++ README.md | 14 +++++++++----- trace-client.ts | 14 +++++++++----- 3 files changed, 23 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 902d945..0d3914c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -60,6 +60,11 @@ against this file to see what a re-vendor would bring. `pagePath()` returns `/` for a non-string or an unparseable URL. The `MAX_VERSION_LENGTH` doc comment now says it bounds `installId` too. No behavior changed. +- The README and the `MAX_TAGS` doc comment now say that the 32-tag count + includes the `version` tag the client adds, so an event that passes 31 + tags of its own goes without `install`. They also say that a `version` + that is not a string throws, and that an `installId` that is not a string + counts as none. No behavior changed. ## 0.4.1 — 2026-10-05 diff --git a/README.md b/README.md index 4814bf3..08e407b 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ await trace.close(); The `version` option is the program's own version, and it is required (`TraceClientOptions.version` is typed `string`, not optional): a missing or -blank one, or one over 255 characters after trimming, throws an `Error`. It +blank one, one that is not a string, or one over 255 characters after +trimming, throws an `Error`. It is trimmed, then sent as the tag `version` on every event the client sends — `startup`, `page-view`, `command`, anything else — so every event can be tied to a release, not just `startup`. An event that passes its own @@ -81,7 +82,7 @@ const trace = new TraceClient(url, "my-game", { — or passes an ID it stores itself: ```ts -new TraceClient(url, "my-game", { version, key, installId: settings.installId }); // null or blank: none sent +new TraceClient(url, "my-game", { version, key, installId: settings.installId }); // null, blank or not a string: none sent ``` `installIdFile` uses `TraceClient.installIdFromFile(path)`: the first line @@ -97,7 +98,9 @@ characters throws, the same as `version`. `trace.installId` is the ID in use (`null` when disabled or when there is none), so a program can print it. An event that passes its own `install` tag keeps it, and the tag is not added to an event that already has 32 tags -(`TraceClient.MAX_TAGS`). +(`TraceClient.MAX_TAGS`). That count includes the `version` tag the client +adds, so an event that passes 31 tags of its own, none of them `version`, +goes without `install`. **Resetting it.** Delete the file (or its ID line); the next start writes a new one. Or put your own value in it. @@ -153,8 +156,9 @@ conversion throws drops the whole report, with a `debug` line. The limits are also available as `TraceClient.TIMEOUT_MS` (5000), `TraceClient.IN_FLIGHT_CAPACITY` (256), `TraceClient.MAX_VERSION_LENGTH` -(255, which bounds `installId` too) and `TraceClient.MAX_TAGS` (32, past -which the `install` tag is not added; an event's own tags are not capped). +(255, which bounds `installId` too) and `TraceClient.MAX_TAGS` (32, counting +the `version` tag, past which the `install` tag is not added; an event's own +tags are not capped). ## Turning it off from the environment diff --git a/trace-client.ts b/trace-client.ts index 860d07a..9f3fe04 100644 --- a/trace-client.ts +++ b/trace-client.ts @@ -56,8 +56,9 @@ const MAX_TIMER_MS = 2147483647; export interface TraceClientOptions { /** * The program's own version, required. Sent as the tag `version` on every - * event; an event's own `version` tag wins. Trimmed; blank, missing, or - * longer than {@link TraceClient.MAX_VERSION_LENGTH} characters throws. + * event; an event's own `version` tag wins. Trimmed; blank, missing, not a + * string, or longer than {@link TraceClient.MAX_VERSION_LENGTH} characters + * throws. */ version: string; /** The program's write key. Blank, missing or not a string yields a client that does nothing. */ @@ -87,8 +88,8 @@ export interface TraceClientOptions { * The installation's ID, sent as the tag `install` on every event so the * trace server can count installations rather than events. It should be * random -- e.g. a `crypto.randomUUID()` the program stores itself -- and - * never derived from a person, account or address. Trimmed; missing or - * blank means none; longer than {@link TraceClient.MAX_VERSION_LENGTH} + * never derived from a person, account or address. Trimmed; missing, + * blank or not a string means none; longer than {@link TraceClient.MAX_VERSION_LENGTH} * characters throws. Wins over `installIdFile`. */ installId?: string | null; @@ -164,7 +165,10 @@ export class TraceClient { static readonly TIMEOUT_MS = 5000; /** The longest program version, or `installId`, accepted after trimming. */ static readonly MAX_VERSION_LENGTH = 255; - /** The `install` tag is not added to an event that already has this many tags; its own tags are not capped. */ + /** + * The `install` tag is not added to an event that already has this many + * tags, counting the `version` tag the client adds; its own tags are not capped. + */ static readonly MAX_TAGS = 32; /** The tag every event carries the installation's ID as. */ static readonly INSTALL_TAG = "install";