@@ -7,6 +7,7 @@ import (
"path/filepath"
"reflect"
"runtime"
+ "time"
"github.com/charmbracelet/crush/internal/version"
"github.com/posthog/posthog-go"
@@ -85,19 +86,16 @@ func Error(err any, props ...any) {
if client == nil {
return
}
- // The PostHog Go client does not yet support sending exceptions.
- // We're mimicking the behavior by sending the minimal info required
- // for PostHog to recognize this as an exception event.
- props = append(
- []any{
- "$exception_list",
- []map[string]string{
- {"type": reflect.TypeOf(err).String(), "value": fmt.Sprintf("%v", err)},
- },
- },
- props...,
- )
- send("$exception", props...)
+ posthogErr := client.Enqueue(posthog.NewDefaultException(
+ time.Now(),
+ distinctId,
+ reflect.TypeOf(err).String(),
+ fmt.Sprintf("%v", err),
+ ))
+ if err != nil {
+ slog.Error("Failed to enqueue PostHog error", "err", err, "props", props, "posthogErr", posthogErr)
+ return
+ }
}
func Flush() {