Documentation ¶
Overview ¶
Package statsig implements feature gating and a/b testing
Index ¶
- Constants
- Variables
- func CheckGate(user User, gate string) bool
- func CheckGateWithExposureLoggingDisabled(user User, gate string) bool
- func GetExperimentLayer(experiment string) (string, bool)
- func InitializeGlobalOutputLogger(options OutputLoggerOptions)
- func InitializeGlobalSessionID()
- func IsInitialized() bool
- func LogEvent(event Event)
- func LogImmediate(events []Event) (*http.Response, error)
- func ManuallyLogConfigExposure(user User, config string)
- func ManuallyLogExperimentExposure(user User, experiment string)
- func ManuallyLogGateExposure(user User, config string)
- func ManuallyLogLayerParameterExposure(user User, layer string, parameter string)
- func NewClientWithDetails(sdkKey string, options *Options) (*Client, InitializeDetails)
- func OverrideConfig(config string, val map[string]interface{})
- func OverrideGate(gate string, val bool)
- func OverrideLayer(layer string, val map[string]interface{})
- func SessionID() string
- func Shutdown()
- func ShutdownAndDangerouslyClearInstance()
- type APIOverrides
- type Client
- func (c *Client) CheckGate(user User, gate string) bool
- func (c *Client) CheckGateWithExposureLoggingDisabled(user User, gate string) bool
- func (c *Client) GetClientInitializeResponse(user User, clientKey string, includeLocalOverrides bool) ClientInitializeResponse
- func (c *Client) GetClientInitializeResponseImpl(user User, options *GCIROptions) ClientInitializeResponse
- func (c *Client) GetClientInitializeResponseWithOptions(user User, options *GCIROptions) ClientInitializeResponse
- func (c *Client) GetConfig(user User, config string) DynamicConfig
- func (c *Client) GetConfigWithExposureLoggingDisabled(user User, config string) DynamicConfig
- func (c *Client) GetExperiment(user User, experiment string) DynamicConfig
- func (c *Client) GetExperimentLayer(experiment string) (string, bool)
- func (c *Client) GetExperimentWithExposureLoggingDisabled(user User, experiment string) DynamicConfig
- func (c *Client) GetExperimentWithOptions(user User, experiment string, options *GetExperimentOptions) DynamicConfig
- func (c *Client) GetGate(user User, gate string) FeatureGate
- func (c *Client) GetGateWithExposureLoggingDisabled(user User, gate string) FeatureGate
- func (c *Client) GetLayer(user User, layer string) Layer
- func (c *Client) GetLayerWithExposureLoggingDisabled(user User, layer string) Layer
- func (c *Client) GetLayerWithOptions(user User, layer string, options *GetLayerOptions) Layer
- func (c *Client) GetUserPersistedValues(user User, idType string) UserPersistedValues
- func (c *Client) LogEvent(event Event)
- func (c *Client) LogImmediate(events []Event) (*http.Response, error)
- func (c *Client) ManuallyLogConfigExposure(user User, config string)
- func (c *Client) ManuallyLogExperimentExposure(user User, experiment string)
- func (c *Client) ManuallyLogGateExposure(user User, gate string)
- func (c *Client) ManuallyLogLayerParameterExposure(user User, layer string, parameter string)
- func (c *Client) OverrideConfig(config string, val map[string]interface{})
- func (c *Client) OverrideGate(gate string, val bool)
- func (c *Client) OverrideLayer(layer string, val map[string]interface{})
- func (c *Client) Shutdown()
- type ClientInitializeResponse
- type ConfigInitializeResponse
- type DataAdapterError
- type DataSource
- type DerivedDeviceMetadata
- type DiagnosticsAction
- type DiagnosticsContext
- type DiagnosticsKey
- type DiagnosticsStep
- type DynamicConfig
- func GetConfig(user User, config string) DynamicConfig
- func GetConfigWithExposureLoggingDisabled(user User, config string) DynamicConfig
- func GetExperiment(user User, experiment string) DynamicConfig
- func GetExperimentWithExposureLoggingDisabled(user User, experiment string) DynamicConfig
- func GetExperimentWithOptions(user User, experiment string, options *GetExperimentOptions) DynamicConfig
- func NewConfig(name string, value map[string]interface{}, ruleID string, groupName string, ...) *DynamicConfig
- func (d *DynamicConfig) GetBool(key string, fallback bool) bool
- func (d *DynamicConfig) GetMap(key string, fallback map[string]interface{}) map[string]interface{}
- func (d *DynamicConfig) GetNumber(key string, fallback float64) float64
- func (d *DynamicConfig) GetSlice(key string, fallback []interface{}) []interface{}
- func (d *DynamicConfig) GetString(key string, fallback string) string
- type Environment
- type EvaluationCallbacks
- type EvaluationDetails
- type EvaluationReason
- type EvaluationSource
- type Event
- type ExposureEvent
- type ExposureEventName
- type FeatureGate
- type GCIROptions
- type GateInitializeResponse
- type GetExperimentOptions
- type GetLayerOptions
- type GlobalState
- type IDataAdapter
- type IPCountryOptions
- type IUserPersistentStorage
- type InitializeDetails
- type Layer
- func GetLayer(user User, layer string) Layer
- func GetLayerWithExposureLoggingDisabled(user User, layer string) Layer
- func GetLayerWithOptions(user User, layer string, options *GetLayerOptions) Layer
- func NewLayer(name string, value map[string]interface{}, ruleID string, groupName string, ...) *Layer
- func (d *Layer) GetBool(key string, fallback bool) bool
- func (d *Layer) GetMap(key string, fallback map[string]interface{}) map[string]interface{}
- func (d *Layer) GetNumber(key string, fallback float64) float64
- func (d *Layer) GetSlice(key string, fallback []interface{}) []interface{}
- func (d *Layer) GetString(key string, fallback string) string
- type LayerInitializeResponse
- type LogEventError
- type Options
- type OutputLogger
- type OutputLoggerOptions
- type RequestMetadata
- type RequestOptions
- type SDKInfo
- type SecondaryExposure
- type StatsigError
- type StatsigLoggerOptions
- type StatsigProcess
- type StickyValues
- type TransportError
- type UAParserOptions
- type User
- type UserPersistedValues
Constants ¶
const ( InvalidSDKKeyError string = "Must provide a valid SDK key." EmptyUserError string = "" /* 127-byte string literal not displayed */ EventBatchSizeError string = "The max number of events supported in one batch is 500. Please reduce the slice size and try again." )
const ( StatsigAPI = "https://statsigapi.net/v1" StatsigCDN = "https://api.statsigcdn.com/v1" )
const CONFIG_SPECS_KEY = "statsig.cache"
const ID_LISTS_KEY = "statsig.id_lists"
const MaxMarkerSize = 50
Variables ¶
var DEFAULT_SAMPLING_RATES = map[string]int{
"initialize": 10000,
"config_sync": 0,
"api_call": 0,
}
var ErrorBoundaryAPI = "https://statsigapi.net/v1"
var ErrorBoundaryEndpoint = "/sdk_exception"
Functions ¶
func CheckGateWithExposureLoggingDisabled ¶ added in v1.8.0
Checks the value of a Feature Gate for the given user without logging an exposure event
func GetExperimentLayer ¶ added in v1.22.0
Gets the name of layer an Experiment
func InitializeGlobalOutputLogger ¶ added in v1.10.0
func InitializeGlobalOutputLogger(options OutputLoggerOptions)
func InitializeGlobalSessionID ¶ added in v1.13.0
func InitializeGlobalSessionID()
func IsInitialized ¶ added in v1.9.0
func IsInitialized() bool
IsInitialized returns whether the global Statsig instance has already been initialized or not
func LogImmediate ¶ added in v1.2.0
Logs a slice of events to Statsig server immediately
func ManuallyLogConfigExposure ¶ added in v1.8.0
Logs an exposure event for the dynamic config
func ManuallyLogExperimentExposure ¶ added in v1.8.0
Logs an exposure event for the experiment
func ManuallyLogGateExposure ¶ added in v1.8.0
Logs an exposure event for the gate
func ManuallyLogLayerParameterExposure ¶ added in v1.8.0
Logs an exposure event for the parameter in the given layer
func NewClientWithDetails ¶ added in v1.30.2
func NewClientWithDetails(sdkKey string, options *Options) (*Client, InitializeDetails)
Initializes a Statsig Client with the given sdkKey and options returning the initialized client and details of initialization
func OverrideConfig ¶ added in v1.3.0
Override the DynamicConfig value for the given user
func OverrideGate ¶ added in v1.3.0
Override the value of a Feature Gate for the given user
func OverrideLayer ¶ added in v1.9.0
Override the Layer value for the given user
func Shutdown ¶
func Shutdown()
Cleans up Statsig, persisting any Event Logs and cleanup processes Using any method is undefined after Shutdown() has been called
func ShutdownAndDangerouslyClearInstance ¶ added in v1.11.0
func ShutdownAndDangerouslyClearInstance()
For test only so we can clear the shared instance. Not thread safe.
Types ¶
type APIOverrides ¶ added in v1.27.0
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
An instance of a StatsigClient for interfacing with Statsig Feature Gates, Dynamic Configs, Experiments, and Event Logging
func NewClientWithOptions ¶ added in v1.0.0
Initializes a Statsig Client with the given sdkKey and options
func (*Client) CheckGateWithExposureLoggingDisabled ¶ added in v1.8.0
Checks the value of a Feature Gate for the given user without logging an exposure event
func (*Client) GetClientInitializeResponse ¶ added in v1.8.1
func (c *Client) GetClientInitializeResponse(user User, clientKey string, includeLocalOverrides bool) ClientInitializeResponse
func (*Client) GetClientInitializeResponseImpl ¶ added in v1.23.0
func (c *Client) GetClientInitializeResponseImpl(user User, options *GCIROptions) ClientInitializeResponse
func (*Client) GetClientInitializeResponseWithOptions ¶ added in v1.23.0
func (c *Client) GetClientInitializeResponseWithOptions(user User, options *GCIROptions) ClientInitializeResponse
func (*Client) GetConfig ¶
func (c *Client) GetConfig(user User, config string) DynamicConfig
Gets the DynamicConfig value for the given user
func (*Client) GetConfigWithExposureLoggingDisabled ¶ added in v1.8.0
func (c *Client) GetConfigWithExposureLoggingDisabled(user User, config string) DynamicConfig
Gets the DynamicConfig value for the given user without logging an exposure event
func (*Client) GetExperiment ¶
func (c *Client) GetExperiment(user User, experiment string) DynamicConfig
Gets the DynamicConfig value of an Experiment for the given user
func (*Client) GetExperimentLayer ¶ added in v1.22.0
Gets the layer name of an Experiment
func (*Client) GetExperimentWithExposureLoggingDisabled ¶ added in v1.8.0
func (c *Client) GetExperimentWithExposureLoggingDisabled(user User, experiment string) DynamicConfig
Gets the DynamicConfig value of an Experiment for the given user without logging an exposure event
func (*Client) GetExperimentWithOptions ¶ added in v1.18.0
func (c *Client) GetExperimentWithOptions(user User, experiment string, options *GetExperimentOptions) DynamicConfig
Gets the DynamicConfig value of an Experiment for the given user with configurable options
func (*Client) GetGate ¶ added in v1.15.0
func (c *Client) GetGate(user User, gate string) FeatureGate
Get the Feature Gate for the given user
func (*Client) GetGateWithExposureLoggingDisabled ¶ added in v1.15.0
func (c *Client) GetGateWithExposureLoggingDisabled(user User, gate string) FeatureGate
Checks the value of a Feature Gate for the given user without logging an exposure event
func (*Client) GetLayerWithExposureLoggingDisabled ¶ added in v1.8.0
Gets the Layer object for the given user without logging an exposure event
func (*Client) GetLayerWithOptions ¶ added in v1.20.0
func (c *Client) GetLayerWithOptions(user User, layer string, options *GetLayerOptions) Layer
Gets the Layer object for the given user with configurable options
func (*Client) GetUserPersistedValues ¶ added in v1.18.0
func (c *Client) GetUserPersistedValues(user User, idType string) UserPersistedValues
func (*Client) LogImmediate ¶ added in v1.2.0
func (*Client) ManuallyLogConfigExposure ¶ added in v1.8.0
Logs an exposure event for the config
func (*Client) ManuallyLogExperimentExposure ¶ added in v1.8.0
Logs an exposure event for the experiment
func (*Client) ManuallyLogGateExposure ¶ added in v1.8.0
Logs an exposure event for the dynamic config
func (*Client) ManuallyLogLayerParameterExposure ¶ added in v1.8.0
Logs an exposure event for the parameter in the given layer
func (*Client) OverrideConfig ¶ added in v1.3.0
Override the DynamicConfig value for the given user
func (*Client) OverrideGate ¶ added in v1.3.0
Override the value of a Feature Gate for the given user
func (*Client) OverrideLayer ¶ added in v1.9.0
Override the Layer value for the given user
type ClientInitializeResponse ¶ added in v1.8.1
type ClientInitializeResponse struct { FeatureGates map[string]GateInitializeResponse `json:"feature_gates"` DynamicConfigs map[string]ConfigInitializeResponse `json:"dynamic_configs"` LayerConfigs map[string]LayerInitializeResponse `json:"layer_configs"` SdkParams map[string]string `json:"sdkParams"` HasUpdates bool `json:"has_updates"` Generator string `json:"generator"` EvaluatedKeys map[string]interface{} `json:"evaluated_keys"` Time int64 `json:"time"` SDKInfo SDKInfo `json:"sdkInfo"` User User `json:"user"` HashUsed string `json:"hash_used"` }
func GetClientInitializeResponse ¶ added in v1.8.1
func GetClientInitializeResponse(user User) ClientInitializeResponse
func GetClientInitializeResponseForTargetApp ¶ added in v1.12.0
func GetClientInitializeResponseForTargetApp(user User, clientKey string) ClientInitializeResponse
func GetClientInitializeResponseWithOptions ¶ added in v1.23.0
func GetClientInitializeResponseWithOptions(user User, options *GCIROptions) ClientInitializeResponse
type ConfigInitializeResponse ¶ added in v1.8.1
type ConfigInitializeResponse struct { Value map[string]interface{} `json:"value"` Group string `json:"group"` IsDeviceBased bool `json:"is_device_based"` IsExperimentActive *bool `json:"is_experiment_active,omitempty"` IsUserInExperiment *bool `json:"is_user_in_experiment,omitempty"` IsInLayer *bool `json:"is_in_layer,omitempty"` ExplicitParameters *[]string `json:"explicit_parameters,omitempty"` GroupName string `json:"group_name,omitempty"` IDType string `json:"id_type,omitempty"` // contains filtered or unexported fields }
type DataAdapterError ¶ added in v1.30.0
func (*DataAdapterError) Error ¶ added in v1.30.0
func (e *DataAdapterError) Error() string
func (*DataAdapterError) Is ¶ added in v1.30.0
func (e *DataAdapterError) Is(target error) bool
func (*DataAdapterError) Unwrap ¶ added in v1.30.0
func (e *DataAdapterError) Unwrap() error
type DataSource ¶ added in v1.18.0
type DataSource string
const ( AdapterDataSource DataSource = "adapter" NetworkDataSource DataSource = "network" )
type DerivedDeviceMetadata ¶ added in v1.29.1
type DiagnosticsAction ¶ added in v1.11.0
type DiagnosticsAction string
const ( StartAction DiagnosticsAction = "start" EndAction DiagnosticsAction = "end" )
type DiagnosticsContext ¶ added in v1.11.0
type DiagnosticsContext string
const ( InitializeContext DiagnosticsContext = "initialize" ConfigSyncContext DiagnosticsContext = "config_sync" ApiCallContext DiagnosticsContext = "api_call" )
type DiagnosticsKey ¶ added in v1.11.0
type DiagnosticsKey string
const ( DownloadConfigSpecsKey DiagnosticsKey = "download_config_specs" BootstrapKey DiagnosticsKey = "bootstrap" GetIDListSourcesKey DiagnosticsKey = "get_id_list_sources" GetIDListKey DiagnosticsKey = "get_id_list" OverallKey DiagnosticsKey = "overall" DataStoreConfigSpecsKey DiagnosticsKey = "data_store_config_specs" DataStoreIDLists DiagnosticsKey = "data_store_id_lists" DataStoreIDList DiagnosticsKey = "data_store_id_list" CheckGateApiKey DiagnosticsKey = "check_gate" GetConfigApiKey DiagnosticsKey = "get_config" GetLayerApiKey DiagnosticsKey = "get_layer" )
type DiagnosticsStep ¶ added in v1.11.0
type DiagnosticsStep string
const ( NetworkRequestStep DiagnosticsStep = "network_request" FetchStep DiagnosticsStep = "fetch" ProcessStep DiagnosticsStep = "process" )
type DynamicConfig ¶ added in v1.0.0
type DynamicConfig struct {
// contains filtered or unexported fields
}
A json blob configured in the Statsig Console
func GetConfig ¶
func GetConfig(user User, config string) DynamicConfig
Gets the DynamicConfig value for the given user
func GetConfigWithExposureLoggingDisabled ¶ added in v1.8.0
func GetConfigWithExposureLoggingDisabled(user User, config string) DynamicConfig
Gets the DynamicConfig value for the given user without logging an exposure event
func GetExperiment ¶
func GetExperiment(user User, experiment string) DynamicConfig
Gets the DynamicConfig value of an Experiment for the given user
func GetExperimentWithExposureLoggingDisabled ¶ added in v1.8.0
func GetExperimentWithExposureLoggingDisabled(user User, experiment string) DynamicConfig
Gets the DynamicConfig value of an Experiment for the given user without logging an exposure event
func GetExperimentWithOptions ¶ added in v1.18.0
func GetExperimentWithOptions(user User, experiment string, options *GetExperimentOptions) DynamicConfig
Gets the DynamicConfig value of an Experiment for the given user with configurable options
func NewConfig ¶ added in v1.0.0
func NewConfig(name string, value map[string]interface{}, ruleID string, groupName string, evaluationDetails *EvaluationDetails) *DynamicConfig
func (*DynamicConfig) GetBool ¶ added in v1.0.0
Gets the boolean value at the given key in the DynamicConfig Returns the fallback boolean if the item at the given key is not found or not of type boolean
func (*DynamicConfig) GetNumber ¶ added in v1.0.0
Gets the float64 value at the given key in the DynamicConfig Returns the fallback float64 if the item at the given key is not found or not of type float64
type Environment ¶ added in v1.0.0
type EvaluationCallbacks ¶ added in v1.14.0
type EvaluationCallbacks struct { GateEvaluationCallback func(name string, result bool, exposure *ExposureEvent) ConfigEvaluationCallback func(name string, result DynamicConfig, exposure *ExposureEvent) ExperimentEvaluationCallback func(name string, result DynamicConfig, exposure *ExposureEvent) LayerEvaluationCallback func(name string, param string, result DynamicConfig, exposure *ExposureEvent) ExposureCallback func(name string, exposure *ExposureEvent) IncludeDisabledExposures bool }
type EvaluationDetails ¶ added in v1.23.0
type EvaluationDetails struct { Source EvaluationSource Reason EvaluationReason ConfigSyncTime int64 InitTime int64 ServerTime int64 }
type EvaluationReason ¶ added in v1.30.0
type EvaluationReason string
const ( ReasonNone EvaluationReason = "None" ReasonLocalOverride EvaluationReason = "LocalOverride" ReasonUnrecognized EvaluationReason = "Unrecognized" ReasonPersisted EvaluationReason = "Persisted" )
type EvaluationSource ¶ added in v1.30.0
type EvaluationSource string
const ( SourceUninitialized EvaluationSource = "Uninitialized" SourceNetwork EvaluationSource = "Network" SourceNetworkNotModified EvaluationSource = "NetworkNotModified" SourceBootstrap EvaluationSource = "Bootstrap" SourceDataAdapter EvaluationSource = "DataAdapter" )
type Event ¶ added in v1.0.0
type Event struct { EventName string `json:"eventName"` User User `json:"user"` Value string `json:"value"` Metadata map[string]string `json:"metadata"` Time int64 `json:"time"` }
an event to be sent to Statsig for logging and analysis
type ExposureEvent ¶ added in v1.14.0
type ExposureEvent struct { EventName ExposureEventName `json:"eventName"` User User `json:"user"` Value string `json:"value"` Metadata map[string]string `json:"metadata"` SecondaryExposures []SecondaryExposure `json:"secondaryExposures"` Time int64 `json:"time"` }
type ExposureEventName ¶ added in v1.14.0
type ExposureEventName string
const ( GateExposureEventName ExposureEventName = "statsig::gate_exposure" ConfigExposureEventName ExposureEventName = "statsig::config_exposure" LayerExposureEventName ExposureEventName = "statsig::layer_exposure" )
type FeatureGate ¶ added in v1.15.0
type FeatureGate struct { Name string `json:"name"` Value bool `json:"value"` RuleID string `json:"rule_id"` GroupName string `json:"group_name"` EvaluationDetails *EvaluationDetails `json:"evaluation_details"` }
func GetGate ¶ added in v1.15.0
func GetGate(user User, gate string) FeatureGate
Get the Feature Gate for the given user
func GetGateWithExposureLoggingDisabled ¶ added in v1.15.0
func GetGateWithExposureLoggingDisabled(user User, gate string) FeatureGate
Get the Feature Gate for the given user without logging an exposure event
func NewGate ¶ added in v1.15.0
func NewGate(name string, value bool, ruleID string, groupName string, evaluationDetails *EvaluationDetails) *FeatureGate
type GCIROptions ¶ added in v1.23.0
type GCIROptions struct { IncludeLocalOverrides bool ClientKey string TargetAppID string HashAlgorithm string }
options for getClientInitializeResponse
type GateInitializeResponse ¶ added in v1.8.1
type GetExperimentOptions ¶ added in v1.18.0
type GetExperimentOptions struct { DisableLogExposures bool PersistedValues UserPersistedValues }
type GetLayerOptions ¶ added in v1.20.0
type GetLayerOptions struct { DisableLogExposures bool PersistedValues UserPersistedValues }
type GlobalState ¶ added in v1.10.0
type GlobalState struct {
// contains filtered or unexported fields
}
Using global state variables directly will lead to race conditions Instead, define an accessor below using the Mutex lock
type IDataAdapter ¶ added in v1.8.0
type IDataAdapter interface { /** * Returns the data stored for a specific key */ Get(key string) string /** * Updates data stored for each key */ Set(key string, value string) /** * Startup tasks to run before any get/set calls can be made */ Initialize() /** * Cleanup tasks to run when statsig is shutdown */ Shutdown() /** * Determines whether the SDK should poll for updates from * the data adapter (instead of Statsig network) for the given key */ ShouldBeUsedForQueryingUpdates(key string) bool }
*
- An adapter for implementing custom storage of config specs.
- Can be used to bootstrap Statsig (priority over bootstrapValues if both provided)
- Also useful for backing up cached data
type IPCountryOptions ¶ added in v1.21.0
type IUserPersistentStorage ¶ added in v1.18.0
type IUserPersistentStorage interface { /** * Returns the full map of persisted values for a specific user key */ Load(key string) (UserPersistedValues, bool) /** * Save the persisted values of a config given a specific user key */ Save(key string, configName string, data StickyValues) /** * Delete the persisted values of a config given a specific user key */ Delete(key string, configName string) }
*
- A storage adapter for persisted values. Can be used for sticky bucketing users in experiments.
type InitializeDetails ¶ added in v1.30.0
type InitializeDetails struct { Duration time.Duration Success bool Error error Source EvaluationSource }
func Initialize ¶
func Initialize(sdkKey string) InitializeDetails
Initializes the global Statsig instance with the given sdkKey
func InitializeWithOptions ¶
func InitializeWithOptions(sdkKey string, options *Options) InitializeDetails
Initializes the global Statsig instance with the given sdkKey and options
type Layer ¶ added in v1.4.0
type Layer struct { LogExposure *func(Layer, string) `json:"log_exposure"` AllocatedExperimentName string `json:"allocated_experiment_name"` // contains filtered or unexported fields }
func GetLayerWithExposureLoggingDisabled ¶ added in v1.8.0
Gets the Layer object for the given user without logging an exposure event
func GetLayerWithOptions ¶ added in v1.20.0
func GetLayerWithOptions(user User, layer string, options *GetLayerOptions) Layer
Gets the Layer object for the given user with configurable options
func (*Layer) GetBool ¶ added in v1.4.0
Gets the boolean value at the given key in the DynamicConfig Returns the fallback boolean if the item at the given key is not found or not of type boolean
func (*Layer) GetNumber ¶ added in v1.4.0
Gets the float64 value at the given key in the DynamicConfig Returns the fallback float64 if the item at the given key is not found or not of type float64
type LayerInitializeResponse ¶ added in v1.8.1
type LayerInitializeResponse struct { Value map[string]interface{} `json:"value"` Group string `json:"group"` IsDeviceBased bool `json:"is_device_based"` IsExperimentActive *bool `json:"is_experiment_active,omitempty"` IsUserInExperiment *bool `json:"is_user_in_experiment,omitempty"` ExplicitParameters *[]string `json:"explicit_parameters,omitempty"` AllocatedExperimentName string `json:"allocated_experiment_name,omitempty"` UndelegatedSecondaryExposures []SecondaryExposure `json:"undelegated_secondary_exposures"` GroupName string `json:"group_name,omitempty"` // contains filtered or unexported fields }
type LogEventError ¶ added in v1.24.0
func (*LogEventError) Error ¶ added in v1.24.0
func (e *LogEventError) Error() string
func (*LogEventError) Is ¶ added in v1.24.0
func (e *LogEventError) Is(target error) bool
func (*LogEventError) Unwrap ¶ added in v1.24.0
func (e *LogEventError) Unwrap() error
type Options ¶ added in v1.0.0
type Options struct { API string `json:"api"` APIOverrides APIOverrides `json:"api_overrides"` FallbackToStatsigAPI bool Transport http.RoundTripper Environment Environment `json:"environment"` LocalMode bool `json:"localMode"` ConfigSyncInterval time.Duration IDListSyncInterval time.Duration LoggingInterval time.Duration LoggingMaxBufferSize int BootstrapValues string RulesUpdatedCallback func(rules string, time int64) InitTimeout time.Duration DataAdapter IDataAdapter OutputLoggerOptions OutputLoggerOptions StatsigLoggerOptions StatsigLoggerOptions EvaluationCallbacks EvaluationCallbacks DisableCDN bool // Disables use of CDN for downloading config specs UserPersistentStorage IUserPersistentStorage IPCountryOptions IPCountryOptions UAParserOptions UAParserOptions }
Advanced options for configuring the Statsig SDK
type OutputLogger ¶ added in v1.10.0
type OutputLogger struct {
// contains filtered or unexported fields
}
func Logger ¶ added in v1.13.0
func Logger() *OutputLogger
func (*OutputLogger) Debug ¶ added in v1.18.0
func (o *OutputLogger) Debug(any interface{})
func (*OutputLogger) Log ¶ added in v1.10.0
func (o *OutputLogger) Log(msg string, err error)
func (*OutputLogger) LogError ¶ added in v1.10.0
func (o *OutputLogger) LogError(err interface{})
func (*OutputLogger) LogStep ¶ added in v1.10.0
func (o *OutputLogger) LogStep(process StatsigProcess, msg string)
type OutputLoggerOptions ¶ added in v1.10.0
type RequestMetadata ¶ added in v1.24.0
type RequestOptions ¶ added in v1.15.0
type RequestOptions struct {
// contains filtered or unexported fields
}
type SecondaryExposure ¶ added in v1.26.0
type StatsigError ¶ added in v1.24.0
type StatsigError error
Error Variables
var ( ErrNetworkRequest StatsigError = errors.New("failed network request") ErrFailedLogEvent StatsigError = errors.New("failed to log events") ErrDataAdapter StatsigError = errors.New("failed data adapter") )
type StatsigLoggerOptions ¶ added in v1.11.0
type StatsigProcess ¶ added in v1.10.0
type StatsigProcess string
const ( StatsigProcessInitialize StatsigProcess = "Initialize" StatsigProcessSync StatsigProcess = "Sync" )
type StickyValues ¶ added in v1.19.0
type StickyValues struct { Value bool `json:"value"` JsonValue map[string]interface{} `json:"json_value"` RuleID string `json:"rule_id"` GroupName string `json:"group_name"` SecondaryExposures []SecondaryExposure `json:"secondary_exposures"` Time int64 `json:"time"` ConfigDelegate string `json:"config_delegate,omitempty"` ExplicitParameters []string `json:"explicit_parameters,omitempty"` UndelegatedSecondaryExposures []SecondaryExposure `json:"undelegated_secondary_exposures"` }
The properties of this struct must fit a universal schema that when JSON-ified, can be parsed by every SDK supporting user persistent evaluation.
type TransportError ¶ added in v1.24.0
type TransportError struct { RequestMetadata *RequestMetadata Err error }
func (*TransportError) Error ¶ added in v1.24.0
func (e *TransportError) Error() string
func (*TransportError) Is ¶ added in v1.30.0
func (e *TransportError) Is(target error) bool
func (*TransportError) Unwrap ¶ added in v1.24.0
func (e *TransportError) Unwrap() error
type UAParserOptions ¶ added in v1.21.0
type User ¶ added in v1.0.0
type User struct { UserID string `json:"userID"` Email string `json:"email,omitempty"` IpAddress string `json:"ip,omitempty"` UserAgent string `json:"userAgent,omitempty"` Country string `json:"country,omitempty"` Locale string `json:"locale,omitempty"` AppVersion string `json:"appVersion,omitempty"` Custom map[string]interface{} `json:"custom,omitempty"` PrivateAttributes map[string]interface{} `json:"privateAttributes,omitempty"` StatsigEnvironment map[string]string `json:"statsigEnvironment,omitempty"` CustomIDs map[string]string `json:"customIDs"` }
User specific attributes for evaluating Feature Gates, Experiments, and DynamicConfigs
NOTE: UserID is **required** - see https://docs.statsig.com/messages/serverRequiredUserID\ PrivateAttributes are only used for user targeting/grouping in feature gates, dynamic configs, experiments and etc; they are omitted in logs.
type UserPersistedValues ¶ added in v1.18.0
type UserPersistedValues = map[string]StickyValues
func GetUserPersistedValues ¶ added in v1.18.0
func GetUserPersistedValues(user User, idType string) UserPersistedValues
Source Files ¶
- client.go
- client_initialize_response.go
- country_lookup.go
- data_adapter_example.go
- data_adapter_interface.go
- diagnostics.go
- error_boundary.go
- errors.go
- evaluation_details.go
- evaluator.go
- global_state.go
- logger.go
- output_logger.go
- statsig.go
- statsig_context.go
- statsig_metadata.go
- store.go
- test_utils.go
- transport.go
- types.go
- ua_parser.go
- user_persistent_storage_example.go
- user_persistent_storage_interface.go
- user_persistent_storage_utils.go
- util.go