chore(events): add events for the CLI session series of commands

Christian Rocha created

Change summary

internal/cmd/session.go | 11 +++++++++++
internal/event/all.go   | 20 ++++++++++++++++++++
2 files changed, 31 insertions(+)

Detailed changes

internal/cmd/session.go 🔗

@@ -17,6 +17,7 @@ import (
 	"github.com/charmbracelet/colorprofile"
 	"github.com/charmbracelet/crush/internal/config"
 	"github.com/charmbracelet/crush/internal/db"
+	"github.com/charmbracelet/crush/internal/event"
 	"github.com/charmbracelet/crush/internal/message"
 	"github.com/charmbracelet/crush/internal/session"
 	"github.com/charmbracelet/crush/internal/ui/chat"
@@ -126,6 +127,8 @@ func sessionSetup(cmd *cobra.Command) (context.Context, *sessionServices, func()
 }
 
 func runSessionList(cmd *cobra.Command, _ []string) error {
+	event.SessionListed(sessionListJSON)
+
 	ctx, svc, cleanup, err := sessionSetup(cmd)
 	if err != nil {
 		return err
@@ -249,6 +252,8 @@ func resolveSessionID(ctx context.Context, svc session.Service, id string) (sess
 }
 
 func runSessionShow(cmd *cobra.Command, args []string) error {
+	event.SessionShown(sessionShowJSON)
+
 	ctx, svc, cleanup, err := sessionSetup(cmd)
 	if err != nil {
 		return err
@@ -273,6 +278,8 @@ func runSessionShow(cmd *cobra.Command, args []string) error {
 }
 
 func runSessionDelete(cmd *cobra.Command, args []string) error {
+	event.SessionDeletedCommand(sessionDeleteJSON)
+
 	ctx, svc, cleanup, err := sessionSetup(cmd)
 	if err != nil {
 		return err
@@ -305,6 +312,8 @@ func runSessionDelete(cmd *cobra.Command, args []string) error {
 }
 
 func runSessionRename(cmd *cobra.Command, args []string) error {
+	event.SessionRenamed(sessionRenameJSON)
+
 	ctx, svc, cleanup, err := sessionSetup(cmd)
 	if err != nil {
 		return err
@@ -338,6 +347,8 @@ func runSessionRename(cmd *cobra.Command, args []string) error {
 }
 
 func runSessionLast(cmd *cobra.Command, _ []string) error {
+	event.SessionLastShown(sessionLastJSON)
+
 	ctx, svc, cleanup, err := sessionSetup(cmd)
 	if err != nil {
 		return err

internal/event/all.go 🔗

@@ -61,3 +61,23 @@ func TokensUsed(props ...any) {
 func StatsViewed() {
 	send("stats viewed")
 }
+
+func SessionListed(json bool) {
+	send("session listed", "json", json, "cli", true)
+}
+
+func SessionShown(json bool) {
+	send("session shown", "json", json, "cli", true)
+}
+
+func SessionLastShown(json bool) {
+	send("session last shown", "json", json, "cli", true)
+}
+
+func SessionDeletedCommand(json bool) {
+	send("session deleted", "json", json, "cli", true)
+}
+
+func SessionRenamed(json bool) {
+	send("session renamed", "json", json, "cli", true)
+}