mixpanel 4.0.1 → 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +13 -7
- data/lib/mixpanel/event.rb +8 -0
- data/lib/mixpanel/person.rb +0 -4
- data/mixpanel.gemspec +1 -1
- data/spec/mixpanel/tracker_spec.rb +16 -0
- metadata +18 -18
data/README.md
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
- [What is Mixpanel] (#what-is-mixpanel)
|
8
8
|
- [What does this Gem do?] (#what-does-this-gem-do)
|
9
9
|
- [Install] (#install)
|
10
|
-
- [Rack Middleware] (#rack-middleware)
|
10
|
+
- [Rack Middleware] (#rack-middleware)
|
11
11
|
- [Usage] (#usage)
|
12
12
|
- [Initialize Mixpanel] (#initialize-mixpanel)
|
13
13
|
- [Track Events Directly](#track-events-directly)
|
@@ -199,6 +199,12 @@ Example:
|
|
199
199
|
@mixpanel.track 'Purchased credits', { :number => 5, 'First Time Buyer' => true }
|
200
200
|
```
|
201
201
|
|
202
|
+
If you would like to alias one distinct id to another, you can use the alias helper method:
|
203
|
+
|
204
|
+
```ruby
|
205
|
+
@mixpanel.alias 'Siddhartha', { distinct_id: previous_distinct_id }
|
206
|
+
```
|
207
|
+
|
202
208
|
### Pixel Based Event Tracking
|
203
209
|
|
204
210
|
```ruby
|
@@ -457,13 +463,13 @@ end
|
|
457
463
|
```ruby
|
458
464
|
class ApplicationController < ActionController::Base
|
459
465
|
before_filter :initialize_env
|
460
|
-
|
466
|
+
|
461
467
|
private
|
462
468
|
##
|
463
469
|
# Initialize env for mixpanel
|
464
470
|
def initialize_env
|
465
|
-
# Similar to the Resque problem above, we need to help DJ serialize the
|
466
|
-
# request object.
|
471
|
+
# Similar to the Resque problem above, we need to help DJ serialize the
|
472
|
+
# request object.
|
467
473
|
@request_env = {
|
468
474
|
'REMOTE_ADDR' => request.env['REMOTE_ADDR'],
|
469
475
|
'HTTP_X_FORWARDED_FOR' => request.env['HTTP_X_FORWARDED_FOR'],
|
@@ -484,9 +490,9 @@ end
|
|
484
490
|
```
|
485
491
|
**Sample Usage**
|
486
492
|
```ruby
|
487
|
-
MixPanel.track("Front Page Load", {
|
488
|
-
url_type: short_url.uid_type,
|
489
|
-
page_name: short_url.page.name,
|
493
|
+
MixPanel.track("Front Page Load", {
|
494
|
+
url_type: short_url.uid_type,
|
495
|
+
page_name: short_url.page.name,
|
490
496
|
distinct_id: @client_uid }, @request_env)
|
491
497
|
```
|
492
498
|
|
data/lib/mixpanel/event.rb
CHANGED
@@ -19,6 +19,14 @@ module Mixpanel::Event
|
|
19
19
|
append 'track', event, track_properties(properties, false)
|
20
20
|
end
|
21
21
|
|
22
|
+
def alias(name, properties={}, options={})
|
23
|
+
track_event '$create_alias', properties.merge(:alias => name), options, TRACK_URL
|
24
|
+
end
|
25
|
+
|
26
|
+
def append_alias(aliased_id)
|
27
|
+
append 'alias', aliased_id
|
28
|
+
end
|
29
|
+
|
22
30
|
protected
|
23
31
|
|
24
32
|
def track_event(event, properties, options, default_url)
|
data/lib/mixpanel/person.rb
CHANGED
data/mixpanel.gemspec
CHANGED
@@ -2,7 +2,7 @@ files = ['README.md', 'LICENSE', 'Rakefile', 'mixpanel.gemspec', '{spec,lib}/**/
|
|
2
2
|
|
3
3
|
spec = Gem::Specification.new do |s|
|
4
4
|
s.name = "mixpanel"
|
5
|
-
s.version = "4.0.
|
5
|
+
s.version = "4.0.2"
|
6
6
|
s.rubyforge_project = "mixpanel"
|
7
7
|
s.description = "Simple lib to track events in Mixpanel service. It can be used in any rack based framework."
|
8
8
|
s.author = "Alvaro Gil"
|
@@ -51,6 +51,22 @@ describe Mixpanel::Tracker do
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
+
describe '#alias' do
|
55
|
+
it 'tracks a simple event' do
|
56
|
+
@mixpanel.alias('James Salter').should be true
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'tracks a $create_alias event to the TRACK_URL' do
|
60
|
+
@mixpanel.should_receive(:track_event).with('$create_alias', anything, {}, Mixpanel::Event::TRACK_URL)
|
61
|
+
@mixpanel.alias('Phillip Dean')
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'includes the aliased name in the properties' do
|
65
|
+
@mixpanel.should_receive(:track_event).with('$create_alias', { :alias => 'Cristina Wheatland' }, {}, Mixpanel::Event::TRACK_URL)
|
66
|
+
@mixpanel.alias('Cristina Wheatland')
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
54
70
|
context "Engaging people" do
|
55
71
|
it "should set attributes" do
|
56
72
|
@mixpanel.set('person-a', { :email => 'me@domain.com', :likeable => false }).should == true
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixpanel
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-23 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement: &
|
16
|
+
requirement: &2153678160 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2153678160
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rack
|
27
|
-
requirement: &
|
27
|
+
requirement: &2153677720 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2153677720
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: escape
|
38
|
-
requirement: &
|
38
|
+
requirement: &2153677300 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2153677300
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec
|
49
|
-
requirement: &
|
49
|
+
requirement: &2153676880 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2153676880
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: rack-test
|
60
|
-
requirement: &
|
60
|
+
requirement: &2153676460 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ! '>='
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '0'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2153676460
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: fakeweb
|
71
|
-
requirement: &
|
71
|
+
requirement: &2153676040 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2153676040
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: nokogiri
|
82
|
-
requirement: &
|
82
|
+
requirement: &2153675620 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2153675620
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rake
|
93
|
-
requirement: &
|
93
|
+
requirement: &2153701540 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2153701540
|
102
102
|
description: Simple lib to track events in Mixpanel service. It can be used in any
|
103
103
|
rack based framework.
|
104
104
|
email: zevarito@gmail.com
|