Skip to content

Commit a3d7fd6

Browse files
dgageotderekmisler
andauthored
telemetry package (#1)
Co-authored-by: Derek Misler <derek.misler@docker.com>
1 parent 2765155 commit a3d7fd6

27 files changed

Lines changed: 2444 additions & 9 deletions

.github/workflows/ci.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ jobs:
4747

4848
- name: Run tests
4949
run: task test
50+
env:
51+
TELEMETRY_ENABLED: true
52+
TELEMETRY_API_KEY: ${{ secrets.TELEMETRY_API_KEY }}
53+
TELEMETRY_ENDPOINT: ${{ secrets.TELEMETRY_ENDPOINT }}
54+
TELEMETRY_HEADER: ${{ secrets.TELEMETRY_HEADER }}
5055

5156
license-check:
5257
runs-on: ubuntu-latest
@@ -87,3 +92,8 @@ jobs:
8792

8893
- name: Build
8994
run: task build
95+
env:
96+
TELEMETRY_ENABLED: true
97+
TELEMETRY_API_KEY: ${{ secrets.TELEMETRY_API_KEY }}
98+
TELEMETRY_ENDPOINT: ${{ secrets.TELEMETRY_ENDPOINT }}
99+
TELEMETRY_HEADER: ${{ secrets.TELEMETRY_HEADER }}

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Many examples can be found [here](/examples/README.md)!
5252

5353
[Prebuilt binaries](https://github.com/docker/cagent/releases) for Windows, macOS and Linux can be found on the releases page of the [project's GitHub repository](https://github.com/docker/cagent/releases)
5454

55-
Once you've downloaded the appropriate binary for your platform, you may need to give it executable permissions.
55+
Once you've downloaded the appropriate binary for your platform, you may need to give it executable permissions.
5656
On macOS and Linux, this is done with the following command:
5757

5858
```sh
@@ -78,7 +78,7 @@ export ANTHROPIC_API_KEY=your_api_key_here
7878
export GOOGLE_API_KEY=your_api_key_here
7979
```
8080

81-
### Run Agents!
81+
### Run Agents!
8282

8383
```bash
8484
# Run an agent!
@@ -188,11 +188,13 @@ cagent pull agentcatalog/pirate
188188

189189
`cagent run agentcatalog_pirate.yaml` will run your newly pulled agent
190190

191-
192191
## Usage
193192

194193
More details on the usage and configuration of `cagent` can be found in [USAGE.md](/docs/USAGE.md)
195194

195+
## Telemetry
196+
197+
We track anonymous usage data to improve the tool. See [TELEMETRY.md](/docs/TELEMETRY.md) for details.
196198

197199
## Contributing
198200

cmd/root/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88

99
"github.com/spf13/cobra"
1010

11+
"github.com/docker/cagent/internal/telemetry"
1112
latest "github.com/docker/cagent/pkg/config/v1"
1213
"github.com/docker/cagent/pkg/server"
1314
"github.com/docker/cagent/pkg/session"
@@ -28,6 +29,7 @@ func NewApiCmd() *cobra.Command {
2829
Long: `Start the API server that exposes the agent via an HTTP API`,
2930
Args: cobra.ExactArgs(1),
3031
RunE: func(cmd *cobra.Command, args []string) error {
32+
telemetry.TrackCommand("api", args)
3133
return runHttp(cmd, false, args)
3234
},
3335
}

cmd/root/catalog.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"text/tabwriter"
1111
"time"
1212

13+
"github.com/docker/cagent/internal/telemetry"
1314
"github.com/spf13/cobra"
1415
)
1516

@@ -34,6 +35,10 @@ func newCatalogListCmd() *cobra.Command {
3435
Short: "List catalog entries",
3536
Args: cobra.MaximumNArgs(1),
3637
RunE: func(cmd *cobra.Command, args []string) error {
38+
// Track catalog list with "list" as the first argument for telemetry
39+
telemetryArgs := append([]string{"list"}, args...)
40+
telemetry.TrackCommand("catalog", telemetryArgs)
41+
3742
var org string
3843
if len(args) == 0 {
3944
org = "agentcatalog"

cmd/root/eval.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55

66
"github.com/spf13/cobra"
77

8+
"github.com/docker/cagent/internal/telemetry"
89
"github.com/docker/cagent/pkg/evaluation"
910
"github.com/docker/cagent/pkg/teamloader"
1011
)
@@ -23,6 +24,8 @@ func NewEvalCmd() *cobra.Command {
2324
}
2425

2526
func runEvalCommand(cmd *cobra.Command, args []string) error {
27+
telemetry.TrackCommand("eval", args)
28+
2629
agents, err := teamloader.Load(cmd.Context(), args[0], runConfig)
2730
if err != nil {
2831
return err

cmd/root/feedback.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package root
33
import (
44
"fmt"
55

6+
"github.com/docker/cagent/internal/telemetry"
67
"github.com/spf13/cobra"
78
)
89

@@ -15,6 +16,7 @@ func NewFeedbackCmd() *cobra.Command {
1516
Short: "Send feedback about cagent",
1617
Long: `Submit feedback or report issues with cagent`,
1718
Run: func(cmd *cobra.Command, args []string) {
19+
telemetry.TrackCommand("feedback", args)
1820
fmt.Println("Feel free to give feedback:\n", FeedbackLink)
1921
},
2022
}

cmd/root/mcp.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"syscall"
1010
"time"
1111

12+
"github.com/docker/cagent/internal/telemetry"
1213
"github.com/docker/cagent/pkg/mcpserver"
1314
"github.com/docker/cagent/pkg/servicecore"
1415
"github.com/spf13/cobra"
@@ -42,7 +43,9 @@ and maintain conversational sessions.`,
4243
return cmd
4344
}
4445

45-
func runMCPCommand(*cobra.Command, []string) error {
46+
func runMCPCommand(_ *cobra.Command, args []string) error {
47+
telemetry.TrackCommand("mcp", args)
48+
4649
// Default agents directory to current working directory if not specified
4750
resolvedAgentsDir := agentsDir
4851
if resolvedAgentsDir == "" {

cmd/root/new.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/spf13/cobra"
1010

1111
"github.com/docker/cagent/internal/creator"
12+
"github.com/docker/cagent/internal/telemetry"
1213
"github.com/docker/cagent/pkg/runtime"
1314
)
1415

@@ -21,6 +22,8 @@ func NewNewCmd() *cobra.Command {
2122
Short: "Create a new agent configuration",
2223
Long: `Create a new agent configuration by asking questions and generating a YAML file`,
2324
RunE: func(cmd *cobra.Command, args []string) error {
25+
telemetry.TrackCommand("new", args)
26+
2427
ctx := cmd.Context()
2528

2629
var model string // final model name

cmd/root/pull.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"path/filepath"
88
"strings"
99

10+
"github.com/docker/cagent/internal/telemetry"
1011
"github.com/docker/cagent/pkg/remote"
1112
"github.com/google/go-containerregistry/pkg/crane"
1213
"github.com/spf13/cobra"
@@ -19,6 +20,7 @@ func NewPullCmd() *cobra.Command {
1920
Long: `Pull an artifact from Docker Hub`,
2021
Args: cobra.ExactArgs(1),
2122
RunE: func(cmd *cobra.Command, args []string) error {
23+
telemetry.TrackCommand("pull", args)
2224
return runPullCommand(args[0])
2325
},
2426
}

cmd/root/push.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"fmt"
55
"log/slog"
66

7+
"github.com/docker/cagent/internal/telemetry"
78
"github.com/docker/cagent/pkg/content"
89
"github.com/docker/cagent/pkg/oci"
910
"github.com/docker/cagent/pkg/remote"
@@ -21,6 +22,7 @@ The local identifier can be either a reference (tag) or a digest that was return
2122
from the build command.`,
2223
Args: cobra.ExactArgs(2),
2324
RunE: func(cmd *cobra.Command, args []string) error {
25+
telemetry.TrackCommand("push", args)
2426
return runPushCommand(args[0], args[1])
2527
},
2628
}

0 commit comments

Comments
 (0)