Documentation ¶
Overview ¶
Package statsig implements feature gating and a/b testing
Index ¶
- Constants
- func CheckGate(user User, gate string) bool
- func Initialize(sdkKey string)
- func InitializeWithOptions(sdkKey string, options *Options)
- func LogEvent(event Event)
- func LogImmediate(events []Event) (*http.Response, error)
- func Shutdown()
- type Client
- func (c *Client) CheckGate(user User, gate string) bool
- func (c *Client) GetConfig(user User, config string) DynamicConfig
- func (c *Client) GetExperiment(user User, experiment string) DynamicConfig
- func (c *Client) LogEvent(event Event)
- func (c *Client) LogImmediate(events []Event) (*http.Response, error)
- func (c *Client) Shutdown()
- type DynamicConfig
- type Environment
- type Event
- type Options
- type User
Constants ¶
const DefaultEndpoint = "https://api.statsig.com/v1"
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
func Initialize(sdkKey string)
Initializes the global Statsig instance with the given sdkKey
func InitializeWithOptions ¶
Initializes the global Statsig instance with the given sdkKey and options
func LogImmediate ¶ added in v1.2.0
Logs a slice of events to Statsig server immediately
Types ¶
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) GetConfig ¶
func (c *Client) GetConfig(user User, config string) DynamicConfig
Gets the DynamicConfig value for the given user
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) LogImmediate ¶ added in v1.2.0
type DynamicConfig ¶ added in v1.0.0
type DynamicConfig struct { Name string `json:"name"` Value map[string]interface{} `json:"value"` RuleID string `json:"rule_id"` }
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 GetExperiment ¶
func GetExperiment(user User, experiment string) DynamicConfig
Gets the DynamicConfig value of an Experiment for the given user
func NewConfig ¶ added in v1.0.0
func NewConfig(name string, value map[string]interface{}, ruleID string) *DynamicConfig
func (*DynamicConfig) GetBool ¶ added in v1.0.0
func (d *DynamicConfig) GetBool(key string, fallback bool) bool
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
func (d *DynamicConfig) GetNumber(key string, fallback float64) float64
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
func (*DynamicConfig) GetSlice ¶ added in v1.0.0
func (d *DynamicConfig) GetSlice(key string, fallback []interface{}) []interface{}
Gets the slice value at the given key in the DynamicConfig Returns the fallback slice if the item at the given key is not found or not of type slice
type Environment ¶ added in v1.0.0
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"` }
an event to be sent to Statsig for logging and analysis
type Options ¶ added in v1.0.0
type Options struct { API string `json:"api"` Environment Environment `json:"environment"` LocalMode bool `json:"localMode"` }
Advanced options for configuring the Statsig SDK
type User ¶ added in v1.0.0
type User struct { UserID string `json:"userID"` Email string `json:"email"` IpAddress string `json:"ip"` UserAgent string `json:"userAgent"` Country string `json:"country"` Locale string `json:"locale"` AppVersion string `json:"appVersion"` Custom map[string]interface{} `json:"custom"` PrivateAttributes map[string]interface{} `json:"privateAttributes"` StatsigEnvironment map[string]string `json:"statsigEnvironment"` CustomIDs map[string]string `json:"customIDs"` }
User specific attributes for evaluating Feature Gates, Experiments, and DyanmicConfigs
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.