types

package
v1.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 28, 2024 License: MIT Imports: 2 Imported by: 5

Documentation

Index

Constants

View Source
const (
	IdentityOpAdd        IdentityOp = "$add"
	IdentityOpAppend     IdentityOp = "$append"
	IdentityOpClearAll   IdentityOp = "$clearAll"
	IdentityOpPrepend    IdentityOp = "$prepend"
	IdentityOpSet        IdentityOp = "$set"
	IdentityOpSetOnce    IdentityOp = "$setOnce"
	IdentityOpUnset      IdentityOp = "$unset"
	IdentityOpPreInsert  IdentityOp = "$preInsert"
	IdentityOpPostInsert IdentityOp = "$postInsert"
	IdentityOpRemove     IdentityOp = "$remove"

	UnsetValue string = "-"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type BeforePlugin added in v0.0.6

type BeforePlugin interface {
	Plugin
	Execute(event *Event) *Event
}

type Config

type Config struct {
	APIKey                 string
	FlushInterval          time.Duration
	FlushQueueSize         int
	FlushSizeDivider       int
	FlushMaxRetries        int
	Logger                 Logger
	MinIDLength            int
	ExecuteCallback        func(result ExecuteResult)
	ServerZone             ServerZone
	UseBatch               bool
	StorageFactory         func() EventStorage
	OptOut                 bool
	Plan                   *Plan
	IngestionMetadata      *IngestionMetadata
	ServerURL              string
	ConnectionTimeout      time.Duration
	MaxStorageCapacity     int
	RetryBaseInterval      time.Duration
	RetryThrottledInterval time.Duration
}

func NewConfig

func NewConfig(apiKey string) Config

func (Config) IsValid

func (c Config) IsValid() bool

type DestinationPlugin

type DestinationPlugin interface {
	Plugin
	Execute(event *Event)
}

type EnrichmentPlugin

type EnrichmentPlugin interface {
	Plugin
	Execute(event *Event) *Event
}

type Event

type Event struct {
	EventType string `json:"event_type"`
	EventOptions
	EventProperties map[string]interface{}                `json:"event_properties,omitempty"`
	UserProperties  map[IdentityOp]map[string]interface{} `json:"user_properties,omitempty"`
	Groups          map[string][]string                   `json:"groups,omitempty"`
	GroupProperties map[IdentityOp]map[string]interface{} `json:"group_properties,omitempty"`

	// UserID is a user identifier. The value is ignored if EventOptions.UserID is set.
	UserID string `json:"-"`

	// DeviceID is a device-specific identifier. The value is ignored if EventOptions.DeviceID is set.
	DeviceID string `json:"-"`
}

func (Event) Clone

func (e Event) Clone() Event

type EventOptions

type EventOptions struct {
	UserID             string             `json:"user_id,omitempty"`
	DeviceID           string             `json:"device_id,omitempty"`
	Time               int64              `json:"time,omitempty"`
	InsertID           string             `json:"insert_id,omitempty"`
	Library            string             `json:"library,omitempty"`
	LocationLat        float64            `json:"location_lat,omitempty"`
	LocationLng        float64            `json:"location_lng,omitempty"`
	AppVersion         string             `json:"app_version,omitempty"`
	VersionName        string             `json:"version_name,omitempty"`
	Platform           string             `json:"platform,omitempty"`
	OSName             string             `json:"os_name,omitempty"`
	OSVersion          string             `json:"os_version,omitempty"`
	DeviceBrand        string             `json:"device_brand,omitempty"`
	DeviceManufacturer string             `json:"device_manufacturer,omitempty"`
	DeviceModel        string             `json:"device_model,omitempty"`
	Carrier            string             `json:"carrier,omitempty"`
	Country            string             `json:"country,omitempty"`
	Region             string             `json:"region,omitempty"`
	City               string             `json:"city,omitempty"`
	DMA                string             `json:"dma,omitempty"`
	IDFA               string             `json:"idfa,omitempty"`
	IDFV               string             `json:"idfv,omitempty"`
	ADID               string             `json:"adid,omitempty"`
	AndroidID          string             `json:"android_id,omitempty"`
	Language           string             `json:"language,omitempty"`
	IP                 string             `json:"ip,omitempty"`
	Price              float64            `json:"price,omitempty"`
	Quantity           int                `json:"quantity,omitempty"`
	Revenue            float64            `json:"revenue,omitempty"`
	ProductID          string             `json:"productId,omitempty"`
	RevenueType        string             `json:"revenueType,omitempty"`
	EventID            int                `json:"event_id,omitempty"`
	SessionID          int                `json:"session_id,omitempty"`
	PartnerID          string             `json:"partner_id,omitempty"`
	Plan               *Plan              `json:"plan,omitempty"`
	IngestionMetadata  *IngestionMetadata `json:"ingestion_metadata,omitempty"`
}

func (*EventOptions) Clone added in v0.0.13

func (eo *EventOptions) Clone() *EventOptions

func (*EventOptions) SetTime

func (eo *EventOptions) SetTime(time time.Time)

type EventStorage

type EventStorage interface {
	PushNew(event *StorageEvent)
	ReturnBack(events ...*StorageEvent)
	Pull(count int, before time.Time) []*StorageEvent
	Count(before time.Time) int
}

type ExecuteResult added in v0.0.5

type ExecuteResult struct {
	PluginName string
	Event      *Event
	Code       int
	Message    string
}

type ExtendedDestinationPlugin

type ExtendedDestinationPlugin interface {
	DestinationPlugin
	Flush()
	Shutdown()
}

type Identify

type Identify struct {
	PropertiesSet map[string]struct{}
	Properties    map[IdentityOp]map[string]interface{}
	// contains filtered or unexported fields
}

func (*Identify) Add

func (i *Identify) Add(property string, value interface{}) *Identify

Add increments a user property by some numerical value. If the user property does not have a value set yet, it will be initialized to 0 before being incremented.

func (*Identify) Append

func (i *Identify) Append(property string, value interface{}) *Identify

Append appends a value or values to a user property array. If the user property does not have a value set yet, it will be initialized to an empty list before the new values are prepended.

func (*Identify) ClearAll

func (i *Identify) ClearAll() *Identify

ClearAll removes all user properties of this user.

func (*Identify) PostInsert

func (i *Identify) PostInsert(property string, value interface{}) *Identify

PostInsert post-inserts a value or values to a user property, if it does not exist in the user property yet. Post-insert means inserting the value(s) at the end of a given list. If the user property does not have a value set yet, it will be initialized to an empty list before the new values are post-inserted. If the user property has an existing value, it will be no operation.

func (*Identify) PreInsert

func (i *Identify) PreInsert(property string, value interface{}) *Identify

PreInsert pre-inserts a value or values to a user property, if it does not exist in the user property yet. Pre-insert means inserting the value(s) at the beginning of a given list. If the user property does not have a value set yet, it will be initialized to an empty list before the new values are pre-inserted. If the user property has an existing value, it will be no operation.

func (*Identify) Prepend

func (i *Identify) Prepend(property string, value interface{}) *Identify

Prepend prepends a value or values to a user property array. If the user property does not have a value set yet, it will be initialized to an empty list before the new values are prepended.

func (*Identify) Remove

func (i *Identify) Remove(property string, value interface{}) *Identify

Remove removes a value or values to a user property, if it exists in the user property. Remove means remove the existing value(s) from the given list. If the item does not exist in the user property, it will be no operation.

func (*Identify) Set

func (i *Identify) Set(property string, value interface{}) *Identify

Set sets the value of a user property.

func (*Identify) SetOnce

func (i *Identify) SetOnce(property string, value interface{}) *Identify

SetOnce sets the value of user property only once. Subsequent calls using SetOnce will be ignored.

func (*Identify) Unset

func (i *Identify) Unset(property string) *Identify

Unset removes the user property from the user profile.

func (*Identify) Validate

func (i *Identify) Validate() ([]string, []string)

type IdentityOp

type IdentityOp string

type IngestionMetadata added in v0.0.9

type IngestionMetadata struct {
	SourceName    string `json:"source_name,omitempty"`
	SourceVersion string `json:"source_version,omitempty"`
}

type Logger

type Logger interface {
	Debugf(message string, args ...interface{})
	Infof(message string, args ...interface{})
	Warnf(message string, args ...interface{})
	Errorf(message string, args ...interface{})
}

type Plan

type Plan struct {
	Branch    string `json:"branch,omitempty"`
	Source    string `json:"source,omitempty"`
	Version   string `json:"version,omitempty"`
	VersionID string `json:"versionId,omitempty"`
}

type Plugin

type Plugin interface {
	Name() string
	Type() PluginType
	Setup(config Config)
}

type PluginType

type PluginType int
const (
	PluginTypeBefore PluginType = iota
	PluginTypeEnrichment
	PluginTypeDestination
)

type Revenue

type Revenue struct {
	Price       float64
	Quantity    int
	ProductID   string
	RevenueType string
	Receipt     string
	ReceiptSig  string
	Properties  map[string]interface{}
	Revenue     float64
}

func (Revenue) Validate

func (r Revenue) Validate() []string

type ServerZone

type ServerZone string
const (
	ServerZoneUS ServerZone = "US"
	ServerZoneEU ServerZone = "EU"
)

type StorageEvent added in v0.0.13

type StorageEvent struct {
	*Event

	RetryAt    time.Time
	RetryCount int
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL