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
+
1
6
-------------------------------------------------------------------------------
2
7
1.1.0
3
8
* Introduce support for event tags.
Original file line number Diff line number Diff line change 1
- #Optimizely Ruby SDK
1
+ # Optimizely Ruby SDK
2
2
[ ![ Build Status] ( https://travis-ci.org/optimizely/ruby-sdk.svg?branch=master )] ( https://travis-ci.org/optimizely/ruby-sdk )
3
3
[ ![ Coverage Status] ( https://coveralls.io/repos/github/optimizely/ruby-sdk/badge.svg )] ( https://coveralls.io/github/optimizely/ruby-sdk )
4
4
[ ![ Apache 2.0] ( https://img.shields.io/github/license/nebula-plugins/gradle-extra-configurations-plugin.svg )] ( http://www.apache.org/licenses/LICENSE-2.0 )
5
5
6
6
This repository houses the Ruby SDK for Optimizely's Full Stack product.
7
7
8
- ##Getting Started
8
+ ## Getting Started
9
9
10
- ###Installing the SDK
10
+ ### Installing the SDK
11
11
12
12
The SDK is available through [ RubyGems] ( https://rubygems.org/gems/optimizely-sdk ) . To install:
13
13
14
14
```
15
15
gem install optimizely-sdk
16
16
```
17
17
18
- ###Using the SDK
18
+ ### Using the SDK
19
19
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.
20
20
21
- ##Development
21
+ ## Development
22
22
23
- ###Building the SDK
23
+ ### Building the SDK
24
24
25
25
To build a local copy of the gem which will be output to ` /pkg ` :
26
26
27
27
```
28
28
rake build
29
29
```
30
30
31
- ###Unit tests
31
+ ### Unit tests
32
32
33
- #####Running all tests
33
+ ##### Running all tests
34
34
You can run all unit tests with:
35
35
36
36
```
37
37
rake spec
38
38
```
39
39
40
- ###Contributing
40
+ ### Contributing
41
41
42
42
Please see [ CONTRIBUTING] ( CONTRIBUTING.md ) .
Original file line number Diff line number Diff line change @@ -100,7 +100,7 @@ def bucket(experiment_key, user_id)
100
100
@config . logger . log ( Logger ::DEBUG , "Assigned variation bucket #{ bucket_value } to user '#{ user_id } '." )
101
101
traffic_allocations = @config . get_traffic_allocation ( experiment_key )
102
102
variation_id = find_bucket ( bucket_value , traffic_allocations )
103
- if variation_id
103
+ if variation_id && variation_id != ''
104
104
variation_key = @config . get_variation_key_from_id ( experiment_key , variation_id )
105
105
@config . logger . log (
106
106
Logger ::INFO ,
@@ -109,6 +109,11 @@ def bucket(experiment_key, user_id)
109
109
return variation_id
110
110
end
111
111
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
+
112
117
@config . logger . log ( Logger ::INFO , "User '#{ user_id } ' is in no variation." )
113
118
nil
114
119
end
Original file line number Diff line number Diff line change 14
14
# limitations under the License.
15
15
#
16
16
module Optimizely
17
- VERSION = '1.1.0 ' . freeze
17
+ VERSION = '1.1.1 ' . freeze
18
18
end
Original file line number Diff line number Diff line change @@ -133,6 +133,15 @@ def get_bucketing_id(user_id, entity_id=nil)
133
133
bucketer . bucket ( 'group1_exp1' , 'test_user' )
134
134
end
135
135
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
+
136
145
describe 'logging' do
137
146
it 'should log the results of bucketing a user into variation 1' do
138
147
expect ( bucketer ) . to receive ( :generate_bucket_value ) . and_return ( 50 )
You can’t perform that action at this time.
0 commit comments