Skip to content

Commit 8817903

Browse files
Add GetUserAttributes
1 parent 52d189b commit 8817903

File tree

10 files changed

+1126
-6
lines changed

10 files changed

+1126
-6
lines changed

.DS_Store

-6 KB
Binary file not shown.

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## Summary
2+
{provide a thorough description of the changes}
3+
4+
## Testing Plan
5+
{explain how this has been tested, and what additional testing should be done}
6+
7+
## Master Issue
8+
Closes https://go.mparticle.com/work/REPLACEME

.github/workflows/react-ci.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Continuous Integration
2+
3+
on:
4+
pull_request:
5+
push:
6+
7+
jobs:
8+
build:
9+
runs-on: macOS-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- uses: actions/setup-node@master
14+
- uses: c-hive/gha-yarn-cache@v1
15+
16+
- name: Install node modules
17+
run: |
18+
yarn install
19+
20+
- name: Run test
21+
run: |
22+
yarn test

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
## Build generated
66
build/
77
DerivedData/
8+
*.DS_Store
89

910
## Various settings
1011
*.pbxuser

.travis.yml

Lines changed: 0 additions & 5 deletions
This file was deleted.

android/src/main/java/com/mparticle/react/MParticleModule.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.mparticle.identity.TaskFailureListener;
3535
import com.mparticle.identity.TaskSuccessListener;
3636
import com.mparticle.internal.Logger;
37+
import com.mparticle.UserAttributeListener;
3738

3839
import java.util.ArrayList;
3940
import java.util.HashMap;
@@ -113,6 +114,21 @@ public void setUserAttributeArray(final String userId, final String key, final R
113114
}
114115
}
115116

117+
@ReactMethod
118+
public void getUserAttributes(final String userId, final Callback completion) {
119+
MParticleUser selectedUser = MParticle.getInstance().Identity().getUser(parseMpid(userId));
120+
if (selectedUser != null) {
121+
selectedUser.getUserAttributes(new UserAttributeListener() {
122+
@Override
123+
public void onUserAttributesReceived(Map<String, String> userAttributes, Map<String, List<String>> userAttributeLists, Long mpid) {
124+
completion.invoke(null, userAttributes);
125+
}
126+
});
127+
} else {
128+
completion.invoke();
129+
}
130+
}
131+
116132
@ReactMethod
117133
public void setUserTag(final String userId, final String tag) {
118134
MParticleUser selectedUser = MParticle.getInstance().Identity().getUser(parseMpid(userId));

ios/.DS_Store

-6 KB
Binary file not shown.

ios/RNMParticle/RNMParticle.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ + (void)load {
140140
values:values];
141141
}
142142

143+
RCT_EXPORT_METHOD(getUserAttributes:(NSString *)userId completion:(RCTResponseSenderBlock)completion)
144+
{
145+
MParticleUser *selectedUser = [[MParticleUser alloc] init];
146+
selectedUser.userId = [NSNumber numberWithLong:userId.longLongValue];
147+
completion(@[[NSNull null], [selectedUser userAttributes]]);
148+
}
149+
143150
RCT_EXPORT_METHOD(setUserTag:(NSString *)userId tag:(NSString *)tag)
144151
{
145152
MParticleUser *selectedUser = [[MParticleUser alloc] init];

js/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const ATTAuthStatus = {
6767
Restricted: 1,
6868
Denied: 2,
6969
Authorized: 3
70-
};
70+
}
7171

7272
// ******** Main API ********
7373

@@ -154,6 +154,15 @@ class User {
154154
NativeModules.MParticle.setUserAttributeArray(this.userId, key, value)
155155
}
156156

157+
getUserAttributes (completion) {
158+
NativeModules.MParticle.getUserAttributes((error, userAttributes) => {
159+
if (error) {
160+
console.log(error.stack)
161+
}
162+
completion(userAttributes)
163+
})
164+
}
165+
157166
setUserTag (value) {
158167
NativeModules.MParticle.setUserTag(this.userId, value)
159168
}

0 commit comments

Comments
 (0)