Skip to content

Commit

Permalink
Merge pull request #73 from amplitude/identify_functions
Browse files Browse the repository at this point in the history
feat(identify): Identify functions
  • Loading branch information
yuhao900914 authored May 12, 2021
2 parents 9c7075d + 4ebd97b commit b86165a
Show file tree
Hide file tree
Showing 12 changed files with 1,500 additions and 5 deletions.
1,016 changes: 1,016 additions & 0 deletions Assets/Amplitude/Amplitude.cs

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Assets/Editor/AmplitudeDependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<repository>https://repo.maven.apache.org/maven2</repository>
</repositories>

<androidPackage spec="com.amplitude:android-sdk:2.30.1">
<androidPackage spec="com.amplitude:android-sdk:2.31.3">
<repositories>
<repository>https://maven.google.com</repository>
</repositories>
Expand Down
Binary file not shown.
Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ extern NSString *const AMP_OP_PREPEND;
extern NSString *const AMP_OP_SET;
extern NSString *const AMP_OP_SET_ONCE;
extern NSString *const AMP_OP_UNSET;
extern NSString *const AMP_OP_PREINSERT;
extern NSString *const AMP_OP_POSTINSERT;
extern NSString *const AMP_OP_REMOVE;

// Revenue
extern NSString *const AMP_REVENUE_PRODUCT_ID;
Expand Down
3 changes: 3 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@
NSString *const AMP_OP_SET = @"$set";
NSString *const AMP_OP_SET_ONCE = @"$setOnce";
NSString *const AMP_OP_UNSET = @"$unset";
NSString *const AMP_OP_PREINSERT = @"$preInsert";
NSString *const AMP_OP_POSTINSERT = @"$postInsert";
NSString *const AMP_OP_REMOVE = @"$remove";

NSString *const AMP_REVENUE_PRODUCT_ID = @"$productId";
NSString *const AMP_REVENUE_QUANTITY = @"$quantity";
Expand Down
29 changes: 29 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPIdentify.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,33 @@
*/
- (AMPIdentify *)unset:(NSString *)property;


/**
Pre-insert the value of a given user property. If the value already exists, it will do no operation.
@param property The user property key
@param value A value or values to set.
@returns the same [AMPIdentify](#) object, allowing you to chain multiple method calls together.
@see [User Properties and User Property Operations](https://github.com/amplitude/amplitude-ios#user-properties-and-user-property-operations)
*/
- (AMPIdentify *)preInsert:(NSString *)property value:(NSObject *)value;


/**
Post-insert the value of a given user property. If the value already exists, it will do no operation.
@param property The user property key
@param value A value or values to set.
@returns the same [AMPIdentify](#) object, allowing you to chain multiple method calls together.
@see [User Properties and User Property Operations](https://github.com/amplitude/amplitude-ios#user-properties-and-user-property-operations)
*/
- (AMPIdentify *)postInsert:(NSString *)property value:(NSObject *)value;


/**
Remove the value of a given user property, if the value exists. If the value doesn't exsit, it will do no opearation.
@param property The user property key
@param value A value or values to set.
@returns the same [AMPIdentify](#) object, allowing you to chain multiple method calls together.
@see [User Properties and User Property Operations](https://github.com/amplitude/amplitude-ios#user-properties-and-user-property-operations)
*/
- (AMPIdentify *)remove:(NSString *)property value:(NSObject *)value;
@end
15 changes: 15 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AMPIdentify.m
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,21 @@ - (AMPIdentify *)unset:(NSString *)property {
return self;
}

- (AMPIdentify *)preInsert:(NSString *)property value:(NSObject *)value {
[self addToUserProperties:AMP_OP_PREINSERT property:property value:value];
return self;
}

- (AMPIdentify *)postInsert:(NSString *)property value:(NSObject *)value {
[self addToUserProperties:AMP_OP_POSTINSERT property:property value:value];
return self;
}

- (AMPIdentify *)remove:(NSString *)property value:(NSObject *)value {
[self addToUserProperties:AMP_OP_REMOVE property:property value:value];
return self;
}

- (void)addToUserProperties:(NSString *)operation property:(NSString *)property value:(NSObject *)value {
if (value == nil) {
AMPLITUDE_LOG(@"Attempting to perform operation '%@' with nil value for property '%@', ignoring", operation, property);
Expand Down
416 changes: 416 additions & 0 deletions Assets/Plugins/iOS/Amplitude/AmplitudeCWrapper.m

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion Assets/Scripts/AmplitudeDemo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ void Start() {
amplitude.unsetUserProperty("bool");
amplitude.setUserProperty("string", "this is a test");
amplitude.setUserProperty("stringArray", new string[]{"replace", "existing", "strings"});
amplitude.appendUserProperty("stringArray", new string[]{ "append", "more", "strings" });
amplitude.appendUserProperty("stringArray", new string[]{"append", "more", "strings"});
amplitude.prependUserProperty("longArray", new long[]{1, 2, 3});
amplitude.preInsertUserProperty("longArray", new long[]{1111,2222,3333});
amplitude.postInsertUserProperty("longArray", new long[]{4444,5555,6666});
amplitude.removeUserProperty("longArray", new long[]{ 1111,2222,3333,4444,5555,6666});
amplitude.setUserProperty("floatArray", new float[]{123.45f, 678.9f});
amplitude.setUserProperty("doubleArray", new double[]{123.45, 678.9});

Expand Down Expand Up @@ -75,6 +79,15 @@ void Start() {
amplitude.appendUserProperty("intList", new int[]{7, 8, 9});
amplitude.appendUserProperty("stringList", stringList);

amplitude.prependUserProperty("prependStringValue", "prependStr1");
amplitude.prependUserProperty("prependStringValue", "prependStr2");

amplitude.preInsertUserProperty("preInsertBooleanValue", true);
amplitude.preInsertUserProperty("preInsertBooleanValue", false);

amplitude.postInsertUserProperty("postInsertintList", new int[]{1, 2, 3});
amplitude.postInsertUserProperty("postInsertintList", new int[]{4, 5, 6});

amplitude.logEvent("this is a test");
Debug.Log(amplitude.getDeviceId());
amplitude.uploadEvents();
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/AndroidResolverDependencies.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<dependencies>
<packages>
<package>com.amplitude:android-sdk:2.30.1</package>
<package>com.amplitude:android-sdk:2.31.3</package>
<package>com.squareup.okhttp3:okhttp:4.2.2</package>
</packages>
<files>
<file>Assets/Plugins/Android/com.amplitude.android-sdk-2.30.1.aar</file>
<file>Assets/Plugins/Android/com.amplitude.android-sdk-2.31.3.aar</file>
<file>Assets/Plugins/Android/com.squareup.okhttp3.okhttp-4.2.2.jar</file>
<file>Assets/Plugins/Android/com.squareup.okio.okio-2.2.2.jar</file>
<file>Assets/Plugins/Android/org.jetbrains.annotations-13.0.jar</file>
Expand Down

0 comments on commit b86165a

Please sign in to comment.