event

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 23, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Batch

type Batch struct {
	Revision        string    `json:"revision"`
	AccountID       string    `json:"account_id"`
	ClientVersion   string    `json:"client_version"`
	Visitors        []Visitor `json:"visitors"`
	ProjectID       string    `json:"project_id"`
	ClientName      string    `json:"client_name"`
	AnonymizeIP     bool      `json:"anonymize_ip"`
	EnrichDecisions bool      `json:"enrich_decisions"`
}

Batch - Context about the event to send in batch

type Context

type Context struct {
	Revision      string `json:"revision"`
	AccountID     string `json:"account_id"`
	ClientVersion string `json:"client_version"`
	ProjectID     string `json:"project_id"`
	ClientName    string `json:"client_name"`
	AnonymizeIP   bool   `json:"anonymize_ip"`
	BotFiltering  bool   `json:"bot_filtering"`
}

Context holds project-related contextual information about a UserEvent

func CreateEventContext

func CreateEventContext(projectConfig optimizely.ProjectConfig) Context

CreateEventContext creates and returns EventContext

type ConversionEvent

type ConversionEvent struct {
	EntityID   string `json:"entity_id"`
	Key        string `json:"key"`
	Attributes []VisitorAttribute
	Tags       map[string]interface{} `json:"tags,omitempty"`
	// these need to be pointers because 0 is a valid Revenue or Value.
	// 0 is equivalent to omitempty for json marshalling.
	Revenue *int64   `json:"revenue,omitempty"`
	Value   *float64 `json:"value,omitempty"`
}

ConversionEvent represents a conversion event

type Decision

type Decision struct {
	VariationID  string `json:"variation_id"`
	CampaignID   string `json:"campaign_id"`
	ExperimentID string `json:"experiment_id"`
}

Decision represents a decision of a snapshot

type Dispatcher

type Dispatcher interface {
	DispatchEvent(event LogEvent, callback func(success bool))
}

Dispatcher dispatches events

type HTTPEventDispatcher

type HTTPEventDispatcher struct {
}

HTTPEventDispatcher is the HTTP implementation of the Dispatcher interface

func (*HTTPEventDispatcher) DispatchEvent

func (*HTTPEventDispatcher) DispatchEvent(event LogEvent, callback func(success bool))

DispatchEvent dispatches event with callback

type ImpressionEvent

type ImpressionEvent struct {
	EntityID     string `json:"entity_id"`
	Key          string `json:"key"`
	Attributes   []VisitorAttribute
	VariationID  string `json:"variation_id"`
	CampaignID   string `json:"campaign_id"`
	ExperimentID string `json:"experiment_id"`
}

ImpressionEvent represents an impression event

type InMemoryQueue

type InMemoryQueue struct {
	Queue []interface{}
	Mux   sync.Mutex
}

InMemoryQueue represents a in-memory queue

func (*InMemoryQueue) Add

func (i *InMemoryQueue) Add(item interface{})

Add appends item to queue

func (*InMemoryQueue) Get

func (i *InMemoryQueue) Get(count int) []interface{}

Get returns queue for given count size

func (*InMemoryQueue) Remove

func (i *InMemoryQueue) Remove(count int) []interface{}

Remove removes item from queue and returns elements slice

func (*InMemoryQueue) Size

func (i *InMemoryQueue) Size() int

Size returns size of queue

type LogEvent

type LogEvent struct {
	// contains filtered or unexported fields
}

LogEvent represents a log event

type Processor

type Processor interface {
	ProcessEvent(event UserEvent)
}

Processor processes events

type Queue

type Queue interface {
	Add(item interface{})
	Remove(count int) []interface{}
	Get(count int) []interface{}
	Size() int
}

Queue represents a queue

func NewInMemoryQueue

func NewInMemoryQueue(queueSize int) Queue

NewInMemoryQueue returns new InMemoryQueue with given queueSize

type QueueingEventProcessor

type QueueingEventProcessor struct {
	MaxQueueSize    int           // max size of the queue before flush
	FlushInterval   time.Duration // in milliseconds
	BatchSize       int
	Q               Queue
	Mux             sync.Mutex
	Ticker          *time.Ticker
	EventDispatcher Dispatcher
}

QueueingEventProcessor is used out of the box by the SDK

func NewEventProcessor

func NewEventProcessor(ctx context.Context, queueSize int, flushInterval time.Duration) *QueueingEventProcessor

NewEventProcessor returns a new instance of QueueingEventProcessor with queueSize and flushInterval

func (*QueueingEventProcessor) EventsCount

func (p *QueueingEventProcessor) EventsCount() int

EventsCount returns size of an event queue

func (*QueueingEventProcessor) FlushEvents

func (p *QueueingEventProcessor) FlushEvents()

FlushEvents flushes events in queue

func (*QueueingEventProcessor) GetEvents

func (p *QueueingEventProcessor) GetEvents(count int) []interface{}

GetEvents returns events from event queue for count

func (*QueueingEventProcessor) ProcessEvent

func (p *QueueingEventProcessor) ProcessEvent(event UserEvent)

ProcessEvent processes the given impression event

func (*QueueingEventProcessor) Remove

func (p *QueueingEventProcessor) Remove(count int) []interface{}

Remove removes events from queue for count

func (*QueueingEventProcessor) StartTicker

func (p *QueueingEventProcessor) StartTicker(ctx context.Context)

StartTicker starts new ticker for flushing events

type Snapshot

type Snapshot struct {
	Decisions []Decision      `json:"decisions"`
	Events    []SnapshotEvent `json:"events"`
}

Snapshot represents a snapshot of a visitor

type SnapshotEvent

type SnapshotEvent struct {
	EntityID  string                 `json:"entity_id"`
	Key       string                 `json:"key"`
	Timestamp int64                  `json:"timestamp"`
	UUID      string                 `json:"uuid"`
	Tags      map[string]interface{} `json:"tags,omitempty"`
	Revenue   *int64                 `json:"revenue,omitempty"`
	Value     *float64               `json:"value,omitempty"`
}

SnapshotEvent represents an event of a snapshot

type UserEvent

type UserEvent struct {
	Timestamp    int64  `json:"timestamp"`
	UUID         string `json:"uuid"`
	EventContext Context
	VisitorID    string
	Impression   *ImpressionEvent
	Conversion   *ConversionEvent
}

UserEvent represents a user event

func CreateConversionUserEvent

func CreateConversionUserEvent(projectConfig optimizely.ProjectConfig, event entities.Event, userContext entities.UserContext, eventTags map[string]interface{}) UserEvent

CreateConversionUserEvent creates and returns ConversionEvent for user

func CreateImpressionUserEvent

func CreateImpressionUserEvent(projectConfig optimizely.ProjectConfig, experiment entities.Experiment,
	variation entities.Variation,
	userContext entities.UserContext) UserEvent

CreateImpressionUserEvent creates and returns ImpressionEvent for user

type Visitor

type Visitor struct {
	Attributes []VisitorAttribute `json:"attributes"`
	Snapshots  []Snapshot         `json:"snapshots"`
	VisitorID  string             `json:"visitor_id"`
}

Visitor represents a visitor of an eventbatch

type VisitorAttribute

type VisitorAttribute struct {
	Value         interface{} `json:"value"`
	Key           string      `json:"key"`
	AttributeType string      `json:"type"`
	EntityID      string      `json:"entity_id"`
}

VisitorAttribute represents an attribute of a visitor

Jump to

Keyboard shortcuts

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