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 OverrideConfig(config string, val map[string]interface{})
- func OverrideGate(gate string, val bool)
- 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) GetLayer(user User, layer string) Layer
- func (c *Client) LogEvent(event Event)
- func (c *Client) LogImmediate(events []Event) (*http.Response, error)
- func (c *Client) OverrideConfig(config string, val map[string]interface{})
- func (c *Client) OverrideGate(gate string, val bool)
- func (c *Client) Shutdown()
- type DynamicConfig
- type Environment
- type Event
- type Layer
- type Options
- type User
Constants ¶
const DefaultEndpoint = "https://statsigapi.net/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
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
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
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
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 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
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 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 Layer ¶ added in v1.4.0
type Layer struct {
// contains filtered or unexported fields
}
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 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.