optimizely_server_side 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changelog.md +7 -0
- data/Gemfile.lock +1 -1
- data/Readme.md +13 -8
- data/lib/optimizely_server_side/configuration.rb +2 -1
- data/lib/optimizely_server_side/experiment.rb +2 -0
- data/lib/optimizely_server_side/helpers/support.rb +2 -2
- data/optimizely_server_side.gemspec +2 -4
- data/spec/optimizely_server_side/configuration_spec.rb +4 -4
- data/spec/optimizely_server_side_spec.rb +9 -5
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 21c1476041632408d773cb808b130c96820800dd
|
4
|
+
data.tar.gz: e331c2e11409f4fc601bd7713cdc6b5ff91747a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24787d1c316e0d09aff313bf6bfac09fd0abec5c59086c7b59800a7bdd15910ad834ee8fa0f5a38ecec44c898072353cdc494907c46a61f60d1d612910fdd8fc
|
7
|
+
data.tar.gz: 2169eb627e065d0ff2bb98b9bc636602d4f2ab326e0e6b7decaffd83ede9bdbd7b26a540e6ad4adc038696449163cbe17c033bbab74c9b9aee123db1c19afcf5
|
data/Changelog.md
ADDED
data/Gemfile.lock
CHANGED
data/Readme.md
CHANGED
@@ -58,11 +58,16 @@ end
|
|
58
58
|
|
59
59
|
```
|
60
60
|
|
61
|
-
|
61
|
+
_Config info_
|
62
62
|
|
63
|
-
`config_endpoint` - This is the Datafile endpoint which returns JSON config. `PROJECT_ID` is a id of your server side project at https://app.optimizely.com .
|
64
|
-
`cache_expiry` - Time we want to keep the config cached in memory.
|
65
|
-
`event_dispatcher` - Optimizely needs to track every visit. You can pass your own event dispatcher from here. Read [more](https://developers.optimizely.com/server/reference/index#event-dispatcher)
|
63
|
+
- `config_endpoint` - This is the Datafile endpoint which returns JSON config. `PROJECT_ID` is a id of your server side project at https://app.optimizely.com .
|
64
|
+
- `cache_expiry` - Time we want to keep the config cached in memory.
|
65
|
+
- `event_dispatcher` - Optimizely needs to track every visit. You can pass your own event dispatcher from here. Read [more](https://developers.optimizely.com/server/reference/index#event-dispatcher)
|
66
|
+
- `user_attributes` - Everything related to user is passed from here. The must have key is `visitor_id`. In the same hash you can pass other other custom attributes. eq
|
67
|
+
|
68
|
+
```
|
69
|
+
config.user_attributes = {'visitor_id' => 1234, 'device_type' => 'iPhone'}
|
70
|
+
```
|
66
71
|
|
67
72
|
|
68
73
|
|
@@ -84,7 +89,7 @@ class ApplicationController < ActionController::Base
|
|
84
89
|
# This links the browser cookie for visitor_id to
|
85
90
|
# OptimizelyServerSide
|
86
91
|
OptimizelyServerSide.configure do |config|
|
87
|
-
config.
|
92
|
+
config.user_attributes = {'visitor_id' => cookies[:visitor_id]}
|
88
93
|
end
|
89
94
|
end
|
90
95
|
|
@@ -99,13 +104,13 @@ class ApplicationController < ActionController::Base
|
|
99
104
|
<% experiment(EXPERIMENT_KEY) do |config| %>
|
100
105
|
|
101
106
|
<% config.variation_one(VARIATION_ONE_KEY) do %>
|
102
|
-
<%= render partial: 'variation_one_experience' %>
|
107
|
+
<%= render partial: 'variation_one_experience' %>
|
103
108
|
<% end %>
|
104
109
|
|
105
110
|
<% config.variation_default(VARIATION_DEFAULT_KEY, primary: true) do %>
|
106
111
|
<%= render partial: 'variation_default_experience' %>
|
107
112
|
<% end %>
|
108
|
-
|
113
|
+
|
109
114
|
<% end %>
|
110
115
|
```
|
111
116
|
|
@@ -151,7 +156,7 @@ You can call you own method names with `variation_` . Below i have `config.varia
|
|
151
156
|
<% config.variation_pathetic_experience(VARIATION_DEFAULT_KEY, primary: true) do %>
|
152
157
|
<%= render partial: 'variation_default_experience' %>
|
153
158
|
<% end %>
|
154
|
-
|
159
|
+
|
155
160
|
<% end %>
|
156
161
|
|
157
162
|
```
|
@@ -6,12 +6,13 @@ module OptimizelyServerSide
|
|
6
6
|
# Configuration enables to open up the configuration of gem for the application.
|
7
7
|
# config_endpoint: Optimizely config endpoint
|
8
8
|
# cache_expiry: (In minutes) How long we want to cache the config.
|
9
|
-
attr_accessor :config_endpoint, :cache_expiry, :
|
9
|
+
attr_accessor :config_endpoint, :cache_expiry, :user_attributes, :logger,
|
10
10
|
:event_dispatcher
|
11
11
|
|
12
12
|
def initialize
|
13
13
|
@config_endpoint = 'http://foo.com'
|
14
14
|
@cache_expiry = 15
|
15
|
+
@user_attributes = {}
|
15
16
|
end
|
16
17
|
|
17
18
|
end
|
@@ -28,8 +28,8 @@ module OptimizelyServerSide
|
|
28
28
|
OptimizelyServerSide::OptimizelySdk
|
29
29
|
.project_instance(event_dispatcher: OptimizelyServerSide.configuration.event_dispatcher)
|
30
30
|
.activate(experiment_key,
|
31
|
-
OptimizelyServerSide.configuration.visitor_id,
|
32
|
-
OptimizelyServerSide.configuration.
|
31
|
+
OptimizelyServerSide.configuration.user_attributes['visitor_id'.freeze],
|
32
|
+
OptimizelyServerSide.configuration.user_attributes)
|
33
33
|
end
|
34
34
|
|
35
35
|
end
|
@@ -2,8 +2,8 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'optimizely_server_side'
|
5
|
-
s.version = '0.0.
|
6
|
-
s.date = '2016-08-
|
5
|
+
s.version = '0.0.10'
|
6
|
+
s.date = '2016-08-28'
|
7
7
|
s.summary = "Optimizely server side. A wrapper on top of optimizely's ruby sdk for easy caching of server side config "
|
8
8
|
s.description = "Optimizely server side. A A/B test wrapper on top of optimizely's ruby sdk for easy caching of server side config and exposing few more utility helpers. Handling of fallbacks and marking primary experiments. "
|
9
9
|
s.authors = ["Ankit Gupta"]
|
@@ -20,5 +20,3 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.add_runtime_dependency 'optimizely-sdk' , '~> 0.1.1'
|
21
21
|
s.add_runtime_dependency 'activesupport', '~> 4.2', '>= 4.2.6'
|
22
22
|
end
|
23
|
-
|
24
|
-
|
@@ -12,10 +12,10 @@ RSpec.describe OptimizelyServerSide::Configuration do
|
|
12
12
|
|
13
13
|
end
|
14
14
|
|
15
|
-
describe '#
|
15
|
+
describe '#user_attributes' do
|
16
16
|
|
17
|
-
it 'defaults to
|
18
|
-
expect(subject.
|
17
|
+
it 'defaults to {}' do
|
18
|
+
expect(subject.user_attributes).to eq({})
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
@@ -23,7 +23,7 @@ RSpec.describe OptimizelyServerSide::Configuration do
|
|
23
23
|
describe '#event_dispatcher' do
|
24
24
|
|
25
25
|
it 'defaults to nil' do
|
26
|
-
expect(subject.
|
26
|
+
expect(subject.event_dispatcher).to be_nil
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
@@ -23,8 +23,8 @@ RSpec.describe OptimizelyServerSide do
|
|
23
23
|
expect(OptimizelyServerSide.configuration.cache_expiry).to eq(12)
|
24
24
|
end
|
25
25
|
|
26
|
-
it 'has
|
27
|
-
expect(OptimizelyServerSide.configuration.
|
26
|
+
it 'has empty user_attributes' do
|
27
|
+
expect(OptimizelyServerSide.configuration.user_attributes).to eq({})
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -41,7 +41,7 @@ RSpec.describe OptimizelyServerSide do
|
|
41
41
|
|
42
42
|
it 'has config_endpoint' do
|
43
43
|
OptimizelyServerSide.configure do |config|
|
44
|
-
config.
|
44
|
+
config.user_attributes = { visitor_id: '1234abcdef' }
|
45
45
|
end
|
46
46
|
|
47
47
|
expect(OptimizelyServerSide.configuration.config_endpoint).to eq('https://cdn.optimizely.com/json/5960232316.json')
|
@@ -51,8 +51,12 @@ RSpec.describe OptimizelyServerSide do
|
|
51
51
|
expect(OptimizelyServerSide.configuration.cache_expiry).to eq(12)
|
52
52
|
end
|
53
53
|
|
54
|
-
it 'has
|
55
|
-
expect(OptimizelyServerSide.configuration.
|
54
|
+
it 'has user_attributes' do
|
55
|
+
expect(OptimizelyServerSide.configuration.user_attributes).to eq({visitor_id: '1234abcdef'})
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'has a visitor_id' do
|
59
|
+
expect(OptimizelyServerSide.configuration.user_attributes[:visitor_id]).to eq('1234abcdef')
|
56
60
|
end
|
57
61
|
|
58
62
|
it 'has instance of event_dispatcher' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optimizely_server_side
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ankit Gupta
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -83,6 +83,7 @@ files:
|
|
83
83
|
- ".gitignore"
|
84
84
|
- ".rspec"
|
85
85
|
- ".travis.yml"
|
86
|
+
- Changelog.md
|
86
87
|
- Gemfile
|
87
88
|
- Gemfile.lock
|
88
89
|
- Readme.md
|