Skip to content

Commit 010f89d

Browse files
committed
feat(android): enabling network logs auto masking
1 parent 61de773 commit 010f89d

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

android/native.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext.instabug = [
2-
version: '14.0.0'
2+
version: '14.0.0.6407912-SNAPSHOT'
33
]
44

55
dependencies {

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

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,26 @@ public void run() {
11481148
}
11491149
});
11501150
}
1151-
1151+
/**
1152+
* Enables or disables network logs sensitive information auto masking.
1153+
* @param isEnabled A boolean to enable/disable.
1154+
*/
1155+
@ReactMethod
1156+
public void setAutoMaskingEnabled(final boolean isEnabled) {
1157+
MainThreadHandler.runOnMainThread(new Runnable() {
1158+
@Override
1159+
public void run() {
1160+
try {
1161+
if(isEnabled)
1162+
Instabug.setNetworkAutoMaskingState(Feature.State.ENABLED);
1163+
else
1164+
Instabug.setNetworkAutoMaskingState(Feature.State.DISABLED);
1165+
} catch (Exception e) {
1166+
e.printStackTrace();
1167+
}
1168+
}
1169+
});
1170+
}
11521171
/**
11531172
* Map between the exported JS constant and the arg key in {@link ArgsRegistry}.
11541173
* The constant name and the arg key should match to be able to resolve the

android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -635,4 +635,23 @@ public void testWillRedirectToStore() {
635635
// then
636636
mockInstabug.verify(() -> Instabug.willRedirectToStore());
637637
}
638+
639+
@Test
640+
public void testEnableAutoMasking() {
641+
642+
rnModule.setAutoMaskingEnabled(true);
643+
644+
verify(Instabug.class, times(1));
645+
Instabug.setNetworkAutoMaskingState(Feature.State.ENABLED);
646+
}
647+
648+
@Test
649+
public void testDisableAutoMasking() {
650+
651+
rnModule.setAutoMaskingEnabled(false);
652+
653+
verify(Instabug.class, times(1));
654+
Instabug.setNetworkAutoMaskingState(Feature.State.DISABLED);
655+
}
656+
638657
}

0 commit comments

Comments
 (0)