File tree Expand file tree Collapse file tree 5 files changed +30
-11
lines changed Expand file tree Collapse file tree 5 files changed +30
-11
lines changed Original file line number Diff line number Diff line change 1+ -------------------------------------------------------------------------------
2+ 1.1.1
3+ * Gracefully handle empty traffic allocation ranges.
4+ -------------------------------------------------------------------------------
5+
16-------------------------------------------------------------------------------
271.1.0
38* Introduce support for event tags.
Original file line number Diff line number Diff line change 1- #Optimizely Ruby SDK
1+ # Optimizely Ruby SDK
22[ ![ Build Status] ( https://travis-ci.org/optimizely/ruby-sdk.svg?branch=master )] ( https://travis-ci.org/optimizely/ruby-sdk )
33[ ![ Coverage Status] ( https://coveralls.io/repos/github/optimizely/ruby-sdk/badge.svg )] ( https://coveralls.io/github/optimizely/ruby-sdk )
44[ ![ Apache 2.0] ( https://img.shields.io/github/license/nebula-plugins/gradle-extra-configurations-plugin.svg )] ( http://www.apache.org/licenses/LICENSE-2.0 )
55
66This repository houses the Ruby SDK for Optimizely's Full Stack product.
77
8- ##Getting Started
8+ ## Getting Started
99
10- ###Installing the SDK
10+ ### Installing the SDK
1111
1212The SDK is available through [ RubyGems] ( https://rubygems.org/gems/optimizely-sdk ) . To install:
1313
1414```
1515gem install optimizely-sdk
1616```
1717
18- ###Using the SDK
18+ ### Using the SDK
1919See 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.
2020
21- ##Development
21+ ## Development
2222
23- ###Building the SDK
23+ ### Building the SDK
2424
2525To build a local copy of the gem which will be output to ` /pkg ` :
2626
2727```
2828rake build
2929```
3030
31- ###Unit tests
31+ ### Unit tests
3232
33- #####Running all tests
33+ ##### Running all tests
3434You can run all unit tests with:
3535
3636```
3737rake spec
3838```
3939
40- ###Contributing
40+ ### Contributing
4141
4242Please see [ CONTRIBUTING] ( CONTRIBUTING.md ) .
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ def bucket(experiment_key, user_id)
100100 @config . logger . log ( Logger ::DEBUG , "Assigned variation bucket #{ bucket_value } to user '#{ user_id } '." )
101101 traffic_allocations = @config . get_traffic_allocation ( experiment_key )
102102 variation_id = find_bucket ( bucket_value , traffic_allocations )
103- if variation_id
103+ if variation_id && variation_id != ''
104104 variation_key = @config . get_variation_key_from_id ( experiment_key , variation_id )
105105 @config . logger . log (
106106 Logger ::INFO ,
@@ -109,6 +109,11 @@ def bucket(experiment_key, user_id)
109109 return variation_id
110110 end
111111
112+ # Handle the case when the traffic range is empty due to sticky bucketing
113+ if variation_id == ''
114+ @config . logger . log ( Logger ::DEBUG , 'Bucketed into an empty traffic range. Returning nil.' )
115+ end
116+
112117 @config . logger . log ( Logger ::INFO , "User '#{ user_id } ' is in no variation." )
113118 nil
114119 end
Original file line number Diff line number Diff line change 1414# limitations under the License.
1515#
1616module Optimizely
17- VERSION = '1.1.0 ' . freeze
17+ VERSION = '1.1.1 ' . freeze
1818end
Original file line number Diff line number Diff line change @@ -133,6 +133,15 @@ def get_bucketing_id(user_id, entity_id=nil)
133133 bucketer . bucket ( 'group1_exp1' , 'test_user' )
134134 end
135135
136+ it 'should return nil when user is in an empty traffic allocation range due to sticky bucketing' do
137+ expect ( bucketer ) . to receive ( :find_bucket ) . once . and_return ( '' )
138+ expect ( bucketer . bucket ( 'test_experiment' , 'test_user' ) ) . to be_nil
139+ expect ( spy_logger ) . to have_received ( :log )
140+ . with ( Logger ::INFO , "User 'test_user' is in no variation." )
141+ expect ( spy_logger ) . to have_received ( :log )
142+ . with ( Logger ::DEBUG , "Bucketed into an empty traffic range. Returning nil." )
143+ end
144+
136145 describe 'logging' do
137146 it 'should log the results of bucketing a user into variation 1' do
138147 expect ( bucketer ) . to receive ( :generate_bucket_value ) . and_return ( 50 )
You can’t perform that action at this time.
0 commit comments