Repository navigation
Tag every event with a random per-installation ID (0.4.0) - #7
Merged
Merged
Conversation
Port of trace-client-java 0.5.0's install ID: new installId and installIdFile options, TraceClient.installIdFromFile(path), the installId accessor, and the install tag on every event (an event's own install tag wins; never past the 32-tag cap). Resolved only after the opt-outs, so a disabled client never generates or writes an ID. node:fs is reached through process.getBuiltinModule at call time, so edge runtimes still load the file and fall back to an in-memory ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014ztkfamsbEqQfcu76me5SL
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.
Ports trace-client-java 0.5.0's per-installation ID to the JS/TS client, so the trace server can count distinct installations rather than raw events. Version bumped 0.3.0 → 0.4.0 (minor; API-compatible — nothing changes unless a new option is passed).
What changes
installId— an ID the program stores itself. Trimmed;null/undefined/blank means none; over 255 characters throws, the same way an overlongversiondoes.installIdFile— a path the program chooses. Read, or created with a random UUID, viaTraceClient.installIdFromFile(path).installIdwins over it.TraceClient.installIdFromFile(path)(static): the first line matching[A-Za-z0-9_.-]{1,255}(trimmed) is the ID; a missing file, or one with no such line, gets a freshcrypto.randomUUID()written to it (parent directories created). A file that exists but cannot be read (e.g. a directory), any write failure, a blank path, or a runtime withoutnode:fsyields an in-memory UUID; it never throws. There is no default location.trace.installIdgetter: the ID in use,nullwhen disabled or none configured.install(applied afterversion); an event's owninstalltag wins, and it is not added once an event already has 32 tags (TraceClient.MAX_TAGS). Also exposed:TraceClient.INSTALL_TAG.TRACE_USAGE_REPORTING,DO_NOT_TRACK,enabled: false, no key): a disabled client never reads, generates or writes an ID.Edge runtimes
No top-level
node:fsimport was added. The file is reached throughprocess.getBuiltinModule("node:fs")(Node 22.3+) at call time, and only wheninstallIdFileis used; where that is missing (Next.js Edge, Workers, older Node) the ID is kept in memory.npm run typecheckstill passes against ES2022 + DOM with no@types/node, and the module's exported values are unchanged (the new API hangs offTraceClient).Docs and tests
installIdnull, no ID configured → no tag, explicit ID wins/blank = none/overlong throws, eventinstalltag override, 32-tag cap, nogetBuiltinModule→ in-memory.npm ci && npm run typecheck && npm test— 53 tests, 53 passing (Node 22).Not tagged or released; consumers are not touched.
🤖 Generated with Claude Code
https://claude.ai/code/session_014ztkfamsbEqQfcu76me5SL
drafted by Claude on behalf of Daniel Stephenson