Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Telemetry #465

Merged
merged 27 commits into from
Jan 10, 2025
Merged

Telemetry #465

merged 27 commits into from
Jan 10, 2025

Conversation

shazarre
Copy link
Contributor

@shazarre shazarre commented Nov 26, 2024

Description

This PR adds telemetry to celocli.

Other changes

Removes unnecessary postinstall hook invocation.

Tested

Ran tests locally and on CI. Ran actual code locally to make sure telemetry is being sent.

For detailed testing please see the how to QA instructions below.

How to QA

First make sure that you start fresh with the telemetry notice:

$ rm ~/.config/@celo/celocli/.telemetry

Also make sure that telemetry is neither explicitly enabled nor disabled in the config:

$ cat ~/.config/@celo/celocli/config.json | jq '.' 

{
  "node": "http://127.0.0.1:8578",
  "derivationPath": "m/44'/52752'/0'"
}

the JSON should not contain telemetry property, if it does, remove it.

Run a command (with DEBUG on to see debug information):

$ DEBUG="celocli:telemetry" yarn workspace @celo/celocli run dev network:parameters --node alfajores

(...)
celocli is now gathering anonymous usage statistics. 
    
None of the data being collected is personally identifiable and no flags or arguments are being stored nor transmitted.
          
Data being reported is:
  - command (for example network:info)
  - celocli version (for example 5.2.3)
  - success status (true/false)
          
If you would like to opt out of this data collection, you can do so by running:
    
celocli config:set --telemetry 0
    
  celocli:telemetry Sending telemetry data: celocli_invocation{success="true", version="6.0.0", command="network:parameters"} 1 +0ms
  celocli:telemetry Failed to send telemetry data: AbortError: This operation was aborted +1s

You should see the telemetry notice and debug information about successfully sending the usage information.

Consequent run should not display the notice, but you should still see the debug information:

$ DEBUG="celocli:telemetry" yarn workspace @celo/celocli run dev network:parameters --node alfajores

(...)
  celocli:telemetry Sending telemetry data: celocli_invocation{success="true", version="6.0.0", command="network:parameters"} 1 +0ms
  celocli:telemetry Telemetry data sent successfuly +692ms

Now set telemetry config value to 0, debug information should show that telemetry is disabled:

$ DEBUG=celocli:telemetry yarn workspace @celo/celocli run dev config:set --telemetry 0
(...)

  celocli:telemetry Telemetry is disabled +0ms

Now run a command and you should see again that telemetry is disabled.

$ DEBUG="celocli:telemetry" yarn workspace @celo/celocli run dev network:parameters --node alfajores

(...)
  celocli:telemetry Telemetry is disabled +0ms

Now set a different config value, telemetry should stay disabled:

DEBUG=celocli:telemetry yarn workspace @celo/celocli run dev config:set --node alfajores
(...)
  celocli:telemetry Telemetry is disabled +0ms

Display the config and make sure telemetry is false:

$ cat ~/.config/@celo/celocli/config.json | jq '.' 

{
  "node": "https://alfajores-forno.celo-testnet.org",
  "derivationPath": "m/44'/52752'/0'",
  "telemetry": false
}

Verify by running a command and you should see again that telemetry is still disabled.

$ DEBUG="celocli:telemetry" yarn workspace @celo/celocli run dev network:parameters --node alfajores

(...)
  celocli:telemetry Telemetry is disabled +0ms

Now set telemetry config value to 1, debug information should show that telemetry is enabled:

$ DEBUG=celocli:telemetry yarn workspace @celo/celocli run dev config:set --telemetry 1
(...)

  celocli:telemetry Sending telemetry data: celocli_invocation{success="true", version="6.0.0", command="config:set"} 1 +0ms
  celocli:telemetry Telemetry data sent successfuly +730ms

Now run a command and you should see again that telemetry is being sent.

$ DEBUG="celocli:telemetry" yarn workspace @celo/celocli run dev network:parameters --node alfajores

(...)
  celocli:telemetry Sending telemetry data: celocli_invocation{success="true", version="6.0.0", command="network:parameters"} 1 +0ms
  celocli:telemetry Telemetry data sent successfuly +575ms

PR-Codex overview

This PR introduces telemetry functionality to collect usage statistics for the celocli tool, allowing users to enable or disable data collection through configuration. It also updates tests and documentation to reflect these changes.

Detailed summary

  • Added TELEMETRY_ENABLED environment variable handling.
  • Introduced reportUsageStatisticsIfTelemetryEnabled for usage reporting.
  • Updated BaseCommand to call telemetry reporting.
  • Added --telemetry flag to config:set command.
  • Updated CeloConfig to include telemetry field.
  • Created tests for telemetry data sending and configuration.
  • Enhanced documentation with telemetry usage instructions.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Nov 26, 2024

⚠️ No Changeset found

Latest commit: b68673c

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link

codecov bot commented Nov 26, 2024

Codecov Report

Attention: Patch coverage is 89.09091% with 6 lines in your changes missing coverage. Please review.

Project coverage is 76.26%. Comparing base (79cd947) to head (b68673c).
Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #465      +/-   ##
==========================================
+ Coverage   76.18%   76.26%   +0.07%     
==========================================
  Files         245      246       +1     
  Lines       10310    10365      +55     
  Branches     1630     1635       +5     
==========================================
+ Hits         7855     7905      +50     
+ Misses       2366     2335      -31     
- Partials       89      125      +36     
Components Coverage Δ
celocli 86.49% <89.09%> (+0.06%) ⬆️
sdk 68.96% <ø> (ø)
wallets 73.30% <ø> (ø)
viem-sdks 95.08% <ø> (ø)

@aaronmgdr
Copy link
Member

aaronmgdr commented Dec 4, 2024

some thoughts. The info here takes up a lot of space. Im worried people want to opt out just to avoid seeing the annoying warning every time they run a command.

yarn celocli config:set --telemetry 1

celocli is now gathering anonymous usage statistics.

None of the data being gathered is personally identifiable and no flags or arguments are being stored.

Data being reported is:
  - command (for example network:info)
  - celocli version (for example 5.2.3)
  - success status (0/1)

If you would like to opt out of this data collection, you can do so by running:

celocli config:set --telemetry 0


Thanks for using the celocli! We are interested in your feedback.
Let us know at github.com/celo-org/developer-tooling/discussions/92

lets discuss solutions

@aaronmgdr
Copy link
Member

made discussion to show on message on install, first time the first command is run post install and if telemetry is turned back on

Copy link

gitguardian bot commented Dec 12, 2024

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
14107627 Triggered Generic High Entropy Secret 095058c packages/cli/src/commands/account/new.test.ts View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

@shazarre shazarre self-assigned this Dec 13, 2024
@shazarre shazarre marked this pull request as ready for review December 20, 2024 10:59
@shazarre shazarre requested a review from a team as a code owner December 20, 2024 10:59
},
signal: controller.signal,
body: `
${telemetryData}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im surprised you can send plain text as octet-stream, thought you had to transmit as a blob/buffer kind of body

Copy link
Contributor

@nicolasbrugneaux nicolasbrugneaux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice work!

@shazarre shazarre changed the title [WIP] Telemetry Telemetry Dec 20, 2024
@shazarre shazarre merged commit df052a1 into master Jan 10, 2025
37 of 50 checks passed
@shazarre shazarre deleted the shazarre/Telemetry branch January 10, 2025 13:46
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.

3 participants