analytics-rails 0.0.2 → 0.0.3
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/lib/analytics/rails.rb +2 -1
- data/lib/analytics/rails/action_view/base.rb +25 -0
- data/lib/analytics/rails/railtie.rb +2 -2
- data/lib/analytics/rails/version.rb +1 -1
- data/test/analytics_rails_test.rb +1 -1
- data/test/dummy/log/development.log +83 -0
- data/test/dummy/log/test.log +9 -0
- metadata +3 -3
- data/lib/analytics/rails/helpers.rb +0 -23
data/lib/analytics/rails.rb
CHANGED
@@ -0,0 +1,25 @@
|
|
1
|
+
module Analytics
|
2
|
+
module Rails
|
3
|
+
module ActionView
|
4
|
+
module Base
|
5
|
+
|
6
|
+
def google_analytics_include_tag(account)
|
7
|
+
if ::Rails.env.production?
|
8
|
+
script = <<-SCRIPT.strip_heredoc
|
9
|
+
var _gaq = _gaq || [];
|
10
|
+
_gaq.push(['_setAccount', '#{account}']);
|
11
|
+
_gaq.push(['_trackPageview']);
|
12
|
+
(function(){
|
13
|
+
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
14
|
+
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
15
|
+
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
16
|
+
})();
|
17
|
+
SCRIPT
|
18
|
+
content_tag(:script, "\n#{script}".html_safe, :type => 'text/javascript')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -2,8 +2,8 @@ module Analytics
|
|
2
2
|
module Rails
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
4
|
|
5
|
-
initializer 'analytics.
|
6
|
-
ActionView::Base.send :include, Analytics::Rails::
|
5
|
+
initializer 'analytics.rails' do
|
6
|
+
::ActionView::Base.send :include, Analytics::Rails::ActionView::Base
|
7
7
|
end
|
8
8
|
|
9
9
|
end
|
@@ -91,3 +91,86 @@ Started GET "/" for 127.0.0.1 at 2013-04-03 16:17:42 -0300
|
|
91
91
|
Processing by StaticsController#home as HTML
|
92
92
|
Rendered statics/home.html.erb within layouts/application (3.1ms)
|
93
93
|
Completed 200 OK in 33ms (Views: 32.8ms | ActiveRecord: 0.0ms)
|
94
|
+
Connecting to database specified by database.yml
|
95
|
+
|
96
|
+
|
97
|
+
Started GET "/" for 127.0.0.1 at 2013-04-17 18:08:27 -0300
|
98
|
+
Processing by StaticsController#home as HTML
|
99
|
+
Rendered statics/home.html.erb within layouts/application (5.8ms)
|
100
|
+
Completed 200 OK in 135ms (Views: 134.8ms | ActiveRecord: 0.0ms)
|
101
|
+
|
102
|
+
|
103
|
+
Started GET "/assets/jquery_ujs.js?body=1" for 127.0.0.1 at 2013-04-17 18:08:27 -0300
|
104
|
+
Served asset /jquery_ujs.js - 304 Not Modified (5ms)
|
105
|
+
|
106
|
+
|
107
|
+
Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2013-04-17 18:08:27 -0300
|
108
|
+
Served asset /application.js - 200 OK (5ms)
|
109
|
+
|
110
|
+
|
111
|
+
Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2013-04-17 18:08:27 -0300
|
112
|
+
Served asset /application.css - 200 OK (2ms)
|
113
|
+
|
114
|
+
|
115
|
+
Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2013-04-17 18:08:27 -0300
|
116
|
+
Served asset /jquery.js - 304 Not Modified (3ms)
|
117
|
+
|
118
|
+
|
119
|
+
Started GET "/" for 127.0.0.1 at 2013-04-17 18:09:19 -0300
|
120
|
+
Processing by StaticsController#home as HTML
|
121
|
+
Rendered statics/home.html.erb within layouts/application (0.1ms)
|
122
|
+
Completed 200 OK in 5ms (Views: 4.6ms | ActiveRecord: 0.0ms)
|
123
|
+
|
124
|
+
|
125
|
+
Started GET "/" for 127.0.0.1 at 2013-04-17 18:09:22 -0300
|
126
|
+
Processing by StaticsController#home as HTML
|
127
|
+
Rendered statics/home.html.erb within layouts/application (0.0ms)
|
128
|
+
Completed 200 OK in 5ms (Views: 4.6ms | ActiveRecord: 0.0ms)
|
129
|
+
Connecting to database specified by database.yml
|
130
|
+
|
131
|
+
|
132
|
+
Started GET "/" for 127.0.0.1 at 2013-04-17 18:09:33 -0300
|
133
|
+
Processing by StaticsController#home as HTML
|
134
|
+
Rendered statics/home.html.erb within layouts/application (24.5ms)
|
135
|
+
Completed 500 Internal Server Error in 83ms
|
136
|
+
|
137
|
+
ActionView::Template::Error (undefined method `scan' for #<#<Class:0x007f9d71bdc520>:0x007f9d71cbae38>):
|
138
|
+
4: <title>Dummy</title>
|
139
|
+
5: <%= stylesheet_link_tag "application", :media => "all" %>
|
140
|
+
6: <%= javascript_include_tag "application" %>
|
141
|
+
7: <%= google_analytics_include_tag 'your-id' %>
|
142
|
+
8: <%= csrf_meta_tags %>
|
143
|
+
9: </head>
|
144
|
+
10: <body>
|
145
|
+
app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb___298453737105053640_70157099377240'
|
146
|
+
|
147
|
+
|
148
|
+
Rendered /Users/Matt/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_trace.erb (2.4ms)
|
149
|
+
Rendered /Users/Matt/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.6ms)
|
150
|
+
Rendered /Users/Matt/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.2.13/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (15.1ms)
|
151
|
+
Connecting to database specified by database.yml
|
152
|
+
|
153
|
+
|
154
|
+
Started GET "/" for 127.0.0.1 at 2013-04-17 18:13:38 -0300
|
155
|
+
Processing by StaticsController#home as HTML
|
156
|
+
Rendered statics/home.html.erb within layouts/application (3.5ms)
|
157
|
+
Completed 200 OK in 56ms (Views: 55.1ms | ActiveRecord: 0.0ms)
|
158
|
+
|
159
|
+
|
160
|
+
Started GET "/" for 127.0.0.1 at 2013-04-17 18:14:25 -0300
|
161
|
+
Processing by StaticsController#home as HTML
|
162
|
+
Rendered statics/home.html.erb within layouts/application (0.0ms)
|
163
|
+
Completed 200 OK in 5ms (Views: 4.8ms | ActiveRecord: 0.0ms)
|
164
|
+
|
165
|
+
|
166
|
+
Started GET "/" for 127.0.0.1 at 2013-04-17 18:14:28 -0300
|
167
|
+
Processing by StaticsController#home as HTML
|
168
|
+
Rendered statics/home.html.erb within layouts/application (0.0ms)
|
169
|
+
Completed 200 OK in 5ms (Views: 4.7ms | ActiveRecord: 0.0ms)
|
170
|
+
Connecting to database specified by database.yml
|
171
|
+
|
172
|
+
|
173
|
+
Started GET "/" for 127.0.0.1 at 2013-04-17 18:14:41 -0300
|
174
|
+
Processing by StaticsController#home as HTML
|
175
|
+
Rendered statics/home.html.erb within layouts/application (3.0ms)
|
176
|
+
Completed 200 OK in 32ms (Views: 31.4ms | ActiveRecord: 0.0ms)
|
data/test/dummy/log/test.log
CHANGED
@@ -64,3 +64,12 @@ Completed 200 OK in 18ms (Views: 17.5ms | ActiveRecord: 0.0ms)
|
|
64
64
|
Connecting to database specified by database.yml
|
65
65
|
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
66
66
|
[1m[35m (0.0ms)[0m rollback transaction
|
67
|
+
Connecting to database specified by database.yml
|
68
|
+
[1m[36m (0.4ms)[0m [1mbegin transaction[0m
|
69
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
70
|
+
Connecting to database specified by database.yml
|
71
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
72
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
73
|
+
Connecting to database specified by database.yml
|
74
|
+
[1m[36m (0.2ms)[0m [1mbegin transaction[0m
|
75
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: analytics-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.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-04-
|
12
|
+
date: 2013-04-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -50,7 +50,7 @@ executables: []
|
|
50
50
|
extensions: []
|
51
51
|
extra_rdoc_files: []
|
52
52
|
files:
|
53
|
-
- lib/analytics/rails/
|
53
|
+
- lib/analytics/rails/action_view/base.rb
|
54
54
|
- lib/analytics/rails/railtie.rb
|
55
55
|
- lib/analytics/rails/version.rb
|
56
56
|
- lib/analytics/rails.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Analytics
|
2
|
-
module Rails
|
3
|
-
module Helpers
|
4
|
-
|
5
|
-
def google_analytics_include_tag(account)
|
6
|
-
if ::Rails.env.production?
|
7
|
-
script = <<-SCRIPT
|
8
|
-
var _gaq = _gaq || [];
|
9
|
-
_gaq.push(['_setAccount', '#{account}']);
|
10
|
-
_gaq.push(['_trackPageview']);
|
11
|
-
(function(){
|
12
|
-
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
|
13
|
-
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
14
|
-
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
15
|
-
})();
|
16
|
-
SCRIPT
|
17
|
-
content_tag(:script, script.html_safe, :type => 'text/javascript')
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|