feat(cli): Add Analytic tracking to CLI commands#224
feat(cli): Add Analytic tracking to CLI commands#224blainekasten wants to merge 8 commits intonextfrom
Conversation
a4ad95a to
c1e4d5d
Compare
5a9095c to
5d91472
Compare
bf5b62f to
f270535
Compare
d10c649 to
66e6327
Compare
5bcfbdf to
bfb1918
Compare
eb340f4 to
47bdd7c
Compare
2b35ec4 to
86cee4c
Compare
976e374 to
9207cc2
Compare
935647e to
efcd5e9
Compare
da96a0a to
0ed4fb8
Compare
0ff5b19 to
675ace9
Compare
7154008 to
df5999f
Compare
df5999f to
0a407e9
Compare
0a407e9 to
d02d5b4
Compare
d541f65 to
2c42042
Compare
| try: | ||
| config = load_telemetry_config() | ||
| if "device_id" in config: | ||
| return cast(str, config["device_id"]) |
There was a problem hiding this comment.
should we cache the id in the config file?
if "device_id" in config:
_cached_device_id = cast(str, config["device_id"])
return _cached_device_id| help="Output in JSON format", | ||
| ) | ||
| @click.pass_context | ||
| @auto_track_command |
There was a problem hiding this comment.
should this be:
@handle_api_errors("Clusters Storage")
@auto_track_command| try: | ||
| track_cli( | ||
| CliTrackingEvents.ApiRequest, | ||
| {"url": str(request.url), "method": request.method}, |
There was a problem hiding this comment.
ooh good find here - this sends full pre-signed URLs:
commands like files upload/multipart uploads in src/together/lib/resources/files.py. Those URLs include bucket/object paths and temporary query credentials (for example X-Amz-* signatures), and custom --base-url values would leak internal hostnames as well.
| ) | ||
| raise e | ||
|
|
||
| except Exception as e: |
There was a problem hiding this comment.
only records failures for Exception, but several decorated commands still abort with sys.exit(1) on common validation paths (for example files upload, files check, endpoints create, and endpoints update). Because sys.exit() raises SystemExit, these error cases skip both CommandFailed and CommandCompleted, so telemetry will show commands that merely “started” with no outcome.
This adds analytics to the CLI. Here is an example of logs going through via the
--debugflag:Notably see the lines with
event_namein them.We are currently sending the following events:
cli_command_startedfor every command startcli_command_user_abortedif the user aborts the command before it finishescli_command_failedif the command fails with any other exceptioncli_commmand_completedfor successful completionscli_command_api_requestfor any api request that is fired within the commandUsers can opt out with:
TOGETHER_TELEMETRY_DISABLED=1ortogether telemetry disabletogether telemetryhas the following help output: