Documentation
¶
Overview ¶
Package optimizely wraps the Optimizely SDK
Package optimizely wraps the Optimizely SDK ¶
Package optimizely wraps the Optimizely SDK ¶
Package optimizely wraps the Optimizely SDK ¶
Package optimizely //
Package optimizely //
Index ¶
- Variables
- func SetLogger(logger *zerolog.Logger)
- type Cache
- type LogConsumer
- type MetricsRegistry
- type OptlyCache
- type OptlyClient
- func (c *OptlyClient) GetExperiment(experimentKey string) (optimizelyconfig.OptimizelyExperiment, error)
- func (c *OptlyClient) GetExperimentVariation(experimentKey string, shouldActivate bool, ctx *OptlyContext) (variation optimizelyconfig.OptimizelyVariation, err error)
- func (c *OptlyClient) GetFeature(featureKey string) (optimizelyconfig.OptimizelyFeature, error)
- func (c *OptlyClient) GetFeatureWithContext(featureKey string, ctx *OptlyContext) (enabled bool, variableMap map[string]string, err error)
- func (c *OptlyClient) ListExperiments() (experiments []optimizelyconfig.OptimizelyExperiment, err error)
- func (c *OptlyClient) ListFeatures() (features []optimizelyconfig.OptimizelyFeature, err error)
- func (c *OptlyClient) RemoveForcedVariation(experimentKey, userID string) error
- func (c *OptlyClient) SetForcedVariation(experimentKey, userID, variationKey string) (bool, error)
- func (c *OptlyClient) TrackEventWithContext(eventKey string, ctx *OptlyContext, eventTags map[string]interface{}) error
- func (c *OptlyClient) UpdateConfig()
- type OptlyContext
Constants ¶
This section is empty.
Variables ¶
var ErrForcedVariationsUninitialized = errors.New("client forced variations store not initialized")
ErrForcedVariationsUninitialized is returned from SetForcedVariation and GetForcedVariation when the forced variations store is not initialized
Functions ¶
Types ¶
type Cache ¶
type Cache interface {
GetClient(sdkKey string) (*OptlyClient, error)
}
Cache defines a basic interface for retrieving an instance of the OptlyClient keyed off of the SDK Key
type LogConsumer ¶
type LogConsumer struct {
// contains filtered or unexported fields
}
LogConsumer is an implementation of the OptimizelyLogConsumer that wraps a zerolog logger
func (*LogConsumer) Log ¶
func (l *LogConsumer) Log(level logging.LogLevel, message string, fields map[string]interface{})
Log logs the message if it's log level is higher than or equal to the logger's set level
func (*LogConsumer) SetLogLevel ¶
func (l *LogConsumer) SetLogLevel(level logging.LogLevel)
SetLogLevel changes the log level to the given level
type MetricsRegistry ¶ added in v0.11.0
type MetricsRegistry struct {
// contains filtered or unexported fields
}
MetricsRegistry initializes metrics registry
func NewRegistry ¶ added in v0.11.0
func NewRegistry(registry *metrics.Registry) *MetricsRegistry
NewRegistry initializes metrics registry
func (*MetricsRegistry) GetCounter ¶ added in v0.11.0
func (m *MetricsRegistry) GetCounter(key string) go_sdk_metrics.Counter
GetCounter gets sdk Counter
func (*MetricsRegistry) GetGauge ¶ added in v0.11.0
func (m *MetricsRegistry) GetGauge(key string) go_sdk_metrics.Gauge
GetGauge gets sdk Gauge
type OptlyCache ¶
type OptlyCache struct {
// contains filtered or unexported fields
}
OptlyCache implements the Cache interface backed by a concurrent map. The default OptlyClient lookup is based on supplied configuration via env variables.
func NewCache ¶
func NewCache(ctx context.Context, conf config.OptlyConfig, metricsRegistry *MetricsRegistry) *OptlyCache
NewCache returns a new implementation of OptlyCache interface backed by a concurrent map.
func (*OptlyCache) GetClient ¶
func (c *OptlyCache) GetClient(sdkKey string) (*OptlyClient, error)
GetClient is used to fetch an instance of the OptlyClient when the SDK Key is explicitly supplied.
func (*OptlyCache) Wait ¶
func (c *OptlyCache) Wait()
Wait for all optimizely clients to gracefully shutdown
type OptlyClient ¶
type OptlyClient struct {
*optimizelyclient.OptimizelyClient
ConfigManager *optimizelyconfig.PollingProjectConfigManager
ForcedVariations *decision.MapExperimentOverridesStore
}
OptlyClient wraps an instance of the OptimizelyClient to provide higher level functionality
func (*OptlyClient) GetExperiment ¶
func (c *OptlyClient) GetExperiment(experimentKey string) (optimizelyconfig.OptimizelyExperiment, error)
GetExperiment returns the experiment definition
func (*OptlyClient) GetExperimentVariation ¶
func (c *OptlyClient) GetExperimentVariation(experimentKey string, shouldActivate bool, ctx *OptlyContext) (variation optimizelyconfig.OptimizelyVariation, err error)
GetExperimentVariation calls the OptimizelyClient with the current OptlyContext
func (*OptlyClient) GetFeature ¶
func (c *OptlyClient) GetFeature(featureKey string) (optimizelyconfig.OptimizelyFeature, error)
GetFeature returns the feature definition
func (*OptlyClient) GetFeatureWithContext ¶
func (c *OptlyClient) GetFeatureWithContext(featureKey string, ctx *OptlyContext) (enabled bool, variableMap map[string]string, err error)
GetFeatureWithContext calls the OptimizelyClient with the current OptlyContext
func (*OptlyClient) ListExperiments ¶
func (c *OptlyClient) ListExperiments() (experiments []optimizelyconfig.OptimizelyExperiment, err error)
ListExperiments returns all available experiments
func (*OptlyClient) ListFeatures ¶
func (c *OptlyClient) ListFeatures() (features []optimizelyconfig.OptimizelyFeature, err error)
ListFeatures returns all available features
func (*OptlyClient) RemoveForcedVariation ¶
func (c *OptlyClient) RemoveForcedVariation(experimentKey, userID string) error
RemoveForcedVariation removes any forced variation that was previously set for the argument experiment key and user ID
func (*OptlyClient) SetForcedVariation ¶
func (c *OptlyClient) SetForcedVariation(experimentKey, userID, variationKey string) (bool, error)
SetForcedVariation sets a forced variation for the argument experiment key and user ID Returns false if the same forced variation was already set for the argument experiment and user, true otherwise Returns an error when forced variations are not available on this OptlyClient instance
func (*OptlyClient) TrackEventWithContext ¶
func (c *OptlyClient) TrackEventWithContext(eventKey string, ctx *OptlyContext, eventTags map[string]interface{}) error
TrackEventWithContext calls the OptimizelyClient Track method with the current OptlyContext.
func (*OptlyClient) UpdateConfig ¶
func (c *OptlyClient) UpdateConfig()
UpdateConfig uses config manager to sync and set project config
type OptlyContext ¶
type OptlyContext struct {
UserContext *entities.UserContext
}
OptlyContext encapsulates the user context. TODO Add support for User Profile Service
func NewContext ¶
func NewContext(id string, attributes map[string]interface{}) *OptlyContext
NewContext creates the base Context for a user
func (*OptlyContext) GetUserID ¶
func (c *OptlyContext) GetUserID() string
GetUserID returns the user ID from within the UserContext
Directories
¶
| Path | Synopsis |
|---|---|
|
Package optimizelytest // Package optimizelytest // Package optimizelytest //
|
Package optimizelytest // Package optimizelytest // Package optimizelytest // |