Repository navigation
Tag every event with an optional random installation ID (0.3.0) - #5
Merged
Merged
Conversation
Port of trace-client-java 0.5.0's per-installation ID. A new constructor overload takes a trace_client::InstallId: InstallId::of(id) for an ID the program stores itself, InstallId::fromFile(path) for a random UUID kept in a file the program chooses (TraceClient::installIdFromFile). It is resolved only after every opt-out, so a disabled client never makes up or writes an ID. Every event carries it as the tag "install" unless the event has its own or is already at the 32-tag cap. installId() returns the ID in use. 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 C++ client, and bumps the client to 0.3.0 (
TRACE_CLIENT_VERSION, header comment, CMake project version, User-Agent in the README).What changes
trace_client::InstallId— where an installation's ID comes from:InstallId::of(id)— an ID the program stores itself. Trimmed; blank means none; over 255 bytes is handled exactly like an overlong version (no throw, client disabled with reason"unavailable").InstallId::fromFile(path)— a random UUID kept in a file the program chooses.idwins and the file is not touched.TraceClient(baseUrl, application, version, key, const InstallId &install, bool enabled = true, Logger logger = Logger()). The existing constructor is unchanged and sends noinstalltag.static std::string TraceClient::installIdFromFile(const std::string &path)— reads the first line that is 1–255 chars of[A-Za-z0-9_.-]; when the file is missing or has none, writes a fresh v4 UUID (parent directories created). A path that exists but cannot be read is never overwritten; any read/write failure yields an in-memory UUID for the run. Never throws.const std::string &TraceClient::installId() const— the ID in use; empty when disabled or none.installafterversionis applied (detail::withInstall), unless the event carries its owninstallor already has 32 tags.TRACE_USAGE_REPORTING/DO_NOT_TRACK,enabled = false, no key, unavailable), so a disabled client never generates or writes one. CallinginstallIdFromFiledirectly writes regardless, which the README and header comment say.<random>/<fstream>plusstat/mkdir(_stat/_mkdiron Windows); nostd::filesystem.Tests
Ten new tests in
test/test_trace_client.cppmirroring the Java ones: UUID v4 format, persist once + reuse (nested dirs created), first valid line read / invalid-only file replaced, unusable path (under a regular file, a directory, empty) → in-memory and nothing written, every event carries the file's ID, disabled clients (config, no key, unavailable, both env opt-outs) write nothing, explicit ID trimmed and wins over the file, blank = none / overlong rejected / exactly 255 accepted, event's owninstallwins, tag cap respected (helper and end to end).Locally (g++ 9.4):
make testat c++11, c++17 and c++2a → 41 tests, 0 failed checks;-fsanitize=address,undefined→ 41/0; CMake build → 41/0. Not verifiable locally (left to CI): clang++,-fsanitize=thread(libtsan missing), libcurl transport, macOS, Windows/MSVC.🤖 Generated with Claude Code
https://claude.ai/code/session_014ztkfamsbEqQfcu76me5SL
drafted by Claude on behalf of Daniel Stephenson