Skip to content

Commit bb6d1ac

Browse files
Enable setPreSendingHandler API for android
1 parent 6e19ace commit bb6d1ac

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -901,6 +901,30 @@ public void run() {
901901
}
902902
}
903903

904+
/**
905+
* Sets a block of code to be executed before sending each report.
906+
* This block is executed in the background before sending each report. Could
907+
* be used for attaching logs and extra data to reports.
908+
*
909+
* @param {preSendingHandler} preSendingHandler - A callback that gets executed before
910+
* sending each bug
911+
* report.
912+
*/
913+
@ReactMethod
914+
public void setPreSendingHandler(final Callback preSendingHandler) {
915+
try {
916+
Runnable preSendingRunnable = new Runnable() {
917+
@Override
918+
public void run() {
919+
preSendingHandler.invoke();
920+
}
921+
};
922+
mInstabug.setPreSendingRunnable(preSendingRunnable);
923+
} catch (java.lang.Exception exception) {
924+
exception.printStackTrace();
925+
}
926+
}
927+
904928
private InstabugCustomTextPlaceHolder.Key getStringToKeyConstant(String key) {
905929
String keyInLowerCase = key.toLowerCase();
906930
switch (keyInLowerCase) {

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,10 @@ module.exports = {
109109
preSendingHandler
110110
);
111111

112-
Instabug.setPreSendingHandler(preSendingHandler);
113112
}
113+
114+
Instabug.setPreSendingHandler(preSendingHandler);
115+
114116
},
115117

116118
/**

0 commit comments

Comments
 (0)