Documentation
¶
Overview ¶
Package client has client definitions
Package client has client facing factories
Index ¶
- type OptimizelyClient
- func (o *OptimizelyClient) Activate(experimentKey string, userContext entities.UserContext) (result string, err error)
- func (o *OptimizelyClient) Close()
- func (o *OptimizelyClient) GetAllFeatureVariables(featureKey string, userContext entities.UserContext) (enabled bool, variableMap map[string]interface{}, err error)
- func (o *OptimizelyClient) GetEnabledFeatures(userContext entities.UserContext) (enabledFeatures []string, err error)
- func (o *OptimizelyClient) GetFeatureVariable(featureKey, variableKey string, userContext entities.UserContext) (value string, valueType entities.VariableType, err error)
- func (o *OptimizelyClient) GetFeatureVariableBoolean(featureKey, variableKey string, userContext entities.UserContext) (value bool, err error)
- func (o *OptimizelyClient) GetFeatureVariableDouble(featureKey, variableKey string, userContext entities.UserContext) (value float64, err error)
- func (o *OptimizelyClient) GetFeatureVariableInteger(featureKey, variableKey string, userContext entities.UserContext) (value int, err error)
- func (o *OptimizelyClient) GetFeatureVariableString(featureKey, variableKey string, userContext entities.UserContext) (value string, err error)
- func (o *OptimizelyClient) GetOptimizelyConfig() (optimizelyConfig *config.OptimizelyConfig)
- func (o *OptimizelyClient) GetVariation(experimentKey string, userContext entities.UserContext) (result string, err error)
- func (o *OptimizelyClient) IsFeatureEnabled(featureKey string, userContext entities.UserContext) (result bool, err error)
- func (o *OptimizelyClient) OnTrack(callback func(eventKey string, userContext entities.UserContext, ...)) (int, error)
- func (o *OptimizelyClient) RemoveOnTrack(id int) error
- func (o *OptimizelyClient) Track(eventKey string, userContext entities.UserContext, ...) (err error)
- type OptimizelyFactory
- type OptionFunc
- func WithBatchEventProcessor(batchSize, queueSize int, flushInterval time.Duration) OptionFunc
- func WithConfigManager(configManager config.ProjectConfigManager) OptionFunc
- func WithContext(ctx context.Context) OptionFunc
- func WithDecisionService(decisionService decision.Service) OptionFunc
- func WithEventDispatcher(eventDispatcher event.Dispatcher) OptionFunc
- func WithEventProcessor(eventProcessor event.Processor) OptionFunc
- func WithExperimentOverrides(overrideStore decision.ExperimentOverrideStore) OptionFunc
- func WithMetricsRegistry(metricsRegistry metrics.Registry) OptionFunc
- func WithPollingConfigManager(pollingInterval time.Duration, initDataFile []byte) OptionFunc
- func WithUserProfileService(userProfileService decision.UserProfileService) OptionFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OptimizelyClient ¶
type OptimizelyClient struct { ConfigManager config.ProjectConfigManager DecisionService decision.Service EventProcessor event.Processor // contains filtered or unexported fields }
OptimizelyClient is the entry point to the Optimizely SDK
func (*OptimizelyClient) Activate ¶
func (o *OptimizelyClient) Activate(experimentKey string, userContext entities.UserContext) (result string, err error)
Activate returns the key of the variation the user is bucketed into and queues up an impression event to be sent to the Optimizely log endpoint for results processing.
func (*OptimizelyClient) Close ¶
func (o *OptimizelyClient) Close()
Close closes the Optimizely instance and stops any ongoing tasks from its children components.
func (*OptimizelyClient) GetAllFeatureVariables ¶
func (o *OptimizelyClient) GetAllFeatureVariables(featureKey string, userContext entities.UserContext) (enabled bool, variableMap map[string]interface{}, err error)
GetAllFeatureVariables returns all the variables for a given feature along with the enabled state.
func (*OptimizelyClient) GetEnabledFeatures ¶
func (o *OptimizelyClient) GetEnabledFeatures(userContext entities.UserContext) (enabledFeatures []string, err error)
GetEnabledFeatures returns an array containing the keys of all features in the project that are enabled for the given user. For features tests, impression events will be queued up to be sent to the Optimizely log endpoint for results processing.
func (*OptimizelyClient) GetFeatureVariable ¶
func (o *OptimizelyClient) GetFeatureVariable(featureKey, variableKey string, userContext entities.UserContext) (value string, valueType entities.VariableType, err error)
GetFeatureVariable returns feature variable as a string along with it's associated type.
func (*OptimizelyClient) GetFeatureVariableBoolean ¶
func (o *OptimizelyClient) GetFeatureVariableBoolean(featureKey, variableKey string, userContext entities.UserContext) (value bool, err error)
GetFeatureVariableBoolean returns the feature variable value of type bool associated with the given feature and variable keys.
func (*OptimizelyClient) GetFeatureVariableDouble ¶
func (o *OptimizelyClient) GetFeatureVariableDouble(featureKey, variableKey string, userContext entities.UserContext) (value float64, err error)
GetFeatureVariableDouble returns the feature variable value of type double associated with the given feature and variable keys.
func (*OptimizelyClient) GetFeatureVariableInteger ¶
func (o *OptimizelyClient) GetFeatureVariableInteger(featureKey, variableKey string, userContext entities.UserContext) (value int, err error)
GetFeatureVariableInteger returns the feature variable value of type int associated with the given feature and variable keys.
func (*OptimizelyClient) GetFeatureVariableString ¶
func (o *OptimizelyClient) GetFeatureVariableString(featureKey, variableKey string, userContext entities.UserContext) (value string, err error)
GetFeatureVariableString returns the feature variable value of type string associated with the given feature and variable keys.
func (*OptimizelyClient) GetOptimizelyConfig ¶
func (o *OptimizelyClient) GetOptimizelyConfig() (optimizelyConfig *config.OptimizelyConfig)
GetOptimizelyConfig returns OptimizelyConfig object
func (*OptimizelyClient) GetVariation ¶
func (o *OptimizelyClient) GetVariation(experimentKey string, userContext entities.UserContext) (result string, err error)
GetVariation returns the key of the variation the user is bucketed into. Does not generate impression events.
func (*OptimizelyClient) IsFeatureEnabled ¶
func (o *OptimizelyClient) IsFeatureEnabled(featureKey string, userContext entities.UserContext) (result bool, err error)
IsFeatureEnabled returns true if the feature is enabled for the given user. If the user is part of a feature test then an impression event will be queued up to be sent to the Optimizely log endpoint for results processing.
func (*OptimizelyClient) OnTrack ¶
func (o *OptimizelyClient) OnTrack(callback func(eventKey string, userContext entities.UserContext, eventTags map[string]interface{}, conversionEvent event.ConversionEvent)) (int, error)
OnTrack registers a handler for Track notifications
func (*OptimizelyClient) RemoveOnTrack ¶
func (o *OptimizelyClient) RemoveOnTrack(id int) error
RemoveOnTrack removes handler for Track notification with given id
func (*OptimizelyClient) Track ¶
func (o *OptimizelyClient) Track(eventKey string, userContext entities.UserContext, eventTags map[string]interface{}) (err error)
Track generates a conversion event with the given event key if it exists and queues it up to be sent to the Optimizely log endpoint for results processing.
type OptimizelyFactory ¶
type OptimizelyFactory struct { SDKKey string Datafile []byte // contains filtered or unexported fields }
OptimizelyFactory is used to customize and construct an instance of the OptimizelyClient.
func (OptimizelyFactory) Client ¶
func (f OptimizelyFactory) Client(clientOptions ...OptionFunc) (*OptimizelyClient, error)
Client instantiates a new OptimizelyClient with the given options.
func (OptimizelyFactory) StaticClient ¶
func (f OptimizelyFactory) StaticClient() (*OptimizelyClient, error)
StaticClient returns a client initialized with a static project config.
type OptionFunc ¶
type OptionFunc func(*OptimizelyFactory)
OptionFunc is used to provide custom client configuration to the OptimizelyFactory.
func WithBatchEventProcessor ¶
func WithBatchEventProcessor(batchSize, queueSize int, flushInterval time.Duration) OptionFunc
WithBatchEventProcessor sets event processor on a client.
func WithConfigManager ¶
func WithConfigManager(configManager config.ProjectConfigManager) OptionFunc
WithConfigManager sets polling config manager on a client.
func WithContext ¶
func WithContext(ctx context.Context) OptionFunc
WithContext allows user to pass in their own context to override the default one in the client.
func WithDecisionService ¶
func WithDecisionService(decisionService decision.Service) OptionFunc
WithDecisionService sets decision service on a client.
func WithEventDispatcher ¶
func WithEventDispatcher(eventDispatcher event.Dispatcher) OptionFunc
WithEventDispatcher sets event dispatcher on the factory.
func WithEventProcessor ¶
func WithEventProcessor(eventProcessor event.Processor) OptionFunc
WithEventProcessor sets event processor on a client
func WithExperimentOverrides ¶
func WithExperimentOverrides(overrideStore decision.ExperimentOverrideStore) OptionFunc
WithExperimentOverrides sets the experiment override store on the decision service.
func WithMetricsRegistry ¶
func WithMetricsRegistry(metricsRegistry metrics.Registry) OptionFunc
WithMetricsRegistry allows user to pass in their own implementation of a metrics collector
func WithPollingConfigManager ¶
func WithPollingConfigManager(pollingInterval time.Duration, initDataFile []byte) OptionFunc
WithPollingConfigManager sets polling config manager on a client.
func WithUserProfileService ¶
func WithUserProfileService(userProfileService decision.UserProfileService) OptionFunc
WithUserProfileService sets the user profile service on the decision service.