diff --git a/README.md b/README.md index 4106fb8..f61bc7d 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ SDK, the Go version. - [Redis](#redis) - [Profiling](#profiling) - [Custom Metrics](#custom-metrics) +- [Experimentation](#experimentation) + - [Usage of StatSig](#usage-of-statsig) - [Using the `go-sdk` in isolation](#using-the--go-sdk--in-isolation) - [Developing the SDK](#developing-the-sdk) - [Building the docker environment](#building-the-docker-environment) @@ -1542,6 +1544,49 @@ func main() { [rate]: [submit-metric]: +## Experimentation + +`go-sdk` comes with an integration with [StatSig](https://statsig.com) to leverage its experimentation and feature flag functionality. +Using the configuration details, namely the [data source +name](https://en.wikipedia.org/wiki/Data_source_name) (DSN) as their product, +statsig is able to open a connection and give the `go-sdk` users a preconfigured +ready-to-use database connection with an ORM attached. This can be done as +follows: + +```go +package main + +import ( + sdkstatsig "github.com/scribd/go-sdk/pkg/statsig" +) + +func main() { + // Loads the statsig configuration. + statsigConfig, err := sdkstatsig.NewConfig() + + // Initialize statsig connection using the configuration. + sdkstatsig.Initialize(statsigConfig) +} +``` + +#### Usage of StatSig + +After initializing the statsig client, one can start using experimentation or feature flag using the following +code: + +```go +import ( + sdkstatsig "github.com/scribd/go-sdk/pkg/statsig" + statsig "github.com/statsig-io/go-sdk" +) + +func main() { + u := statsig.User{} + exampleExperiment := sdkstatsig.GetExperiment(u, "{experiment}") + examplefeatureFlag := sdkstatsig.GetFeatureFlag(u, "{feature_flag}") +} +``` + ## Using the `go-sdk` in isolation The `go-sdk` is a standalone Go module. This means that it can be imported and