Skip to content
Browse files

allow reserved property override

  • Loading branch information...
1 parent 0aac72d commit 93a379e3703163d5c5682f4ff5c833da702013b2 @neilrahilly neilrahilly committed Nov 20, 2012
Showing with 22 additions and 8 deletions.
  1. +18 −6 HelloMixpanel/HelloMixpanelTests/HelloMixpanelTests.m
  2. +4 −2 Mixpanel/Mixpanel.m
View
24 HelloMixpanel/HelloMixpanelTests/HelloMixpanelTests.m
@@ -141,13 +141,15 @@ - (void)testTrackProperties
@"yello", @"string",
[NSNumber numberWithInt:3], @"number",
[NSDate date], @"date",
+ @"override", @"$app_version",
nil];
[self.mixpanel track:@"Something Happened" properties:p];
STAssertTrue(self.mixpanel.eventsQueue.count == 1, @"event not queued");
NSDictionary *e = self.mixpanel.eventsQueue.lastObject;
STAssertEquals([e objectForKey:@"event"], @"Something Happened", @"incorrect event name");
p = [e objectForKey:@"properties"];
STAssertTrue(p.count == 17, @"incorrect number of properties");
+ STAssertEqualObjects([p objectForKey:@"$app_version"], @"override", @"reserved property override failed");
}
- (void)testTrackWithCustomDistinctIdAndToken
@@ -338,8 +340,8 @@ - (void)testPeopleIdentify
STAssertTrue(p.count == 4, @"incorrect people properties: %@", p);
STAssertEqualObjects([p objectForKey:@"p1"], @"a", @"custom people property not queued");
STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_device_model property");
- STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_version property");
- STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_app_version property");
+ STAssertNotNil([p objectForKey:@"$ios_version"], @"missing $ios_version property");
+ STAssertNotNil([p objectForKey:@"$ios_app_version"], @"missing $ios_app_version property");
[self.mixpanel.people identify:@"d1"];
STAssertEqualObjects(self.mixpanel.people.distinctId, @"d1", @"set people distinct id failed");
STAssertTrue(self.mixpanel.peopleQueue.count == 1, @"identify should move unidentified records to main queue");
@@ -377,8 +379,18 @@ - (void)testPeopleSet
STAssertTrue(p.count == 4, @"incorrect people properties: %@", p);
STAssertEqualObjects([p objectForKey:@"p1"], @"a", @"custom people property not queued");
STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_device_model property");
- STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_version property");
- STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_app_version property");
+ STAssertNotNil([p objectForKey:@"$ios_version"], @"missing $ios_version property");
+ STAssertNotNil([p objectForKey:@"$ios_app_version"], @"missing $ios_app_version property");
+}
+
+- (void)testPeopleSetReservedProperty
+{
+ [self.mixpanel.people identify:@"d1"];
+ NSDictionary *p = [NSDictionary dictionaryWithObject:@"override" forKey:@"$ios_app_version"];
+ [self.mixpanel.people set:p];
+ NSDictionary *r = self.mixpanel.peopleQueue.lastObject;
+ p = [r objectForKey:@"$set"];
+ STAssertEqualObjects([p objectForKey:@"$ios_app_version"], @"override", @"reserved property override failed");
}
- (void)testPeopleSetTo
@@ -394,8 +406,8 @@ - (void)testPeopleSetTo
STAssertTrue(p.count == 4, @"incorrect people properties: %@", p);
STAssertEqualObjects([p objectForKey:@"p1"], @"a", @"custom people property not queued");
STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_device_model property");
- STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_version property");
- STAssertNotNil([p objectForKey:@"$ios_device_model"], @"missing $ios_app_version property");
+ STAssertNotNil([p objectForKey:@"$ios_version"], @"missing $ios_version property");
+ STAssertNotNil([p objectForKey:@"$ios_app_version"], @"missing $ios_app_version property");
}
- (void)testPeopleIncrement
View
6 Mixpanel/Mixpanel.m
@@ -30,7 +30,7 @@
#import "Mixpanel.h"
#import "NSData+MPBase64.h"
-#define VERSION @"1.0.0"
+#define VERSION @"1.0.1"
#ifndef IFT_ETHER
#define IFT_ETHER 0x6 // ethernet CSMACD
@@ -1067,14 +1067,16 @@ - (void)addPeopleRecordToQueueWithAction:(NSString *)action andProperties:(NSDic
@synchronized(self) {
NSMutableDictionary *r = [NSMutableDictionary dictionary];
- NSMutableDictionary *p = [NSMutableDictionary dictionaryWithDictionary:properties];
+ NSMutableDictionary *p = [NSMutableDictionary dictionary];
[r setObject:self.mixpanel.apiToken forKey:@"$token"];
if ([action isEqualToString:@"$set"]) {
[p addEntriesFromDictionary:[MixpanelPeople deviceInfoProperties]];
}
+ [p addEntriesFromDictionary:properties];
+
[r setObject:[NSDictionary dictionaryWithDictionary:p] forKey:action];
if (self.distinctId) {

0 comments on commit 93a379e

Please sign in to comment.
Something went wrong with that request. Please try again.