Skip to content

Commit

Permalink
Merge pull request #994 from mixpanel/jared-ms-time
Browse files Browse the repository at this point in the history
use millisecond precision for event.time property
  • Loading branch information
jaredmixpanel authored Jun 24, 2022
2 parents 83c5c4e + 1d75a41 commit 1438eb1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Sources/Mixpanel.m
Original file line number Diff line number Diff line change
Expand Up @@ -523,12 +523,12 @@ - (void)track:(NSString *)event properties:(NSDictionary *)properties
[Mixpanel assertPropertyTypes:properties];

NSTimeInterval epochInterval = [[NSDate date] timeIntervalSince1970];
NSNumber *epochSeconds = @(round(epochInterval));
NSNumber *epochMilliseconds = @(round(epochInterval * 1000));
dispatch_async(self.serialQueue, ^{
NSNumber *eventStartTime = self.timedEvents[event];
NSMutableDictionary *p = [NSMutableDictionary dictionaryWithDictionary:self.automaticProperties];
p[@"token"] = self.apiToken;
p[@"time"] = epochSeconds;
p[@"time"] = epochMilliseconds;
if (eventStartTime != nil) {
[self.timedEvents removeObjectForKey:event];
p[@"$duration"] = @([[NSString stringWithFormat:@"%.3f", epochInterval - [eventStartTime doubleValue]] floatValue]);
Expand Down

0 comments on commit 1438eb1

Please sign in to comment.