Skip to content

WIP: Record one cli.command telemetry event per run - #46

Draft
zmofei wants to merge 4 commits into
mainfrom
telemetry-events
Draft

zmofei wants to merge 4 commits into
mainfrom
telemetry-events

Conversation

@zmofei

@zmofei zmofei commented Sep 24, 2026 •

Copy link
Copy Markdown
Member

WIP — not ready for review.

Each run now records one cli.command telemetry event, following the draft schema in the Telemetry proposal. By default the event is appended to ~/.mapbox/.telemetry/<UTC date>.jsonl (kept 7 days) and nothing leaves the machine.

What's in it

  • src/telemetry_event.rs: decides what the event contains. It collects what the run reports (command path, invocation, params, options, token prefix and account, exit and error codes, stdout bytes, duration, requests), and builds the event at exit.
  • src/telemetry_sink.rs: where the event goes. A Sink trait with two implementations; selected() is the one place that picks one:
    • FileSink (used today) appends one JSON line per run. It's for local testing.
    • HttpSink is the interface for Mapbox Events, with its contract written down. It's not implemented, so it isn't selected.
  • Parameters: a value is sent only for enums, booleans, spec-typed numbers and language/country/types. Free strings send their length, --file its size, --data its size and top-level keys. lon/lat send their name only.
  • Every request now goes through a new http::send, which records it. A new source guard, only_http_sends_requests, keeps it that way.
  • Opt-out: MAPBOX_CLI_NO_TELEMETRY=1. A persisted mapbox config set telemetry off is in the stacked PR WIP: Add a persisted telemetry setting to mapbox config #47.
  • A panic is recorded as errorCode: "panic". completion records nothing, since it runs at every shell startup.

Behavior changes to confirm

  • Every run now creates ~/.mapbox/.telemetry/, including runs that previously touched nothing on disk. tests/non_interactive.rs was narrowed to allow that directory after a refused auth login.

Before HttpSink is implemented

  • cli.command has to be registered in mapbox/event-schema and get a warehouse table.
  • The README privacy disclosure has to be rewritten: it still says "never the operation or its arguments". This PR only adds a short note about the local file.
  • Legal review of the collected fields.

Not checked

  • The Windows tilesets-cli exit path hasn't been compiled locally.
  • Nothing is sent anywhere yet. HttpSink is an interface only.
  • installMethod is inferred from the binary's location, so it reads other when MAPBOX_INSTALL_DIR was used.

Each run builds one event from what the command reports as it runs (the
parse, the token, each request, stdout bytes, the error code) and hands it
to a sink at exit: a JSON line in ~/.mapbox/.telemetry/<date>.jsonl by
default, or Mapbox Events through a detached child with
MAPBOX_CLI_TELEMETRY_SINK=api. Argument values leave only when they come
from a fixed set; free strings are sent as a length, files as a size.

Every request now goes through http::send, which records it; a source
guard holds that.
telemetry.rs is the User-Agent markers; the event is a separate module, and
its name should say it is telemetry rather than a generic "events".
telemetry_event decides what the event contains; telemetry_sink decides
where it goes. FileSink writes the local file for testing; HttpSink is the
interface for Mapbox Events, documented but not implemented, so the
detached sender, http::bare_client and the sink/debug variables are gone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant