From 4d61214abc3b75985d3ebd4cd875504d92607bfa Mon Sep 17 00:00:00 2001 From: Hossam Hassan Date: Fri, 3 Feb 2017 20:33:00 +0200 Subject: [PATCH] Add mapping for getUserAttribute API --- .../RNInstabugReactnativeModule.java | 16 ++++++++++++++++ index.js | 13 +++++++++++++ 2 files changed, 29 insertions(+) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 47c8bff..96b2bea 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -548,6 +548,22 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Gets specific user attribute. + * + * @param key the attribute key as string + * @return the desired user attribute + */ + @ReactMethod + public static String getUserAttribute(String key) { + try { + return mInstabug.getUserAttribute(key); + } catch (Exception e) { + e.printStackTrace(); + return null; + } + } + private Locale getLocaleByKey(String instabugLocale) { String localeInLowerCase = instabugLocale.toLowerCase(); switch (localeInLowerCase) { diff --git a/index.js b/index.js index baf1aeb..d8045af 100644 --- a/index.js +++ b/index.js @@ -635,6 +635,19 @@ module.exports = { } }, + /** + * Gets specific user attribute. + * + * @param key the attribute key as string + * @return the desired user attribute + */ + getUserAttribute(key){ + if (!key) throw new TypeError("Invalid param type, Expected String"); + if (Platform.OS === 'android') { + return Instabug.getUserAttribute(key); + } + }, + /** * The event used to invoke the feedback form * @readonly