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)
73 lines
1.6 KiB
Go
73 lines
1.6 KiB
Go
package insights
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
var _ Message = (*Identify)(nil)
|
|
|
|
// This type represents object sent in an identify call
|
|
type Identify struct {
|
|
// This field is exported for serialization purposes and shouldn't be set by
|
|
// the application, its value is always overwritten by the library.
|
|
Type string
|
|
// Uuid is optional. If not provided, a random UUID will be generated.
|
|
Uuid string
|
|
|
|
DistinctId string
|
|
Timestamp time.Time
|
|
Properties Properties
|
|
DisableGeoIP bool
|
|
}
|
|
|
|
func (msg Identify) internal() {
|
|
panic(unimplementedError)
|
|
}
|
|
|
|
func (msg Identify) Validate() error {
|
|
if len(msg.DistinctId) == 0 {
|
|
return FieldError{
|
|
Type: "insights.Identify",
|
|
Name: "DistinctId",
|
|
Value: msg.DistinctId,
|
|
}
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
type IdentifyInApi struct {
|
|
Type string `json:"type"`
|
|
Uuid string `json:"uuid"`
|
|
Library string `json:"library"`
|
|
LibraryVersion string `json:"library_version"`
|
|
Timestamp time.Time `json:"timestamp"`
|
|
|
|
Event string `json:"event"`
|
|
DistinctId string `json:"distinct_id"`
|
|
Properties Properties `json:"properties"`
|
|
Set Properties `json:"$set"`
|
|
}
|
|
|
|
func (msg Identify) APIfy() APIMessage {
|
|
myProperties := Properties{}.Set("$lib", SDKName).Set("$lib_version", getVersion())
|
|
if msg.DisableGeoIP {
|
|
myProperties.Set(propertyGeoipDisable, true)
|
|
}
|
|
|
|
apified := IdentifyInApi{
|
|
Type: msg.Type,
|
|
Uuid: msg.Uuid,
|
|
Event: "$identify",
|
|
Library: SDKName,
|
|
LibraryVersion: getVersion(),
|
|
Timestamp: msg.Timestamp,
|
|
DistinctId: msg.DistinctId,
|
|
|
|
Properties: myProperties,
|
|
Set: msg.Properties,
|
|
}
|
|
|
|
return apified
|
|
}
|