mitamirri 0.13.8 → 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/Capfile +4 -0
- data/Gemfile +29 -0
- data/README.rdoc +6 -55
- data/Rakefile +34 -21
- data/VERSION +1 -1
- data/app/controllers/admin/tracking/reports_controller.rb +78 -0
- data/app/controllers/admin/tracking/trackable_sessions_controller.rb +7 -0
- data/app/controllers/application_controller.rb +1 -8
- data/app/controllers/trackable_actions_controller.rb +0 -2
- data/app/helpers/application_helper.rb +21 -0
- data/app/helpers/layout_helper.rb +18 -0
- data/app/models/content_report.rb +35 -0
- data/app/models/content_stat.rb +4 -0
- data/app/models/destination.rb +4 -0
- data/app/models/intersite_traffic_report.rb +47 -0
- data/app/models/keyword_stat.rb +4 -0
- data/app/models/lead.rb +3 -0
- data/app/models/lead_stat.rb +5 -0
- data/app/models/leads_report.rb +32 -0
- data/app/models/location_stat.rb +37 -0
- data/app/models/referrer_stat.rb +4 -0
- data/app/models/report.rb +83 -0
- data/app/models/stat_base.rb +11 -0
- data/app/models/trackable_action.rb +114 -91
- data/app/models/trackable_base.rb +12 -0
- data/app/models/trackable_location.rb +7 -13
- data/app/models/trackable_session.rb +255 -171
- data/app/models/trackable_stat.rb +45 -27
- data/app/models/traffic_explorer_report.rb +92 -0
- data/app/models/traffic_summary_report.rb +142 -0
- data/app/models/user_agent_stat.rb +4 -0
- data/app/models/visit.rb +6 -0
- data/app/models/visit_stat.rb +5 -0
- data/app/models/visitor.rb +4 -0
- data/app/models/visitor_profile_report.rb +23 -0
- data/app/views/admin/tracking/reports/_content.html.erb +28 -0
- data/app/views/admin/tracking/reports/_conversion_rate.html.erb +30 -0
- data/app/views/admin/tracking/reports/_criteria.html.erb +33 -0
- data/app/views/admin/tracking/reports/_entrance_pages.html.erb +29 -0
- data/app/views/admin/tracking/reports/_exit_pages.html.erb +28 -0
- data/app/views/admin/tracking/reports/_explorer_criteria.html.erb +22 -0
- data/app/views/admin/tracking/reports/_explorer_summary.html.erb +22 -0
- data/app/views/admin/tracking/reports/_intersite_destinations.html.erb +28 -0
- data/app/views/admin/tracking/reports/_intersite_referrals.html.erb +30 -0
- data/app/views/admin/tracking/reports/_leads.html.erb +30 -0
- data/app/views/admin/tracking/reports/_locations.html.erb +47 -0
- data/app/views/admin/tracking/reports/_recent_visits.html.erb +33 -0
- data/app/views/admin/tracking/reports/_referring_keywords.html.erb +28 -0
- data/app/views/admin/tracking/reports/_referring_sites.html.erb +28 -0
- data/app/views/admin/tracking/reports/_traffic_summary.html.erb +26 -0
- data/app/views/admin/tracking/reports/_user_agents.html.erb +28 -0
- data/app/views/{trackable_sessions/_visits_graph.html.erb → admin/tracking/reports/_visits_by_kind.html.erb} +3 -3
- data/app/views/admin/tracking/reports/content.html.erb +12 -0
- data/app/views/admin/tracking/reports/explorer.html.erb +13 -0
- data/app/views/admin/tracking/reports/index.html.erb +16 -0
- data/app/views/admin/tracking/reports/intersite.html.erb +11 -0
- data/app/views/admin/tracking/reports/leads.html.erb +11 -0
- data/app/views/admin/tracking/reports/summary.html.erb +16 -0
- data/app/views/admin/tracking/reports/visitor_profile.html.erb +11 -0
- data/app/views/{trackable_sessions → admin/tracking/trackable_sessions}/show.html.erb +5 -4
- data/app/views/layouts/application.html.erb +51 -18
- data/config.ru +4 -0
- data/config/application.rb +13 -0
- data/config/boot.rb +13 -110
- data/config/cucumber.yml +10 -0
- data/config/deploy.rb +40 -0
- data/config/environment.rb +4 -23
- data/config/environments/development.rb +24 -13
- data/config/environments/production.rb +41 -20
- data/config/environments/test.rb +28 -24
- data/config/initializers/formats.rb +19 -0
- data/config/initializers/metric_fu.rb +9 -0
- data/config/initializers/secret_token.rb +7 -0
- data/config/initializers/session_store.rb +3 -10
- data/config/locales/en.yml +1 -1
- data/config/mongoid.yml +19 -0
- data/config/routes.rb +16 -10
- data/features/access_reports.feature +26 -0
- data/features/step_definitions/reports_steps.rb +9 -0
- data/features/step_definitions/web_steps.rb +219 -0
- data/features/support/env.rb +32 -0
- data/features/support/hooks.rb +1 -0
- data/features/support/paths.rb +33 -0
- data/features/traffic_summary_report.feature +43 -0
- data/init.rb +0 -7
- data/lib/mitamirri.rb +9 -12
- data/lib/mitamirri/engine.rb +7 -0
- data/lib/mitamirri/helper.rb +13 -29
- data/lib/mitamirri/railtie.rb +10 -0
- data/lib/tasks/cucumber.rake +60 -0
- data/lib/tasks/rcov.rake +44 -0
- data/mitamirri.gemspec +228 -100
- data/public/404.html +26 -0
- data/public/422.html +26 -0
- data/public/500.html +26 -0
- data/{config/database.yml → public/favicon.ico} +0 -0
- data/public/images/icons/add.png +0 -0
- data/public/images/icons/collapsed.gif +0 -0
- data/public/images/icons/delete.png +0 -0
- data/public/images/icons/drag.png +0 -0
- data/public/images/icons/edit.png +0 -0
- data/public/images/icons/expanded.gif +0 -0
- data/public/images/icons/help_icon.png +0 -0
- data/public/images/icons/link_icon.png +0 -0
- data/public/images/icons/move.png +0 -0
- data/public/images/icons/move_white.png +0 -0
- data/public/images/icons/note.png +0 -0
- data/public/images/icons/note_white.png +0 -0
- data/public/images/icons/notification_icon_sprite.png +0 -0
- data/public/images/icons/spinner.gif +0 -0
- data/public/images/icons/view.png +0 -0
- data/public/images/icons/warning.png +0 -0
- data/public/images/icons/warning_2.png +0 -0
- data/public/images/icons/warning_box.png +0 -0
- data/public/images/icons/warning_icon.png +0 -0
- data/public/images/icons/warning_white.png +0 -0
- data/public/images/layout/arrow_asc.png +0 -0
- data/public/images/layout/arrow_desc.png +0 -0
- data/public/images/layout/back.png +0 -0
- data/public/images/layout/black_bar.png +0 -0
- data/public/images/layout/branding.png +0 -0
- data/public/images/layout/breadcrumb_bg.png +0 -0
- data/public/images/layout/button_bg.png +0 -0
- data/public/images/layout/content_left_bg.png +0 -0
- data/public/images/layout/content_right_bg.png +0 -0
- data/public/images/layout/footer_bg.png +0 -0
- data/public/images/layout/h1_bg.png +0 -0
- data/public/images/layout/h2_bg.png +0 -0
- data/public/images/layout/h2_bg_for_table.png +0 -0
- data/public/images/layout/header_bg_grey.png +0 -0
- data/public/images/layout/header_bg_purple.png +0 -0
- data/public/images/layout/legend_bg.png +0 -0
- data/public/images/layout/menu_box_bg.png +0 -0
- data/public/images/layout/shadow_border.png +0 -0
- data/public/images/layout/shadow_border_2.png +0 -0
- data/public/images/layout/shadow_border_3.png +0 -0
- data/public/images/layout/shadow_border_4.png +0 -0
- data/public/images/layout/tab.png +0 -0
- data/public/images/layout/tab_active.png +0 -0
- data/public/images/layout/table_header.png +0 -0
- data/public/images/layout/text_field_bg.jpg +0 -0
- data/public/images/layout/text_field_error_bg.png +0 -0
- data/public/images/layout/th_bg.png +0 -0
- data/public/images/layout/th_bg_selected.png +0 -0
- data/public/images/menu_icons/content_report.png +0 -0
- data/public/images/menu_icons/content_report_on.png +0 -0
- data/public/images/menu_icons/funnel.png +0 -0
- data/public/images/menu_icons/funnel_on.png +0 -0
- data/public/images/menu_icons/intersite_traffic.png +0 -0
- data/public/images/menu_icons/intersite_traffic_on.png +0 -0
- data/public/images/menu_icons/leads.png +0 -0
- data/public/images/menu_icons/leads_on.png +0 -0
- data/public/images/menu_icons/traffic_explorer.png +0 -0
- data/public/images/menu_icons/traffic_explorer_on.png +0 -0
- data/public/images/menu_icons/traffic_summary.png +0 -0
- data/public/images/menu_icons/traffic_summary_on.png +0 -0
- data/public/images/menu_icons/visitor_profile.png +0 -0
- data/public/images/menu_icons/visitor_profile_on.png +0 -0
- data/public/index.html +8 -0
- data/public/javascripts/application.js +2 -0
- data/public/javascripts/controls.js +965 -0
- data/public/javascripts/dragdrop.js +974 -0
- data/public/javascripts/effects.js +1123 -0
- data/public/javascripts/prototype.js +6001 -0
- data/public/javascripts/rails.js +175 -0
- data/public/robots.txt +5 -0
- data/public/stylesheets/.gitkeep +0 -0
- data/public/stylesheets/application.css +876 -0
- data/public/stylesheets/core.css +1146 -0
- data/public/stylesheets/core_ie.css +52 -0
- data/public/stylesheets/csshover3.htc +14 -0
- data/public/stylesheets/mitamirri.css +37 -724
- data/public/stylesheets/mitamirri_print.css +3 -0
- data/script/cucumber +10 -0
- data/script/rails +6 -0
- data/spec/blueprints.rb +13 -0
- data/spec/helpers/application_helper_spec.rb +23 -35
- data/spec/{lib → models}/content_report_spec.rb +12 -8
- data/spec/{lib → models}/intersite_traffic_report_spec.rb +6 -9
- data/spec/{lib → models}/leads_report_spec.rb +11 -12
- data/spec/models/location_stat_spec.rb +18 -0
- data/spec/models/trackable_action_spec.rb +46 -14
- data/spec/models/trackable_base_spec.rb +27 -0
- data/spec/models/trackable_session_spec.rb +181 -57
- data/spec/{lib/session_report_spec.rb → models/traffic_explorer_report_spec.rb} +8 -25
- data/spec/spec_helper.rb +8 -28
- data/{lib/mitamirri/tasks.rb → tasks/mitamirri.rake} +6 -7
- data/vendor/plugins/.gitkeep +0 -0
- metadata +316 -77
- data/.gitignore +0 -26
- data/app/controllers/trackable_sessions_controller.rb +0 -100
- data/app/views/trackable_sessions/_keywords_graph.html.erb +0 -24
- data/app/views/trackable_sessions/_print_buttons.html.erb +0 -3
- data/app/views/trackable_sessions/_sessions.html.erb +0 -26
- data/app/views/trackable_sessions/_top_referrers.html.erb +0 -24
- data/app/views/trackable_sessions/_traffic_summary_all.html.erb +0 -64
- data/app/views/trackable_sessions/_traffic_summary_by_kind.html.erb +0 -48
- data/app/views/trackable_sessions/content.html.erb +0 -119
- data/app/views/trackable_sessions/explorer.html.erb +0 -67
- data/app/views/trackable_sessions/export.xls.erb +0 -5
- data/app/views/trackable_sessions/index.html.erb +0 -47
- data/app/views/trackable_sessions/intersite.html.erb +0 -97
- data/app/views/trackable_sessions/leads.html.erb +0 -98
- data/app/views/trackable_sessions/visitor_profile.html.erb +0 -114
- data/config/initializers/backtrace_silencers.rb +0 -7
- data/config/initializers/database.rb +0 -1
- data/config/initializers/inflections.rb +0 -10
- data/config/initializers/mime_types.rb +0 -5
- data/config/initializers/new_rails_defaults.rb +0 -21
- data/db/development.sqlite3 +0 -0
- data/db/migrate/20100810173533_create_trackable_sessions.rb +0 -23
- data/db/migrate/20100810173605_create_trackable_actions.rb +0 -20
- data/db/test.sqlite3 +0 -1
- data/lib/mitamirri/content_report.rb +0 -75
- data/lib/mitamirri/intersite_traffic_report.rb +0 -122
- data/lib/mitamirri/leads_report.rb +0 -90
- data/lib/mitamirri/session_report.rb +0 -219
- data/lib/mitamirri/stat_report.rb +0 -216
- data/lib/mitamirri/visitor_profile_report.rb +0 -127
- data/script/about +0 -4
- data/script/console +0 -3
- data/script/dbconsole +0 -3
- data/script/destroy +0 -3
- data/script/generate +0 -3
- data/script/performance/benchmarker +0 -3
- data/script/performance/profiler +0 -3
- data/script/plugin +0 -3
- data/script/runner +0 -3
- data/script/server +0 -3
- data/spec/controllers/trackable_actions_controller_spec.rb +0 -5
- data/spec/controllers/trackable_sessions_controller_spec.rb +0 -5
- data/spec/custom_matchers.rb +0 -23
- data/spec/lib/stat_report_spec.rb +0 -106
- data/spec/rcov.opts +0 -4
- data/spec/schema.rb +0 -34
- data/spec/spec.opts +0 -4
@@ -1,216 +0,0 @@
|
|
1
|
-
module Mitamirri
|
2
|
-
|
3
|
-
class StatReport
|
4
|
-
|
5
|
-
# Search params
|
6
|
-
attr_accessor :action_kind
|
7
|
-
attr_accessor :site
|
8
|
-
attr_accessor :time_period
|
9
|
-
attr_accessor :visit_kind
|
10
|
-
|
11
|
-
# Initialization
|
12
|
-
|
13
|
-
def initialize(args = {})
|
14
|
-
args.each{|k,v| self.send("#{k}=",v) if self.respond_to?(k)}
|
15
|
-
self.time_period = args[:time_period] || 'past 6 months'
|
16
|
-
self.stats
|
17
|
-
end
|
18
|
-
|
19
|
-
def stats
|
20
|
-
if self.site && self.site.downcase != 'all sites'
|
21
|
-
@stats ||= TrackableStat.by_site(self.site).for_date_range(dates.first, dates.last.end_of_month)
|
22
|
-
else
|
23
|
-
@stats ||= TrackableStat.for_date_range(dates.first, dates.last.end_of_month)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
# Generate an array of dates spanning the appropriate time period.
|
28
|
-
def dates
|
29
|
-
return @dates if @dates
|
30
|
-
@dates = []
|
31
|
-
case self.time_period
|
32
|
-
when 'past month'
|
33
|
-
_increment = 1
|
34
|
-
when 'past 3 months'
|
35
|
-
_increment = 2
|
36
|
-
when 'past 6 months'
|
37
|
-
_increment = 5
|
38
|
-
when 'past 12 months'
|
39
|
-
_increment = 11
|
40
|
-
else 'all time'
|
41
|
-
_increment = 24
|
42
|
-
end
|
43
|
-
|
44
|
-
(1.._increment).each{ |i| @dates << (Time.zone.now - i.months).beginning_of_month }
|
45
|
-
@dates.reverse!
|
46
|
-
@dates << Time.zone.now.end_of_month
|
47
|
-
@dates
|
48
|
-
end
|
49
|
-
|
50
|
-
# Graphing data
|
51
|
-
def self.keywords_by_frequency(args)
|
52
|
-
TrackableSession.keywords_histogram(args).inject([]){|a,v| a << KeywordStat.new(:keyword => v[0], :count => v[1]); a}.sort{|a,b| a.count <=> b.count}.reverse[0..24]
|
53
|
-
end
|
54
|
-
|
55
|
-
def self.top_referrers(args)
|
56
|
-
TrackableSession.referrers_histogram(args).inject([]){|a,v| a << ReferrerStat.new(:referrer => v[0], :count => v[1]); a}.sort{|a,b| a.count <=> b.count}.reverse[0..24]
|
57
|
-
end
|
58
|
-
|
59
|
-
def visits(args)
|
60
|
-
_visits = []
|
61
|
-
_visits << Visit.new(:kind => 'All', :stats => visit_stats(args))
|
62
|
-
_visits << Visit.new(:kind => 'Direct Traffic', :stats => visit_stats(args.merge(:visit_kind => 'direct')))
|
63
|
-
_visits << Visit.new(:kind => 'Referring Sites', :stats => visit_stats(args.merge(:visit_kind => 'natural')))
|
64
|
-
_visits << Visit.new(:kind => 'Organic Search', :stats => visit_stats(args.merge(:visit_kind => 'search')))
|
65
|
-
_visits << Visit.new(:kind => 'Paid Search', :stats => visit_stats(args.merge(:visit_kind => 'paid')))
|
66
|
-
_visits
|
67
|
-
end
|
68
|
-
|
69
|
-
def visit_stats(args)
|
70
|
-
_visit_stats = []
|
71
|
-
dates.each do |date|
|
72
|
-
_visit_stats << VisitStat.new(:date => date, :visits => TrackableSession.search_without_date(args).for_month(date).count)
|
73
|
-
end
|
74
|
-
_visit_stats
|
75
|
-
end
|
76
|
-
|
77
|
-
# Statistics
|
78
|
-
|
79
|
-
def average_pages_per_visit
|
80
|
-
sprintf("%.1f", total_pageviews / total_visits.to_f)
|
81
|
-
end
|
82
|
-
|
83
|
-
def average_time_on_site
|
84
|
-
average = total_duration / total_visits.to_f
|
85
|
-
average > 60 ? sprintf("%.1f minutes", average / 60.0) : sprintf("%.1f seconds", average)
|
86
|
-
end
|
87
|
-
|
88
|
-
def bounce_rate
|
89
|
-
bounce_rate = total_bounces / total_visits.to_f
|
90
|
-
sprintf("%.1f%", bounce_rate * 100)
|
91
|
-
end
|
92
|
-
|
93
|
-
def conversion_rate
|
94
|
-
conversion_rate = total_conversions / total_visits.to_f
|
95
|
-
sprintf("%.1f%", conversion_rate * 100)
|
96
|
-
end
|
97
|
-
|
98
|
-
def total_bounces
|
99
|
-
@total_bounces ||= stats.fields(:bounces).map{|s| s.bounces}.sum
|
100
|
-
end
|
101
|
-
|
102
|
-
def total_clickthroughs
|
103
|
-
@total_clickthroughs ||= stats.fields(:clickthroughs).map{|s| s.clickthroughs}.sum
|
104
|
-
end
|
105
|
-
|
106
|
-
def total_clickthroughs_percentage
|
107
|
-
sprintf("%.1f%", (total_clickthroughs / total_visits.to_f) * 100)
|
108
|
-
end
|
109
|
-
|
110
|
-
def total_conversions
|
111
|
-
@total_conversions ||= stats.fields(:conversions).map{|s| s.conversions}.sum
|
112
|
-
end
|
113
|
-
|
114
|
-
def total_direct_visits
|
115
|
-
@total_direct_visits ||= stats.fields(:direct_visits).map{|s| s.direct_visits}.sum
|
116
|
-
end
|
117
|
-
|
118
|
-
def total_direct_visits_percentage
|
119
|
-
sprintf("%.1f%", (total_direct_visits / total_visits.to_f) * 100)
|
120
|
-
end
|
121
|
-
|
122
|
-
def total_duration
|
123
|
-
@total_duration ||= stats.fields(:duration).map{|s| s.duration}.sum
|
124
|
-
end
|
125
|
-
|
126
|
-
def total_new_visits
|
127
|
-
@total_new_visits ||= stats.fields(:new_visits).map{|s| s.new_visits}.sum
|
128
|
-
end
|
129
|
-
|
130
|
-
def total_new_visits_percentage
|
131
|
-
sprintf("%.1f%", (total_new_visits / total_visits.to_f) * 100)
|
132
|
-
end
|
133
|
-
|
134
|
-
def total_organic_visits
|
135
|
-
@total_organic_visits ||= stats.fields(:organic_visits).map{|s| s.organic_visits}.sum
|
136
|
-
end
|
137
|
-
|
138
|
-
def total_organic_visits_percentage
|
139
|
-
sprintf("%.1f%", (total_organic_visits / total_visits.to_f) * 100)
|
140
|
-
end
|
141
|
-
|
142
|
-
def total_pageviews
|
143
|
-
@total_pageviews ||= stats.fields(:pageviews).map{|s| s.pageviews}.sum
|
144
|
-
end
|
145
|
-
|
146
|
-
def total_ppc_visits
|
147
|
-
@total_ppc_visits ||= stats.fields(:ppc_visits).map{|s| s.ppc_visits}.sum
|
148
|
-
end
|
149
|
-
|
150
|
-
def total_ppc_visits_percentage
|
151
|
-
sprintf("%.1f%", (total_ppc_visits / total_visits.to_f) * 100)
|
152
|
-
end
|
153
|
-
|
154
|
-
def total_return_visits
|
155
|
-
@total_return_visits ||= stats.fields(:return_visits).map{|s| s.return_visits}.sum
|
156
|
-
end
|
157
|
-
|
158
|
-
def total_return_visits_percentage
|
159
|
-
sprintf("%.1f%", (total_return_visits / total_visits.to_f) * 100)
|
160
|
-
end
|
161
|
-
|
162
|
-
def total_search_visits
|
163
|
-
@total_search_visits ||= stats.fields(:search_visits).map{|s| s.search_visits}.sum
|
164
|
-
end
|
165
|
-
|
166
|
-
def total_search_visits_percentage
|
167
|
-
sprintf("%.1f%", (total_search_visits / total_visits.to_f) * 100)
|
168
|
-
end
|
169
|
-
|
170
|
-
def total_visits
|
171
|
-
@total_visits ||= stats.fields(:visits).map{|s| s.visits}.sum
|
172
|
-
end
|
173
|
-
|
174
|
-
# Inner stat classes
|
175
|
-
class KeywordStat
|
176
|
-
attr_accessor :keyword
|
177
|
-
attr_accessor :count
|
178
|
-
def initialize(args)
|
179
|
-
args.each{ |k,v| self.send("#{k}=", v) }
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
class ReferrerStat
|
184
|
-
attr_accessor :referrer
|
185
|
-
attr_accessor :count
|
186
|
-
def initialize(args)
|
187
|
-
args.each{ |k,v| self.send("#{k}=", v) }
|
188
|
-
end
|
189
|
-
end
|
190
|
-
|
191
|
-
class Visit
|
192
|
-
attr_accessor :kind
|
193
|
-
attr_accessor :date
|
194
|
-
attr_accessor :stats
|
195
|
-
def initialize(args)
|
196
|
-
args.each{ |k,v| self.send("#{k}=", v) }
|
197
|
-
end
|
198
|
-
end
|
199
|
-
|
200
|
-
class VisitStat
|
201
|
-
attr_accessor :date
|
202
|
-
attr_accessor :visits
|
203
|
-
|
204
|
-
def initialize(args)
|
205
|
-
args.each{ |k,v| self.send("#{k}=", v) }
|
206
|
-
end
|
207
|
-
|
208
|
-
def short_date
|
209
|
-
self.date.to_s(:month_year)
|
210
|
-
end
|
211
|
-
|
212
|
-
end
|
213
|
-
|
214
|
-
end
|
215
|
-
|
216
|
-
end
|
@@ -1,127 +0,0 @@
|
|
1
|
-
module Mitamirri
|
2
|
-
|
3
|
-
class VisitorProfileReport
|
4
|
-
|
5
|
-
# Search params
|
6
|
-
attr_accessor :action_kind
|
7
|
-
attr_accessor :site
|
8
|
-
attr_accessor :time_period
|
9
|
-
attr_accessor :visit_kind
|
10
|
-
|
11
|
-
# Initialization
|
12
|
-
|
13
|
-
def initialize(args = {})
|
14
|
-
args.each{|k,v| self.send("#{k}=",v) if self.respond_to?(k)}
|
15
|
-
self.time_period = args[:time_period] || 'past 6 months'
|
16
|
-
self.sessions
|
17
|
-
end
|
18
|
-
|
19
|
-
def criteria
|
20
|
-
_criteria = self.sessions.to_hash
|
21
|
-
_criteria.delete(:sort)
|
22
|
-
_criteria
|
23
|
-
end
|
24
|
-
|
25
|
-
def sessions
|
26
|
-
@sessions ||= TrackableSession.search(
|
27
|
-
:action_kind => self.action_kind,
|
28
|
-
:site => self.site,
|
29
|
-
:time_period => self.time_period,
|
30
|
-
:visit_kind => self.visit_kind
|
31
|
-
)
|
32
|
-
end
|
33
|
-
|
34
|
-
# Generate an array of dates spanning the appropriate time period.
|
35
|
-
def dates
|
36
|
-
return @dates if @dates
|
37
|
-
@dates = []
|
38
|
-
case self.time_period
|
39
|
-
when 'past month'
|
40
|
-
_increment = 1
|
41
|
-
when 'past 3 months'
|
42
|
-
_increment = 2
|
43
|
-
when 'past 6 months'
|
44
|
-
_increment = 5
|
45
|
-
when 'past 12 months'
|
46
|
-
_increment = 11
|
47
|
-
else 'all time'
|
48
|
-
_increment = 24
|
49
|
-
end
|
50
|
-
|
51
|
-
(1.._increment).each{ |i| @dates << (Time.zone.now - i.months).beginning_of_month }
|
52
|
-
@dates.reverse!
|
53
|
-
@dates << Time.zone.now.end_of_month
|
54
|
-
@dates
|
55
|
-
end
|
56
|
-
|
57
|
-
# Graphing data
|
58
|
-
|
59
|
-
def locations_by_frequency(args)
|
60
|
-
TrackableSession.locations_histogram(args).inject([]){|a,v| a << LocationStat.new(:name => v[0], :count => v[1]); a}.sort{|a,b| a.count <=> b.count}.reverse[0..24]
|
61
|
-
end
|
62
|
-
|
63
|
-
def user_agents_by_frequency(args)
|
64
|
-
TrackableSession.user_agents_histogram(args).inject([]){|a,v| a << UserAgentStat.new(:user_agent => v[0], :count => v[1]); a}.sort{|a,b| a.count <=> b.count}.reverse[0..24]
|
65
|
-
end
|
66
|
-
|
67
|
-
# Inner stat classes
|
68
|
-
|
69
|
-
class Visitor
|
70
|
-
attr_accessor :user_agent_stats
|
71
|
-
attr_accessor :location_stats
|
72
|
-
def initialize(args)
|
73
|
-
args.each{ |k,v| self.send("#{k}=", v) }
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
class UserAgentStat
|
78
|
-
attr_accessor :user_agent
|
79
|
-
attr_accessor :count
|
80
|
-
def initialize(args)
|
81
|
-
args.each{ |k,v| self.send("#{k}=", v) }
|
82
|
-
end
|
83
|
-
end
|
84
|
-
|
85
|
-
class LocationStat
|
86
|
-
|
87
|
-
attr_accessor :name
|
88
|
-
attr_accessor :latitude
|
89
|
-
attr_accessor :longitude
|
90
|
-
attr_accessor :count
|
91
|
-
|
92
|
-
def initialize(args)
|
93
|
-
args.each{ |k,v| self.send("#{k}=", v) }
|
94
|
-
geocode
|
95
|
-
end
|
96
|
-
|
97
|
-
def geocode
|
98
|
-
if _location = TrackableLocation.where(:location => self.name).first
|
99
|
-
self.latitude = _location.latitude
|
100
|
-
self.longitude = _location.longitude
|
101
|
-
else
|
102
|
-
begin
|
103
|
-
_coords = Geokit::Geocoders::MultiGeocoder.geocode(self.name)
|
104
|
-
rescue
|
105
|
-
end
|
106
|
-
if _coords && _coords.success
|
107
|
-
self.latitude = _coords.lat
|
108
|
-
self.longitude = _coords.lng
|
109
|
-
TrackableLocation.create(:location => self.name, :latitude => self.latitude, :longitude => self.longitude)
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def geocoded?
|
115
|
-
self.latitude && self.longitude
|
116
|
-
end
|
117
|
-
|
118
|
-
def sanitized_name
|
119
|
-
self.name.gsub(/'/,"\\'")
|
120
|
-
end
|
121
|
-
|
122
|
-
end
|
123
|
-
|
124
|
-
|
125
|
-
end
|
126
|
-
|
127
|
-
end
|
data/script/about
DELETED
data/script/console
DELETED
data/script/dbconsole
DELETED
data/script/destroy
DELETED
data/script/generate
DELETED
data/script/performance/profiler
DELETED
data/script/plugin
DELETED
data/script/runner
DELETED
data/script/server
DELETED
data/spec/custom_matchers.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
module CustomMatcher
|
2
|
-
def set_cell(row, column, value)
|
3
|
-
value = "'#{value}'" if value.is_a?(String)
|
4
|
-
|
5
|
-
simple_matcher("setCell(#{row}, #{column}, #{value})") do |actual|
|
6
|
-
actual =~ /data\.setCell\(#{row},\s*#{column},\s*#{value}\)/
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def set_value(row, column, value)
|
11
|
-
value = "'#{value}'" if value.is_a?(String)
|
12
|
-
|
13
|
-
simple_matcher("setValue(#{row}, #{column}, #{value})") do |actual|
|
14
|
-
actual =~ /data\.setValue\(#{row},\s*#{column},\s*#{value}\)/
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def add_column(column_type, value)
|
19
|
-
simple_matcher("addColumn('#{column_type}', '#{value}')") do |actual|
|
20
|
-
actual =~ /data\.addColumn\('#{column_type}',\s*'#{value}'\)/
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,106 +0,0 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
-
require 'mitamirri'
|
3
|
-
|
4
|
-
describe "StatReport" do
|
5
|
-
|
6
|
-
before :all do
|
7
|
-
@args = {
|
8
|
-
:site => 'www.foo.com',
|
9
|
-
:time_period => 'past 3 months',
|
10
|
-
:action_kind => 'clickthrough',
|
11
|
-
:visit_kind => 'search'
|
12
|
-
}
|
13
|
-
TrackableSession.stubs(:search).returns([])
|
14
|
-
@report = Mitamirri::StatReport.new(@args)
|
15
|
-
@report.stubs(:total_bounces).returns(5)
|
16
|
-
@report.stubs(:total_clickthroughs).returns(10)
|
17
|
-
@report.stubs(:total_conversions).returns(20)
|
18
|
-
@report.stubs(:total_direct_visits).returns(10)
|
19
|
-
@report.stubs(:total_duration).returns(18000.0)
|
20
|
-
@report.stubs(:total_new_visits).returns(20)
|
21
|
-
@report.stubs(:total_organic_visits).returns(30)
|
22
|
-
@report.stubs(:total_pageviews).returns(100)
|
23
|
-
@report.stubs(:total_ppc_visits).returns(10)
|
24
|
-
@report.stubs(:total_return_visits).returns(90)
|
25
|
-
@report.stubs(:total_search_visits).returns(30)
|
26
|
-
@report.stubs(:total_visits).returns(100)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'initializes with arguments' do
|
30
|
-
@report.site.should == @args[:site]
|
31
|
-
@report.time_period.should == @args[:time_period]
|
32
|
-
@report.action_kind.should == 'clickthrough'
|
33
|
-
@report.visit_kind.should == 'search'
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'calculates its dates' do
|
37
|
-
@report.dates.should == [
|
38
|
-
(Time.zone.now - 2.months).beginning_of_month,
|
39
|
-
(Time.zone.now - 1.months).beginning_of_month,
|
40
|
-
(Time.zone.now).end_of_month,
|
41
|
-
]
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'calculates average pages per visit' do
|
45
|
-
@report.average_pages_per_visit.should == "1.0"
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'calculates average time on site' do
|
49
|
-
@report.average_time_on_site.should == "3.0 minutes"
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'calculates the bounce rate' do
|
53
|
-
@report.bounce_rate.should == "5.0%"
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'calculates the conversion rate' do
|
57
|
-
@report.conversion_rate.should == "20.0%"
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'calculates the total direct visits percentage' do
|
61
|
-
@report.total_direct_visits_percentage.should == "10.0%"
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'calculates the total new visits percentage' do
|
65
|
-
@report.total_new_visits_percentage.should == "20.0%"
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'calculates the total return visits percentage' do
|
69
|
-
@report.total_return_visits_percentage.should == "90.0%"
|
70
|
-
end
|
71
|
-
|
72
|
-
it 'calculates the total organic visits percentage' do
|
73
|
-
@report.total_organic_visits_percentage.should == "30.0%"
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'calculates the total ppc visits percentage' do
|
77
|
-
@report.total_ppc_visits_percentage.should == "10.0%"
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'creates a KeywordStat object from arguments' do
|
81
|
-
_stat = Mitamirri::StatReport::KeywordStat.new(:keyword => 'foo', :count => 3)
|
82
|
-
_stat.count.should == 3
|
83
|
-
_stat.keyword.should == 'foo'
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'creates a ReferrerStat object from arguments' do
|
87
|
-
_stat = Mitamirri::StatReport::ReferrerStat.new(:referrer => 'www.foo.com', :count => 3)
|
88
|
-
_stat.count.should == 3
|
89
|
-
_stat.referrer.should == 'www.foo.com'
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'creates a Visit object from arguments' do
|
93
|
-
_visit = Mitamirri::StatReport::Visit.new(:kind => 'search', :date => Time.zone.now.to_s(:concise), :stats => [])
|
94
|
-
_visit.kind.should == "search"
|
95
|
-
_visit.date.should == Time.zone.now.to_s(:concise)
|
96
|
-
_visit.stats.should == []
|
97
|
-
end
|
98
|
-
|
99
|
-
it 'creates a VisitStat object from arguments' do
|
100
|
-
_stat = Mitamirri::StatReport::VisitStat.new(:date => Time.zone.now, :visits => 3)
|
101
|
-
_stat.visits.should == 3
|
102
|
-
_stat.date.to_s(:concise).should == Time.zone.now.to_s(:concise)
|
103
|
-
_stat.short_date.should == Time.zone.now.to_s(:month_year)
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|