mitamirri 0.13.8 → 2.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. data/Capfile +4 -0
  2. data/Gemfile +29 -0
  3. data/README.rdoc +6 -55
  4. data/Rakefile +34 -21
  5. data/VERSION +1 -1
  6. data/app/controllers/admin/tracking/reports_controller.rb +78 -0
  7. data/app/controllers/admin/tracking/trackable_sessions_controller.rb +7 -0
  8. data/app/controllers/application_controller.rb +1 -8
  9. data/app/controllers/trackable_actions_controller.rb +0 -2
  10. data/app/helpers/application_helper.rb +21 -0
  11. data/app/helpers/layout_helper.rb +18 -0
  12. data/app/models/content_report.rb +35 -0
  13. data/app/models/content_stat.rb +4 -0
  14. data/app/models/destination.rb +4 -0
  15. data/app/models/intersite_traffic_report.rb +47 -0
  16. data/app/models/keyword_stat.rb +4 -0
  17. data/app/models/lead.rb +3 -0
  18. data/app/models/lead_stat.rb +5 -0
  19. data/app/models/leads_report.rb +32 -0
  20. data/app/models/location_stat.rb +37 -0
  21. data/app/models/referrer_stat.rb +4 -0
  22. data/app/models/report.rb +83 -0
  23. data/app/models/stat_base.rb +11 -0
  24. data/app/models/trackable_action.rb +114 -91
  25. data/app/models/trackable_base.rb +12 -0
  26. data/app/models/trackable_location.rb +7 -13
  27. data/app/models/trackable_session.rb +255 -171
  28. data/app/models/trackable_stat.rb +45 -27
  29. data/app/models/traffic_explorer_report.rb +92 -0
  30. data/app/models/traffic_summary_report.rb +142 -0
  31. data/app/models/user_agent_stat.rb +4 -0
  32. data/app/models/visit.rb +6 -0
  33. data/app/models/visit_stat.rb +5 -0
  34. data/app/models/visitor.rb +4 -0
  35. data/app/models/visitor_profile_report.rb +23 -0
  36. data/app/views/admin/tracking/reports/_content.html.erb +28 -0
  37. data/app/views/admin/tracking/reports/_conversion_rate.html.erb +30 -0
  38. data/app/views/admin/tracking/reports/_criteria.html.erb +33 -0
  39. data/app/views/admin/tracking/reports/_entrance_pages.html.erb +29 -0
  40. data/app/views/admin/tracking/reports/_exit_pages.html.erb +28 -0
  41. data/app/views/admin/tracking/reports/_explorer_criteria.html.erb +22 -0
  42. data/app/views/admin/tracking/reports/_explorer_summary.html.erb +22 -0
  43. data/app/views/admin/tracking/reports/_intersite_destinations.html.erb +28 -0
  44. data/app/views/admin/tracking/reports/_intersite_referrals.html.erb +30 -0
  45. data/app/views/admin/tracking/reports/_leads.html.erb +30 -0
  46. data/app/views/admin/tracking/reports/_locations.html.erb +47 -0
  47. data/app/views/admin/tracking/reports/_recent_visits.html.erb +33 -0
  48. data/app/views/admin/tracking/reports/_referring_keywords.html.erb +28 -0
  49. data/app/views/admin/tracking/reports/_referring_sites.html.erb +28 -0
  50. data/app/views/admin/tracking/reports/_traffic_summary.html.erb +26 -0
  51. data/app/views/admin/tracking/reports/_user_agents.html.erb +28 -0
  52. data/app/views/{trackable_sessions/_visits_graph.html.erb → admin/tracking/reports/_visits_by_kind.html.erb} +3 -3
  53. data/app/views/admin/tracking/reports/content.html.erb +12 -0
  54. data/app/views/admin/tracking/reports/explorer.html.erb +13 -0
  55. data/app/views/admin/tracking/reports/index.html.erb +16 -0
  56. data/app/views/admin/tracking/reports/intersite.html.erb +11 -0
  57. data/app/views/admin/tracking/reports/leads.html.erb +11 -0
  58. data/app/views/admin/tracking/reports/summary.html.erb +16 -0
  59. data/app/views/admin/tracking/reports/visitor_profile.html.erb +11 -0
  60. data/app/views/{trackable_sessions → admin/tracking/trackable_sessions}/show.html.erb +5 -4
  61. data/app/views/layouts/application.html.erb +51 -18
  62. data/config.ru +4 -0
  63. data/config/application.rb +13 -0
  64. data/config/boot.rb +13 -110
  65. data/config/cucumber.yml +10 -0
  66. data/config/deploy.rb +40 -0
  67. data/config/environment.rb +4 -23
  68. data/config/environments/development.rb +24 -13
  69. data/config/environments/production.rb +41 -20
  70. data/config/environments/test.rb +28 -24
  71. data/config/initializers/formats.rb +19 -0
  72. data/config/initializers/metric_fu.rb +9 -0
  73. data/config/initializers/secret_token.rb +7 -0
  74. data/config/initializers/session_store.rb +3 -10
  75. data/config/locales/en.yml +1 -1
  76. data/config/mongoid.yml +19 -0
  77. data/config/routes.rb +16 -10
  78. data/features/access_reports.feature +26 -0
  79. data/features/step_definitions/reports_steps.rb +9 -0
  80. data/features/step_definitions/web_steps.rb +219 -0
  81. data/features/support/env.rb +32 -0
  82. data/features/support/hooks.rb +1 -0
  83. data/features/support/paths.rb +33 -0
  84. data/features/traffic_summary_report.feature +43 -0
  85. data/init.rb +0 -7
  86. data/lib/mitamirri.rb +9 -12
  87. data/lib/mitamirri/engine.rb +7 -0
  88. data/lib/mitamirri/helper.rb +13 -29
  89. data/lib/mitamirri/railtie.rb +10 -0
  90. data/lib/tasks/cucumber.rake +60 -0
  91. data/lib/tasks/rcov.rake +44 -0
  92. data/mitamirri.gemspec +228 -100
  93. data/public/404.html +26 -0
  94. data/public/422.html +26 -0
  95. data/public/500.html +26 -0
  96. data/{config/database.yml → public/favicon.ico} +0 -0
  97. data/public/images/icons/add.png +0 -0
  98. data/public/images/icons/collapsed.gif +0 -0
  99. data/public/images/icons/delete.png +0 -0
  100. data/public/images/icons/drag.png +0 -0
  101. data/public/images/icons/edit.png +0 -0
  102. data/public/images/icons/expanded.gif +0 -0
  103. data/public/images/icons/help_icon.png +0 -0
  104. data/public/images/icons/link_icon.png +0 -0
  105. data/public/images/icons/move.png +0 -0
  106. data/public/images/icons/move_white.png +0 -0
  107. data/public/images/icons/note.png +0 -0
  108. data/public/images/icons/note_white.png +0 -0
  109. data/public/images/icons/notification_icon_sprite.png +0 -0
  110. data/public/images/icons/spinner.gif +0 -0
  111. data/public/images/icons/view.png +0 -0
  112. data/public/images/icons/warning.png +0 -0
  113. data/public/images/icons/warning_2.png +0 -0
  114. data/public/images/icons/warning_box.png +0 -0
  115. data/public/images/icons/warning_icon.png +0 -0
  116. data/public/images/icons/warning_white.png +0 -0
  117. data/public/images/layout/arrow_asc.png +0 -0
  118. data/public/images/layout/arrow_desc.png +0 -0
  119. data/public/images/layout/back.png +0 -0
  120. data/public/images/layout/black_bar.png +0 -0
  121. data/public/images/layout/branding.png +0 -0
  122. data/public/images/layout/breadcrumb_bg.png +0 -0
  123. data/public/images/layout/button_bg.png +0 -0
  124. data/public/images/layout/content_left_bg.png +0 -0
  125. data/public/images/layout/content_right_bg.png +0 -0
  126. data/public/images/layout/footer_bg.png +0 -0
  127. data/public/images/layout/h1_bg.png +0 -0
  128. data/public/images/layout/h2_bg.png +0 -0
  129. data/public/images/layout/h2_bg_for_table.png +0 -0
  130. data/public/images/layout/header_bg_grey.png +0 -0
  131. data/public/images/layout/header_bg_purple.png +0 -0
  132. data/public/images/layout/legend_bg.png +0 -0
  133. data/public/images/layout/menu_box_bg.png +0 -0
  134. data/public/images/layout/shadow_border.png +0 -0
  135. data/public/images/layout/shadow_border_2.png +0 -0
  136. data/public/images/layout/shadow_border_3.png +0 -0
  137. data/public/images/layout/shadow_border_4.png +0 -0
  138. data/public/images/layout/tab.png +0 -0
  139. data/public/images/layout/tab_active.png +0 -0
  140. data/public/images/layout/table_header.png +0 -0
  141. data/public/images/layout/text_field_bg.jpg +0 -0
  142. data/public/images/layout/text_field_error_bg.png +0 -0
  143. data/public/images/layout/th_bg.png +0 -0
  144. data/public/images/layout/th_bg_selected.png +0 -0
  145. data/public/images/menu_icons/content_report.png +0 -0
  146. data/public/images/menu_icons/content_report_on.png +0 -0
  147. data/public/images/menu_icons/funnel.png +0 -0
  148. data/public/images/menu_icons/funnel_on.png +0 -0
  149. data/public/images/menu_icons/intersite_traffic.png +0 -0
  150. data/public/images/menu_icons/intersite_traffic_on.png +0 -0
  151. data/public/images/menu_icons/leads.png +0 -0
  152. data/public/images/menu_icons/leads_on.png +0 -0
  153. data/public/images/menu_icons/traffic_explorer.png +0 -0
  154. data/public/images/menu_icons/traffic_explorer_on.png +0 -0
  155. data/public/images/menu_icons/traffic_summary.png +0 -0
  156. data/public/images/menu_icons/traffic_summary_on.png +0 -0
  157. data/public/images/menu_icons/visitor_profile.png +0 -0
  158. data/public/images/menu_icons/visitor_profile_on.png +0 -0
  159. data/public/index.html +8 -0
  160. data/public/javascripts/application.js +2 -0
  161. data/public/javascripts/controls.js +965 -0
  162. data/public/javascripts/dragdrop.js +974 -0
  163. data/public/javascripts/effects.js +1123 -0
  164. data/public/javascripts/prototype.js +6001 -0
  165. data/public/javascripts/rails.js +175 -0
  166. data/public/robots.txt +5 -0
  167. data/public/stylesheets/.gitkeep +0 -0
  168. data/public/stylesheets/application.css +876 -0
  169. data/public/stylesheets/core.css +1146 -0
  170. data/public/stylesheets/core_ie.css +52 -0
  171. data/public/stylesheets/csshover3.htc +14 -0
  172. data/public/stylesheets/mitamirri.css +37 -724
  173. data/public/stylesheets/mitamirri_print.css +3 -0
  174. data/script/cucumber +10 -0
  175. data/script/rails +6 -0
  176. data/spec/blueprints.rb +13 -0
  177. data/spec/helpers/application_helper_spec.rb +23 -35
  178. data/spec/{lib → models}/content_report_spec.rb +12 -8
  179. data/spec/{lib → models}/intersite_traffic_report_spec.rb +6 -9
  180. data/spec/{lib → models}/leads_report_spec.rb +11 -12
  181. data/spec/models/location_stat_spec.rb +18 -0
  182. data/spec/models/trackable_action_spec.rb +46 -14
  183. data/spec/models/trackable_base_spec.rb +27 -0
  184. data/spec/models/trackable_session_spec.rb +181 -57
  185. data/spec/{lib/session_report_spec.rb → models/traffic_explorer_report_spec.rb} +8 -25
  186. data/spec/spec_helper.rb +8 -28
  187. data/{lib/mitamirri/tasks.rb → tasks/mitamirri.rake} +6 -7
  188. data/vendor/plugins/.gitkeep +0 -0
  189. metadata +316 -77
  190. data/.gitignore +0 -26
  191. data/app/controllers/trackable_sessions_controller.rb +0 -100
  192. data/app/views/trackable_sessions/_keywords_graph.html.erb +0 -24
  193. data/app/views/trackable_sessions/_print_buttons.html.erb +0 -3
  194. data/app/views/trackable_sessions/_sessions.html.erb +0 -26
  195. data/app/views/trackable_sessions/_top_referrers.html.erb +0 -24
  196. data/app/views/trackable_sessions/_traffic_summary_all.html.erb +0 -64
  197. data/app/views/trackable_sessions/_traffic_summary_by_kind.html.erb +0 -48
  198. data/app/views/trackable_sessions/content.html.erb +0 -119
  199. data/app/views/trackable_sessions/explorer.html.erb +0 -67
  200. data/app/views/trackable_sessions/export.xls.erb +0 -5
  201. data/app/views/trackable_sessions/index.html.erb +0 -47
  202. data/app/views/trackable_sessions/intersite.html.erb +0 -97
  203. data/app/views/trackable_sessions/leads.html.erb +0 -98
  204. data/app/views/trackable_sessions/visitor_profile.html.erb +0 -114
  205. data/config/initializers/backtrace_silencers.rb +0 -7
  206. data/config/initializers/database.rb +0 -1
  207. data/config/initializers/inflections.rb +0 -10
  208. data/config/initializers/mime_types.rb +0 -5
  209. data/config/initializers/new_rails_defaults.rb +0 -21
  210. data/db/development.sqlite3 +0 -0
  211. data/db/migrate/20100810173533_create_trackable_sessions.rb +0 -23
  212. data/db/migrate/20100810173605_create_trackable_actions.rb +0 -20
  213. data/db/test.sqlite3 +0 -1
  214. data/lib/mitamirri/content_report.rb +0 -75
  215. data/lib/mitamirri/intersite_traffic_report.rb +0 -122
  216. data/lib/mitamirri/leads_report.rb +0 -90
  217. data/lib/mitamirri/session_report.rb +0 -219
  218. data/lib/mitamirri/stat_report.rb +0 -216
  219. data/lib/mitamirri/visitor_profile_report.rb +0 -127
  220. data/script/about +0 -4
  221. data/script/console +0 -3
  222. data/script/dbconsole +0 -3
  223. data/script/destroy +0 -3
  224. data/script/generate +0 -3
  225. data/script/performance/benchmarker +0 -3
  226. data/script/performance/profiler +0 -3
  227. data/script/plugin +0 -3
  228. data/script/runner +0 -3
  229. data/script/server +0 -3
  230. data/spec/controllers/trackable_actions_controller_spec.rb +0 -5
  231. data/spec/controllers/trackable_sessions_controller_spec.rb +0 -5
  232. data/spec/custom_matchers.rb +0 -23
  233. data/spec/lib/stat_report_spec.rb +0 -106
  234. data/spec/rcov.opts +0 -4
  235. data/spec/schema.rb +0 -34
  236. data/spec/spec.opts +0 -4
