feat: add X-CLI-Event header for analytics tracking#15
Draft
pjcdawkins wants to merge 1 commit intomainfrom
Draft
feat: add X-CLI-Event header for analytics tracking#15pjcdawkins wants to merge 1 commit intomainfrom
pjcdawkins wants to merge 1 commit intomainfrom
Conversation
pjcdawkins
commented
Jan 9, 2026
| } | ||
|
|
||
| // Build the transport chain: | ||
| // EventTransport (adds X-CLI-Event + User-Agent) |
Contributor
Author
There was a problem hiding this comment.
we already add User-Agent elsewhere so is this right?
4a919b8 to
1d110cf
Compare
Add a custom HTTP header to all API requests that tracks the command
name and interactive mode for analytics purposes via Pendo.
Header format: `X-CLI-Event: command=<name>; interactive=<bool>`
Example: `X-CLI-Event: command=backup:restore; interactive=true`
Users can opt out via:
- DO_NOT_TRACK=1 (or true) - standard opt-out environment variable
- {PREFIX}DISABLE_TELEMETRY=1 (e.g., UPSUN_CLI_DISABLE_TELEMETRY=1)
Go CLI changes:
- Add EventTransport to inject X-CLI-Event and User-Agent headers
- Add WithEventName/WithInteractive context helpers
- Pass event name and interactive flag via context from root command
- Pass EVENT_NAME environment variable to legacy PHP CLI
- Respect DO_NOT_TRACK and DISABLE_TELEMETRY opt-out settings
Legacy PHP CLI changes:
- Add EventHeaderMiddleware to inject X-CLI-Event header
- Add Config::getEventName() and Config::isInteractive() methods
- Register middleware in Api::getConnectorOptions()
- Respect DO_NOT_TRACK and DISABLE_TELEMETRY opt-out settings
The interactive flag is determined by the NO_INTERACTION environment
variable, which is already passed from Go to PHP.
Co-Authored-By: Claude Code <claude-code@anthropic.com>
1d110cf to
8873a01
Compare
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.
Summary
X-CLI-Event) to all API requests for analytics tracking via Pendocommand=<name>; interactive=<bool>X-CLI-Event: command=backup:restore; interactive=trueOpt-out
Users can disable telemetry via environment variables:
DO_NOT_TRACK=1(ortrue) - standard opt-out{PREFIX}DISABLE_TELEMETRY=1(e.g.,UPSUN_CLI_DISABLE_TELEMETRY=1)Changes
Go CLI
EventTransportininternal/auth/event_transport.gothat injectsX-CLI-EventandUser-AgentheadersWithEventName,WithInteractive, and corresponding gettersEVENT_NAMEenvironment variable passed to the legacy PHP CLIDO_NOT_TRACKand{PREFIX}DISABLE_TELEMETRYopt-out settingsLegacy PHP CLI
EventHeaderMiddlewarethat addsX-CLI-Eventheader to Guzzle requestsConfig::getEventName()andConfig::isInteractive()methodsApi::getConnectorOptions()DO_NOT_TRACKand{PREFIX}DISABLE_TELEMETRYopt-out settingsHeader Format
Examples:
X-CLI-Event: command=backup:restore; interactive=trueX-CLI-Event: command=project:info; interactive=falseThe
interactiveflag isfalsewhen--no-interaction,-y, or--quietflags are used, or when the{PREFIX}NO_INTERACTION=1environment variable is set.Test plan
make testcd legacy && php vendor/bin/phpunit tests/EventHeaderMiddlewareTest.php tests/ConfigTest.phpupsun project:info -vvv 2>&1 | grep -i "x-cli-event"DO_NOT_TRACK=1 upsun project:info -vvv 2>&1 | grep -i "x-cli-event"(should show nothing)🤖 Generated with Claude Code