From b009e16315b0ca3bbd3b1ef9cb9bd1aad048b693 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 22 Jun 2017 00:30:12 +0200 Subject: [PATCH] Enable `logUserEventWithName` API for android --- .../reactlibrary/RNInstabugReactnativeModule.java | 15 +++++++++++++++ index.js | 8 ++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index d748ead..8a73ac3 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -830,6 +830,21 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Logs a user event that happens through the lifecycle of the application. + * Logged user events are going to be sent with each report, as well as at the end of a session. + * + * @param {string} name Event name. + */ + @ReactMethod + public void logUserEventWithName(String name) { + try { + mInstabug.logUserEvent(name); + } catch (java.lang.Exception exception) { + exception.printStackTrace(); + } + } + private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) { String keyInLowerCase = key.toLowerCase(); switch (keyInLowerCase) { diff --git a/index.js b/index.js index 2577e15..9c676fc 100644 --- a/index.js +++ b/index.js @@ -460,9 +460,7 @@ module.exports = { * @param {string} name Event name. */ logUserEventWithName: function (name) { - if (Platform.OS == 'ios') { - Instabug.logUserEventWithName(name); - } + Instabug.logUserEventWithName(name); }, /** @@ -472,9 +470,7 @@ module.exports = { * @param {Object} params An optional dictionary or parameters to be associated with the event. */ logUserEventWithNameAndParams: function (name, params) { - if (Platform.OS == 'ios') { - Instabug.logUserEventWithNameAndParams(name, params); - } + Instabug.logUserEventWithNameAndParams(name, params); }, /**