fluidfeatures-rails 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -5,6 +5,82 @@ Rails graceful feature rollout and simple A/B testing
5
5
 
6
6
  `gem fluidfeatures-rails` is a Ruby on Rails client for the API of FluidFeatures.com, which provides an elegant way to wrap new code so you have real-time control over rolling out new features to your user-base.
7
7
 
8
+ Integration
9
+ -----------
10
+
11
+ Add the gem to your application's `Gemfile` and run `bundle update fluidfeatures-rails`
12
+
13
+ ```ruby
14
+ gem "fluidfeatures-rails"
15
+ ```
16
+
17
+ Add this line to your `config/application.rb`
18
+
19
+ ```ruby
20
+ FluidFeatures::Rails.initializer
21
+ ```
22
+
23
+ Add this `fluidfeature_current_user` method in your `ApplicationController` (`app/controllers/application_controller.rb`), where `current_user` returns your currently logged in user object.
24
+ See [User definition and cohorts](#user-definition-and-cohorts) for more details.
25
+
26
+ ```ruby
27
+ def fluidfeatures_current_user(verbose=false)
28
+ current_user ? { :id => current_user.id } : nil
29
+ end
30
+ ```
31
+
32
+ Generate a `config/fluidfeatures.yml` config file by running
33
+
34
+ `rails g fluidfeatures:config`
35
+
36
+ This will prompt you for your app credentials which you can find on the [fluidfeatures.com/dashboard](https://www.fluidfeatures.com/dashboard) and are specific to each app you create.
37
+ Enter your `app_id` and `secret` for your `development` environment. You can skip the rest for now.
38
+
39
+ Start adding your features and goals using `if ff?` (or `if fluidfeature`) and `fluidgoal`.
40
+
41
+ In your controllers or your views...
42
+
43
+ ```ruby
44
+ # "theme" is simply an example feature name, used to represent
45
+ # a migration to a styling of your website
46
+ if ff? "theme", "default"
47
+ # wrap code related to your default theme, so it is
48
+ # only executed when the user is allocated this version
49
+ # of the feature "theme".
50
+ end
51
+ # Alternate verison of the "theme" feature.
52
+ # FluidFeatures will only assign a user to one version
53
+ # of a feature.
54
+ if ff? "theme", "tropical"
55
+ # implement code specifically related to your new theme
56
+ end
57
+
58
+ fluidgoal "bought-bieber-dvd"
59
+
60
+ fluidgoal "added-a-comment"
61
+
62
+ fluidgoal "upgraded-to-pro-account"
63
+
64
+ fluidgoal "general-engagement"
65
+ ```
66
+
67
+ Dashboard
68
+ ---------
69
+
70
+ If you log into your FluidFeatures account and visit [fluidfeatures.com/dashboard](https://www.fluidfeatures.com/dashboard) you will see your feature and goal dashboard.
71
+
72
+ ![Example dashboard view](http://commondatastorage.googleapis.com/philwhln/blog/images/ab-test-rails/full-dashboard.png)
73
+
74
+ This shows one feature `"ab-test"` with two versions simply named `"a"` and `"b"`.
75
+
76
+ There are two goals called `"yes"` and `"no"`.
77
+
78
+ Version `"a"` is seen by 75% of the user-base, whether they are anonymous or not, and version `"b"` is seen by the remaining 25%.
79
+
80
+ You can read more about this example in a blog post here...
81
+ http://www.bigfastblog.com/ab-testing-in-ruby-on-rails
82
+
83
+
8
84
  Rollout new versions of features
9
85
  --------------------------------
10
86
 
@@ -12,7 +88,7 @@ Using `if ff? "foo"` you can easily rollout new code to production and then use
12
88
 
13
89
  Use `if ff? "foo", "v2"` to wrap the code for a new version of the "foo" feature.
14
90
 
15
- `if ff? "foo"` defaults to version `"default"`, so anyone seeing "v2" will not also see "v2". This is a great way to test new features in production.
91
+ `if ff? "foo"` defaults to version `"default"`, so anyone seeing "v2" will not also see "default". This is a great way to test new features in production.
16
92
 
17
93
  Once you have moved all your users over to the newer "v2" version you can factor out code from the older version.
18
94
 
@@ -39,22 +115,20 @@ You can define any number of versions for a feature and track them all.
39
115
 
40
116
  You can also compare the performance of different features against each other over time.
41
117
 
42
- On your server
43
- --------------
118
+ In your controllers
119
+ -------------------
44
120
 
45
121
  A/B testing on the server gives you the ability to test things at all levels of your stack. Test alternate SQL statements, different versions of emails sent to users, or different backend 3rd party API services.
46
122
 
47
- In your templates
48
- -----------------
123
+ In your views
124
+ -------------
49
125
 
50
- fluidfeatures-rails exposes `def ff?` (alias to `def fluidfeature`) and `def fluidgoal` to your templates, so can also wrap versioned code there.
126
+ fluidfeatures-rails exposes `def ff?` (alias to `def fluidfeature`) and `def fluidgoal` to your views, so can also wrap versioned code there.
51
127
 
52
128
  User definition and cohorts
53
129
  ---------------------------
54
130
 
55
- In your `application_controller.rb` you will define a function called `def fluidfeatures_current_user` which can be called by `gem fluidfeatures-rails` to determine who the current user is.
56
-
57
- This important for FluidFeatures to determine which feature versions to enable for the user, but is also the place where you can define any cohorts you wish to use for rolling out features.
131
+ In your `app/controllers/application_controller.rb` you will define a function called `def fluidfeatures_current_user` which will be called by fluidfeatures to determine who the current user is, what their name is and which cohorts they belong to. Cohorts can then be used for rolling out specific versions of features. All the details you add here are searchable within the dashboard, so the more fields you add here, the easier it is to find your users.
58
132
 
59
133
  ```ruby
60
134
  def fluidfeatures_current_user(verbose)
@@ -109,69 +183,3 @@ If your `ApplicationController` method `fluidfeatures_current_user` returns `nil
109
183
 
110
184
  It is possible handle anonymous users yourself by managing the cookies yourself, generating a unique `:id` for each anonymous user and additionally passing `:anonymous => true` in the `Hash` of `fluidfeatures_current_user` for both verbose and non-verbose calls. This basically what `gem fluidfeatures-rails` does under the hood for your convenience, so you do not have to.
111
185
 
112
- Integration
113
- -----------
114
-
115
- Add the gem to your application
116
-
117
- ```ruby
118
- gem "fluidfeatures-rails"
119
- ```
120
-
121
- Call the initializer when your application starts
122
-
123
- ```ruby
124
- module MyRailsApp
125
- class Application < Rails::Application
126
- FluidFeatures::Rails.initializer
127
- end
128
- end
129
- ```
130
-
131
- Create a `fluidfeature_current_user` method in your `ApplicationController`. See [User definition and cohorts](#user-definition-and-cohorts).
132
-
133
- Start adding your features and goals using `if ff?` (or `if fluidfeature`) and `fluidgoal`.
134
-
135
- In your controllers or your views...
136
-
137
- ```ruby
138
- # "theme" is simply an example feature name, used to represent
139
- # a migration to a styling of your website
140
- if ff? "theme", "default"
141
- # wrap code related to your default theme, so it is
142
- # only executed when the user is allocated this version
143
- # of the feature "theme".
144
- end
145
- # Alternate verison of the "theme" feature.
146
- # FluidFeatures will only assign a user to one version
147
- # of a feature.
148
- if ff? "theme", "tropical"
149
- # implement code specifically related to your new theme
150
- end
151
-
152
- fluidgoal "bought-bieber-dvd"
153
-
154
- fluidgoal "added-a-comment"
155
-
156
- fluidgoal "upgraded-to-pro-account"
157
-
158
- fluidgoal "general-engagement"
159
- ```
160
-
161
- Dashboard
162
- ---------
163
-
164
- If you log into your FluidFeatures account and visit [fluidfeatures.com/dashboard](https://www.fluidfeatures.com/dashboard) you will see your feature and goal dashboard.
165
-
166
- ![Example dashboard view](http://commondatastorage.googleapis.com/philwhln/blog/images/ab-test-rails/full-dashboard.png)
167
-
168
- This shows one features `"ab-test"` with two versions simply named `"a"` and `"b"`.
169
-
170
- There are two goals called `"yes"` and `"no"`.
171
-
172
- Version `"a"` is seen by 75% of the user-base, whether they are anonymous or not, and version `"b"` is seen by the remaining 25%.
173
-
174
- You can read more about this example in a blog post here...
175
- http://www.bigfastblog.com/ab-testing-in-ruby-on-rails
176
-
177
-
@@ -84,13 +84,12 @@ module ActionController
84
84
  # call app defined method "fluidfeatures_current_user"
85
85
  user = nil
86
86
  begin
87
- user = fluidfeatures_current_user(verbose=true)
87
+ user = fluidfeatures_current_user(verbose=true) || {}
88
88
  rescue NoMethodError
89
- ::Rails.logger.error "[FF] Method fluidfeatures_current_user is not defined in your ApplicationController"
90
- return nil
89
+ raise FFeaturesException.new("Method fluidfeatures_current_user is not defined in your ApplicationController")
91
90
  end
92
91
  unless user.is_a? Hash
93
- raise "fluidfeatures_current_user returned invalid user (Hash expected) : #{user}"
92
+ raise FFeaturesException.new("fluidfeatures_current_user returned invalid user (Hash or nil expected) : #{user}")
94
93
  end
95
94
 
96
95
  # default to anonymous is no user id given
@@ -1,5 +1,5 @@
1
1
  module FluidFeatures
2
2
  module Rails
3
- VERSION = '0.6.2'
3
+ VERSION = '0.6.3'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluidfeatures-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-12 00:00:00.000000000 Z
12
+ date: 2013-01-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluidfeatures