vanity 2.2.8 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +55 -0
- data/Appraisals +24 -20
- data/CHANGELOG +20 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +24 -14
- data/README.md +118 -34
- data/gemfiles/rails42.gemfile +6 -6
- data/gemfiles/rails42.gemfile.lock +94 -85
- data/gemfiles/rails42_protected_attributes.gemfile +6 -6
- data/gemfiles/rails42_protected_attributes.gemfile.lock +96 -74
- data/gemfiles/{rails5.gemfile → rails51.gemfile} +6 -6
- data/gemfiles/rails51.gemfile.lock +285 -0
- data/gemfiles/{rails41.gemfile → rails52.gemfile} +6 -6
- data/gemfiles/rails52.gemfile.lock +295 -0
- data/gemfiles/{rails32.gemfile → rails60.gemfile} +6 -9
- data/gemfiles/rails60.gemfile.lock +293 -0
- data/gemfiles/rails61.gemfile +33 -0
- data/gemfiles/rails61.gemfile.lock +293 -0
- data/lib/generators/templates/add_participants_unique_index_migration.rb.erb +24 -0
- data/lib/generators/templates/add_unique_indexes_migration.rb.erb +28 -0
- data/lib/generators/templates/{vanity_migration.rb → vanity_migration.rb.erb} +6 -4
- data/lib/generators/vanity/migration_generator.rb +34 -0
- data/lib/vanity/adapters/active_record_adapter.rb +29 -9
- data/lib/vanity/adapters/redis_adapter.rb +20 -20
- data/lib/vanity/commands/report.rb +4 -3
- data/lib/vanity/frameworks/rails.rb +20 -9
- data/lib/vanity/locales/vanity.ru.yml +50 -0
- data/lib/vanity/templates/_experiment.erb +3 -3
- data/lib/vanity/templates/_experiments.erb +1 -1
- data/lib/vanity/templates/_metrics.erb +1 -1
- data/lib/vanity/templates/_report.erb +2 -2
- data/lib/vanity/templates/vanity.css +5 -5
- data/lib/vanity/version.rb +1 -1
- data/test/adapters/redis_adapter_test.rb +8 -12
- data/test/adapters/shared_tests.rb +7 -6
- data/test/commands/report_test.rb +13 -1
- data/test/configuration_test.rb +15 -2
- data/test/dummy/app/mailers/vanity_mailer.rb +3 -1
- data/test/dummy/config/initializers/secret_token.rb +5 -2
- data/test/dummy/config/routes.rb +17 -3
- data/test/experiment/ab_test.rb +3 -3
- data/test/frameworks/rails/action_controller_test.rb +12 -6
- data/test/frameworks/rails/action_mailer_test.rb +0 -1
- data/test/metric/active_record_test.rb +8 -2
- data/test/test_helper.rb +57 -10
- data/test/web/rails/dashboard_test.rb +19 -10
- data/vanity.gemspec +1 -1
- metadata +20 -16
- data/.travis.yml +0 -33
- data/gemfiles/rails32.gemfile.lock +0 -242
- data/gemfiles/rails41.gemfile.lock +0 -230
- data/gemfiles/rails5.gemfile.lock +0 -256
- data/lib/generators/vanity_generator.rb +0 -15
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 7481c8ea284e72b569511d54af761ad1626fdfe9246dbb0750fdf56d5f04b2ba
|
|
4
|
+
data.tar.gz: 8ebab61bbb360d445e30d555114a006608693499878cf9655b6765b0148959da
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 930f5cd9d45efdbd8bb9463cfe40914d3e6f87a57cd481d1accc5c7bd328aaf2d52e18a132665dc5100deda3f80662bcc96d94ffab76499c05a1c7b5a14aaf68
|
|
7
|
+
data.tar.gz: 0aa058369c4f8218be1837d24bbc9c68e5f27110e9829a97aab1e8183d5748e0f614be9901de4f9fd8b266dceb0342efbe57baef9b320cd17c69db1574575dfc
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
name: Test
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: '*'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
name: Test
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
timeout-minutes: 15
|
|
14
|
+
services:
|
|
15
|
+
redis:
|
|
16
|
+
image: redis
|
|
17
|
+
ports:
|
|
18
|
+
- 6379:6379
|
|
19
|
+
mongo:
|
|
20
|
+
image: mongo
|
|
21
|
+
ports:
|
|
22
|
+
- 27017:27017
|
|
23
|
+
strategy:
|
|
24
|
+
matrix:
|
|
25
|
+
ruby:
|
|
26
|
+
- 2.5
|
|
27
|
+
# - jruby-9.2.20.1
|
|
28
|
+
db:
|
|
29
|
+
- mongodb
|
|
30
|
+
- redis
|
|
31
|
+
- active_record
|
|
32
|
+
gemfile:
|
|
33
|
+
- gemfiles/rails42.gemfile
|
|
34
|
+
- gemfiles/rails42_protected_attributes.gemfile
|
|
35
|
+
- gemfiles/rails51.gemfile
|
|
36
|
+
- gemfiles/rails52.gemfile
|
|
37
|
+
- gemfiles/rails60.gemfile
|
|
38
|
+
- gemfiles/rails61.gemfile
|
|
39
|
+
exclude:
|
|
40
|
+
- ruby: jruby-9.1.13.0
|
|
41
|
+
gemfile: gemfiles/rails5.gemfile
|
|
42
|
+
env:
|
|
43
|
+
DB: ${{ matrix.db }}
|
|
44
|
+
BUNDLE_GEMFILE: ${{ github.workspace }}/${{ matrix.gemfile }}
|
|
45
|
+
steps:
|
|
46
|
+
- name: Checkout code
|
|
47
|
+
uses: actions/checkout@v2
|
|
48
|
+
|
|
49
|
+
- name: Set up Ruby
|
|
50
|
+
uses: ruby/setup-ruby@v1
|
|
51
|
+
with:
|
|
52
|
+
ruby-version: ${{ matrix.ruby }}
|
|
53
|
+
bundler-cache: true
|
|
54
|
+
- name: Run Tests
|
|
55
|
+
run: bundle exec rake test
|
data/Appraisals
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
|
-
appraise "
|
|
1
|
+
appraise "rails42" do
|
|
2
2
|
gem "mocha", "~> 1.0", :require=>false
|
|
3
|
-
gem "
|
|
4
|
-
gem "
|
|
5
|
-
gem "minitest_tu_shim", "~> 1.3.3", :platforms => :mri_22
|
|
6
|
-
gem "fastthread", :git => "git://github.com/zoltankiss/fastthread.git", :platforms => :mri_20
|
|
3
|
+
gem "rails", "4.2.9"
|
|
4
|
+
gem "fastthread", :github => "zoltankiss/fastthread", :platforms => :mri_20
|
|
7
5
|
gem "passenger", "~>3.0"
|
|
8
|
-
gem "test-unit", "~> 3.0"
|
|
9
6
|
end
|
|
10
7
|
|
|
11
|
-
appraise "
|
|
8
|
+
appraise "rails42-protected_attributes" do
|
|
9
|
+
gem "protected_attributes", "1.1.0"
|
|
12
10
|
gem "mocha", "~> 1.0", :require=>false
|
|
13
|
-
gem "rails", "4.
|
|
14
|
-
gem "fastthread", :
|
|
11
|
+
gem "rails", "4.2.9"
|
|
12
|
+
gem "fastthread", :github => "zoltankiss/fastthread", :platforms => :mri_20
|
|
15
13
|
gem "passenger", "~>3.0"
|
|
16
14
|
end
|
|
17
15
|
|
|
18
|
-
appraise "
|
|
16
|
+
appraise "rails51" do
|
|
19
17
|
gem "mocha", "~> 1.0", :require=>false
|
|
20
|
-
gem "rails", "
|
|
21
|
-
gem "fastthread", :
|
|
18
|
+
gem "rails", "~>5.1.0"
|
|
19
|
+
gem "fastthread", :github => "zoltankiss/fastthread", :platforms => :mri_20
|
|
22
20
|
gem "passenger", "~>3.0"
|
|
23
21
|
end
|
|
24
22
|
|
|
25
|
-
appraise "
|
|
26
|
-
gem "protected_attributes", "1.1.0"
|
|
23
|
+
appraise "rails52" do
|
|
27
24
|
gem "mocha", "~> 1.0", :require=>false
|
|
28
|
-
gem "rails", "
|
|
29
|
-
gem "fastthread", :
|
|
25
|
+
gem "rails", "~>5.2.0"
|
|
26
|
+
gem "fastthread", :github => "zoltankiss/fastthread", :platforms => :mri_20
|
|
30
27
|
gem "passenger", "~>3.0"
|
|
31
28
|
end
|
|
32
29
|
|
|
33
|
-
appraise "
|
|
30
|
+
appraise "rails60" do
|
|
34
31
|
gem "mocha", "~> 1.0", :require=>false
|
|
35
|
-
gem "rails", "5.
|
|
36
|
-
gem "fastthread", :
|
|
32
|
+
gem "rails", "~>5.2.0"
|
|
33
|
+
gem "fastthread", :github => "zoltankiss/fastthread", :platforms => :mri_20
|
|
37
34
|
gem "passenger", "~>3.0"
|
|
38
|
-
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
appraise "rails61" do
|
|
38
|
+
gem "mocha", "~> 1.0", :require=>false
|
|
39
|
+
gem "rails", "~>5.2.0"
|
|
40
|
+
gem "fastthread", :github => "zoltankiss/fastthread", :platforms => :mri_20
|
|
41
|
+
gem "passenger", "~>3.0"
|
|
42
|
+
end
|
data/CHANGELOG
CHANGED
|
@@ -1,4 +1,23 @@
|
|
|
1
|
-
==
|
|
1
|
+
== 3.0.1 (2022-01-26)
|
|
2
|
+
|
|
3
|
+
* Update template rendering and update_attributes for Rails 6.1 compatibility (@bensheldon)
|
|
4
|
+
|
|
5
|
+
== 3.0.0 (2018-11-02)
|
|
6
|
+
|
|
7
|
+
* Fully destroy experiments using the Redis adapter (@urbanautomaton)
|
|
8
|
+
* Fix support for rails 5.1, 5.2 migrations (@phillbaker)
|
|
9
|
+
* Support for redis 4 (#334) (@askehansen)
|
|
10
|
+
* Drop support for redis-rb <= 3.2.0 (@phillbaker)
|
|
11
|
+
* Drop support for rails 2, test recent rubies (@phillbaker)
|
|
12
|
+
|
|
13
|
+
== 2.2.10 (2018-03-18)
|
|
14
|
+
|
|
15
|
+
* Fix broken table size in report dashboard (#339) (@ilyasovd)
|
|
16
|
+
* Prevent dupe participation in same experiment (#335)(@pihman)
|
|
17
|
+
|
|
18
|
+
== 2.2.9 (2018-02-03)
|
|
19
|
+
|
|
20
|
+
* Fix race condition using the activerecord adapater when vanity creates experiments or rows in the conversions table (@fcheung)
|
|
2
21
|
|
|
3
22
|
== 2.2.8 (2017-09-26)
|
|
4
23
|
* Rails 5.1 compatibility (#326, #327, #330, @sebjacobs, @bensheldon, @terracatta)
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
source 'https://rubygems.org'
|
|
2
|
+
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
|
2
3
|
|
|
3
4
|
# "development" gems in gemspec are required for testing, gems in the
|
|
4
5
|
# development group here are for documentation
|
|
@@ -8,7 +9,7 @@ gemspec development_group: :test
|
|
|
8
9
|
gem "rack"
|
|
9
10
|
|
|
10
11
|
# Persistence
|
|
11
|
-
gem "redis", ">= 2.1"
|
|
12
|
+
gem "redis", ">= 3.2.1"
|
|
12
13
|
gem "redis-namespace", ">= 1.1.0"
|
|
13
14
|
gem "mongo", "~> 2.1"
|
|
14
15
|
|
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
vanity (
|
|
4
|
+
vanity (3.0.1)
|
|
5
5
|
i18n
|
|
6
6
|
|
|
7
7
|
GEM
|
|
@@ -15,7 +15,7 @@ GEM
|
|
|
15
15
|
activerecord (>= 2.2)
|
|
16
16
|
activesupport (2.3.14)
|
|
17
17
|
addressable (2.2.7)
|
|
18
|
-
appraisal (
|
|
18
|
+
appraisal (2.4.1)
|
|
19
19
|
bundler
|
|
20
20
|
rake
|
|
21
21
|
thor (>= 0.14.0)
|
|
@@ -32,16 +32,19 @@ GEM
|
|
|
32
32
|
execjs
|
|
33
33
|
coffee-script-source (1.9.1)
|
|
34
34
|
colorator (0.1)
|
|
35
|
+
concurrent-ruby (1.1.9)
|
|
35
36
|
crack (0.3.1)
|
|
36
37
|
execjs (2.5.2)
|
|
37
38
|
fakefs (0.6.7)
|
|
38
39
|
fast-stemmer (1.0.2)
|
|
39
|
-
ffi (1.
|
|
40
|
+
ffi (1.15.5)
|
|
41
|
+
ffi (1.15.5-java)
|
|
40
42
|
garb (0.9.1)
|
|
41
43
|
activesupport (>= 2.2.0)
|
|
42
44
|
crack (>= 0.1.6)
|
|
43
45
|
hitimes (1.2.2)
|
|
44
|
-
i18n (
|
|
46
|
+
i18n (1.9.0)
|
|
47
|
+
concurrent-ruby (~> 1.0)
|
|
45
48
|
integration (0.1.0)
|
|
46
49
|
jdbc-sqlite3 (3.8.7)
|
|
47
50
|
jekyll (2.5.3)
|
|
@@ -85,24 +88,31 @@ GEM
|
|
|
85
88
|
coderay (~> 1.1.0)
|
|
86
89
|
method_source (~> 0.8.1)
|
|
87
90
|
slop (~> 3.4)
|
|
91
|
+
pry (0.10.3-java)
|
|
92
|
+
coderay (~> 1.1.0)
|
|
93
|
+
method_source (~> 0.8.1)
|
|
94
|
+
slop (~> 3.4)
|
|
95
|
+
spoon (~> 0.0)
|
|
88
96
|
pygments.rb (0.6.3)
|
|
89
97
|
posix-spawn (~> 0.3.6)
|
|
90
98
|
yajl-ruby (~> 1.2.0)
|
|
91
99
|
rack (1.1.3)
|
|
92
|
-
rake (
|
|
100
|
+
rake (13.0.6)
|
|
93
101
|
rb-fsevent (0.9.4)
|
|
94
102
|
rb-inotify (0.9.5)
|
|
95
103
|
ffi (>= 0.5.0)
|
|
96
104
|
redcarpet (3.2.3)
|
|
97
|
-
redis (
|
|
98
|
-
redis-namespace (1.
|
|
99
|
-
redis (
|
|
105
|
+
redis (4.0.3)
|
|
106
|
+
redis-namespace (1.6.0)
|
|
107
|
+
redis (>= 3.0.4)
|
|
100
108
|
rubystats (0.2.5)
|
|
101
109
|
safe_yaml (1.0.4)
|
|
102
110
|
sass (3.4.13)
|
|
103
111
|
slop (3.6.0)
|
|
112
|
+
spoon (0.0.6)
|
|
113
|
+
ffi
|
|
104
114
|
sqlite3 (1.3.10)
|
|
105
|
-
thor (
|
|
115
|
+
thor (1.2.1)
|
|
106
116
|
timecop (0.3.5)
|
|
107
117
|
timers (4.0.1)
|
|
108
118
|
hitimes
|
|
@@ -111,8 +121,8 @@ GEM
|
|
|
111
121
|
webmock (1.8.0)
|
|
112
122
|
addressable (>= 2.2.7)
|
|
113
123
|
crack (>= 0.1.7)
|
|
114
|
-
yajl-ruby (1.2.
|
|
115
|
-
yard (0.
|
|
124
|
+
yajl-ruby (1.2.3)
|
|
125
|
+
yard (0.9.16)
|
|
116
126
|
|
|
117
127
|
PLATFORMS
|
|
118
128
|
java
|
|
@@ -121,7 +131,7 @@ PLATFORMS
|
|
|
121
131
|
DEPENDENCIES
|
|
122
132
|
RedCloth
|
|
123
133
|
activerecord-jdbc-adapter
|
|
124
|
-
appraisal (~>
|
|
134
|
+
appraisal (~> 2.0)
|
|
125
135
|
bundler (>= 1.8.0)
|
|
126
136
|
fakefs
|
|
127
137
|
garb (< 0.9.2)
|
|
@@ -133,7 +143,7 @@ DEPENDENCIES
|
|
|
133
143
|
pry
|
|
134
144
|
rack
|
|
135
145
|
rake
|
|
136
|
-
redis (>= 2.1)
|
|
146
|
+
redis (>= 3.2.1)
|
|
137
147
|
redis-namespace (>= 1.1.0)
|
|
138
148
|
rubystats (>= 0.2.5)
|
|
139
149
|
sqlite3 (~> 1.3.10)
|
|
@@ -143,4 +153,4 @@ DEPENDENCIES
|
|
|
143
153
|
yard
|
|
144
154
|
|
|
145
155
|
BUNDLED WITH
|
|
146
|
-
1.
|
|
156
|
+
1.17.1
|
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Vanity
|
|
2
|
-
[](https://github.com/assaf/vanity/actions)
|
|
3
|
+
|
|
4
4
|
|
|
5
5
|
Vanity is an A/B testing framework for Rails that is datastore agnostic.
|
|
6
6
|
|
|
@@ -9,13 +9,34 @@ Vanity is an A/B testing framework for Rails that is datastore agnostic.
|
|
|
9
9
|
|
|
10
10
|
[](http://github.com/assaf/vanity)
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
<!-- toc -->
|
|
13
|
+
|
|
14
|
+
- [Installation](#installation)
|
|
15
|
+
- [Setup](#setup)
|
|
16
|
+
* [Datastore](#datastore)
|
|
17
|
+
+ [Redis Setup](#redis-setup)
|
|
18
|
+
+ [MongoDB Setup](#mongodb-setup)
|
|
19
|
+
+ [SQL Database Setup](#sql-database-setup)
|
|
20
|
+
+ [Forking servers and reconnecting](#forking-servers-and-reconnecting)
|
|
21
|
+
* [Initialization](#initialization)
|
|
22
|
+
* [User identification](#user-identification)
|
|
23
|
+
+ [Rails](#rails)
|
|
24
|
+
+ [Other](#other)
|
|
25
|
+
* [Define a A/B test](#define-a-ab-test)
|
|
26
|
+
* [Present the different options to your users](#present-the-different-options-to-your-users)
|
|
27
|
+
* [Measure conversion](#measure-conversion)
|
|
28
|
+
* [Check the report](#check-the-report)
|
|
29
|
+
+ [Rails report dashboard](#rails-report-dashboard)
|
|
30
|
+
- [Registering participants with Javascript](#registering-participants-with-javascript)
|
|
31
|
+
- [Compatibility](#compatibility)
|
|
32
|
+
- [Testing](#testing)
|
|
33
|
+
- [Updating documentation](#updating-documentation)
|
|
34
|
+
- [Contributing](#contributing)
|
|
35
|
+
- [Credits/License](#creditslicense)
|
|
36
|
+
|
|
37
|
+
<!-- tocstop -->
|
|
38
|
+
|
|
39
|
+
## Installation
|
|
19
40
|
|
|
20
41
|
Add to your Gemfile:
|
|
21
42
|
|
|
@@ -26,19 +47,21 @@ gem "vanity"
|
|
|
26
47
|
(For support for older versions of Rails and Ruby 1.8, please see the [1.9.x
|
|
27
48
|
branch](https://github.com/assaf/vanity/tree/1-9-stable).)
|
|
28
49
|
|
|
29
|
-
|
|
50
|
+
## Setup
|
|
51
|
+
|
|
52
|
+
### Datastore
|
|
30
53
|
|
|
31
54
|
Choose a datastore that best fits your needs and preferences for storing
|
|
32
55
|
experiment results. Choose one of: Redis, MongoDB or an SQL database. While
|
|
33
56
|
Redis is usually faster, it may add additional complexity to your stack.
|
|
34
57
|
Datastores should be configured using a `config/vanity.yml`.
|
|
35
58
|
|
|
36
|
-
|
|
59
|
+
#### Redis Setup
|
|
37
60
|
|
|
38
61
|
Add to your Gemfile:
|
|
39
62
|
|
|
40
63
|
```ruby
|
|
41
|
-
gem "redis", ">= 2
|
|
64
|
+
gem "redis", ">= 3.2"
|
|
42
65
|
gem "redis-namespace", ">= 1.1.0"
|
|
43
66
|
```
|
|
44
67
|
|
|
@@ -73,7 +96,7 @@ Vanity.connect!(
|
|
|
73
96
|
)
|
|
74
97
|
```
|
|
75
98
|
|
|
76
|
-
|
|
99
|
+
#### MongoDB Setup
|
|
77
100
|
|
|
78
101
|
Add to your Gemfile:
|
|
79
102
|
|
|
@@ -94,7 +117,7 @@ production:
|
|
|
94
117
|
database: analytics
|
|
95
118
|
```
|
|
96
119
|
|
|
97
|
-
|
|
120
|
+
#### SQL Database Setup
|
|
98
121
|
|
|
99
122
|
Vanity supports multiple SQL stores (like MySQL, MariaDB, Postgres, Sqlite,
|
|
100
123
|
etc.) using ActiveRecord, which is built into Rails. If you're using
|
|
@@ -116,10 +139,11 @@ test:
|
|
|
116
139
|
active_record_adapter: default
|
|
117
140
|
collecting: false
|
|
118
141
|
production:
|
|
142
|
+
adapter: active_record
|
|
119
143
|
active_record_adapter: postgresql
|
|
120
144
|
<% uri = URI.parse(ENV['DATABASE_URL']) %>
|
|
121
145
|
host: <%= uri.host %>
|
|
122
|
-
username: <%= uri.
|
|
146
|
+
username: <%= uri.user%>
|
|
123
147
|
password: <%= uri.password %>
|
|
124
148
|
port: <%= uri.port %>
|
|
125
149
|
database: <%= uri.path.sub('/', '') %>
|
|
@@ -133,7 +157,7 @@ $ rails generate vanity
|
|
|
133
157
|
$ rake db:migrate
|
|
134
158
|
```
|
|
135
159
|
|
|
136
|
-
|
|
160
|
+
#### Forking servers and reconnecting
|
|
137
161
|
|
|
138
162
|
If you're using a forking server (like Passenger or Unicorn), you should
|
|
139
163
|
reconnect after a new worker is created:
|
|
@@ -165,7 +189,25 @@ Vanity.connect!(
|
|
|
165
189
|
)
|
|
166
190
|
```
|
|
167
191
|
|
|
168
|
-
|
|
192
|
+
### Initialization
|
|
193
|
+
|
|
194
|
+
If you're using Rails, this is done automagically. Otherwise, some manual setup is required, for example on an app's booting:
|
|
195
|
+
|
|
196
|
+
```
|
|
197
|
+
$redis = Redis.new # or from elsewhere
|
|
198
|
+
Vanity.configure do |config|
|
|
199
|
+
# ... any config
|
|
200
|
+
end
|
|
201
|
+
Vanity.connect!(
|
|
202
|
+
adapter: :redis,
|
|
203
|
+
redis: $redis
|
|
204
|
+
)
|
|
205
|
+
Vanity.load!
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### User identification
|
|
209
|
+
|
|
210
|
+
#### Rails
|
|
169
211
|
|
|
170
212
|
Turn Vanity on, and pass a reference to a method that identifies a user. For
|
|
171
213
|
example:
|
|
@@ -179,7 +221,28 @@ end
|
|
|
179
221
|
For more information, please see the [identity
|
|
180
222
|
documentation](http://vanity.labnotes.org/identity.html).
|
|
181
223
|
|
|
182
|
-
|
|
224
|
+
#### Other
|
|
225
|
+
|
|
226
|
+
Vanity pulls the identity from a "context" object that responds to `vanity_identity`, so we need to define a `Vanity.context` (this is how the [ActionMailer integration](https://github.com/assaf/vanity/blob/master/lib/vanity/frameworks/rails.rb#L107-L133) works):
|
|
227
|
+
|
|
228
|
+
```
|
|
229
|
+
class AVanityContext
|
|
230
|
+
def vanity_identity
|
|
231
|
+
"123"
|
|
232
|
+
end
|
|
233
|
+
end
|
|
234
|
+
|
|
235
|
+
Vanity.context = AVanityContext.new() # Any object that responds to `#vanity_identity`
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
If you're using plain ruby objects, you could also alias something in your identity model to respond similarly and then set that as the vanity context:
|
|
239
|
+
```
|
|
240
|
+
class User
|
|
241
|
+
alias_method :vanity_identity, :id
|
|
242
|
+
end
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### Define a A/B test
|
|
183
246
|
|
|
184
247
|
This experiment goes in the file `experiments/price_options.rb`:
|
|
185
248
|
|
|
@@ -200,15 +263,25 @@ metric "Signup (Activation)" do
|
|
|
200
263
|
end
|
|
201
264
|
```
|
|
202
265
|
|
|
203
|
-
###
|
|
266
|
+
### Present the different options to your users
|
|
267
|
+
|
|
268
|
+
In Rails' templates, this is straightforward:
|
|
204
269
|
|
|
205
270
|
```erb
|
|
206
271
|
<h2>Get started for only $<%= ab_test :price_options %> a month!</h2>
|
|
207
272
|
```
|
|
208
273
|
|
|
209
|
-
|
|
274
|
+
Outside of templates:
|
|
210
275
|
|
|
211
|
-
|
|
276
|
+
```
|
|
277
|
+
Vanity.ab_test(:invite_subject)
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
### Measure conversion
|
|
281
|
+
|
|
282
|
+
Conversions are created via the `Vanity.track!` method. A user should already be added to an experiment, via `ab_test` before this is called - otherwise, the conversion will be tracked, but the user will not be added to the experiment.
|
|
283
|
+
|
|
284
|
+
For example, in Rails:
|
|
212
285
|
|
|
213
286
|
```ruby
|
|
214
287
|
class SignupController < ApplicationController
|
|
@@ -224,12 +297,26 @@ class SignupController < ApplicationController
|
|
|
224
297
|
end
|
|
225
298
|
```
|
|
226
299
|
|
|
227
|
-
|
|
300
|
+
Outside of an Rails controller, for example in a Rack handler:
|
|
301
|
+
|
|
302
|
+
```
|
|
303
|
+
identity_object = Identity.new(env['rack.session'])
|
|
304
|
+
Vanity.track!(:click, {
|
|
305
|
+
# can be any object that responds to `to_s` with a string
|
|
306
|
+
# that contains the unique identifier or the string identifier itself
|
|
307
|
+
:identity=>identity_object,
|
|
308
|
+
:values=>[1] # optional
|
|
309
|
+
})
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Check the report
|
|
228
313
|
|
|
229
314
|
```sh
|
|
230
315
|
vanity report --output vanity.html
|
|
231
316
|
```
|
|
232
317
|
|
|
318
|
+
#### Rails report dashboard
|
|
319
|
+
|
|
233
320
|
To view metrics and experiment results with the dashboard in Rails 3 & Rails
|
|
234
321
|
4:
|
|
235
322
|
|
|
@@ -293,18 +380,15 @@ your view no participants will be recorded.
|
|
|
293
380
|
|
|
294
381
|
Here's what's tested and known to work:
|
|
295
382
|
|
|
296
|
-
Ruby 2.1
|
|
297
|
-
Persistence: Redis, Mongo, ActiveRecord
|
|
298
|
-
Rails: 3.2, 4.1, 4.2
|
|
299
|
-
Ruby 2.2
|
|
300
|
-
Persistence: Redis, Mongo, ActiveRecord
|
|
301
|
-
Rails: 3.2, 4.1, 4.2, 5
|
|
302
383
|
Ruby 2.3
|
|
303
|
-
Persistence: Redis, Mongo, ActiveRecord
|
|
304
|
-
Rails:
|
|
305
|
-
|
|
306
|
-
Persistence: Redis, Mongo, ActiveRecord
|
|
307
|
-
Rails:
|
|
384
|
+
Persistence: Redis (redis-rb >= 3.2.1), Mongo, ActiveRecord
|
|
385
|
+
Rails: 4.1, 4.2, 5
|
|
386
|
+
Ruby 2.4
|
|
387
|
+
Persistence: Redis (redis-rb >= 3.2.1), Mongo, ActiveRecord
|
|
388
|
+
Rails: 4.1, 4.2, 5
|
|
389
|
+
JRuby 9.1
|
|
390
|
+
Persistence: Redis (redis-rb >= 3.2.1), Mongo, ActiveRecord
|
|
391
|
+
Rails: 4.1, 4.2
|
|
308
392
|
|
|
309
393
|
## Testing
|
|
310
394
|
|
|
@@ -341,7 +425,7 @@ Go ahead and target a pull request against the `gh-pages` branch.
|
|
|
341
425
|
prepare the test suite to run against multiple versions of Rails
|
|
342
426
|
* Fix, patch, enhance, document, improve, sprinkle pixie dust
|
|
343
427
|
* Tests. Please. Run `appraisal rake test`, of if you can, `rake test:all`.
|
|
344
|
-
(This project uses
|
|
428
|
+
(This project uses Github Actions where the test suite is run against multiple
|
|
345
429
|
versions of ruby, rails and backends.)
|
|
346
430
|
* Send a pull request on GitHub
|
|
347
431
|
|
data/gemfiles/rails42.gemfile
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
source "https://rubygems.org"
|
|
4
4
|
|
|
5
5
|
gem "rack"
|
|
6
|
-
gem "redis", ">= 2.1"
|
|
6
|
+
gem "redis", ">= 3.2.1"
|
|
7
7
|
gem "redis-namespace", ">= 1.1.0"
|
|
8
8
|
gem "mongo", "~> 2.1"
|
|
9
9
|
gem "integration", "<= 0.1.0"
|
|
10
10
|
gem "rubystats", ">= 0.2.5"
|
|
11
|
-
gem "garb", "< 0.9.2", :
|
|
12
|
-
gem "mocha", "~> 1.0", :
|
|
13
|
-
gem "rails", "4.2.
|
|
14
|
-
gem "fastthread", :git
|
|
11
|
+
gem "garb", "< 0.9.2", require: false
|
|
12
|
+
gem "mocha", "~> 1.0", require: false
|
|
13
|
+
gem "rails", "4.2.9"
|
|
14
|
+
gem "fastthread", platforms: :mri_20, git: "https://github.com/zoltankiss/fastthread.git"
|
|
15
15
|
gem "passenger", "~>3.0"
|
|
16
16
|
|
|
17
17
|
group :development do
|
|
@@ -30,4 +30,4 @@ platforms :jruby do
|
|
|
30
30
|
gem "jdbc-sqlite3"
|
|
31
31
|
end
|
|
32
32
|
|
|
33
|
-
gemspec :
|
|
33
|
+
gemspec development_group: :test, path: "../"
|