Skip to content

Commit

Permalink
doc: Add Experimentation section
Browse files Browse the repository at this point in the history
  • Loading branch information
laynax committed Jul 26, 2024
1 parent b7c05df commit e0f713a
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1542,6 +1542,48 @@ func main() {
[rate]: <https://docs.datadoghq.com/developers/metrics/dogstatsd_metrics_submission/?tab=go#metric-submission-options>
[submit-metric]: <https://docs.datadoghq.com/developers/metrics/dogstatsd_metrics_submission/?tab=go>

## 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
Expand Down

0 comments on commit e0f713a

Please sign in to comment.