diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 1d1dee6..47c8bff 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -533,6 +533,21 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Sets user attribute to overwrite it's value or create a new one if it doesn't exist. + * + * @param key the attribute + * @param value the value + */ + @ReactMethod + public static void setUserAttribute(String key, String value) { + try { + mInstabug.setUserAttribute(key, value); + } 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 8e0cf52..baf1aeb 100644 --- a/index.js +++ b/index.js @@ -622,6 +622,19 @@ module.exports = { } }, + /** + * Sets user attribute to overwrite it's value or create a new one if it doesn't exist. + * + * @param key the attribute + * @param value the value + */ + setUserAttribute(key, value){ + if (!key || !value)return; + if (Platform.OS === 'android') { + Instabug.setUserAttribute(key, value); + } + }, + /** * The event used to invoke the feedback form * @readonly