event_tracker 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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # EventTracker
1
+ # Event Tracker
2
2
 
3
3
  Easy tracking using mixpanel or kissmetrics
4
4
 
@@ -16,6 +16,35 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install event_tracker
18
18
 
19
+ ## Usage
20
+
21
+ ```ruby
22
+ # config/application.rb
23
+ config.event_tracker.mixpanel_key = "YOUR_KEY"
24
+ config.event_tracker.kissmetrics_key = "YOUR_KEY"
25
+
26
+ class ApplicationController < ActionController::Base
27
+ after_filter :append_event_tracking_tags
28
+
29
+ # optionally identify users
30
+ def mixpanel_distinct_id
31
+ current_visitor_id
32
+ end
33
+
34
+ def mixpanel_name_tag
35
+ current_user && current_user.email
36
+ end
37
+
38
+ def kissmetrics_identity
39
+ current_user && current_user.email
40
+ end
41
+ end
42
+
43
+ # in controller or views
44
+ track_event("Event Name", optional_property: "value")
45
+ register_properties(name: "value")
46
+ ```
47
+
19
48
  ## Todos
20
49
 
21
50
  * AJAX handling
data/lib/event_tracker.rb CHANGED
@@ -3,7 +3,7 @@ require "event_tracker/mixpanel"
3
3
  require "event_tracker/kissmetrics"
4
4
 
5
5
  module EventTracker
6
- module ActionControllerExtension
6
+ module HelperMethods
7
7
  def track_event(event_name, args = {})
8
8
  (session[:event_tracker_queue] ||= []) << [event_name, args]
9
9
  end
@@ -11,7 +11,9 @@ module EventTracker
11
11
  def register_properties(args)
12
12
  (session[:registered_properties] ||= {}).merge!(args)
13
13
  end
14
+ end
14
15
 
16
+ module ActionControllerExtension
15
17
  def append_event_tracking_tags
16
18
  mixpanel_key = Rails.application.config.event_tracker.mixpanel_key
17
19
  kissmetrics_key = Rails.application.config.event_tracker.kissmetrics_key
@@ -64,6 +66,8 @@ module EventTracker
64
66
  initializer "event_tracker" do |app|
65
67
  ActiveSupport.on_load :action_controller do
66
68
  include ActionControllerExtension
69
+ include HelperMethods
70
+ helper HelperMethods
67
71
  end
68
72
  end
69
73
  end
@@ -1,3 +1,3 @@
1
1
  module EventTracker
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -0,0 +1 @@
1
+ <% track_event "Register for site" %>
@@ -53,6 +53,11 @@ feature 'basic integration' do
53
53
  it_should_behave_like "with event"
54
54
  end
55
55
 
56
+ context 'visit page with tracking' do
57
+ background { visit '/basic/in_views' }
58
+ it_should_behave_like "with event"
59
+ end
60
+
56
61
  context 'visit page with tracking then without tracking' do
57
62
  background do
58
63
  visit '/basic/with_tracking'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: event_tracker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -60,6 +60,7 @@ files:
60
60
  - lib/event_tracker/kissmetrics.rb
61
61
  - lib/event_tracker/mixpanel.rb
62
62
  - lib/event_tracker/version.rb
63
+ - spec/app/views/basic/in_views.html.erb
63
64
  - spec/app/views/layouts/application.html.erb
64
65
  - spec/event_tracker_spec.rb
65
66
  - spec/spec_helper.rb
@@ -77,7 +78,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
78
  version: '0'
78
79
  segments:
79
80
  - 0
80
- hash: -2338464354941489983
81
+ hash: -2292007241673597298
81
82
  required_rubygems_version: !ruby/object:Gem::Requirement
82
83
  none: false
83
84
  requirements:
@@ -86,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
86
87
  version: '0'
87
88
  segments:
88
89
  - 0
89
- hash: -2338464354941489983
90
+ hash: -2292007241673597298
90
91
  requirements: []
91
92
  rubyforge_project:
92
93
  rubygems_version: 1.8.24
@@ -94,6 +95,7 @@ signing_key:
94
95
  specification_version: 3
95
96
  summary: Track using javascript from your controllers, even when redirecting
96
97
  test_files:
98
+ - spec/app/views/basic/in_views.html.erb
97
99
  - spec/app/views/layouts/application.html.erb
98
100
  - spec/event_tracker_spec.rb
99
101
  - spec/spec_helper.rb