chore: send `interactive` attribute (for `crush run`) (#1635)

Andrey Nering created

Change summary

internal/cmd/run.go     | 7 +++++++
internal/event/event.go | 7 ++++++-
2 files changed, 13 insertions(+), 1 deletion(-)

Detailed changes

internal/cmd/run.go 🔗

@@ -8,6 +8,7 @@ import (
 	"os/signal"
 	"strings"
 
+	"github.com/charmbracelet/crush/internal/event"
 	"github.com/spf13/cobra"
 )
 
@@ -58,8 +59,14 @@ crush run --quiet "Generate a README for this project"
 			return fmt.Errorf("no prompt provided")
 		}
 
+		event.SetInteractive(true)
+		event.AppInitialized()
+
 		return app.RunNonInteractive(ctx, os.Stdout, prompt, quiet)
 	},
+	PostRun: func(cmd *cobra.Command, args []string) {
+		event.AppExited()
+	},
 }
 
 func init() {

internal/event/event.go 🔗

@@ -26,9 +26,14 @@ var (
 			Set("TERM", os.Getenv("TERM")).
 			Set("SHELL", filepath.Base(os.Getenv("SHELL"))).
 			Set("Version", version.Version).
-			Set("GoVersion", runtime.Version())
+			Set("GoVersion", runtime.Version()).
+			Set("Interactive", false)
 )
 
+func SetInteractive(interactive bool) {
+	baseProps = baseProps.Set("interactive", interactive)
+}
+
 func Init() {
 	c, err := posthog.NewWithConfig(key, posthog.Config{
 		Endpoint: endpoint,