Skip to content

Commit

Permalink
move time out of async block
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Rahilly committed Oct 22, 2013
1 parent 16e211a commit 684569d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Mixpanel/Mixpanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#import "NSData+MPBase64.h"
#import "ODIN.h"

#define VERSION @"2.0.1"
#define VERSION @"2.0.3"

#ifdef MIXPANEL_LOG
#define MixpanelLog(...) NSLog(__VA_ARGS__)
Expand Down Expand Up @@ -419,11 +419,12 @@ - (void)track:(NSString *)event properties:(NSDictionary *)properties
event = @"mp_event";
}
[Mixpanel assertPropertyTypes:properties];
NSNumber *epochSeconds = @(round([[NSDate date] timeIntervalSince1970]));
dispatch_async(self.serialQueue, ^{
NSMutableDictionary *p = [NSMutableDictionary dictionary];
[p addEntriesFromDictionary:self.automaticProperties];
[p setObject:self.apiToken forKey:@"token"];
[p setObject:[NSNumber numberWithLong:(long)[[NSDate date] timeIntervalSince1970]] forKey:@"time"];
[p setObject:epochSeconds forKey:@"time"];
if (self.nameTag) {
[p setObject:self.nameTag forKey:@"mp_name_tag"];
}
Expand Down Expand Up @@ -1006,14 +1007,14 @@ - (NSDictionary *)collectAutomaticProperties

- (void)addPeopleRecordToQueueWithAction:(NSString *)action andProperties:(NSDictionary *)properties
{
NSNumber *epochMilliseconds = @(round([[NSDate date] timeIntervalSince1970] * 1000));
dispatch_async(self.mixpanel.serialQueue, ^{
NSMutableDictionary *r = [NSMutableDictionary dictionary];
NSMutableDictionary *p = [NSMutableDictionary dictionary];
[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"];
[r setObject:epochMilliseconds forKey:@"$time"];
}
if ([action isEqualToString:@"$set"] || [action isEqualToString:@"$set_once"]) {
[p addEntriesFromDictionary:self.automaticProperties];
Expand Down

0 comments on commit 684569d

Please sign in to comment.