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 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
 
@@ -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)
@@ -63,10 +63,6 @@ module Mixpanel::Person
63
63
  append 'identify', distinct_id
64
64
  end
65
65
 
66
- def append_alias(aliased_id)
67
- append 'alias', aliased_id
68
- end
69
-
70
66
  protected
71
67
 
72
68
  def engage(action, request_properties_or_distinct_id, properties, options)
@@ -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.1"
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.1
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-10 00:00:00.000000000Z
12
+ date: 2013-05-23 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
16
- requirement: &2153783040 !ruby/object:Gem::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: *2153783040
24
+ version_requirements: *2153678160
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rack
27
- requirement: &2153782600 !ruby/object:Gem::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: *2153782600
35
+ version_requirements: *2153677720
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: escape
38
- requirement: &2153782180 !ruby/object:Gem::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: *2153782180
46
+ version_requirements: *2153677300
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec
49
- requirement: &2153781760 !ruby/object:Gem::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: *2153781760
57
+ version_requirements: *2153676880
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rack-test
60
- requirement: &2153781340 !ruby/object:Gem::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: *2153781340
68
+ version_requirements: *2153676460
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: fakeweb
71
- requirement: &2153780920 !ruby/object:Gem::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: *2153780920
79
+ version_requirements: *2153676040
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: nokogiri
82
- requirement: &2153780500 !ruby/object:Gem::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: *2153780500
90
+ version_requirements: *2153675620
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rake
93
- requirement: &2153806420 !ruby/object:Gem::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: *2153806420
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