track_me 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/generators/track_me/install/install_generator.rb +10 -3
- data/lib/generators/track_me/install/templates/_init.html.haml +2 -0
- data/lib/generators/track_me/install/templates/_kissmetrics.html.haml +0 -15
- data/lib/generators/track_me/install/templates/_kissmetrics_init.html.haml +15 -0
- data/lib/generators/track_me/install/templates/_mixpanel.html.haml +0 -5
- data/lib/generators/track_me/install/templates/_mixpanel_init.html.haml +4 -0
- data/lib/track_me/version.rb +1 -1
- data/spec/install_generator_spec.rb +2 -2
- metadata +7 -4
data/README.md
CHANGED
@@ -4,16 +4,23 @@ module TrackMe
|
|
4
4
|
|
5
5
|
def copy_files
|
6
6
|
copy_file '_js.html.haml', 'app/views/track_me/_js.html.haml'
|
7
|
+
copy_file '_init.html.haml', 'app/views/track_me/_init.html.haml'
|
7
8
|
copy_file '_mixpanel.html.haml', 'app/views/track_me/_mixpanel.html.haml'
|
9
|
+
copy_file '_mixpanel_init.html.haml', 'app/views/track_me/_mixpanel_init.html.haml'
|
8
10
|
copy_file '_kissmetrics.html.haml', 'app/views/track_me/_kissmetrics.html.haml'
|
11
|
+
copy_file '_kissmetrics_init.html.haml', 'app/views/track_me/_kissmetrics_init.html.haml'
|
9
12
|
copy_file 'track_me.rb', 'config/initializers/track_me.rb'
|
10
13
|
|
11
14
|
say "\n"
|
12
|
-
say 'Please dont forget to add the
|
15
|
+
say 'Please dont forget to add the init file to the head section of your html templates. The main reason why the init file is separated is for applications that use pjax or turbolinks where the head section is only loaded once.', :green
|
13
16
|
say "\n"
|
14
|
-
say " = render 'track_me/
|
17
|
+
say " = render 'track_me/init'", :green
|
15
18
|
say "\n"
|
16
|
-
say
|
19
|
+
say "You can then add the partial that actually sends the data"
|
20
|
+
say "\n"
|
21
|
+
say " = render 'track_me/js'", :green
|
22
|
+
say "\n"
|
23
|
+
say 'and then include the main module on application controller', :green
|
17
24
|
say "\n"
|
18
25
|
say " include TrackMe", :green
|
19
26
|
say "\n"
|
@@ -1,19 +1,4 @@
|
|
1
1
|
:javascript
|
2
|
-
// Initialize Kissmetrics
|
3
|
-
var _kmq = _kmq || [];
|
4
|
-
var _kmk = _kmk || '#{KISSMETRICS_ID}';
|
5
|
-
|
6
|
-
function _kms(u){
|
7
|
-
setTimeout(function(){
|
8
|
-
var d = document, f = d.getElementsByTagName('script')[0],
|
9
|
-
s = d.createElement('script');
|
10
|
-
s.type = 'text/javascript'; s.async = true; s.src = u;
|
11
|
-
f.parentNode.insertBefore(s, f);
|
12
|
-
}, 1);
|
13
|
-
}
|
14
|
-
_kms('//i.kissmetrics.com/i.js');
|
15
|
-
_kms('//doug1izaerwt3.cloudfront.net/' + _kmk + '.1.js');
|
16
|
-
|
17
2
|
// Identify current user
|
18
3
|
_kmq.push(['identify', '#{current_user.email}']);
|
19
4
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
:javascript
|
2
|
+
// Initialize Kissmetrics
|
3
|
+
var _kmq = _kmq || [];
|
4
|
+
var _kmk = _kmk || '#{KISSMETRICS_ID}';
|
5
|
+
|
6
|
+
function _kms(u){
|
7
|
+
setTimeout(function(){
|
8
|
+
var d = document, f = d.getElementsByTagName('script')[0],
|
9
|
+
s = d.createElement('script');
|
10
|
+
s.type = 'text/javascript'; s.async = true; s.src = u;
|
11
|
+
f.parentNode.insertBefore(s, f);
|
12
|
+
}, 1);
|
13
|
+
}
|
14
|
+
_kms('//i.kissmetrics.com/i.js');
|
15
|
+
_kms('//doug1izaerwt3.cloudfront.net/' + _kmk + '.1.js');
|
@@ -1,8 +1,3 @@
|
|
1
|
-
:javascript
|
2
|
-
// Initialize Mixpanel
|
3
|
-
(function(c,a){window.mixpanel=a;var b,d,h,e;b=c.createElement("script");b.type="text/javascript";b.async=!0;b.src=("https:"===c.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.0.min.js';d=c.getElementsByTagName("script")[0];d.parentNode.insertBefore(b,d);a._i=[];a.init=function(b,c,f){function d(a,b){var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]);a[b]=function(){a.push([b].concat(Array.prototype.slice.call(arguments,0)))}}var g=a;"undefined"!==typeof f? g=a[f]=[]:f="mixpanel";g.people=g.people||[];h="disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config people.set people.increment".split(" ");for(e=0;e<h.length;e++)d(g,h[e]);a._i.push([b,c,f])};a.__SV=1.1})(document,window.mixpanel||[]);
|
4
|
-
mixpanel.init("#{MIXPANEL_ID}");
|
5
|
-
|
6
1
|
- if @trackme_object
|
7
2
|
:javascript
|
8
3
|
mixpanel.track('#{escape_javascript @trackme_string}', #{@trackme_object.to_json});
|
@@ -0,0 +1,4 @@
|
|
1
|
+
:javascript
|
2
|
+
// Initialize Mixpanel
|
3
|
+
(function(c,a){window.mixpanel=a;var b,d,h,e;b=c.createElement("script");b.type="text/javascript";b.async=!0;b.src=("https:"===c.location.protocol?"https:":"http:")+'//cdn.mxpnl.com/libs/mixpanel-2.0.min.js';d=c.getElementsByTagName("script")[0];d.parentNode.insertBefore(b,d);a._i=[];a.init=function(b,c,f){function d(a,b){var c=b.split(".");2==c.length&&(a=a[c[0]],b=c[1]);a[b]=function(){a.push([b].concat(Array.prototype.slice.call(arguments,0)))}}var g=a;"undefined"!==typeof f? g=a[f]=[]:f="mixpanel";g.people=g.people||[];h="disable track track_pageview track_links track_forms register register_once unregister identify name_tag set_config people.set people.increment".split(" ");for(e=0;e<h.length;e++)d(g,h[e]);a._i.push([b,c,f])};a.__SV=1.1})(document,window.mixpanel||[]);
|
4
|
+
mixpanel.init("#{MIXPANEL_ID}");
|
data/lib/track_me/version.rb
CHANGED
@@ -18,7 +18,7 @@ describe TrackMe::InstallGenerator do
|
|
18
18
|
|
19
19
|
specify 'metric templates are properly generated' do
|
20
20
|
assert_file 'app/views/track_me/_js.html.haml'
|
21
|
-
assert_file 'app/views/track_me/
|
22
|
-
assert_file 'app/views/track_me/
|
21
|
+
assert_file 'app/views/track_me/_mixpanel_init.html.haml', /Initialize Mixpanel/
|
22
|
+
assert_file 'app/views/track_me/_kissmetrics_init.html.haml', /Initialize Kissmetrics/
|
23
23
|
end
|
24
24
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: track_me
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
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: 2012-12-
|
12
|
+
date: 2012-12-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: generator_spec
|
@@ -90,9 +90,12 @@ files:
|
|
90
90
|
- README.md
|
91
91
|
- Rakefile
|
92
92
|
- lib/generators/track_me/install/install_generator.rb
|
93
|
+
- lib/generators/track_me/install/templates/_init.html.haml
|
93
94
|
- lib/generators/track_me/install/templates/_js.html.haml
|
94
95
|
- lib/generators/track_me/install/templates/_kissmetrics.html.haml
|
96
|
+
- lib/generators/track_me/install/templates/_kissmetrics_init.html.haml
|
95
97
|
- lib/generators/track_me/install/templates/_mixpanel.html.haml
|
98
|
+
- lib/generators/track_me/install/templates/_mixpanel_init.html.haml
|
96
99
|
- lib/generators/track_me/install/templates/track_me.rb
|
97
100
|
- lib/track_me.rb
|
98
101
|
- lib/track_me/version.rb
|
@@ -114,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
114
117
|
version: '0'
|
115
118
|
segments:
|
116
119
|
- 0
|
117
|
-
hash:
|
120
|
+
hash: -40853105
|
118
121
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
119
122
|
none: false
|
120
123
|
requirements:
|
@@ -123,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
123
126
|
version: '0'
|
124
127
|
segments:
|
125
128
|
- 0
|
126
|
-
hash:
|
129
|
+
hash: -40853105
|
127
130
|
requirements: []
|
128
131
|
rubyforge_project:
|
129
132
|
rubygems_version: 1.8.23
|