chainloop icon indicating copy to clipboard operation
chainloop copied to clipboard

feat(posthog): Add Telemetry client Posthog

Open javirln opened this issue 1 year ago • 2 comments

This PR creates a new implementation of a Tracker client based on Posthog.

Users can deactivate telemetry by setting the env variable DO_NOT_TRACK=1, it follows the convention at: https://consoledonottrack.com/

Information being tracked:

  • System information (OS, ARCH)
  • Command ran
  • CI Runner information if detected
  • CLI version
  • Hashed Control Plane URL
  • Anonymous device ID
  • User and Organization if logged in

Refs: #780

javirln avatar May 15 '24 18:05 javirln

Secrets on the repository updated already to the proper project.

javirln avatar May 16 '24 16:05 javirln

Do not show debug messages by default, especially the one about telemetry enabled

I've moved the message to the root command. I was not able to set the proper flag from outside not making the logger to be consistent with the logging level. I even tried the global setting from zerlog without luck.

javirln avatar May 17 '24 10:05 javirln

Refactored all code with:

  • Moved all logic from main to root.
  • Use a separated go routine to send the telemetry on the persistentPreRunE. Use a sync.WaitGroup to wait for it in case it's slow.
  • Refactored pase of the jwt token in a generic way, otherwise we would have to cast the token to each type of claim coupling backend and CLI due to types being on the backend.
  • Added more tests with empty fields and random tokens.

javirln avatar May 20 '24 08:05 javirln