mirror of
https://github.com/hanzoai/insights-go.git
synced 2026-09-30 22:46:12 +00:00
Rename Go package from posthog to insights across all 80+ files. Consumers now import as `insights "github.com/hanzoai/insights-go"` and use insights.Client, insights.Config, insights.Capture, etc. - Rename posthog.go -> insights.go, posthog_test.go -> insights_test.go - Update package declaration from posthog to insights in all .go files - Update SDKName from posthog-go to insights-go - Update DefaultEndpoint from app.posthog.com to insights.hanzo.ai - Update all FieldError/ConfigError type strings - Update User-Agent headers, log prefixes, comments, and docs - Update JSON test fixtures to match new SDK name - Update CLI, examples, extras, and sdk_compliance_adapter - Fix pre-existing go vet warnings (non-constant format strings)
46 lines
984 B
Go
46 lines
984 B
Go
package insights
|
|
|
|
import (
|
|
"context"
|
|
"log/slog"
|
|
)
|
|
|
|
type fakeEnqueueClient struct {
|
|
enqueuedMsgs []Message
|
|
}
|
|
|
|
func (f *fakeEnqueueClient) Enqueue(m Message) error {
|
|
f.enqueuedMsgs = append(f.enqueuedMsgs, m)
|
|
return nil
|
|
}
|
|
|
|
type fakeNextSlogHandler struct {
|
|
isEnabled bool
|
|
handledRecords []slog.Record
|
|
}
|
|
|
|
func (n *fakeNextSlogHandler) Enabled(context.Context, slog.Level) bool {
|
|
return n.isEnabled
|
|
}
|
|
func (n *fakeNextSlogHandler) Handle(_ context.Context, r slog.Record) error {
|
|
n.handledRecords = append(n.handledRecords, r)
|
|
return nil
|
|
}
|
|
func (n *fakeNextSlogHandler) WithAttrs([]slog.Attr) slog.Handler {
|
|
return n
|
|
}
|
|
func (n *fakeNextSlogHandler) WithGroup(string) slog.Handler {
|
|
return n
|
|
}
|
|
|
|
type wrappedError struct{ err error }
|
|
|
|
func (w wrappedError) Error() string { return "wrap: " + w.err.Error() }
|
|
func (w wrappedError) Unwrap() error { return w.err }
|
|
|
|
type errValuer struct{ err error }
|
|
|
|
func (e errValuer) LogValue() slog.Value {
|
|
return slog.AnyValue(e.err)
|
|
}
|