Skip to content

[FSSDK-8956] docs: change full stack to feature experimentation #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 61 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
# Optimizely Ruby SDK

[![Build Status](https://github.com/optimizely/ruby-sdk/actions/workflows/ruby.yml/badge.svg?branch=master)](https://github.com/optimizely/ruby-sdk/actions/workflows/ruby.yml?query=branch%3Amaster)
[![Coverage Status](https://coveralls.io/repos/github/optimizely/ruby-sdk/badge.svg)](https://coveralls.io/github/optimizely/ruby-sdk)
[![Apache 2.0](https://img.shields.io/github/license/nebula-plugins/gradle-extra-configurations-plugin.svg)](http://www.apache.org/licenses/LICENSE-2.0)

This repository houses the Ruby SDK for use with Optimizely Full Stack and Optimizely Rollouts.

Optimizely Full Stack is A/B testing and feature flag management for product development teams. Experiment in any application. Make every feature on your roadmap an opportunity to learn. Learn more at https://www.optimizely.com/platform/full-stack/, or see the [documentation](https://docs.developers.optimizely.com/full-stack/docs).
This repository houses the Ruby 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 for development teams. Easily roll out and roll back features in any application without code deploys. Mitigate risk for every feature on your roadmap. Learn more at https://www.optimizely.com/rollouts/, or see the [documentation](https://docs.developers.optimizely.com/rollouts/docs).
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.

## Getting Started
## Get Started

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

### Requirements

* Ruby 2.7+

### Installing the SDK
### Install the SDK

The SDK is available through [RubyGems](https://rubygems.org/gems/optimizely-sdk). To install:

Expand All @@ -23,40 +28,42 @@ gem install optimizely-sdk
```

### Feature Management Access
To access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely account executive.
To access the Feature Management configuration in the Optimizely dashboard, please contact your Optimizely customer success manager.

### Using the SDK
## Use the Ruby SDK

### Initialization

You can initialize the Optimizely instance in two ways: directly with a datafile, or by using a factory class, `OptimizelyFactory`, which provides methods to create an Optimizely instance with the default configuration.

#### Initialization with datafile

Initialize Optimizely with a datafile. This datafile will be used as ProjectConfig throughout the life of the Optimizely instance.

```
```ruby
optimizely_instance = Optimizely::Project.new(datafile)
```

#### Initialization by OptimizelyFactory

1. Initialize Optimizely by providing an `sdk_key` and an optional `datafile`. This will initialize an HTTPConfigManager that makes an HTTP GET request to the URL (formed using your provided `sdk_key` and the default datafile CDN url template) to asynchronously download the project datafile at regular intervals and update ProjectConfig when a new datafile is received.

```
```ruby
optimizely_instance = Optimizely::OptimizelyFactory.default_instance('put_your_sdk_key_here', datafile)
```

When the `datafile` is given then it will be used initially before any update.

2. Initialize Optimizely by providing a Config Manager that implements a `config` method. You can customize our `HTTPConfigManager` as needed.

```
```ruby
custom_config_manager = CustomConfigManager.new
optimizely_instance = Optimizely::OptimizelyFactory.default_instance_with_config_manager(custom_config_manager)
```

3. Initialize Optimizely with required `sdk_key` and other optional arguments.

```
```ruby
optimizely_instance = Optimizely::OptimizelyFactory.custom_instance(
sdk_key,
datafile,
Expand All @@ -71,13 +78,12 @@ You can initialize the Optimizely instance in two ways: directly with a datafile
)
```


#### HTTP Config Manager

The `HTTPConfigManager` asynchronously polls for datafiles from a specified URL at regular intervals by making HTTP requests.


~~~~~~
```ruby
http_project_config_manager = Optimizely::HTTPProjectConfigManager.new(
sdk_key: nil,
url: nil,
Expand All @@ -94,7 +100,7 @@ The `HTTPConfigManager` asynchronously polls for datafiles from a specified URL
datafile_access_token: nil,
proxy_config: nil
)
~~~~~~
```
**Note:** You must provide either the `sdk_key` or URL. If you provide both, the URL takes precedence.

**sdk_key**
Expand All @@ -110,7 +116,7 @@ The polling interval is used to specify a fixed delay between consecutive HTTP r
A string with placeholder `{sdk_key}` can be provided so that this template along with the provided `sdk_key` is used to form the target URL.

**start_by_default**
Boolean flag used to start the `AsyncScheduler` for datafile polling if set to `True`.
Boolean flag used to start the `AsyncScheduler` for datafile polling if set to `true`.

**blocking_timeout**
The blocking timeout period is used to specify a maximum time to wait for initial bootstrapping. Valid blocking timeout period is between 1 and 2592000 seconds. Default is 15 seconds.
Expand All @@ -135,7 +141,10 @@ The following properties can be set to override the default configurations for `
| start_by_default | true | Boolean flag to specify if datafile polling should start right away as soon as `HTTPConfigManager` initializes
| blocking_timeout | 15 seconds | Maximum time in seconds to block the `config` call until config has been initialized

A notification signal will be triggered whenever a _new_ datafile is fetched and Project Config is updated. To subscribe to these notifications, use the `notification_center.add_notification_listener(Optimizely::NotificationCenter::NOTIFICATION_TYPES[:OPTIMIZELY_CONFIG_UPDATE], @callback)`
A notification signal will be triggered whenever a _new_ datafile is fetched and Project Config is updated. To subscribe to these notifications, use the
```ruby
notification_center.add_notification_listener(Optimizely::NotificationCenter::NOTIFICATION_TYPES[:OPTIMIZELY_CONFIG_UPDATE], @callback)
```


#### BatchEventProcessor
Expand All @@ -146,8 +155,8 @@ A notification signal will be triggered whenever a _new_ datafile is fetched and

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, line 144: use block code style instead of in-line code style for notification_center.add_notification_listener(Optimizely::NotificationCenter::NOTIFICATION_TYPES[:OPTIMIZELY_CONFIG_UPDATE], @callback)

* The `BatchEventProcessor` maintains a single consumer thread that pulls events off of the `Queue` and buffers them for either a configured batch size or for a maximum duration before the resulting `LogEvent` is sent to the `NotificationCenter`.

##### Use BatchEventProcessor
~~~~~~
#### Use BatchEventProcessor
```ruby
event_processor = Optimizely::BatchEventProcessor.new(
event_queue: SizedQueue.new(10),
event_dispatcher: event_dispatcher,
Expand All @@ -156,7 +165,7 @@ event_processor = Optimizely::BatchEventProcessor.new(
logger: logger,
notification_center: notification_center
)
~~~~~~
```

#### Advanced configuration
The following properties can be used to customize the `BatchEventProcessor` configuration.
Expand All @@ -179,9 +188,10 @@ If you enable event batching, make sure that you call the `close` method, `optim
| -- | --
| `close()` | Stops all timers and flushes the event queue. This method will also stop any timers that are happening for the datafile manager.

See the Optimizely Full Stack [developer documentation](http://developers.optimizely.com/server/reference/index.html) to learn how to set up your first Full Stack project and use the SDK.
For Further details see the Optimizely [Feature Experimentation documentation](https://docs.developers.optimizely.com/experimentation/v4.0.0-full-stack/docs/welcome)
to learn how to set up your first Ruby project and use the SDK.

## Development
## SDK Development

### Building the SDK

Expand All @@ -191,9 +201,9 @@ To build a local copy of the gem which will be output to `/pkg`:
rake build
```

### Unit tests
### Unit Tests

##### Running all tests
#### Running all tests
You can run all unit tests with:

```
Expand All @@ -205,6 +215,7 @@ rake spec
Please see [CONTRIBUTING](CONTRIBUTING.md).

### Credits

This software incorporates code from the following open source projects:

**Httparty** [https://github.com/jnunemaker/httparty](https://github.com/jnunemaker/httparty)
Expand All @@ -219,8 +230,8 @@ License (MIT): [https://github.com/ruby-json-schema/json-schema/blob/master/LICE
Copyright © 2012 Sokolov Yura 'funny-falcon'
License (MIT): [https://github.com/funny-falcon/murmurhash3-ruby/blob/master/LICENSE](https://github.com/funny-falcon/murmurhash3-ruby/blob/master/LICENSE)


### Additional Code

This software may be used with additional code that is separately downloaded by you. _These components are subject to
their own license terms, which you should review carefully_.

Expand Down Expand Up @@ -249,3 +260,29 @@ License (MIT): [https://github.com/rubocop-hq/rubocop/blob/master/LICENSE.txt](h
**WebMock** [https://github.com/bblimke/webmock](https://github.com/bblimke/webmock)
Copyright © 2009-2010 Bartosz Blimke
License (MIT): [https://github.com/bblimke/webmock/blob/master/LICENSE](https://github.com/bblimke/webmock/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

- Go - https://github.com/optimizely/go-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
2 changes: 1 addition & 1 deletion optimizely-sdk.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
spec.required_ruby_version = '>= 2.7'

spec.summary = "Ruby SDK for Optimizely's testing framework"
spec.description = "A Ruby SDK for Optimizely's Full Stack product."
spec.description = 'A Ruby SDK for use with Optimizely Feature Experimentation, Optimizely Full Stack (legacy), and Optimizely Rollouts'
spec.homepage = 'https://www.optimizely.com/'
spec.license = 'Apache-2.0'

Expand Down