client

package
Version: v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2021 License: Apache-2.0 Imports: 12 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client represent the Flagship SDK client object

func Create

func Create(f *Options) (*Client, error)

Create creates a Client from options

func (*Client) Dispose

func (c *Client) Dispose() (err error)

Dispose disposes the Client and close all connections

func (*Client) GetCacheManager

func (c *Client) GetCacheManager() cache.Manager

GetCacheManager returns the current cache manager

func (*Client) GetDecisionMode

func (c *Client) GetDecisionMode() DecisionMode

GetDecisionMode returns the current decision mode

func (*Client) GetEnvID

func (c *Client) GetEnvID() string

GetEnvID returns the current set env id

func (*Client) NewVisitor

func (c *Client) NewVisitor(visitorID string, context model.Context, options ...VisitorOptionBuilder) (visitor *Visitor, err error)

NewVisitor returns a new Visitor from ID and context

func (*Client) SendHit

func (c *Client) SendHit(visitorID string, hit model.HitInterface) (err error)

SendHit sends a tracking hit to the Data Collect API

type DecisionMode

type DecisionMode string

DecisionMode represents the decision mode of the Client engine

const (
	API       DecisionMode = "API"
	Bucketing DecisionMode = "Bucketing"
)

The different decision modes

type ModificationInfo

type ModificationInfo struct {
	CampaignID       string
	VariationGroupID string
	VariationID      string
	IsReference      bool
	Value            interface{}
}

ModificationInfo represents additional info linked to the modification key, for third party services

type OptionBuilder

type OptionBuilder func(*Options)

OptionBuilder is a func type to set options to the FlagshipOption.

func WithBucketing

func WithBucketing(options ...func(*bucketing.Engine)) OptionBuilder

WithBucketing enables the bucketing decision mode for the SDK

func WithDecisionAPI

func WithDecisionAPI(options ...func(*decisionapi.APIClient)) OptionBuilder

WithDecisionAPI changes the decision API options

func WithVisitorCache

func WithVisitorCache(options ...cache.OptionBuilder) OptionBuilder

WithVisitorCache enables visitor assignment caching with options

type Options

type Options struct {
	EnvID  string
	APIKey string
	// contains filtered or unexported fields
}

Options represent the options passed to the Flagship SDK client

func (*Options) BuildOptions

func (f *Options) BuildOptions(clientOptions ...OptionBuilder)

BuildOptions fill out the FlagshipOption struct from option builders

type Visitor

type Visitor struct {
	ID          string
	AnonymousID *string
	Context     map[string]interface{}
	// contains filtered or unexported fields
}

Visitor represents a visitor instance of the Flagship SDK

func (*Visitor) ActivateCacheModification

func (v *Visitor) ActivateCacheModification(key string) (err error)

ActivateCacheModification activates a modification from the cache of assigned visitor campaigns

func (*Visitor) ActivateModification

func (v *Visitor) ActivateModification(key string) (err error)

ActivateModification notifies Flagship that the visitor has seen to modification

func (*Visitor) Authenticate added in v2.1.0

func (v *Visitor) Authenticate(newID string, newContext map[string]interface{}, sync bool) (err error)

Authenticate set the authenticated ID for the visitor, along with optional new context and re-synchronize flag

func (*Visitor) GetAllModifications

func (v *Visitor) GetAllModifications() (flagInfos map[string]model.FlagInfos)

GetAllModifications return all the modifications

func (*Visitor) GetDecisionResponse added in v2.0.7

func (v *Visitor) GetDecisionResponse() *model.APIClientResponse

GetDecisionResponse return the decision response

func (*Visitor) GetModificationArray

func (v *Visitor) GetModificationArray(key string, defaultValue []interface{}, activate bool) (castVal []interface{}, err error)

GetModificationArray get a modification array as []interface{} by its key

func (*Visitor) GetModificationBool

func (v *Visitor) GetModificationBool(key string, defaultValue bool, activate bool) (castVal bool, err error)

GetModificationBool get a modification bool by its key

func (*Visitor) GetModificationInfo

func (v *Visitor) GetModificationInfo(key string) (modifInfo *ModificationInfo, err error)

GetModificationInfo returns a modification info by its key

func (*Visitor) GetModificationNumber

func (v *Visitor) GetModificationNumber(key string, defaultValue float64, activate bool) (castVal float64, err error)

GetModificationNumber get a modification number as float64 by its key

func (*Visitor) GetModificationObject

func (v *Visitor) GetModificationObject(key string, defaultValue map[string]interface{}, activate bool) (castVal map[string]interface{}, err error)

GetModificationObject get a modification object as map[string]interface{} by its key

func (*Visitor) GetModificationString

func (v *Visitor) GetModificationString(key string, defaultValue string, activate bool) (castVal string, err error)

GetModificationString get a modification string by its key

func (*Visitor) SendHit

func (v *Visitor) SendHit(hit model.HitInterface) (err error)

SendHit sends a tracking hit to the Data Collect API

func (*Visitor) SynchronizeModifications

func (v *Visitor) SynchronizeModifications() (err error)

SynchronizeModifications updates the latest campaigns and modifications for the visitor

func (*Visitor) Unauthenticate added in v2.1.0

func (v *Visitor) Unauthenticate(newContext map[string]interface{}, sync bool) (err error)

Unauthenticate unset the authenticated ID for the visitor

func (*Visitor) UpdateContext

func (v *Visitor) UpdateContext(newContext model.Context) (err error)

UpdateContext updates the Visitor context with new value

func (*Visitor) UpdateContextKey

func (v *Visitor) UpdateContextKey(key string, value interface{}) (err error)

UpdateContextKey updates a single Visitor context key with new value

type VisitorOptionBuilder added in v2.1.0

type VisitorOptionBuilder func(*VisitorOptions)

VisitorOptionBuilder is a func type to set options to the VisitorOptions.

func WithAuthenticated added in v2.1.0

func WithAuthenticated(isAuthenticated bool) VisitorOptionBuilder

WithAuthenticated sets the is authenticated options of the visitor

type VisitorOptions added in v2.1.0

type VisitorOptions struct {
	IsAuthenticated bool
}

VisitorOptions represents the visitor options of the Flagship SDK

func (*VisitorOptions) BuildVisitorOptions added in v2.1.0

func (f *VisitorOptions) BuildVisitorOptions(visitorOptions ...VisitorOptionBuilder)

BuildVisitorOptions fill out the FlagshipOption struct from option builders

Jump to

Keyboard shortcuts

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