chainloop
chainloop copied to clipboard
feat(posthog): Add Telemetry client Posthog
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
Secrets on the repository updated already to the proper project.
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.
Refactored all code with:
- Moved all logic from
maintoroot. - Use a separated go routine to send the telemetry on the
persistentPreRunE. Use async.WaitGroupto 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.