Permalink
Browse files

add timestamps to people records

  • Loading branch information...
1 parent aed0f5d commit 9b326fc89756cd3d29b56d784d9d6c625ccadac9 @neilrahilly neilrahilly committed Feb 1, 2013
Showing with 7 additions and 0 deletions.
  1. +1 −0 HelloMixpanel/HelloMixpanelTests/HelloMixpanelTests.m
  2. +6 −0 Mixpanel/Mixpanel.m
@@ -394,6 +394,7 @@ - (void)testPeopleSet
NSDictionary *r = self.mixpanel.peopleQueue.lastObject;
STAssertEqualObjects([r objectForKey:@"$token"], TEST_TOKEN, @"project token not set");
STAssertEqualObjects([r objectForKey:@"$distinct_id"], @"d1", @"distinct id not set");
+ STAssertNotNil([r objectForKey:@"$time"], @"$time timestamp missing");
STAssertNotNil([r objectForKey:@"$set"], @"$set dictionary missing");
p = [r objectForKey:@"$set"];
STAssertTrue(p.count == 4, @"incorrect people properties: %@", p);
View
@@ -1176,6 +1176,12 @@ - (void)addPeopleRecordToQueueWithAction:(NSString *)action andProperties:(NSDic
[r setObject:self.mixpanel.apiToken forKey:@"$token"];
+ if (![r objectForKey:@"$time"]) {
+ // milliseconds unix timestamp
+ NSNumber *time = [NSNumber numberWithUnsignedLongLong:(uint64_t)([[NSDate date] timeIntervalSince1970] * 1000)];
+ [r setObject:time forKey:@"$time"];
+ }
+
if ([action isEqualToString:@"$set"]) {
[p addEntriesFromDictionary:[MixpanelPeople deviceInfoProperties]];
}

0 comments on commit 9b326fc

Please sign in to comment.