Skip to content

Commit

Permalink
Renamed all People methods to add User prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
Kasra Kyanzadeh committed Jul 5, 2012
1 parent 29790ec commit b09215a
Show file tree
Hide file tree
Showing 10 changed files with 569 additions and 831 deletions.
877 changes: 378 additions & 499 deletions Docs/API/Classes/MixpanelAPI/index.html

Large diffs are not rendered by default.

141 changes: 48 additions & 93 deletions Docs/API/Classes/MixpanelAPI/toc.html

Large diffs are not rendered by default.

92 changes: 31 additions & 61 deletions Docs/API/Protocols/MixpanelDelegate/toc.html

Large diffs are not rendered by default.

77 changes: 30 additions & 47 deletions Docs/API/index.html

Large diffs are not rendered by default.

136 changes: 42 additions & 94 deletions Docs/API/toc.html

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions MPLib/MixpanelAPI.h
Expand Up @@ -276,7 +276,7 @@ static const NSUInteger kMPUploadInterval = 30;
- (void)track:(NSString*) event properties:(NSDictionary*) properties;

/*!
@method setProperties:
@method setUserProperties:
@abstract Set properties on the user.
@discussion The properties will be set on the current user. Note that if the user's $distinct_id is not set
an exception will be raised. The $distinct_id is set automatically by calling <code>initWithToken:</code>
Expand All @@ -285,21 +285,21 @@ static const NSUInteger kMPUploadInterval = 30;
NSString, NSNumber, NSArray, NSDate, or NSNull objects. You can over-ride the default $token and $distinct_id
on specific requests by creating entries in this dictionary with the corresponding keys.
*/
- (void)setProperties:(NSDictionary*)properties;
- (void)setUserProperties:(NSDictionary*)properties;

/*!
@method setProperty:forKey:
@method setUserProperty:forKey:
@abstract Set a single property on the user.
@discussion The property will be set on the current user. Note that if the user's $distinct_id is not set
an exception will be raised. The $distinct_id is set automatically by calling <code>initWithToken:</code>
or <code>sharedAPIWithToken:</code> and can be manually set by calling <code>identifyUser:</code>.
@param property The value of the property to set. Should be NSString, NSNumber, NSArray, NSDate, or NSNull.
@param key The key of the property to set.
*/
- (void)setProperty:(id)property forKey:(NSString*)key;
- (void)setUserProperty:(id)property forKey:(NSString*)key;

/*!
@method incrementProperties:
@method incrementUserProperties:
@abstract Increment the given numeric properties by the given values.
@discussion Increment the given numeric properties by the given values. Note that if the user's $distinct_id is not set
an exception will be raised. The $distinct_id is set automatically by calling <code>initWithToken:</code>
Expand All @@ -309,7 +309,7 @@ static const NSUInteger kMPUploadInterval = 30;
You can over-ride the default $token and $distinct_id on specific requests by creating entries in this
dictionary with the corresponding keys.
*/
- (void)incrementProperties:(NSDictionary*)properties;
- (void)incrementUserProperties:(NSDictionary*)properties;

/*!
@method incrementPropertyWithKey:
Expand All @@ -319,7 +319,7 @@ static const NSUInteger kMPUploadInterval = 30;
or <code>sharedAPIWithToken:</code> and can be manually set by calling <code>identifyUser:</code>.
@param key The key of the property to increment.
*/
- (void)incrementPropertyWithKey:(NSString*)key;
- (void)incrementUserPropertyWithKey:(NSString*)key;

/*!
@method incrementPropertyWithKey:byNumber:
Expand All @@ -330,29 +330,29 @@ static const NSUInteger kMPUploadInterval = 30;
@param key The key of the property to increment.
@param amount The amount to increment by.
*/
- (void)incrementPropertyWithKey:(NSString*)key byNumber:(NSNumber*)amount;
- (void)incrementUserPropertyWithKey:(NSString*)key byNumber:(NSNumber*)amount;

