Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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.
Expand Down Expand Up @@ -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

Expand Down
14 changes: 9 additions & 5 deletions trace-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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";
Expand Down
Loading