-
Notifications
You must be signed in to change notification settings - Fork 192
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
User property operations #47
Merged
Merged
Changes from 8 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
540a8e2
added identify class and test, converted setUserProperties
djih 2650b87
added identifys table to db
djih b74df54
use identify queue in log event, merge events and identifys
djih 6babae5
cleaned up and begin updating readme
djih 7cf5afc
update readme, truncate strings
djih 5d6fbfd
update from master, added backwards compatabilty test
djih e36deea
cleanup
djih 1bf63a2
update from master
djih 4950cf7
added create identifys table sql string
djih c1df9ae
update from master
djih File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// | ||
// AMPIdentify.h | ||
// Amplitude | ||
// | ||
// Created by Daniel Jih on 10/5/15. | ||
// Copyright © 2015 Amplitude. All rights reserved. | ||
// | ||
|
||
@interface AMPIdentify : NSObject | ||
|
||
@property (nonatomic, strong, readonly) NSMutableDictionary *userPropertyOperations; | ||
|
||
+ (instancetype)identify; | ||
- (AMPIdentify*)add:(NSString*) property value:(NSObject*) value; | ||
- (AMPIdentify*)set:(NSString*) property value:(NSObject*) value; | ||
- (AMPIdentify*)setOnce:(NSString*) property value:(NSObject*) value; | ||
- (AMPIdentify*)unset:(NSString*) property; | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// | ||
// AMPIdentify.m | ||
// Amplitude | ||
// | ||
// Created by Daniel Jih on 10/5/15. | ||
// Copyright © 2015 Amplitude. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import "AMPIdentify.h" | ||
#import "AMPARCMacros.h" | ||
#import "AMPConstants.h" | ||
|
||
@interface AMPIdentify() | ||
@end | ||
|
||
@implementation AMPIdentify | ||
{ | ||
NSMutableSet *_userProperties; | ||
} | ||
|
||
- (id)init | ||
{ | ||
if (self = [super init]) { | ||
_userPropertyOperations = [[NSMutableDictionary alloc] init]; | ||
_userProperties = [[NSMutableSet alloc] init]; | ||
} | ||
return self; | ||
} | ||
|
||
+ (instancetype)identify | ||
{ | ||
return SAFE_ARC_AUTORELEASE([[self alloc] init]); | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
SAFE_ARC_RELEASE(_userPropertyOperations); | ||
SAFE_ARC_RELEASE(_userProperties); | ||
SAFE_ARC_SUPER_DEALLOC(); | ||
} | ||
|
||
- (AMPIdentify*)add:(NSString*) property value:(NSObject*) value | ||
{ | ||
if ([value isKindOfClass:[NSNumber class]] || [value isKindOfClass:[NSString class]]) { | ||
[self addToUserProperties:AMP_OP_ADD property:property value:value]; | ||
} else { | ||
NSLog(@"Unsupported value type for ADD operation, expecting NSNumber or NSString"); | ||
} | ||
return self; | ||
} | ||
|
||
- (AMPIdentify*)set:(NSString*) property value:(NSObject*) value | ||
{ | ||
[self addToUserProperties:AMP_OP_SET property:property value:value]; | ||
return self; | ||
} | ||
|
||
- (AMPIdentify*)setOnce:(NSString*) property value:(NSObject*) value | ||
{ | ||
[self addToUserProperties:AMP_OP_SET_ONCE property:property value:value]; | ||
return self; | ||
} | ||
|
||
- (AMPIdentify*)unset:(NSString*) property | ||
{ | ||
[self addToUserProperties:AMP_OP_UNSET property:property value:@"-"]; | ||
return self; | ||
} | ||
|
||
- (void)addToUserProperties:(NSString*)operation property:(NSString*) property value:(NSObject*) value | ||
{ | ||
// check if property already used in a previous operation | ||
if ([_userProperties containsObject:property]) { | ||
NSLog(@"Already used property '%@' in previous operation, ignoring for operation '%@'", property, operation); | ||
return; | ||
} | ||
|
||
NSMutableDictionary *operations = [_userPropertyOperations objectForKey:operation]; | ||
if (operations == nil) { | ||
operations = [NSMutableDictionary dictionary]; | ||
[_userPropertyOperations setObject:operations forKey:operation]; | ||
} | ||
[operations setObject:value forKey:property]; | ||
[_userProperties addObject:property]; | ||
} | ||
|
||
@end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems a little risky to reuse CREATE_EVENT_TABLE here