Skip to content

Commit 75e987b

Browse files
authored
feat: add brev feedback command (#324)
* feat: add brev feedback command for user feedback via PostHog Add a new `brev feedback` command that lets users send feedback, bug reports, and feature requests directly from the CLI. Feedback is sent as a `brev-cli-feedback` event to PostHog. Also update the agent skill SKILL.md to instruct AI agents to proactively send feedback when they encounter issues. * fix: use format string in Vprintf call * fix: use logged-in user ID for feedback events when available * fix: warn users not to include secrets in feedback * fix: remove secrets warning from long description, keep in prompt only * fix: move secrets warning to skill only
1 parent cf7015a commit 75e987b

4 files changed

Lines changed: 96 additions & 0 deletions

File tree

.agents/skills/brev-cli/SKILL.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,22 @@ brev invite
247247
- Confirm instance name before deletion
248248
- Check `brev ls` before assuming instance exists
249249

250+
## Feedback
251+
252+
If you get stuck, encounter bugs, can't achieve what you're trying to do, or have ideas for improvements, send feedback to the Brev team:
253+
254+
```bash
255+
brev feedback "description of issue or suggestion"
256+
```
257+
258+
**IMPORTANT: Never include secrets, passwords, API keys, or sensitive information in feedback.**
259+
260+
Do this proactively when:
261+
- A brev command fails unexpectedly or returns confusing errors
262+
- You can't figure out how to accomplish a task with the available commands
263+
- You notice missing features or rough edges
264+
- A workflow feels harder than it should be
265+
250266
## Troubleshooting
251267

252268
**"Instance not found":**

pkg/analytics/posthog.go

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,32 @@ func captureEvent(userID string, cmd *cobra.Command, args []string, succeeded bo
279279
})
280280
}
281281

282+
// CaptureFeedback sends a brev-cli-feedback event to PostHog.
283+
// This is sent regardless of analytics opt-in since the user explicitly chose to send feedback.
284+
func CaptureFeedback(userID, message string) {
285+
if userID == "" {
286+
userID = GetOrCreateAnalyticsID()
287+
}
288+
if userID == "" {
289+
return
290+
}
291+
292+
c, err := getClient()
293+
if err != nil {
294+
return
295+
}
296+
297+
_ = c.Enqueue(posthog.Capture{
298+
DistinctId: userID,
299+
Event: "brev-cli-feedback",
300+
Properties: posthog.NewProperties().
301+
Set("message", message).
302+
Set("os", runtime.GOOS).
303+
Set("arch", runtime.GOARCH).
304+
Set("cli_version", version.Version),
305+
})
306+
}
307+
282308
// Close flushes any pending events and closes the PostHog client.
283309
func Close() {
284310
if client != nil {

pkg/cmd/cmd.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import (
1717
"github.com/brevdev/brev-cli/pkg/cmd/enablessh"
1818
"github.com/brevdev/brev-cli/pkg/cmd/envvars"
1919
"github.com/brevdev/brev-cli/pkg/cmd/exec"
20+
"github.com/brevdev/brev-cli/pkg/cmd/feedback"
2021
"github.com/brevdev/brev-cli/pkg/cmd/fu"
2122
"github.com/brevdev/brev-cli/pkg/cmd/gpucreate"
2223
"github.com/brevdev/brev-cli/pkg/cmd/gpusearch"
@@ -358,6 +359,7 @@ func createCmdTree(cmd *cobra.Command, t *terminal.Terminal, loginCmdStore *stor
358359
cmd.AddCommand(recreate.NewCmdRecreate(t, loginCmdStore))
359360
cmd.AddCommand(writeconnectionevent.NewCmdwriteConnectionEvent(t, loginCmdStore))
360361
cmd.AddCommand(updatemodel.NewCmdupdatemodel(t, loginCmdStore))
362+
cmd.AddCommand(feedback.NewCmdFeedback(t, noLoginCmdStore))
361363
}
362364

363365
func hasWorkspaceCommands(cmd *cobra.Command) bool {

pkg/cmd/feedback/feedback.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package feedback
2+
3+
import (
4+
"strings"
5+
6+
"github.com/brevdev/brev-cli/pkg/analytics"
7+
"github.com/brevdev/brev-cli/pkg/entity"
8+
"github.com/brevdev/brev-cli/pkg/terminal"
9+
"github.com/spf13/cobra"
10+
)
11+
12+
type FeedbackStore interface {
13+
GetCurrentUser() (*entity.User, error)
14+
}
15+
16+
func NewCmdFeedback(t *terminal.Terminal, store FeedbackStore) *cobra.Command {
17+
var message string
18+
19+
cmd := &cobra.Command{
20+
Annotations: map[string]string{"configuration": ""},
21+
Use: "feedback [message]",
22+
DisableFlagsInUseLine: true,
23+
Short: "Send feedback to the Brev team",
24+
Long: "Send feedback, bug reports, or feature requests to the Brev team.",
25+
Example: "brev feedback \"I love this tool!\"\nbrev feedback",
26+
RunE: func(cmd *cobra.Command, args []string) error {
27+
if message == "" && len(args) > 0 {
28+
message = strings.Join(args, " ")
29+
}
30+
if message == "" {
31+
message = terminal.PromptGetInput(terminal.PromptContent{
32+
Label: "What feedback do you have for us?",
33+
ErrorMsg: "Please enter some feedback",
34+
})
35+
}
36+
37+
userID := analytics.GetOrCreateAnalyticsID()
38+
if user, err := store.GetCurrentUser(); err == nil && user != nil {
39+
userID = user.ID
40+
}
41+
42+
analytics.CaptureFeedback(userID, message)
43+
44+
t.Vprintf("%s", t.Green("Thanks for your feedback! We really appreciate it.\n"))
45+
return nil
46+
},
47+
}
48+
49+
cmd.Flags().StringVarP(&message, "message", "m", "", "Feedback message (skips interactive prompt)")
50+
51+
return cmd
52+
}

0 commit comments

Comments
 (0)