ab_panel 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
data/README.md CHANGED
@@ -1,7 +1,25 @@
1
+ [![Build Status](https://travis-ci.org/Springest/ab_panel.png?branch=master)](https://travis-ci.org/Springest/ab_panel)
2
+
1
3
  # AbPanel
2
4
 
3
5
  Run A/B test experiments on your Rails 3+ site using Mixpanel as a backend.
4
6
 
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ gem 'ab_panel'
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install ab_panel
20
+
21
+ ## Usage
22
+
5
23
  Create a config file with one or more experiments and conditions.
6
24
 
7
25
  In `config/ab_panel.yml`
@@ -22,6 +40,23 @@ You can add as many experiments and conditions as you want. Every visitor
22
40
  will be assigned randomly to one condition for each scenario for as long as
23
41
  their session remains active.
24
42
 
43
+ To track events in [Mixpanel](https://mixpanel.com), add a file called `config/mixpanel.yml` with your
44
+ api key, api secret, and the token of of your project, like so:
45
+
46
+ ```yaml
47
+ api_key: 383340bfea74ab839ebb667ab3c59fa3
48
+ api_secret: 3990703d6d73d2b7fd78a1d19de66605
49
+ token: 735cc06a1b1ded4827d7faff385ad6fc
50
+ ```
51
+
52
+ Enable the Mixpanel Middleware by creating a file `config/initializers/mixpanel_middleware.rb`:
53
+
54
+ ```ruby
55
+ Example::Application.config.middleware.use "Mixpanel::Middleware", AbPanel::Mixpanel::Config.token, persist: true
56
+ ```
57
+
58
+ See [Mixpanel Gem docs](https://github.com/zevarito/mixpanel#rack-middleware) on the Middleware for more info.
59
+
25
60
  In your application controller:
26
61
 
27
62
  ```ruby
@@ -40,6 +75,18 @@ class CoursesController < ApplicationController
40
75
  end
41
76
  ```
42
77
 
78
+ You can track variables from within your controller actions:
79
+
80
+ ```ruby
81
+ def show
82
+ # A single variable
83
+ track_variable :id, params[:id]
84
+
85
+ # Or a hash with variables
86
+ track_variables params
87
+ end
88
+ ```
89
+
43
90
  Use conditions based on experiments and conditions throughout your code, e.g. in your views:
44
91
 
45
92
  ```erb
@@ -67,23 +114,7 @@ else
67
114
  end
68
115
  ```
69
116
 
70
- ## Installation
71
-
72
- Add this line to your application's Gemfile:
73
-
74
- gem 'ab_panel'
75
-
76
- And then execute:
77
-
78
- $ bundle
79
-
80
- Or install it yourself as:
81
-
82
- $ gem install ab_panel
83
-
84
- ## Usage
85
-
86
- TODO: Write usage instructions here
117
+ Make sure to check the [Example App](https://github.com/Springest/ab_panel/tree/master/example)
87
118
 
88
119
  ## Contributing
89
120
 
data/Rakefile CHANGED
@@ -1 +1,5 @@
1
1
  require "bundler/gem_tasks"
2
+
3
+ task :default do
4
+ system 'bundle exec rspec spec'
5
+ end
@@ -2,6 +2,24 @@ module AbPanel
2
2
  module ControllerAdditions
3
3
  extend ActiveSupport::Concern
4
4
 
5
+ # Track a single variable
6
+ #
7
+ # Example:
8
+ # track_variable :name, value
9
+ def track_variable(name, value)
10
+ ab_panel_options[name.to_sym] = value
11
+ end
12
+
13
+ # Track multiple variables at once.
14
+ #
15
+ # Example:
16
+ # track_variables { foo: 'bar', ping: 'pong'}
17
+ def track_variables(variables={})
18
+ variables.each do |key, val|
19
+ track_variable key, val
20
+ end
21
+ end
22
+
5
23
  # This sets a unique id for this user.
6
24
  #
7
25
  # You could override this in your ApplicationController to use your
@@ -29,6 +47,10 @@ module AbPanel
29
47
  }
30
48
  end
31
49
 
50
+ def ab_panel_options
51
+ @ab_panel_options ||= {}
52
+ end
53
+
32
54
  module ClassMethods
33
55
  # Initializes AbPanel's environment.
34
56
  #
@@ -99,6 +121,8 @@ module AbPanel
99
121
  end
100
122
  end
101
123
 
124
+ options.merge controller.ab_panel_options
125
+
102
126
  AbPanel.identify(controller.ab_panel_id)
103
127
  AbPanel.track name, options
104
128
 
@@ -1,3 +1,3 @@
1
1
  module AbPanel
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ab_panel
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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-09-16 00:00:00.000000000 Z
12
+ date: 2013-09-17 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -131,6 +131,7 @@ extensions: []
131
131
  extra_rdoc_files: []
132
132
  files:
133
133
  - .gitignore
134
+ - .travis.yml
134
135
  - Gemfile
135
136
  - LICENSE.txt
136
137
  - README.md
@@ -230,7 +231,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
230
231
  version: '0'
231
232
  segments:
232
233
  - 0
233
- hash: -4159639941527965212
234
+ hash: 4452037711961914346
234
235
  required_rubygems_version: !ruby/object:Gem::Requirement
235
236
  none: false
236
237
  requirements:
@@ -239,7 +240,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
239
240
  version: '0'
240
241
  segments:
241
242
  - 0
242
- hash: -4159639941527965212
243
+ hash: 4452037711961914346
243
244
  requirements: []
244
245
  rubyforge_project:
245
246
  rubygems_version: 1.8.23