Skip to content

Commit cf81303

Browse files
committed
✨ Add getAllUserAttributes api for Android.
1 parent 9267e30 commit cf81303

File tree

2 files changed

+21
-2
lines changed

2 files changed

+21
-2
lines changed

src/android/IBGPlugin.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import android.content.Intent;
44
import android.graphics.Color;
55
import android.net.Uri;
6+
import android.util.Log;
67

78
import com.instabug.library.Instabug;
89
import com.instabug.library.invocation.InstabugInvocationEvent;
@@ -18,6 +19,7 @@
1819

1920
import java.io.File;
2021
import java.lang.Integer;
22+
import java.util.HashMap;
2123

2224
/**
2325
* This plugin initializes Instabug.
@@ -139,7 +141,10 @@ public boolean execute(final String action, JSONArray args, final CallbackContex
139141
} else if ("logOut".equals(action)) {
140142
logOut(callbackContext);
141143

142-
} else {
144+
} else if ("getAllUserAttributes".equals(action)) {
145+
getAllUserAttributes(callbackContext);
146+
147+
}else {
143148
// Method not found.
144149
return false;
145150
}
@@ -533,6 +538,16 @@ private void removeUserAttribute(final CallbackContext callbackContext, String k
533538
}
534539
}
535540

541+
private void getAllUserAttributes(final CallbackContext callbackContext) {
542+
try {
543+
HashMap userAttributes = Instabug.getAllUserAttributes();
544+
JSONObject jsonUserAttributes = new JSONObject(userAttributes);
545+
callbackContext.success(jsonUserAttributes);
546+
} catch (IllegalStateException e) {
547+
callbackContext.error(errorMsg);
548+
}
549+
}
550+
536551
/**
537552
* Adds intent extras for all options passed to activate().
538553
*/

www/instabug.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,15 @@ Instabug.removeUserAttribute = function (key, success, error) {
127127
exec(success, error, 'IBGPlugin', 'removeUserAttribute', [key]);
128128
};
129129

130+
Instabug.getAllUserAttributes = function (success, error) {
131+
exec(success, error, 'IBGPlugin', 'getAllUserAttributes', []);
132+
};
133+
130134
Instabug.identifyUserWithEmail = function (email, name, success, error) {
131135
exec(success, error, 'IBGPlugin', 'identifyUserWithEmail', [email, name]);
132136
};
133137

134-
Instabug.logOut = function (email, name, success, error) {
138+
Instabug.logOut = function (success, error) {
135139
exec(success, error, 'IBGPlugin', 'logOut', []);
136140
};
137141

0 commit comments

Comments
 (0)