Skip to content

Commit

Permalink
[FSSDK-8957] Update non-code path resources for FX (#366)
Browse files Browse the repository at this point in the history
* updated README

* changes to other files

* clenup

* PR fixes

* remove ampty sections, update code sample

* updtae code sample

* updtae other code sample
  • Loading branch information
Mat001 authored Mar 10, 2023
1 parent 5a0d450 commit 4d68d51
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 32 deletions.
123 changes: 94 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,30 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/optimizely/go-sdk)](https://goreportcard.com/report/github.com/optimizely/go-sdk)
[![Coverage Status](https://coveralls.io/repos/github/optimizely/go-sdk/badge.svg?branch=master)](https://coveralls.io/github/optimizely/go-sdk?branch=master)

## Installation

### Install from github:
This repository houses the Go SDK for use with Optimizely Feature Experimentation and Optimizely Full Stack (legacy).

Optimizely Feature Experimentation is an A/B testing and feature management tool for product development teams that enables you to experiment at every step. Using Optimizely Feature Experimentation allows for every feature on your roadmap to be an opportunity to discover hidden insights. Learn more at [Optimizely.com](https://www.optimizely.com/products/experiment/feature-experimentation/), or see the [developer documentation](https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/welcome).

Optimizely Rollouts is [free feature flags](https://www.optimizely.com/free-feature-flagging/) for development teams. You can easily roll out and roll back features in any application without code deploys, mitigating risk for every feature on your roadmap.

## Get Started

Refer to the [Go SDK's developer documentation](https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/go-sdk) for detailed instructions on getting started with using the SDK.

### Requirements

Requires Golang version 1.13 or higher.

### Install the SDK

#### Install from github:

```$sh
go get github.com/optimizely/go-sdk
```

### Install from source:
#### Install from source:
```$sh
go get github.com/optimizely/go-sdk
cd $GOPATH/src/github.com/optimizely/go-sdk
Expand All @@ -21,7 +36,7 @@ go install
NOTE:
We practice trunk-based development, and as such our default branch, `master` might not always be the most stable. We do tag releases on Github and you can pin your installation to those particular release versions. One way to do this is to use [*Go Modules*](https://blog.golang.org/using-go-modules) for managing external dependencies:

### Install using go.mod:
#### Install using go.mod:

```
module mymodule
Expand Down Expand Up @@ -49,46 +64,72 @@ go get github.com/optimizely/go-sdk/pkg
```
will install it as a package to pkg directory, rather than src directory. It could be useful for future development and vendoring.

## Usage

### Instantiation
To start using the SDK, create an instance using our factory method:
## Use the Go SDK

See the example file in examples/main.go.

### Initialization

```
import optly "github.com/optimizely/go-sdk"
import "github.com/optimizely/go-sdk/client"
// Simple one-line initialization with the SDK key
client, err := optly.Client("SDK_KEY")
// Simple one-line initialization with the SDK key   
optlyClient, err := optly.Client("SDK_KEY")   
// You can also instantiate with a hard-coded datafile using our client factory method
optimizelyFactory := &client.OptimizelyFactory{
Datafile: []byte("datafile_string"),
// You can also instantiate with a hard-coded datafile using our client factory method   
optimizelyFactory := &client.OptimizelyFactory {       
Datafile: []byte("datafile_string"),   
}   
optlyClient, err = optimizelyFactory.Client()
```
### Make Decisions
```
import (
optly "github.com/optimizely/go-sdk"
)
// instantiate a client
client, err := optly.Client("SDK_KEY")
// User attributes are optional and used for targeting and results segmentation
attributes := map[string]interface{}{
"state": "California",
"likes_donuts": true,
}
user := client.CreateUserContext("optimizely end user", attributes)
options := []decide.OptimizelyDecideOptions{decide.IncludeReasons}
decision := user.Decide("my_flag", options)
var variationKey string
if variationKey = decision.VariationKey; variationKey == "" {
fmt.Printf("[decide] error: %v", decision.Reasons)
return
}
if variationKey == "control" {
// Execute code for control variation
} else if variationKey == "treatment" {
// Execute code for treatment variation
}
```

client, err = optimizelyFactory.Client()
## SDK Development

```
### Unit Tests

### Feature Rollouts
Run
```
make test
```
import (
optly "github.com/optimizely/go-sdk"
)

// instantiate a client
client, err := optly.Client("SDK_KEY")
### Contributing

// User attributes are optional and used for targeting and results segmentation
atributes := map[string]interface{}{
"state": "California",
"likes_donuts": true,
},
user := optly.UserContext("optimizely end user", attributes)
enabled, _ := client.IsFeatureEnabled("binary_feature", user)
```
Please see [CONTRIBUTING](https://github.com/optimizely/go-sdk/blob/master/CONTRIBUTING.md).

## Credits
### Credits

This software is distributed with code from the following open source projects:

Expand Down Expand Up @@ -119,3 +160,27 @@ License (BSD): https://github.com/pkg/profile/blob/master/LICENSE
sync
Copyright (c) 2009 The Go Authors. All rights reserved.
https://github.com/golang/sync/blob/master/LICENSE

### Other Optimizely SDKs

- Agent - https://github.com/optimizely/agent

- Android - https://github.com/optimizely/android-sdk

- C# - https://github.com/optimizely/csharp-sdk

- Flutter - https://github.com/optimizely/optimizely-flutter-sdk

- Java - https://github.com/optimizely/java-sdk

- JavaScript - https://github.com/optimizely/javascript-sdk

- PHP - https://github.com/optimizely/php-sdk

- Python - https://github.com/optimizely/python-sdk

- React - https://github.com/optimizely/react-sdk

- Ruby - https://github.com/optimizely/ruby-sdk

- Swift - https://github.com/optimizely/swift-sdk
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ updatedAt: "2020-01-28T21:53:26.607Z"
---
### Overview

Full Stack SDKs open a well-defined set of public APIs, hiding all implementation details. However, some clients may need access to project configuration data within the "datafile".
Optimizely Feature Experimentation and Optimizely Full Stack (legacy) SDKs open a well-defined set of public APIs, hiding all implementation details. However, some clients may need access to project configuration data within the "datafile".

In this document, we extend our public APIs to define data models and access methods, which clients can use to access project configuration data.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ hidden: true
createdAt: "2019-10-29T23:36:28.978Z"
updatedAt: "2020-01-16T20:42:04.941Z"
---
The [Optimizely Full Stack Go SDK](https://github.com/optimizely/go-sdk) batches impression and conversion events into a single payload before sending it to Optimizely. This is achieved through an SDK component called the event processor.
The [Optimizely Feature Experimentation Go SDK](https://github.com/optimizely/go-sdk) batches impression and conversion events into a single payload before sending it to Optimizely. This is achieved through an SDK component called the event processor.

Event batching has the advantage of reducing the number of outbound requests to Optimizely depending on how you define, configure, and use the event processor. It means less network traffic for the same number of Impression and conversion events tracked.

Expand Down
2 changes: 1 addition & 1 deletion pkg/odp/utils/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const OdpAPIKeyHeader = "x-api-key"
// OdpEventType holds the value for the odp event type
const OdpEventType = "fullstack"

// OdpFSUserIDKey holds the key for the odp fullstack userID
// OdpFSUserIDKey holds the key for the odp fullstack/feature experimentation userID
const OdpFSUserIDKey = "fs_user_id"

// OdpActionIdentified holds the value for identified action type
Expand Down

0 comments on commit 4d68d51

Please sign in to comment.