Skip to content

Commit 6a2d4c4

Browse files
Merge remote-tracking branch 'origin/dev' into feat/dev-into-network-spans
# Conflicts: # CHANGELOG.md # android/native.gradle # android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java # examples/default/ios/Podfile.lock # src/native/NativeInstabug.ts # test/mocks/mockInstabug.ts
2 parents 8fba8a5 + 461eee5 commit 6a2d4c4

File tree

18 files changed

+162
-48
lines changed

18 files changed

+162
-48
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v14.1.0...dev)
44

5+
### Changed
6+
7+
- Bump Instabug iOS SDK to v14.3.0 ([#1367](https://github.com/Instabug/Instabug-React-Native/pull/1367)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/14.3.0).
8+
59
### Added
610

711
- Add support for Network Spans in network logging module ([#1360](https://github.com/Instabug/Instabug-React-Native/pull/1360)).

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.1.0.6273967-SNAPSHOT'
2+
version: '14.3.0.6624149-SNAPSHOT'
33
]
44

55
dependencies {

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import com.instabug.library.invocation.util.InstabugVideoRecordingButtonPosition;
1818
import com.instabug.library.sessionreplay.model.SessionMetadata;
1919
import com.instabug.library.ui.onboarding.WelcomeMessage;
20+
import com.instabug.library.MaskingType;
2021

2122
import java.util.ArrayList;
2223
import java.util.HashMap;
@@ -60,6 +61,7 @@ static Map<String, Object> getAll() {
6061
putAll(locales);
6162
putAll(placeholders);
6263
putAll(launchType);
64+
putAll(autoMaskingTypes);
6365
}};
6466
}
6567

@@ -253,5 +255,10 @@ static Map<String, Object> getAll() {
253255
put(SessionMetadata.LaunchType.COLD,"cold");
254256
put(SessionMetadata.LaunchType.WARM,"warm" );
255257
}};
256-
258+
public static final ArgsMap<Integer> autoMaskingTypes = new ArgsMap<Integer>() {{
259+
put("labels", MaskingType.LABELS);
260+
put("textInputs", MaskingType.TEXT_INPUTS);
261+
put("media", MaskingType.MEDIA);
262+
put("none", MaskingType.MASK_NOTHING);
263+
}};
257264
}

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

Lines changed: 55 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ public void setEnabled(final boolean isEnabled) {
123123
@Override
124124
public void run() {
125125
try {
126-
if(isEnabled)
126+
if (isEnabled)
127127
Instabug.enable();
128128
else
129129
Instabug.disable();
@@ -136,10 +136,11 @@ public void run() {
136136

137137
/**
138138
* Initializes the SDK.
139-
* @param token The token that identifies the app. You can find it on your dashboard.
139+
*
140+
* @param token The token that identifies the app. You can find it on your dashboard.
140141
* @param invocationEventValues The events that invoke the SDK's UI.
141-
* @param logLevel The level of detail in logs that you want to print.
142-
* @param codePushVersion The Code Push version to be used for all reports.
142+
* @param logLevel The level of detail in logs that you want to print.
143+
* @param codePushVersion The Code Push version to be used for all reports.
143144
*/
144145
@ReactMethod
145146
public void init(
@@ -165,8 +166,8 @@ public void run() {
165166
.setInvocationEvents(invocationEvents)
166167
.setLogLevel(parsedLogLevel);
167168

168-
if(codePushVersion != null) {
169-
if(Instabug.isBuilt()) {
169+
if (codePushVersion != null) {
170+
if (Instabug.isBuilt()) {
170171
Instabug.setCodePushVersion(codePushVersion);
171172
} else {
172173
builder.setCodePushVersion(codePushVersion);
@@ -332,7 +333,7 @@ public void run() {
332333
*
333334
* @param userEmail User's default email
334335
* @param userName Username.
335-
* @param userId User's ID
336+
* @param userId User's ID
336337
*/
337338
@ReactMethod
338339
public void identifyUser(
@@ -752,15 +753,15 @@ public void addFileAttachmentWithDataToReport(String data, String fileName) {
752753

753754
private WritableMap convertFromHashMapToWriteableMap(HashMap hashMap) {
754755
WritableMap writableMap = new WritableNativeMap();
755-
for(int i = 0; i < hashMap.size(); i++) {
756+
for (int i = 0; i < hashMap.size(); i++) {
756757
Object key = hashMap.keySet().toArray()[i];
757758
Object value = hashMap.get(key);
758-
writableMap.putString((String) key,(String) value);
759+
writableMap.putString((String) key, (String) value);
759760
}
760761
return writableMap;
761762
}
762763

763-
private static JSONObject objectToJSONObject(Object object){
764+
private static JSONObject objectToJSONObject(Object object) {
764765
Object json = null;
765766
JSONObject jsonObject = null;
766767
try {
@@ -777,13 +778,12 @@ private static JSONObject objectToJSONObject(Object object){
777778
private WritableArray convertArrayListToWritableArray(List arrayList) {
778779
WritableArray writableArray = new WritableNativeArray();
779780

780-
for(int i = 0; i < arrayList.size(); i++) {
781+
for (int i = 0; i < arrayList.size(); i++) {
781782
Object object = arrayList.get(i);
782783

783-
if(object instanceof String) {
784+
if (object instanceof String) {
784785
writableArray.pushString((String) object);
785-
}
786-
else {
786+
} else {
787787
JSONObject jsonObject = objectToJSONObject(object);
788788
writableArray.pushMap((WritableMap) jsonObject);
789789
}
@@ -839,7 +839,7 @@ public void run() {
839839
* Shows the welcome message in a specific mode.
840840
*
841841
* @param welcomeMessageMode An enum to set the welcome message mode to
842-
* live, or beta.
842+
* live, or beta.
843843
*/
844844
@ReactMethod
845845
public void showWelcomeMessageWithMode(final String welcomeMessageMode) {
@@ -861,7 +861,7 @@ public void run() {
861861
* Sets the welcome message mode to live, beta or disabled.
862862
*
863863
* @param welcomeMessageMode An enum to set the welcome message mode to
864-
* live, beta or disabled.
864+
* live, beta or disabled.
865865
*/
866866
@ReactMethod
867867
public void setWelcomeMessageMode(final String welcomeMessageMode) {
@@ -996,7 +996,6 @@ public void run() {
996996
* Reports that the screen name been changed (Current View).
997997
*
998998
* @param screenName string containing the screen name
999-
*
1000999
*/
10011000
@ReactMethod
10021001
public void reportCurrentViewChange(final String screenName) {
@@ -1019,7 +1018,6 @@ public void run() {
10191018
* Reports that the screen has been changed (Repro Steps) the screen sent to this method will be the 'current view' on the dashboard
10201019
*
10211020
* @param screenName string containing the screen name
1022-
*
10231021
*/
10241022
@ReactMethod
10251023
public void reportScreenChange(final String screenName) {
@@ -1029,7 +1027,7 @@ public void run() {
10291027
try {
10301028
Method method = getMethod(Class.forName("com.instabug.library.Instabug"), "reportScreenChange", Bitmap.class, String.class);
10311029
if (method != null) {
1032-
method.invoke(null , null, screenName);
1030+
method.invoke(null, null, screenName);
10331031
}
10341032
} catch (Exception e) {
10351033
e.printStackTrace();
@@ -1123,7 +1121,7 @@ public void removeFeatureFlags(final ReadableArray featureFlags) {
11231121
@Override
11241122
public void run() {
11251123
try {
1126-
ArrayList<String> stringArray = ArrayUtil.parseReadableArrayOfStrings(featureFlags);
1124+
ArrayList<String> stringArray = ArrayUtil.parseReadableArrayOfStrings(featureFlags);
11271125
Instabug.removeFeatureFlag(stringArray);
11281126
} catch (Exception e) {
11291127
e.printStackTrace();
@@ -1159,11 +1157,12 @@ public void run() {
11591157
}
11601158
});
11611159
}
1160+
11621161
/**
11631162
* Register a listener for W3C flags value change
11641163
*/
11651164
@ReactMethod
1166-
public void registerW3CFlagsChangeListener(){
1165+
public void registerW3CFlagsChangeListener() {
11671166

11681167
MainThreadHandler.runOnMainThread(new Runnable() {
11691168
@Override
@@ -1180,8 +1179,7 @@ public void invoke(@NonNull CoreFeaturesState featuresState) {
11801179
sendEvent(Constants.IBG_ON_NEW_W3C_FLAGS_UPDATE_RECEIVED_CALLBACK, params);
11811180
}
11821181
});
1183-
}
1184-
catch (Exception e) {
1182+
} catch (Exception e) {
11851183
e.printStackTrace();
11861184
}
11871185

@@ -1192,18 +1190,17 @@ public void invoke(@NonNull CoreFeaturesState featuresState) {
11921190

11931191

11941192
/**
1195-
* Get first time Value of W3ExternalTraceID flag
1193+
* Get first time Value of W3ExternalTraceID flag
11961194
*/
11971195
@ReactMethod
1198-
public void isW3ExternalTraceIDEnabled(Promise promise){
1196+
public void isW3ExternalTraceIDEnabled(Promise promise) {
11991197

12001198
MainThreadHandler.runOnMainThread(new Runnable() {
12011199
@Override
12021200
public void run() {
12031201
try {
12041202
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_EXTERNAL_TRACE_ID));
1205-
}
1206-
catch (Exception e) {
1203+
} catch (Exception e) {
12071204
e.printStackTrace();
12081205
promise.resolve(false);
12091206
}
@@ -1215,18 +1212,17 @@ public void run() {
12151212

12161213

12171214
/**
1218-
* Get first time Value of W3ExternalGeneratedHeader flag
1215+
* Get first time Value of W3ExternalGeneratedHeader flag
12191216
*/
12201217
@ReactMethod
1221-
public void isW3ExternalGeneratedHeaderEnabled(Promise promise){
1218+
public void isW3ExternalGeneratedHeaderEnabled(Promise promise) {
12221219

12231220
MainThreadHandler.runOnMainThread(new Runnable() {
12241221
@Override
12251222
public void run() {
12261223
try {
12271224
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_ATTACHING_GENERATED_HEADER));
1228-
}
1229-
catch (Exception e) {
1225+
} catch (Exception e) {
12301226
e.printStackTrace();
12311227
promise.resolve(false);
12321228
}
@@ -1237,18 +1233,17 @@ public void run() {
12371233
}
12381234

12391235
/**
1240-
* Get first time Value of W3CaughtHeader flag
1236+
* Get first time Value of W3CaughtHeader flag
12411237
*/
12421238
@ReactMethod
1243-
public void isW3CaughtHeaderEnabled(Promise promise){
1239+
public void isW3CaughtHeaderEnabled(Promise promise) {
12441240

12451241
MainThreadHandler.runOnMainThread(new Runnable() {
12461242
@Override
12471243
public void run() {
12481244
try {
12491245
promise.resolve(InternalCore.INSTANCE._isFeatureEnabled(CoreFeature.W3C_ATTACHING_CAPTURED_HEADER));
1250-
}
1251-
catch (Exception e) {
1246+
} catch (Exception e) {
12521247
e.printStackTrace();
12531248
promise.resolve(false);
12541249
}
@@ -1278,6 +1273,31 @@ public Map<String, Object> getConstants() {
12781273
return constants;
12791274
}
12801275

1276+
/**
1277+
* Sets the auto mask screenshots types.
1278+
*
1279+
* @param autoMaskingTypes The masking type to be applied.
1280+
*/
1281+
@ReactMethod
1282+
public void enableAutoMasking(@NonNull ReadableArray autoMaskingTypes) {
1283+
MainThreadHandler.runOnMainThread(new Runnable() {
1284+
1285+
@Override
1286+
public void run() {
1287+
int[] autoMassingTypesArray = new int[autoMaskingTypes.size()];
1288+
for (int i = 0; i < autoMaskingTypes.size(); i++) {
1289+
String key = autoMaskingTypes.getString(i);
1290+
1291+
autoMassingTypesArray[i] = ArgsRegistry.autoMaskingTypes.get(key);
1292+
1293+
}
1294+
1295+
Instabug.setAutoMaskScreenshotsTypes(autoMassingTypesArray);
1296+
}
1297+
1298+
});
1299+
}
1300+
12811301
@ReactMethod
12821302
public void setOnFeaturesUpdatedListener() {
12831303
InternalCore.INSTANCE._setOnFeaturesUpdatedListener(new OnFeaturesUpdatedListener() {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import com.instabug.library.internal.module.InstabugLocale;
2626
import com.instabug.library.ui.onboarding.WelcomeMessage;
2727
import com.instabug.reactlibrary.utils.MainThreadHandler;
28+
import com.instabug.library.MaskingType;
2829

2930
import org.junit.After;
3031
import org.junit.Assert;
@@ -662,4 +663,17 @@ public void testW3CCaughtHeaderFlag(){
662663
boolean expected=internalAPM._isFeatureEnabled(CoreFeature.W3C_ATTACHING_CAPTURED_HEADER);
663664
verify(promise).resolve(expected);
664665
}
666+
667+
@Test
668+
public void testEnableAutoMasking(){
669+
670+
String maskLabel = "labels";
671+
String maskTextInputs = "textInputs";
672+
String maskMedia = "media";
673+
String maskNone = "none";
674+
675+
rnModule.enableAutoMasking(JavaOnlyArray.of(maskLabel, maskMedia, maskTextInputs,maskNone));
676+
677+
mockInstabug.verify(() -> Instabug.setAutoMaskScreenshotsTypes(MaskingType.LABELS,MaskingType.MEDIA,MaskingType.TEXT_INPUTS,MaskingType.MASK_NOTHING));
678+
}
665679
}

examples/default/ios/InstabugTests/InstabugSampleTests.m

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,5 +608,21 @@ - (void) testIsW3CaughtHeaderEnabled {
608608
OCMVerify([mock w3CaughtHeaderEnabled]);
609609
}
610610

611+
- (void)testEnableAutoMasking {
612+
id mock = OCMClassMock([Instabug class]);
613+
614+
NSArray *autoMaskingTypes = [NSArray arrayWithObjects:
615+
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionLabels],
616+
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionTextInputs],
617+
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionMedia],
618+
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionMaskNothing],
619+
nil];
620+
621+
OCMStub([mock setAutoMaskScreenshots:IBGAutoMaskScreenshotOptionLabels | IBGAutoMaskScreenshotOptionTextInputs | IBGAutoMaskScreenshotOptionMedia | IBGAutoMaskScreenshotOptionMaskNothing]);
622+
623+
[self.instabugBridge enableAutoMasking:autoMaskingTypes];
624+
625+
OCMVerify([mock setAutoMaskScreenshots:IBGAutoMaskScreenshotOptionLabels | IBGAutoMaskScreenshotOptionTextInputs | IBGAutoMaskScreenshotOptionMedia | IBGAutoMaskScreenshotOptionMaskNothing]);
626+
}
611627

612628
@end

0 commit comments

Comments
 (0)