atmos icon indicating copy to clipboard operation
atmos copied to clipboard

Telemetry - `atmos` cmd

Open goruha opened this issue 5 months ago โ€ข 3 comments

what

  • Added telemetry to atmos custom command

why

  • Collect info about usage atmos commands

References

  • #1308

Summary by CodeRabbit

  • New Features

    • Introduced anonymous telemetry to collect usage data and improve the product, with clear opt-out options via configuration or environment variables.
    • Added configuration options for telemetry, including enablement, endpoint, and token settings.
    • Telemetry events now capture command executions, errors, CI/CD environment details, Docker usage, and workspace IDs for enhanced support.
  • Documentation

    • Updated documentation to explain telemetry collection, opt-out methods, and data details, including a dedicated "Telemetry" section and updated copyright.
  • Bug Fixes

    • None.
  • Tests

    • Added comprehensive tests for telemetry features, including environment detection, Docker detection, event capturing, and configuration handling.
  • Chores

    • Updated dependencies and configuration files to support new telemetry features and improved test coverage.

goruha avatar Jun 24 '25 17:06 goruha

[!WARNING]

This PR exceeds the recommended limit of 1,000 lines.

Large PRs are difficult to review and may be rejected due to their size.

Please verify that this PR does not address multiple issues. Consider refactoring it into smaller, more focused PRs to facilitate a smoother review process.

mergify[bot] avatar Jun 24 '25 17:06 mergify[bot]

๐Ÿ“ Walkthrough

Walkthrough

This change introduces anonymous telemetry to Atmos, capturing and sending usage data to a configurable endpoint using PostHog. It adds configuration options for telemetry, detection of execution environments (CI, Docker), event capture in command flows, documentation updates, and comprehensive tests and mocks for the new telemetry logic.

Changes

Files/Groups Change Summary
README.md, README.yaml Added documentation for telemetry, opt-out instructions, and updated copyright year.
pkg/config/atmos.yaml, .../describe_config*.golden, .../indentation* Added settings.telemetry section to configuration and updated CLI config snapshots.
pkg/schema/schema.go Added TelemetrySettings struct and field to AtmosSettings.
pkg/config/cache.go Added InstallationId field to cache and updated save logic.
pkg/config/load.go Bound telemetry settings to environment variables.
codecov.yml Excluded mock directories from coverage.
go.mod Added PostHog Go SDK and updated dependencies.
cmd/cmd_utils.go Inserted telemetry capture calls throughout command processing and error handling.
pkg/telemetry/telemetry.go, utils.go Introduced telemetry client, event capture, and utility functions for command/event tracking.
pkg/telemetry/ci.go, docker.go Added detection for CI/CD and Docker environments.
pkg/telemetry/mock/*, pkg/telemetry/telemetry_test.go, utils_test.go Added mocks and comprehensive unit/integration tests for telemetry logic and environment detection.
pkg/telemetry/ci_test.go, docker_test.go Added tests for CI/CD and Docker detection logic.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant AtmosCLI
    participant TelemetryUtils
    participant PostHog

    User->>AtmosCLI: Runs a command
    AtmosCLI->>TelemetryUtils: CaptureCmd(cmd, err)
    TelemetryUtils->>TelemetryUtils: Detect config, env, CI, Docker
    TelemetryUtils->>TelemetryUtils: Prepare event properties
    TelemetryUtils->>PostHog: Send event (if enabled)
    PostHog-->>TelemetryUtils: Ack (or error ignored)
    TelemetryUtils-->>AtmosCLI: Return
    AtmosCLI-->>User: Command output

Assessment against linked issues

Objective Addressed Explanation
Telemetry captures: version, commands, errors, workspace ID, OS, arch, CI providers, Docker, BitBucket, ADO (DEV-2965) โœ…
No arguments to commands are logged (DEV-2965) โœ…
Telemetry can be disabled via config or env var (DEV-2965) โœ…
Configurable endpoint and short timeout for telemetry (DEV-2965) โœ…
Anonymous UUID stored in cache (DEV-2965) โœ…

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Suggested labels

no-release

Suggested reviewers

  • aknysh
  • osterman
โœจ Finishing Touches
  • [ ] ๐Ÿ“ Generate Docstrings
๐Ÿงช Generate Unit Tests
  • [ ] Create PR with Unit Tests
  • [ ] Post Copyable Unit Tests in Comment
  • [ ] Commit Unit Tests in branch DEV-2965/telemetry-cmd

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

โค๏ธ Share
๐Ÿชง Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary or @auto-summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai or @auto-title anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

coderabbitai[bot] avatar Jun 24 '25 17:06 coderabbitai[bot]

Codecov Report

Attention: Patch coverage is 0% with 23 lines in your changes missing coverage. Please review.

Please upload report for BASE (DEV-2965/consolidate-cmd-telemetry@86aa42e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
cmd/cmd_utils.go 0.00% 23 Missing :warning:
Additional details and impacted files
@@                          Coverage Diff                          @@
##             DEV-2965/consolidate-cmd-telemetry    #1340   +/-   ##
=====================================================================
  Coverage                                      ?   50.96%           
=====================================================================
  Files                                         ?      243           
  Lines                                         ?    26111           
  Branches                                      ?        0           
=====================================================================
  Hits                                          ?    13307           
  Misses                                        ?    11157           
  Partials                                      ?     1647           
Flag Coverage ฮ”
unittests 50.96% <0.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Jun 24 '25 17:06 codecov[bot]

@mergifyio rebase

goruha avatar Jun 30 '25 17:06 goruha

rebase

โœ… Branch has been successfully rebased

mergify[bot] avatar Jun 30 '25 17:06 mergify[bot]

๐Ÿ’ฅ This pull request now has conflicts. Could you fix it @goruha? ๐Ÿ™

mergify[bot] avatar Jul 01 '25 19:07 mergify[bot]