i_wonder 0.0.3 → 0.0.4
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.
- data/README.rdoc +9 -97
- data/app/assets/javascripts/i_wonder/ab_tests.js +2 -0
- data/app/assets/javascripts/i_wonder/application.js +15 -0
- data/app/assets/stylesheets/i_wonder/ab_tests.css.scss +22 -0
- data/app/assets/stylesheets/i_wonder/application.css.scss +1 -0
- data/app/controllers/i_wonder/ab_tests_controller.rb +48 -0
- data/app/controllers/i_wonder/application_controller.rb +4 -4
- data/app/controllers/i_wonder/metrics_controller.rb +33 -34
- data/app/helpers/i_wonder/ab_tests_helper.rb +4 -0
- data/app/models/i_wonder/ab_test.rb +101 -0
- data/app/models/i_wonder/ab_test_goal.rb +49 -0
- data/app/models/i_wonder/event.rb +5 -2
- data/app/models/i_wonder/test_group_membership.rb +12 -0
- data/app/views/i_wonder/ab_tests/_ab_test_goal_row.html.erb +23 -0
- data/app/views/i_wonder/ab_tests/_ab_test_goals.html.erb +13 -0
- data/app/views/i_wonder/ab_tests/_ab_test_group_row.html.erb +5 -0
- data/app/views/i_wonder/ab_tests/_ab_test_groups.html.erb +9 -0
- data/app/views/i_wonder/ab_tests/_form.html.erb +50 -0
- data/app/views/i_wonder/ab_tests/_show_not_started.html.erb +18 -0
- data/app/views/i_wonder/ab_tests/_show_report.html.erb +26 -0
- data/app/views/i_wonder/ab_tests/edit.html.erb +7 -0
- data/app/views/i_wonder/ab_tests/index.html.erb +20 -0
- data/app/views/i_wonder/ab_tests/new.html.erb +7 -0
- data/app/views/i_wonder/ab_tests/show.html.erb +20 -0
- data/app/views/i_wonder/reports/_form.html.erb +9 -5
- data/app/views/layouts/i_wonder.html.erb +1 -0
- data/config/routes.rb +1 -0
- data/db/migrate/20111022230720_i_wonder_migrations.rb +35 -26
- data/lib/i_wonder/ab_testing/action_controller_mixins.rb +20 -0
- data/lib/i_wonder/engine.rb +2 -0
- data/lib/i_wonder/logging/{mixins/action_controller_mixins.rb → action_controller_mixins.rb} +3 -3
- data/lib/i_wonder/logging/{mixins/active_record_mixins.rb → active_record_mixins.rb} +0 -0
- data/lib/i_wonder/version.rb +1 -1
- data/lib/i_wonder.rb +7 -3
- data/test/dummy/app/controllers/application_controller.rb +7 -7
- data/test/dummy/db/schema.rb +33 -0
- data/test/dummy/log/development.log +16012 -0
- data/test/dummy/log/test.log +30206 -0
- data/test/dummy/tmp/cache/assets/C7B/1F0/sprockets%2F69ce38b6f0a103527048612c29753c1f +0 -0
- data/test/dummy/tmp/cache/assets/C81/600/sprockets%2F30b4f9798169b0d0157b48c09ea23472 +0 -0
- data/test/dummy/tmp/cache/assets/CB1/1C0/sprockets%2F0677230b357317e47dffaff9013e0377 +0 -0
- data/test/dummy/tmp/cache/assets/CE6/720/sprockets%2F9718b522ff20c58a59b179b7759ca20b +0 -0
- data/test/dummy/tmp/cache/assets/D20/120/sprockets%2F73fcb7f2f97642793feb2c3d871c1482 +0 -0
- data/test/dummy/tmp/cache/assets/D2F/9D0/sprockets%2F50ce229bd4200bed47618724bcab6c73 +0 -0
- data/test/dummy/tmp/cache/assets/D37/100/sprockets%2F4e900e2ccfdda5075214028c89e25f0e +0 -0
- data/test/dummy/tmp/cache/assets/D79/600/sprockets%2Fc2a1e7e47cead78810554cc9c0de9388 +0 -0
- data/test/dummy/tmp/cache/assets/D84/210/sprockets%2Fabd0103ccec2b428ac62c94e4c40b384 +0 -0
- data/test/dummy/tmp/cache/assets/D8E/250/sprockets%2Fefe57e932e1d26c3b6af42a5311f0a1c +0 -0
- data/test/dummy/tmp/cache/assets/DA7/BA0/sprockets%2F463a9dd811f2418d96fa72cfe05fb8cd +0 -0
- data/test/dummy/tmp/cache/assets/DAD/040/sprockets%2Fc59fd78ac2642a5f3c1b6ef899d50cf3 +0 -0
- data/test/dummy/tmp/cache/assets/DD1/B10/sprockets%2F85b9bce1c5bc3fb86a83d8c8c34e05e0 +0 -0
- data/test/dummy/tmp/cache/assets/DDF/BA0/sprockets%2F187ad995e2ff3588c339fdbecceba119 +0 -0
- data/test/dummy/tmp/cache/assets/DF9/5C0/sprockets%2Fd711a81a91fcc3cd1a30798dd94fdcbd +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/pids/server.pid +1 -0
- data/test/functional/ab_controller_mixins_test.rb +80 -0
- data/test/functional/{test_controller_test.rb → logging_controller_mixins_test.rb} +4 -3
- data/test/integration/i_wonder/dashboard_controller_test.rb +10 -3
- data/test/integration/middleware_test.rb +4 -0
- data/test/unit/helpers/i_wonder/ab_tests_helper_test.rb +6 -0
- data/test/unit/i_wonder/ab_test_test.rb +37 -0
- data/test/unit/i_wonder/event_test.rb +5 -3
- data/test/unit/i_wonder/test_group_membership_test.rb +9 -0
- metadata +65 -24
@@ -0,0 +1,20 @@
|
|
1
|
+
<h1>A/B Tests</h1>
|
2
|
+
|
3
|
+
<% if @ab_tests.empty? %>
|
4
|
+
<p class="empty_list">You don't have any tests</p>
|
5
|
+
<% else %>
|
6
|
+
<ul id="ab_test_list" class="primary_list">
|
7
|
+
<% for ab_test in @ab_tests do %>
|
8
|
+
<li>
|
9
|
+
<%= link_to ab_test do %>
|
10
|
+
<h3><span>I wonder</span> <%= ab_test.name %></h3>
|
11
|
+
<p><%= ab_test.description %></p>
|
12
|
+
<% end %>
|
13
|
+
</li>
|
14
|
+
<% end %>
|
15
|
+
</ul>
|
16
|
+
<% end %>
|
17
|
+
|
18
|
+
<p>
|
19
|
+
<%= button_to "Create a new ABTest", url_for(:action => :new), :method => :get%>
|
20
|
+
</p>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<div class="show">
|
2
|
+
<p>
|
3
|
+
<%= link_to "Edit", edit_ab_test_path(@ab_test) %>
|
4
|
+
|
|
5
|
+
<%= link_to "Delete", @ab_test, :method => :delete, :confirm => "Are you sure?" %>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<h2>I wonder <%= @ab_test.name%>?</h2>
|
9
|
+
<p class="description">
|
10
|
+
<%= @ab_test.description.present? ? @ab_test.description : "no description..."%>
|
11
|
+
</p>
|
12
|
+
|
13
|
+
<% if @ab_test.started? %>
|
14
|
+
<%= render "show_report" %>
|
15
|
+
<% else %>
|
16
|
+
<%= render "show_not_started" %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
|
20
|
+
</div>
|
@@ -29,11 +29,15 @@
|
|
29
29
|
|
30
30
|
<h4>Tracks these metrics</h4>
|
31
31
|
<ul class="report_metric_ids">
|
32
|
-
<%
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
<% if IWonder::Metric.active.length > 0%>
|
33
|
+
<% for metric in IWonder::Metric.active.order(:name) do %>
|
34
|
+
<li>
|
35
|
+
<%= check_box_tag "report[metric_ids][]", metric.id, @report.metrics.include?(metric) %>
|
36
|
+
<%= label_tag "report[metric_ids][]", metric.name %>
|
37
|
+
</li>
|
38
|
+
<% end %>
|
39
|
+
<% else %>
|
40
|
+
You don't have any metrics to track yet.
|
37
41
|
<% end %>
|
38
42
|
</ul>
|
39
43
|
|
@@ -14,6 +14,7 @@
|
|
14
14
|
<nav>
|
15
15
|
<%= link_to "< #{IWonder.configuration.app_name }", IWonder.configuration.back_to_app_link %>
|
16
16
|
<%= link_to "Dashboard", root_path %>
|
17
|
+
<%= link_to "ABTests", ab_tests_path %>
|
17
18
|
<%= link_to "Reports", reports_path %>
|
18
19
|
<%= link_to "Metrics", metrics_path %>
|
19
20
|
<%= link_to "Events", events_path %>
|
data/config/routes.rb
CHANGED
@@ -59,31 +59,40 @@ class IWonderMigrations < ActiveRecord::Migration
|
|
59
59
|
t.timestamps
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
62
|
+
create_table :i_wonder_ab_tests do |t|
|
63
|
+
t.string :name
|
64
|
+
t.string :sym
|
65
|
+
t.text :description
|
66
|
+
|
67
|
+
t.string :test_applies_to
|
68
|
+
t.text :options # serialized
|
69
|
+
t.text :test_group_data # serialized
|
70
|
+
|
71
|
+
t.timestamps
|
72
|
+
end
|
73
|
+
add_index :i_wonder_ab_tests, :sym
|
74
|
+
|
75
|
+
create_table :i_wonder_ab_test_goals do |t|
|
76
|
+
t.integer :ab_test_id
|
77
|
+
t.text :options # serialized
|
78
|
+
end
|
79
|
+
add_index :i_wonder_ab_test_goals, :ab_test_id
|
80
|
+
|
81
|
+
|
82
|
+
|
83
|
+
|
84
|
+
create_table :i_wonder_test_group_memberships do |t|
|
85
|
+
t.integer :ab_test_id
|
86
|
+
t.string :test_group_name
|
87
|
+
|
88
|
+
t.string :member_type
|
89
|
+
t.string :member_id
|
90
|
+
|
91
|
+
t.timestamps
|
92
|
+
end
|
93
|
+
add_index :i_wonder_test_group_memberships, :ab_test_id
|
94
|
+
add_index :i_wonder_test_group_memberships, :test_group_name
|
95
|
+
add_index :i_wonder_test_group_memberships, [:member_type, :member_id], :name => "i_wonder_test_group_memberships_member"
|
96
|
+
|
88
97
|
end
|
89
98
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module IWonder
|
2
|
+
module AbTesting
|
3
|
+
module ActionControllerMixins
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
helper_method :which_test_group?
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
def which_test_group?(event_sym)
|
12
|
+
ab_test = IWonder::AbTest.find_by_sym(event_sym.to_s)
|
13
|
+
raise "Not a valid test group" unless ab_test
|
14
|
+
ab_test.which_test_group?(self)
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/i_wonder/engine.rb
CHANGED
@@ -17,6 +17,8 @@ class Railtie < Rails::Railtie
|
|
17
17
|
|
18
18
|
config.to_prepare do
|
19
19
|
ApplicationController.send :include, IWonder::Logging::ActionControllerMixins
|
20
|
+
ApplicationController.send :include, IWonder::AbTesting::ActionControllerMixins
|
21
|
+
|
20
22
|
ActiveRecord.send :include, IWonder::Logging::ActiveRecordMixins
|
21
23
|
end
|
22
24
|
|
data/lib/i_wonder/logging/{mixins/action_controller_mixins.rb → action_controller_mixins.rb}
RENAMED
@@ -13,17 +13,17 @@ module IWonder
|
|
13
13
|
|
14
14
|
def i_wonder_for_user_id(user_id)
|
15
15
|
self.request.env[ENV_KEY] ||= {} # this is for when the middleware doesn't get run first
|
16
|
-
self.request.env[ENV_KEY]["user_id"] = user_id.
|
16
|
+
self.request.env[ENV_KEY]["user_id"] = user_id.to_s
|
17
17
|
end
|
18
18
|
|
19
19
|
def i_wonder_for_account_id(account_id)
|
20
20
|
self.request.env[ENV_KEY] ||= {} # this is for when the middleware doesn't get run first
|
21
|
-
self.request.env[ENV_KEY]["account_id"] = account_id.
|
21
|
+
self.request.env[ENV_KEY]["account_id"] = account_id.to_s
|
22
22
|
end
|
23
23
|
|
24
24
|
def i_wonder_for_session_id(session_id)
|
25
25
|
self.request.env[ENV_KEY] ||= {} # this is for when the middleware doesn't get run first
|
26
|
-
self.request.env[ENV_KEY]["session_id"] = session_id
|
26
|
+
self.request.env[ENV_KEY]["session_id"] = session_id.to_s
|
27
27
|
end
|
28
28
|
|
29
29
|
end
|
File without changes
|
data/lib/i_wonder/version.rb
CHANGED
data/lib/i_wonder.rb
CHANGED
@@ -3,15 +3,19 @@ require 'i_wonder/core_ext'
|
|
3
3
|
require "i_wonder/configuration"
|
4
4
|
|
5
5
|
module IWonder
|
6
|
+
ENV_KEY = COOKIE_KEY = "i_wonder"
|
6
7
|
|
7
8
|
# These are all things used just for logging events
|
8
9
|
module Logging
|
9
|
-
ENV_KEY = COOKIE_KEY = "i_wonder"
|
10
10
|
SESSION_KEY_NAME = "_session_id"
|
11
11
|
|
12
12
|
autoload :Middleware, 'i_wonder/logging/middleware'
|
13
|
-
autoload :ActionControllerMixins, 'i_wonder/logging/
|
14
|
-
autoload :ActiveRecordMixins, 'i_wonder/logging/
|
13
|
+
autoload :ActionControllerMixins, 'i_wonder/logging/action_controller_mixins'
|
14
|
+
autoload :ActiveRecordMixins, 'i_wonder/logging/active_record_mixins'
|
15
|
+
end
|
16
|
+
|
17
|
+
module AbTesting
|
18
|
+
autoload :ActionControllerMixins, 'i_wonder/ab_testing/action_controller_mixins'
|
15
19
|
end
|
16
20
|
|
17
21
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
2
|
protect_from_forgery
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
before_filter :check_for_admin
|
5
|
+
def check_for_admin
|
6
|
+
if params[:controller] =~ /i_wonder/ and params[:block_this].present?
|
7
|
+
flash[:error] = "Authentication check occurred"
|
8
|
+
redirect_to "/"
|
9
|
+
end
|
10
|
+
end
|
11
11
|
|
12
12
|
end
|
data/test/dummy/db/schema.rb
CHANGED
@@ -34,6 +34,26 @@ ActiveRecord::Schema.define(:version => 20111023231947) do
|
|
34
34
|
|
35
35
|
add_index "delayed_jobs", ["priority", "run_at"], :name => "delayed_jobs_priority"
|
36
36
|
|
37
|
+
create_table "i_wonder_ab_test_goals", :force => true do |t|
|
38
|
+
t.integer "ab_test_id"
|
39
|
+
t.text "options"
|
40
|
+
end
|
41
|
+
|
42
|
+
add_index "i_wonder_ab_test_goals", ["ab_test_id"], :name => "index_i_wonder_ab_test_goals_on_ab_test_id"
|
43
|
+
|
44
|
+
create_table "i_wonder_ab_tests", :force => true do |t|
|
45
|
+
t.string "name"
|
46
|
+
t.string "sym"
|
47
|
+
t.text "description"
|
48
|
+
t.string "test_applies_to"
|
49
|
+
t.text "options"
|
50
|
+
t.text "test_group_data"
|
51
|
+
t.datetime "created_at"
|
52
|
+
t.datetime "updated_at"
|
53
|
+
end
|
54
|
+
|
55
|
+
add_index "i_wonder_ab_tests", ["sym"], :name => "index_i_wonder_ab_tests_on_sym"
|
56
|
+
|
37
57
|
create_table "i_wonder_events", :force => true do |t|
|
38
58
|
t.string "event_type"
|
39
59
|
t.integer "account_id"
|
@@ -93,4 +113,17 @@ ActiveRecord::Schema.define(:version => 20111023231947) do
|
|
93
113
|
t.datetime "updated_at"
|
94
114
|
end
|
95
115
|
|
116
|
+
create_table "i_wonder_test_group_memberships", :force => true do |t|
|
117
|
+
t.integer "ab_test_id"
|
118
|
+
t.string "test_group_name"
|
119
|
+
t.string "member_type"
|
120
|
+
t.string "member_id"
|
121
|
+
t.datetime "created_at"
|
122
|
+
t.datetime "updated_at"
|
123
|
+
end
|
124
|
+
|
125
|
+
add_index "i_wonder_test_group_memberships", ["ab_test_id"], :name => "index_i_wonder_test_group_memberships_on_ab_test_id"
|
126
|
+
add_index "i_wonder_test_group_memberships", ["member_type", "member_id"], :name => "i_wonder_test_group_memberships_member"
|
127
|
+
add_index "i_wonder_test_group_memberships", ["test_group_name"], :name => "index_i_wonder_test_group_memberships_on_test_group_name"
|
128
|
+
|
96
129
|
end
|