/*!
@method incrementPropertyWithKey:byInt:
@method incrementUserPropertyWithKey:byInt:
@abstract Increment the given numeric property by the given int.
@discussion Note that if the user's $distinct_id is not set
an exception will be raised. The $distinct_id is set automatically by calling <code>initWithToken:</code>
or <code>sharedAPIWithToken:</code> and can be manually set by calling <code>identifyUser:</code>.
@param key The key of the property to increment.
@param amount The amount to increment by.
*/
- (void)incrementPropertyWithKey:(NSString*)key byInt:(int)amount;
- (void)incrementUserPropertyWithKey:(NSString*)key byInt:(int)amount;

/*!
@method append:toPropertyWithKey:
@method append:toUserPropertyWithKey:
@abstract Append an item to a list property.
@discussion Append an item to a list property. Note that if the user's $distinct_id is not set
an exception will be raised. The $distinct_id is set automatically by calling <code>initWithToken:</code>
or <code>sharedAPIWithToken:</code> and can be manually set by calling <code>identifyUser:</code>.
@param item The item to append. Should be NSString, NSNumber, NSArray, NSDate, or NSNull object
@param key The key of the list property to append to.
*/
- (void)append:(id)item toPropertyWithKey:(NSString*)key;
- (void)append:(id)item toUserPropertyWithKey:(NSString*)key;

