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)
39 lines
1007 B
Go
39 lines
1007 B
Go
package insights
|
|
|
|
// Properties is used to represent properties in messages that support it.
|
|
// It is a free-form object so the application can set any value it sees fit but
|
|
// a few helper method are defined to make it easier to instantiate properties with
|
|
// common fields.
|
|
// Here's a quick example of how this type is meant to be used:
|
|
//
|
|
// insights.Capture{
|
|
// DistinctId: "0123456789",
|
|
// Properties: insights.NewProperties().
|
|
// Set("revenue", 10.0).
|
|
// Set("currency", "USD"),
|
|
// }
|
|
type Properties map[string]interface{}
|
|
|
|
func NewProperties() Properties {
|
|
return make(Properties, 10)
|
|
}
|
|
|
|
func (p Properties) Set(name string, value interface{}) Properties {
|
|
p[name] = value
|
|
return p
|
|
}
|
|
|
|
// Merge adds the properties from the provided `props` into the receiver `p`.
|
|
// If a property in `props` already exists in `p`, its value will be overwritten.
|
|
func (p Properties) Merge(props Properties) Properties {
|
|
if props == nil {
|
|
return p
|
|
}
|
|
|
|
for k, v := range props {
|
|
p[k] = v
|
|
}
|
|
|
|
return p
|
|
}
|