mixpanel-ruby 1.1.0 → 1.2.0
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.rdoc
CHANGED
@@ -38,6 +38,10 @@ For more information please visit:
|
|
38
38
|
|
39
39
|
== Changes
|
40
40
|
|
41
|
+
== 1.2.0
|
42
|
+
* All objects with a "strftime" method will be formatted as dates in
|
43
|
+
people updates.
|
44
|
+
|
41
45
|
== 1.1.0
|
42
46
|
* The default consumer now sends requests (and expects responses) in
|
43
47
|
verbose, JSON mode, which may improve error reporting.
|
data/lib/mixpanel-ruby/people.rb
CHANGED
@@ -244,27 +244,9 @@ module Mixpanel
|
|
244
244
|
|
245
245
|
def fix_property_dates(h)
|
246
246
|
h.inject({}) do |ret,(k,v)|
|
247
|
-
ret[k] =
|
247
|
+
ret[k] = v.respond_to?(:strftime) ? v.strftime('%Y-%m-%dT%H:%M:%S') : v
|
248
248
|
ret
|
249
249
|
end
|
250
250
|
end
|
251
|
-
|
252
|
-
class PeopleDate
|
253
|
-
def initialize(date)
|
254
|
-
@date = date
|
255
|
-
end
|
256
|
-
|
257
|
-
def to_json(*a)
|
258
|
-
@date.strftime('%Y-%m-%dT%H:%M:%S').to_json(*a)
|
259
|
-
end
|
260
|
-
|
261
|
-
def self.asPeopleDate(thing)
|
262
|
-
if thing.is_a?(Date)
|
263
|
-
PeopleDate.new(thing)
|
264
|
-
else
|
265
|
-
thing
|
266
|
-
end
|
267
|
-
end
|
268
|
-
end
|
269
251
|
end
|
270
252
|
end
|
@@ -6,7 +6,7 @@ require 'time'
|
|
6
6
|
describe Mixpanel::Events do
|
7
7
|
before(:each) do
|
8
8
|
@time_now = Time.parse('Jun 6 1972, 16:23:04')
|
9
|
-
Time.stub
|
9
|
+
Time.stub(:now).and_return(@time_now)
|
10
10
|
|
11
11
|
@log = []
|
12
12
|
@events = Mixpanel::Events.new('TEST TOKEN') do |type, message|
|
@@ -1,12 +1,10 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require '
|
3
|
-
require 'json'
|
4
|
-
require 'mixpanel-ruby/people.rb'
|
2
|
+
require 'mixpanel-ruby/people'
|
5
3
|
|
6
4
|
describe Mixpanel::People do
|
7
5
|
before(:each) do
|
8
6
|
@time_now = Time.parse('Jun 6 1972, 16:23:04')
|
9
|
-
Time.stub
|
7
|
+
Time.stub(:now).and_return(@time_now)
|
10
8
|
|
11
9
|
@log = []
|
12
10
|
@people = Mixpanel::People.new('TEST TOKEN') do |type, message|
|
@@ -30,6 +28,20 @@ describe Mixpanel::People do
|
|
30
28
|
}]])
|
31
29
|
end
|
32
30
|
|
31
|
+
it 'should properly cast dates' do
|
32
|
+
@people.set("TEST ID", {
|
33
|
+
'created_at' => DateTime.new(2013, 1, 2, 3, 4, 5)
|
34
|
+
})
|
35
|
+
@log.should eq([[ :profile_update, 'data' => {
|
36
|
+
'$token' => 'TEST TOKEN',
|
37
|
+
'$distinct_id' => 'TEST ID',
|
38
|
+
'$time' => @time_now.to_i * 1000,
|
39
|
+
'$set' => {
|
40
|
+
'created_at' => '2013-01-02T03:04:05'
|
41
|
+
}
|
42
|
+
}]])
|
43
|
+
end
|
44
|
+
|
33
45
|
it 'should send a well formed engage/set_once message' do
|
34
46
|
@people.set_once("TEST ID", {
|
35
47
|
'$firstname' => 'David',
|
@@ -63,7 +75,7 @@ describe Mixpanel::People do
|
|
63
75
|
@log.should eq([[ :profile_update, 'data' => {
|
64
76
|
'$token' => 'TEST TOKEN',
|
65
77
|
'$distinct_id' => 'TEST ID',
|
66
|
-
'$time' =>
|
78
|
+
'$time' => @time_now.to_i * 1000,
|
67
79
|
'$add' => {
|
68
80
|
'Albums Released' => 1
|
69
81
|
}
|
@@ -6,7 +6,7 @@ require 'uri'
|
|
6
6
|
describe Mixpanel::Tracker do
|
7
7
|
before(:each) do
|
8
8
|
@time_now = Time.parse('Jun 6 1972, 16:23:04')
|
9
|
-
Time.stub
|
9
|
+
Time.stub(:now).and_return(@time_now)
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should send an alias message to mixpanel no matter what the consumer is' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixpanel-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
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: 2013-10-
|
12
|
+
date: 2013-10-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|