mixpanel 1.1.1 → 1.1.2

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.
@@ -112,3 +112,4 @@ All collaborations are welcome to this project, please fork and make a pull requ
112
112
  * {Logan Bowers}[https://github.com/loganb]
113
113
  * {jakemack}[https://github.com/jakemack]
114
114
  * {James Ferguson}[https://github.com/JamesFerguson]
115
+ * {Brad Wilson}[https://github.com/bradx3]
@@ -29,7 +29,13 @@ module Mixpanel
29
29
  end
30
30
 
31
31
  def ip
32
- @env.has_key?("REMOTE_ADDR") ? @env["REMOTE_ADDR"] : ""
32
+ if @env.has_key?("HTTP_X_FORWARDED_FOR")
33
+ @env["HTTP_X_FORWARDED_FOR"].split(",").last
34
+ elsif @env.has_key?("REMOTE_ADDR")
35
+ @env["REMOTE_ADDR"]
36
+ else
37
+ ""
38
+ end
33
39
  end
34
40
 
35
41
  def queue
@@ -2,7 +2,7 @@ files = ['README.rdoc', 'LICENSE', 'Rakefile', 'mixpanel.gemspec', '{spec,lib}/*
2
2
 
3
3
  spec = Gem::Specification.new do |s|
4
4
  s.name = "mixpanel"
5
- s.version = "1.1.1"
5
+ s.version = "1.1.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"
@@ -26,12 +26,21 @@ describe Mixpanel::Tracker do
26
26
  @mixpanel.track_event("Sign up").should == true
27
27
  end
28
28
 
29
- it "should call request method with token and time value" do
29
+ it "should call request method with token, time value and ip address" do
30
30
  params = {:event => "Sign up", :properties => {:token => MIX_PANEL_TOKEN, :time => Time.now.utc.to_i, :ip => "127.0.0.1"}}
31
31
 
32
32
  @mixpanel.should_receive(:request).with(params).and_return("1")
33
33
  @mixpanel.track_event("Sign up").should == true
34
34
  end
35
+
36
+ it "should call request method with token, and send ip address from HTTP_X_FORWARDED_FOR" do
37
+ @mixpanel = Mixpanel::Tracker.new(MIX_PANEL_TOKEN, @env = {"HTTP_X_FORWARDED_FOR" => "10.1.0.2"})
38
+
39
+ params = {:event => "Sign up", :properties => {:token => MIX_PANEL_TOKEN, :time => Time.now.utc.to_i, :ip => "10.1.0.2"}}
40
+
41
+ @mixpanel.should_receive(:request).with(params).and_return("1")
42
+ @mixpanel.track_event("Sign up")
43
+ end
35
44
  end
36
45
  end
37
46
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 1
8
- - 1
9
- version: 1.1.1
8
+ - 2
9
+ version: 1.1.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Alvaro Gil
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-11-23 00:00:00 -02:00
17
+ date: 2012-01-09 00:00:00 -02:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency