Repository navigation
Make every opt-out fail closed (0.5.0) - #46
Merged
Merged
Conversation
A switch that does not clearly mean "on" now turns reporting off, so an opt-out can never be read as consent (trace-client-java 0.8.0 counterpart): - TRACE_USAGE_REPORTING set to anything but blank or true/on/yes/1 now disables; only off/false/0/no did. - DO_NOT_TRACK set to anything but blank or 0/false/off/no now disables; only 1/true/yes did. - An environment that cannot be read (process.env or an env lookup throwing) now disables; it used to opt nothing out. A non-string env value disables too. No process / no process.env still opts nothing out. - The enabled option, when given, is read through the new TraceClient.allowsReporting(); only enabled: false turned it off, so "false", null, undefined or 0 reported. Left out, it defaults to on. - README examples use allowsReporting(process.env.USAGE_REPORTING_ENABLED ?? true) instead of !== "false", which read "off" or a typo as on. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This was referenced Nov 19, 2026
Merged
This was referenced Nov 20, 2026
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.
Every opt-out now fails closed: a switch that does not clearly mean "on" turns usage reporting off, so a disabled setting can never be read as consent. This is the JavaScript counterpart of Stephenson-Software/trace-client-java#51 (0.8.0).
Since 0.2.0 the client reads the environment itself (0.1.0 left that to the consumer); this brings that reading, and the
enabledoption, to the Java semantics.Fail-open paths fixed
TRACE_USAGE_REPORTINGonly turned reporting off foroff/false/0/no. Now anything but blank ortrue/on/yes/1turns it off.DO_NOT_TRACKonly turned reporting off for1/true/yes. Now anything but blank or0/false/off/noturns it off.environmentOptsOut()caught an unreadable environment and returnedfalse, andprocessEnvironment()swallowed a throwingprocess.envas an empty one. Both now count as opting out. A non-stringenvvalue (untyped code) opts out too. A runtime with noprocess/ noprocess.envstill opts nothing out.enabled === false, soenabled: "false",null,undefinedor0from a config file or untyped code reported. When given,enabledis now read throughallowsReporting(); left out, it still defaults to on.process.env.USAGE_REPORTING_ENABLED !== "false", which readsoff,FALSEor a typo as on. They now useTraceClient.allowsReporting(process.env.USAGE_REPORTING_ENABLED ?? true); the CHANGELOG tells consumers who copied the old line to switch.New helper
TraceClient.allowsReporting(value), a static member like the other post-0.1.0 additions, so the module's exported values are unchanged. True only fortrueor a stringtrue/on/yes/1(any case, trimmed).The client reads no config-file switch of its own (the install-ID file holds only an ID), so the file rules do not apply.
Version
0.4.1 → 0.5.0 in
package.json,package-lock.json, the header comment,TRACE_CLIENT_VERSIONand the README User-Agent line. CHANGELOG entry under[Unreleased].Tests
npm test: 90 tests, 90 pass.npm run typecheck: clean. Tests pinning the fail-open behaviour (non-string values and throwing environments opting nothing out,disabledleaving reporting on) were updated; new tests cover unfamiliar values for both variables,allowsReporting, and theenabledoption.🤖 Generated with Claude Code
drafted by Claude on behalf of Daniel Stephenson