data/Capfile ADDED
@@ -0,0 +1,4 @@
1
+ load 'deploy' if respond_to?(:namespace) # cap2 differentiator
2
+ Dir['vendor/plugins/*/recipes/*.rb'].each { |plugin| load(plugin) }
3
+
4
+ load 'config/deploy' # remove this line to skip loading any of the default tasks
data/Gemfile ADDED
@@ -0,0 +1,29 @@
1
+ source "http://rubygems.org"
2
+ source 'http://jose.seologic.com:8808/'
3
+
4
+ gem 'bantik-user-agent', :require => 'user-agent'
5
+ gem 'bson_ext'
6
+ gem 'geokit'
7
+ gem 'mongoid'
8
+ gem 'rails', '>= 3.0.1'
9
+ gem 'pdfkit'
10
+ gem 'scaffold_logic'
11
+ gem 'seer'
12
+ gem 'SystemTimer'
13
+
14
+ group :development do
15
+ gem 'jeweler'
16
+ end
17
+
18
+ group :test do
19
+ gem 'be_valid_asset'
20
+ gem 'capybara'
21
+ gem 'cucumber-rails'
22
+ gem 'database_cleaner'
23
+ gem 'faker'
24
+ gem 'launchy'
25
+ gem 'machinist_mongo', :require => 'machinist/mongoid'
26
+ gem 'metric_fu'
27
+ gem 'mocha'
28
+ gem 'rspec-rails'
29
+ end
@@ -1,45 +1,13 @@
1
1
  = mitamirri
2
2
 
3
- Mitamirri is still in development and will not be production-ready until version 1.0.
4
-
5
- It's a Rails engine designed to be a drop-in substitute for (or companion to) Google Analytics that allows tracking of custom user events at a very granular level (e.g. specific link or button clicks and even mouseovers) in addition to the standard visits, etc. It uses MongoDB on the backend for optimal performance, even with hundreds of thousands of visits, and to stay out of the way of your application's database.
3
+ Mitamirri is a Rails engine designed to be a drop-in substitute for (or companion to) Google Analytics that allows tracking of custom user events at a very granular level (e.g. specific link or button clicks and even mouseovers) in addition to the standard visits, etc.
6
4
 
7
5
  == Installation
8
6
 
9
- * Make sure that you have MongoDB installed and configured for your environment.
10
-
11
- * See http://www.mongodb.org/display/DOCS/Quickstart
12
-
13
- * For the development environment, this OSX-specific installation guide is useful: http://shiftcommathree.com/articles/how-to-install-mongodb-on-os-x
14
-
15
- * Install the mongo_mapper:
16
-
17
- gem install mongo_mapper
18
-
19
- * Install mongo_mapper's dependency:
20
-
21
- gem install bson_ext
22
-
23
- * Make sure that you have the Jeweler gem installed:
24
-
25
- gem install jeweler
26
-
27
- * Install the gem. From the Mitamirri repo:
28
-
29
- rake install
30
-
31
7
  * Add the following lines to your config/environment.rb file:
32
8
 
33
- config.gem 'bantik-user-agent', :lib => 'user-agent'
34
9
  config.gem 'mitamirri'
35
- config.gem 'mongo_mapper'
36
- config.gem 'pdfkit'
37
- config.gem 'seer'
38
10
 
39
- * Add the following line to your application's Rakefile:
40
-
41
- require 'mitamirri/tasks'
42
-
43
11
  * Add this to the top of your app/helpers/application_helper.rb file:
44
12
 
45
13
  include Mitamirri::Helper
@@ -48,28 +16,15 @@ It's a Rails engine designed to be a drop-in substitute for (or companion to) Go
48
16
 
49
17
  rake mitamirri:install
50
18
 
51
- * Update the database name in config/initializers/database.rb with the name of your application. Be sure to remove the timestamp from the database name!
52
-
53
19
  * If you want to override default behaviour (strongly recommended, to at least require authorization for accessing reports), run the following rake command to copy Mitamirri's views and controllers to your application for customization:
54
20
 
55
21
  rake mitamirri:override
56
22
 
57
- * Mitamirri will automatically detect the host application's ability to render PDF versions of reports. To enable PDF output of reports, install PDFKit on your system add the following lines to your environment.rb file:
58
-
59
- config.gem 'pdfkit'
60
- config.gem 'geokit'
61
- config.gem 'user-agent'
62
- config.gem 'bantik-user-agent', :lib => 'user-agent'
63
- config.middleware.use "PDFKit::Middleware", :print_media_type => true
23
+ * Include Mitamirri's CSS in your admin layout:
64
24
 
65
- * Recommended for optimal PDF output: add the following rule to your application's print style sheet:
66
-
67
- .page_break { display: block; text-align: center; margin-top: 2em; page-break-after: always; }
25
+ <link href="/stylesheets/mitamirri.css" media="all" rel="stylesheet" type="text/css" />
26
+ <link href="/stylesheets/mitamirri_print.css" media="print" rel="stylesheet" type="text/css" />
68
27
 
69
- And the following to your screen style sheet:
70
-
71
- .page_break { display: none; }
72
-
73
28
  == Configuring Tracking
74
29
 
75
30
  * To track pageviews, add this anywhere in the HTML body of your view (or layout) file:
@@ -98,15 +53,11 @@ It's a Rails engine designed to be a drop-in substitute for (or companion to) Go
98
53
 
99
54
  == Accessing Reports
100
55
 
101
- To view reports and session details, point your browser to http://localhost:3000/tracking/
56
+ To view reports and session details, point your browser to http://localhost:3000/admin/tracking/
102
57
 
103
58
  == Development Tips
104
59
 
105
- * To run specs, use spec spec/
106
-
107
- * If you're just changing views, run rake:install from your local Mitamirri directory and updates will appear in your host application immediately.
108
-
109
- * If you're changing models, run rake:install and then restart your host application.
60
+ * To run specs, use rspec spec/
110
61
 
111
62
  * If you add features, run rake version:bump:minor to adjust the version number accordingly.
112
63
 
data/Rakefile CHANGED
@@ -1,26 +1,39 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- #require(File.join(File.dirname(__FILE__), 'config', 'boot'))
5
-
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'metric_fu'
6
4
  require 'rake'
7
- require 'rake/testtask'
8
- require 'rake/rdoctask'
5
+ require 'jeweler'
6
+ require File.expand_path('../config/application', __FILE__)
7
+
8
+ Mitamirri::Application.load_tasks
9
9
 
10
10
  begin
11
- require 'jeweler'
12
- require 'seer'
13
- Jeweler::Tasks.new do |gemspec|
14
- gemspec.name = "mitamirri"
15
- gemspec.summary = "View and action tracking for Rails 2.x."
16
- gemspec.description = "View and action tracking for Rails 2.x."
17
- gemspec.email = "corey@seologic.com"
18
- gemspec.homepage = "http://github.com/Bantik/mitamarri"
19
- gemspec.authors = ["Corey Ehmke"]
20
- gemspec.test_files = []
21
- end
22
- Jeweler::GemcutterTasks.new
23
- rescue LoadError
24
- puts "Jeweler not available. Install it with: gem install jeweler"
11
+ Bundler.setup(:default, :development)
12
+ rescue Bundler::BundlerError => e
13
+ $stderr.puts e.message
14
+ $stderr.puts "Run `bundle install` to install missing gems"
15
+ exit e.status_code
25
16
  end
26
17
 
18
+ Jeweler::Tasks.new do |gem|
19
+ gem.name = "mitamirri"
20
+ gem.homepage = "http://github.com/ivanoblomov/mitamirri"
21
+ gem.summary = %Q{Analytics for Rails 3 applications.}
22
+ gem.description = %Q{Mitamirri is a Rails engine designed to be a drop-in substitute for (or companion to) Google Analytics that enables standard analytics tracking in addition to tracking of custom client-side events.}
23
+ gem.email = "rod@seologic.com"
24
+ gem.authors = ["Bantik"]
25
+ # Include your dependencies below. Runtime dependencies are required when using your gem,
26
+ # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
27
+ # gem.add_runtime_dependency 'jabber4r', '> 0.1'
28
+ # gem.add_development_dependency 'rspec', '> 1.2.3'
29
+ end
30
+ Jeweler::RubygemsDotOrgTasks.new
31
+
32
+ require 'rake/rdoctask'
33
+ Rake::RDocTask.new do |rdoc|
34
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
35
+ rdoc.rdoc_dir = 'rdoc'
36
+ rdoc.title = "mitamirri #{version}"
37
+ rdoc.rdoc_files.include('README*')
38
+ rdoc.rdoc_files.include('lib/**/*.rb')
39
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.13.8
1
+ 2.0.8
@@ -0,0 +1,78 @@
1
+ class Admin::Tracking::ReportsController < ApplicationController
2
+
3
+ Mime::Type.register "application/vnd.ms-excel", :xls
4
+
5
+ before_filter :configure_options
6
+
7
+ # RESTful
8
+
9
+ def index
10
+ end
11
+
12
+ # Custom
13
+
14
+ def content
15
+ @report = ContentReport.new(params)
16
+ if @report.ready?
17
+ @pages_series = @report.pages_series(params)
18
+ @entrance_pages_series = @report.entrance_pages_series(params)
19
+ @exit_pages_series = @report.exit_pages_series(params)
20
+ end
21
+ end
22
+
23
+ def explorer
24
+ params[:visit_kind] = nil if params[:visit_kind] == 'total'
25
+ @report = TrafficExplorerReport.new(params)
26
+ if @report.ready?
27
+ @visits = @report.visits(params)
28
+ @visits_series = @visits.map{|v| v.stats}
29
+ end
30
+ end
31
+
32
+ def export
33
+ end
34
+
35
+ def intersite
36
+ @report = IntersiteTrafficReport.new(params)
37
+ if @report.ready?
38
+ @total_visits = @report.total_visits(params)
39
+ @total_visits_series = @total_visits.map{|v| v.stats}
40
+ @destinations_series = @report.destinations(params)
41
+ end
42
+ end
43
+
44
+ def leads
45
+ @report = LeadsReport.new(params)
46
+ if @report.ready?
47
+ @leads = @report.leads(params)
48
+ @leads_series = @leads.map{|l| l.stats}
49
+ end
50
+ end
51
+
52
+ def summary
53
+ @report = TrafficSummaryReport.new(params)
54
+ if @report.ready?
55
+ @keywords_series = @report.keywords_by_frequency(params)
56
+ @referrers_series = @report.top_referrers(params)
57
+ @visits = @report.visits(params)
58
+ @visits_series = @visits.map{|v| v.stats}
59
+ end
60
+ end
61
+
62
+ def visitor_profile
63
+ @report = VisitorProfileReport.new(params)
64
+ if @report.ready?
65
+ @user_agents_series = @report.user_agents_by_frequency(params)
66
+ @locations_series = @report.locations_by_frequency(params)
67
+ end
68
+ end
69
+
70
+ private
71
+
72
+ def configure_options
73
+ @sites = (TrackableStat.sites + ["All Sites"]).sort
74
+ @time_periods = ["Past 3 Months", "Past 6 Months", "Past 12 Months"]
75
+ params[:time_period] ||= @time_periods.first
76
+ end
77
+
78
+ end
@@ -0,0 +1,7 @@
1
+ class Admin::Tracking::TrackableSessionsController < ApplicationController
2
+
3
+ def show
4
+ @trackable_session = TrackableSession.find(params[:id])
5
+ end
6
+
7
+ end
@@ -1,10 +1,3 @@
1
- # Filters added to this controller apply to all controllers in the application.
2
- # Likewise, all the methods added will be available for all controllers.
3
-
4
1
  class ApplicationController < ActionController::Base
5
- helper :all # include all helpers, all the time
6
- protect_from_forgery # See ActionController::RequestForgeryProtection for details
7
-
8
- # Scrub sensitive parameters from your log
9
- # filter_parameter_logging :password
2
+ protect_from_forgery
10
3
  end
@@ -1,7 +1,5 @@
1
1
  class TrackableActionsController < ApplicationController
2
2
 
3
- unloadable
4
-
5
3
  def create
6
4
  TrackableAction.create_from_params(params)
7
5
  render :text => ''
@@ -1,2 +1,23 @@
1
1
  module ApplicationHelper
2
+
3
+ def breadcrumbs
4
+ html = %{<ol class="breadcrumbs">}
5
+
6
+ # Top-level
7
+ html << content_tag(:li, link_to('Home', root_path)) if defined?(root_path)
8
+ html << content_tag(:li, link_to('Tracking', admin_tracking_root_path))
9
+ html << content_tag(:li, link_to("Traffic Summary", admin_tracking_summary_path)) if controller?('tracking') && action?('summary')
10
+ html << content_tag(:li, link_to("Intersite Traffic", admin_tracking_foo_path)) if controller?('tracking') && action?('foo')
11
+ html << content_tag(:li, link_to("Traffic Explorer", admin_tracking_explorer_path)) if controller?('tracking') && action?('explorer')
12
+ html << content_tag(:li, link_to("Top Content", admin_tracking_content_path)) if controller?('tracking') && action?('content')
13
+ html << content_tag(:li, link_to("Leads", admin_tracking_leads_path)) if controller?('tracking') && action?('leads')
14
+ html << content_tag(:li, link_to("Visitor Profile", admin_tracking_visitor_profile_path)) if controller?('tracking') && action?('visitor_profile')
15
+
16
+ # Tidy up
17
+ html << %{</ol>}
18
+
19
+ # Output that puppy.
20
+ html.html_safe
21
+
22
+ end
2
23
  end
@@ -0,0 +1,18 @@
1
+ module LayoutHelper
2
+ include ScaffoldLogic::FormHelper
3
+ include ScaffoldLogic::Helper
4
+ include ScaffoldLogic::TabInterfaceHelper
5
+ include ScaffoldLogic::MenuHelper
6
+
7
+ def set_title(title = nil, window_title = nil)
8
+ app_name ||= 'SEO Logic'
9
+ window_title ||= title
10
+ if title.nil?
11
+ content_for(:title) { app_name }
12
+ content_for(:page_title) { }
13
+ else
14
+ content_for(:title) { window_title + " - #{app_name}" }
15
+ content_for(:page_title) { title }
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,35 @@
1
+ class ContentReport < Report
2
+
3
+ # Initialization =================================================================================
4
+
5
+ def ready?
6
+ self.site && self.time_period && self.visit_kind
7
+ end
8
+
9
+ def stats
10
+ if multiple_sites?
11
+ @stats ||= TrackableStat.for_date_range(start_date, end_date)
12
+ else
13
+ @stats ||= TrackableStat.for_site(site).for_date_range(start_date, end_date)
14
+ end
15
+ end
16
+
17
+ def wants_traffic_kind?
18
+ true
19
+ end
20
+
21
+ # Graph data =====================================================================================
22
+
23
+ def pages_series(args)
24
+ TrackableAction.pages_histogram(args).map{|datum| ContentStat.new(:url => datum[0], :views => datum[1].to_i)}
25
+ end
26
+
27
+ def entrance_pages_series(args)
28
+ TrackableSession.entrance_pages_histogram(args).map{|datum| ContentStat.new(:url => datum[0], :views => datum[1].to_i)}
29
+ end
30
+
31
+ def exit_pages_series(args)
32
+ TrackableSession.exit_pages_histogram(args).map{|datum| ContentStat.new(:url => datum[0], :views => datum[1].to_i)}
33
+ end
34
+
35
+ end
@@ -0,0 +1,4 @@
1
+ class ContentStat < StatBase
2
+ attr_accessor :url
3
+ attr_accessor :views
4
+ end
@@ -0,0 +1,4 @@
1
+ class Destination < StatBase
2
+ attr_accessor :site
3
+ attr_accessor :clickthroughs
4
+ end
@@ -0,0 +1,47 @@
1
+ class IntersiteTrafficReport < Report
2
+
3
+ # Initialization =================================================================================
4
+
5
+ def ready?
6
+ self.site && self.time_period && self.visit_kind
7
+ end
8
+
9
+ def destination_histogram(args)
10
+ @destination_histogram ||= TrackableSession.clickthroughs_histogram(args)
11
+ end
12
+
13
+ def destination_sites(args)
14
+ self.destination_histogram(args).keys
15
+ end
16
+
17
+ # Graph data =====================================================================================
18
+
19
+ def total_visits(args)
20
+ [Visit.new(:stats => visit_stats(args))]
21
+ end
22
+
23
+ def total_visit_stats(args)
24
+ _visit_stats = []
25
+ dates_by_week.each do |date|
26
+ _visit_stats << VisitStat.new(:date => date, :clickthroughs => TrackableSession.search_without_date(args).for_week(date).with_clickthroughs.count)
27
+ end
28
+ _visit_stats
29
+ end
30
+
31
+ def destinations(args)
32
+ _destinations = []
33
+ self.destination_sites(args).each do |site|
34
+ _destinations << Destination.new(:site => site, :clickthroughs => self.sessions.with_clickthroughs.count)
35
+ end
36
+ _destinations
37
+ end
38
+
39
+ def visit_stats(args)
40
+ _visit_stats = []
41
+ dates_by_week.each do |date|
42
+ _visit_stats << VisitStat.new(:date => date, :clickthroughs => TrackableSession.search_without_date(args).for_week(date).with_clickthroughs.count)
43
+ end
44
+ _visit_stats
45
+ end
46
+
47
+ end