/*!
@method deleteUser:
Expand Down
22 changes: 11 additions & 11 deletions MPLib/MixpanelAPI.m
Expand Up @@ -355,31 +355,31 @@ - (void)addPersonToQueueWithAction:(NSString*)action andProperties:(NSDictionary

}

- (void)setProperties:(NSDictionary*)properties {
- (void)setUserProperties:(NSDictionary*)properties {
[self addPersonToQueueWithAction:@"$set" andProperties:properties];
}

- (void)setProperty:(id)property forKey:(NSString*)key {
[self setProperties:[NSDictionary dictionaryWithObject:property forKey:key]];
- (void)setUserProperty:(id)property forKey:(NSString*)key {
[self setUserProperties:[NSDictionary dictionaryWithObject:property forKey:key]];
}

- (void)incrementProperties:(NSDictionary*)properties {
- (void)incrementUserProperties:(NSDictionary*)properties {
[self addPersonToQueueWithAction:@"$add" andProperties:properties];
}

- (void)incrementPropertyWithKey:(NSString*)key {
[self incrementProperties:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:1] forKey:key]];
- (void)incrementUserPropertyWithKey:(NSString*)key {
[self incrementUserProperties:[NSDictionary dictionaryWithObject:[NSNumber numberWithInt:1] forKey:key]];
}

- (void)incrementPropertyWithKey:(NSString*)key byNumber:(NSNumber*)amount {
[self incrementProperties:[NSDictionary dictionaryWithObject:amount forKey:key]];
- (void)incrementUserPropertyWithKey:(NSString*)key byNumber:(NSNumber*)amount {
[self incrementUserProperties:[NSDictionary dictionaryWithObject:amount forKey:key]];
}

- (void)incrementPropertyWithKey:(NSString*)key byInt:(int)amount {
[self incrementPropertyWithKey:key byNumber:[NSNumber numberWithInt:amount]];
- (void)incrementUserPropertyWithKey:(NSString*)key byInt:(int)amount {
[self incrementUserPropertyWithKey:key byNumber:[NSNumber numberWithInt:amount]];
}

- (void)append:(id)item toPropertyWithKey:(NSString*)key {
- (void)append:(id)item toUserPropertyWithKey:(NSString*)key {
[self addPersonToQueueWithAction:@"$append" andProperties:[NSDictionary dictionaryWithObject:item forKey:key]];
}

Expand Down
Expand Up @@ -22,7 +22,7 @@ - (IBAction) registerEvent:(id)sender {
- (IBAction) registerPerson:(id)sender {
MixpanelAPI *mixpanel = [MixpanelAPI sharedAPI];

[mixpanel setProperties:[NSDictionary dictionaryWithObjectsAndKeys:
[mixpanel setUserProperties:[NSDictionary dictionaryWithObjectsAndKeys:
[genderControl titleForSegmentAtIndex:genderControl.selectedSegmentIndex], @"gender",
[weaponControl titleForSegmentAtIndex:weaponControl.selectedSegmentIndex], @"weapon",
nil]];
Expand Down
26 changes: 13 additions & 13 deletions MixpanelEventSample/Unit Tests/Unit_Tests.m
Expand Up @@ -45,7 +45,7 @@ - (void)tearDown {

- (void)testFlush {
[mp track:@"Event"];
[mp setProperty:@"John" forKey:@"name"];
[mp setUserProperty:@"John" forKey:@"name"];

STAssertTrue([mp.eventQueue count] == 1, @"track: failed, not in queue");
STAssertTrue([mp.peopleQueue count] == 1, @"setProperty:forKey: failed, not in queue");
Expand All @@ -58,18 +58,18 @@ - (void)testFlush {
}

- (void)testMultipleSet {
[mp setProperty:@"1" forKey:@"1"];
[mp setProperty:@"2" forKey:@"2"];
[mp incrementPropertyWithKey:@"3"];
[mp setProperties:[NSDictionary dictionaryWithObject:@"4" forKey:@"4"]];
[mp append:@"5" toPropertyWithKey:@"5"];
[mp setUserProperty:@"1" forKey:@"1"];
[mp setUserProperty:@"2" forKey:@"2"];
[mp incrementUserPropertyWithKey:@"3"];
[mp setUserProperties:[NSDictionary dictionaryWithObject:@"4" forKey:@"4"]];
[mp append:@"5" toUserPropertyWithKey:@"5"];

STAssertTrue(mp.peopleQueue.count == 5, @"Not all sets recorded");
}

- (void)testArchive {
[mp track:@"Event"];
[mp setProperty:@"John" forKey:@"name"];
[mp setUserProperty:@"John" forKey:@"name"];

[mp archiveData];

Expand Down Expand Up @@ -99,7 +99,7 @@ - (void)testSetPropertyFormat {
NSString *value = @"John Smith";
NSString *key = @"name";

[mp setProperty:value forKey:key];
[mp setUserProperty:value forKey:key];

STAssertTrue([mp.peopleQueue count] == 1, @"setProperty:forKey: failed. Set not in queue.");

Expand All @@ -115,10 +115,10 @@ - (void)testSetPropertyFormat {
- (void)testIncrementPropertyFormat {
NSString *key = @"numeric";

[mp incrementPropertyWithKey:key];
[mp incrementPropertyWithKey:key byInt:2];
[mp incrementPropertyWithKey:key byNumber:[NSNumber numberWithInt:3]];
[mp incrementProperties:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:4], key, nil]];
[mp incrementUserPropertyWithKey:key];
[mp incrementUserPropertyWithKey:key byInt:2];
[mp incrementUserPropertyWithKey:key byNumber:[NSNumber numberWithInt:3]];
[mp incrementUserProperties:[NSDictionary dictionaryWithObjectsAndKeys: [NSNumber numberWithInt:4], key, nil]];

STAssertEquals([NSNumber numberWithInt:1], [[[mp.peopleQueue objectAtIndex:0] objectForKey:@"$add"] objectForKey:key], @"incrementPropertyWithKey: failed.");
STAssertEquals([NSNumber numberWithInt:2], [[[mp.peopleQueue objectAtIndex:1] objectForKey:@"$add"] objectForKey:key], @"incrementPropertyWithKey:byInt: failed.");
Expand All @@ -130,7 +130,7 @@ - (void)testAppendPropertyFormat {
NSString *key = @"property_key";
NSString *value = @"to_append";

[mp append:value toPropertyWithKey:key];
[mp append:value toUserPropertyWithKey:key];

STAssertEquals(value, [[[mp.peopleQueue objectAtIndex:0] objectForKey:@"$append"] objectForKey:key], @"append:toPropertyWithKey: failed.");
}
Expand Down
3 changes: 3 additions & 0 deletions readme.mdown
@@ -1,5 +1,8 @@
# Release notes #

### v1.2 - July 5, 2012 ###
- Renamed all People functions to add User prefix

### v1.1.1 - July 3, 2012 ###
- Fixed a bug that affected setProperties: and setProperty:forKey:

Expand Down

0 comments on commit b09215a

Please sign in to comment.