diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 96b2bea..99b0ae3 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -540,7 +540,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { * @param value the value */ @ReactMethod - public static void setUserAttribute(String key, String value) { + public void setUserAttribute(String key, String value) { try { mInstabug.setUserAttribute(key, value); } catch (Exception e) { @@ -555,7 +555,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { * @return the desired user attribute */ @ReactMethod - public static String getUserAttribute(String key) { + public String getUserAttribute(String key) { try { return mInstabug.getUserAttribute(key); } catch (Exception e) { @@ -564,6 +564,21 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Removes user attribute if exists. + * + * @param key the attribute key as string + * @see #setUserAttribute(String, String) + */ + @ReactMethod + public void removeUserAttribute(String key) { + try { + mInstabug.removeUserAttribute(key); + } catch (Exception e) { + e.printStackTrace(); + } + } + private Locale getLocaleByKey(String instabugLocale) { String localeInLowerCase = instabugLocale.toLowerCase(); switch (localeInLowerCase) { diff --git a/index.js b/index.js index 4bd5bdc..a620b11 100644 --- a/index.js +++ b/index.js @@ -650,6 +650,20 @@ module.exports = { } }, + /** + * Removes user attribute if exists. + * + * @param key the attribute key as string + * @see #setUserAttribute(String, String) + */ + removeUserAttribute(key){ + if (!key || typeof key !== "string") + throw new TypeError("Invalid param, Expected String"); + if (Platform.OS === 'android') { + Instabug.removeUserAttribute(key); + } + }, + /** * The event used to invoke the feedback form * @readonly