Skip to content

Commit 8033bb4

Browse files
Release: v15.0.2 (#1428)
* fix: SDK initialized async (#1427) * fix: SDK initialized async * fix: remove logs * fix: remove unnecessary async & await from Instabug.spec.ts * chore: add change log --------- Co-authored-by: ahmed alaa <[email protected]> * feat: support ignore flag secure on android. (#1412) * feat: support ignore flag secure on android. --------- Co-authored-by: Andrew Amin <[email protected]> * Release: v15.0.2 * Release: v15.0.2 --------- Co-authored-by: Andrew Amin <[email protected]>
1 parent 5c8f2cf commit 8033bb4

File tree

16 files changed

+153
-113
lines changed

16 files changed

+153
-113
lines changed

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
# Changelog
22

3+
## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v15.1.0...dev)
4+
5+
### Added
6+
7+
- Add support for ignoreFlagSecure to bypass SDK screenshot security protocols on Android. ([#1394](https://github.com/Instabug/Instabug-React-Native/pull/1394))
8+
9+
### Fixed
10+
11+
- async initialization. ([#1427](https://github.com/Instabug/Instabug-React-Native/pull/1427))
12+
313
## [15.0.1](https://github.com/Instabug/Instabug-React-Native/compare/v14.3.0...v15.0.1)
414

515
### Added

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

Lines changed: 38 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@ public class RNInstabug {
1919

2020
private static RNInstabug instance;
2121

22-
private RNInstabug() {}
22+
private RNInstabug() {
23+
}
2324

2425

2526
public static RNInstabug getInstance() {
@@ -36,14 +37,13 @@ public static RNInstabug getInstance() {
3637
/**
3738
* Initializes the SDK on the native side, which is useful for capturing startup issues specific to the native part of the app.
3839
*
39-
* @param application The application context.
40+
* @param application The application context.
4041
* @param applicationToken The app's identifying token, available on your dashboard.
41-
* @param logLevel The level of detail in logs that you want to print.
42-
* <p>Pick one of the log levels described in {@link LogLevel}.
43-
* default logLevel is {@link LogLevel#ERROR}</p>
44-
* @param InvocationEvent The events that trigger the SDK's user interface.
45-
* Choose from the available events listed in {@link InstabugInvocationEvent}.
46-
*
42+
* @param logLevel The level of detail in logs that you want to print.
43+
* <p>Pick one of the log levels described in {@link LogLevel}.
44+
* default logLevel is {@link LogLevel#ERROR}</p>
45+
* @param InvocationEvent The events that trigger the SDK's user interface.
46+
* Choose from the available events listed in {@link InstabugInvocationEvent}.
4747
* @example <p>Here's an example usage: </p>
4848
* <blockquote><pre>
4949
* RNInstabug.getInstance().init(
@@ -59,17 +59,24 @@ public void init(
5959
@NonNull Application application,
6060
@NonNull String applicationToken,
6161
int logLevel,
62+
Boolean ignoreSecureFlag,
6263
@NonNull InstabugInvocationEvent... InvocationEvent
63-
) {
64+
) {
6465
try {
6566

6667
setBaseUrlForDeprecationLogs();
6768
setCurrentPlatform();
6869

69-
new Instabug.Builder(application, applicationToken)
70+
Instabug.Builder builder = new Instabug.Builder(application, applicationToken)
7071
.setInvocationEvents(InvocationEvent)
71-
.setSdkDebugLogsLevel(logLevel)
72-
.build();
72+
.setSdkDebugLogsLevel(logLevel);
73+
74+
if (ignoreSecureFlag != null) {
75+
builder.ignoreFlagSecure(ignoreSecureFlag);
76+
}
77+
78+
builder.build();
79+
7380

7481
// Temporarily disabling APM hot launches
7582
APM.setHotAppLaunchEnabled(false);
@@ -80,15 +87,13 @@ public void init(
8087
}
8188

8289

83-
8490
/**
8591
* Initializes the SDK on the native side, which is useful for capturing startup issues specific to the native part of the app.
8692
*
87-
* @param application The application context.
93+
* @param application The application context.
8894
* @param applicationToken The app's identifying token, available on your dashboard.
89-
* @param invocationEvent The events that trigger the SDK's user interface.
90-
* Choose from the available events listed in {@link InstabugInvocationEvent}.
91-
*
95+
* @param invocationEvent The events that trigger the SDK's user interface.
96+
* Choose from the available events listed in {@link InstabugInvocationEvent}.
9297
* @example <p>Here's an example usage: </p>
9398
* <blockquote><pre>
9499
* RNInstabug.getInstance().init(
@@ -104,7 +109,7 @@ public void init(
104109
@NonNull String applicationToken,
105110
@NonNull InstabugInvocationEvent... invocationEvent
106111
) {
107-
init(application, applicationToken, LogLevel.ERROR, invocationEvent);
112+
init(application, applicationToken, LogLevel.ERROR,null, invocationEvent);
108113
}
109114

110115
@VisibleForTesting
@@ -160,6 +165,7 @@ public static class Builder {
160165
* The events that trigger the SDK's user interface.
161166
*/
162167
private InstabugInvocationEvent[] invocationEvents;
168+
private Boolean ignoreFlagSecure;
163169

164170

165171
/**
@@ -210,6 +216,16 @@ public Builder setCodePushVersion(String codePushVersion) {
210216
return this;
211217
}
212218

219+
/**
220+
* Sets flag to override SDK screenshot security behavior.
221+
*
222+
* @param ignoreFlagSecure flag to override SDK screenshot security behavior.
223+
*/
224+
public Builder ignoreFlagSecure(boolean ignoreFlagSecure) {
225+
this.ignoreFlagSecure = ignoreFlagSecure;
226+
return this;
227+
}
228+
213229
/**
214230
* Sets the invocation triggering events for the SDK's user interface
215231
*
@@ -237,6 +253,10 @@ public void build() {
237253
instabugBuilder.setCodePushVersion(codePushVersion);
238254
}
239255

256+
if (ignoreFlagSecure != null) {
257+
instabugBuilder.ignoreFlagSecure(ignoreFlagSecure);
258+
}
259+
240260
instabugBuilder.build();
241261

242262
// Temporarily disabling APM hot launches

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,8 @@ public void init(
148148
final ReadableArray invocationEventValues,
149149
final String logLevel,
150150
final boolean useNativeNetworkInterception,
151-
@Nullable final String codePushVersion
151+
@Nullable final String codePushVersion,
152+
final ReadableMap map
152153
) {
153154
MainThreadHandler.runOnMainThread(new Runnable() {
154155
@Override
@@ -166,6 +167,10 @@ public void run() {
166167
.setInvocationEvents(invocationEvents)
167168
.setLogLevel(parsedLogLevel);
168169

170+
if (map!=null&&map.hasKey("ignoreAndroidSecureFlag")) {
171+
builder.ignoreFlagSecure(map.getBoolean("ignoreAndroidSecureFlag"));
172+
}
173+
169174
if (codePushVersion != null) {
170175
if (Instabug.isBuilt()) {
171176
Instabug.setCodePushVersion(codePushVersion);

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static com.instabug.reactlibrary.util.GlobalMocks.reflected;
55
import static org.junit.Assert.assertEquals;
66
import static org.mockito.ArgumentMatchers.any;
7+
import static org.mockito.ArgumentMatchers.anyBoolean;
78
import static org.mockito.ArgumentMatchers.anyInt;
89
import static org.mockito.Mockito.mock;
910
import static org.mockito.Mockito.mockConstruction;
@@ -62,18 +63,20 @@ public void testInitWithLogLevel() {
6263
// Initializes Instabug with the correct token
6364
assertEquals(token, actualToken);
6465
when(mock.setSdkDebugLogsLevel(anyInt())).thenReturn(mock);
66+
when(mock.ignoreFlagSecure(anyBoolean())).thenReturn(mock);
6567
when(mock.setInvocationEvents(any())).thenReturn(mock);
6668
});
6769

68-
sut.init(mContext, token, logLevel, invocationEvents);
70+
sut.init(mContext, token, logLevel, true, invocationEvents);
6971

7072
Instabug.Builder builder = mInstabugBuilder.constructed().get(0);
7173

7274
// Here we check that it has changed to verbose value of the `logLevel` property
7375
verify(builder).setSdkDebugLogsLevel(LogLevel.VERBOSE);
7476
verify(builder).setInvocationEvents(invocationEvents);
75-
verify(builder).build();
77+
verify(builder).ignoreFlagSecure(true);
7678

79+
verify(builder).build();
7780

7881

7982
verify(sut).setBaseUrlForDeprecationLogs();
@@ -95,7 +98,7 @@ public void testInitWithoutLogLevel() {
9598

9699
sut.init(mContext, token, invocationEvents);
97100

98-
verify(sut).init(mContext, token, defaultLogLevel, invocationEvents);
101+
verify(sut).init(mContext, token, defaultLogLevel, null,invocationEvents);
99102
mInstabugBuilder.close();
100103
}
101104

examples/default/ios/InstabugTests/InstabugSampleTests.m

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,9 @@ - (void)testInit {
7575

7676
OCMStub([mock setCodePushVersion:codePushVersion]);
7777

78-
[self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion];
78+
[self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion
79+
options:nil
80+
];
7981
OCMVerify([mock setCodePushVersion:codePushVersion]);
8082

8183
OCMVerify([self.mRNInstabug initWithToken:appToken invocationEvents:floatingButtonInvocationEvent debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception]);
@@ -610,18 +612,18 @@ - (void) testIsW3CaughtHeaderEnabled {
610612

611613
- (void)testEnableAutoMasking {
612614
id mock = OCMClassMock([Instabug class]);
613-
615+
614616
NSArray *autoMaskingTypes = [NSArray arrayWithObjects:
615617
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionLabels],
616618
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionTextInputs],
617619
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionMedia],
618620
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionMaskNothing],
619621
nil];
620-
622+
621623
OCMStub([mock setAutoMaskScreenshots:IBGAutoMaskScreenshotOptionLabels | IBGAutoMaskScreenshotOptionTextInputs | IBGAutoMaskScreenshotOptionMedia | IBGAutoMaskScreenshotOptionMaskNothing]);
622-
624+
623625
[self.instabugBridge enableAutoMasking:autoMaskingTypes];
624-
626+
625627
OCMVerify([mock setAutoMaskScreenshots:IBGAutoMaskScreenshotOptionLabels | IBGAutoMaskScreenshotOptionTextInputs | IBGAutoMaskScreenshotOptionMedia | IBGAutoMaskScreenshotOptionMaskNothing]);
626628
}
627629

examples/default/src/App.tsx

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, { useEffect, useState } from 'react';
2-
import { ActivityIndicator, StyleSheet } from 'react-native';
1+
import React, { useEffect } from 'react';
2+
import { StyleSheet } from 'react-native';
33

44
import { GestureHandlerRootView } from 'react-native-gesture-handler';
55
import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
@@ -40,13 +40,11 @@ export const App: React.FC = () => {
4040

4141
const navigationRef = useNavigationContainerRef();
4242

43-
const [isInstabugInitialized, setIsInstabugInitialized] = useState(false);
44-
45-
const initializeInstabug = async () => {
43+
const initializeInstabug = () => {
4644
try {
4745
SessionReplay.setSyncCallback((data) => shouldSyncSession(data));
4846

49-
await Instabug.init({
47+
Instabug.init({
5048
token: 'deb1910a7342814af4e4c9210c786f35',
5149
invocationEvents: [InvocationEvent.floatingButton],
5250
debugLogsLevel: LogLevel.verbose,
@@ -55,21 +53,16 @@ export const App: React.FC = () => {
5553

5654
CrashReporting.setNDKCrashesEnabled(true);
5755
Instabug.setReproStepsConfig({ all: ReproStepsMode.enabled });
58-
59-
setIsInstabugInitialized(true); // Set to true after initialization
6056
} catch (error) {
6157
console.error('Instabug initialization failed:', error);
62-
setIsInstabugInitialized(true); // Proceed even if initialization fails
6358
}
6459
};
6560

6661
useEffect(() => {
67-
initializeInstabug().then(() => {
68-
NetworkLogger.setNetworkDataObfuscationHandler(async (networkData) => {
69-
networkData.url = `${networkData.url}/JS/Obfuscated`;
70-
return networkData;
71-
});
72-
// NetworkLogger.setRequestFilterExpression('false');
62+
initializeInstabug();
63+
NetworkLogger.setNetworkDataObfuscationHandler(async (networkData) => {
64+
networkData.url = `${networkData.url}/JS/Obfuscated`;
65+
return networkData;
7366
});
7467
});
7568

@@ -80,10 +73,6 @@ export const App: React.FC = () => {
8073
return unregisterListener;
8174
}, [navigationRef]);
8275

83-
if (!isInstabugInitialized) {
84-
return <ActivityIndicator size="large" color="#0000ff" style={styles.loading} />;
85-
}
86-
8776
return (
8877
<GestureHandlerRootView style={styles.root}>
8978
<NativeBaseProvider theme={nativeBaseTheme}>

ios/RNInstabug/InstabugNetworkLoggerBridge.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ typedef NS_ENUM(NSInteger, NetworkListenerType) {
2424
+------------------------------------------------------------------------+
2525
*/
2626

27-
- (void)isNativeInterceptionEnabled:(RCTPromiseResolveBlock _Nullable )resolve :(RCTPromiseRejectBlock _Nullable )reject;
27+
- (BOOL)isNativeInterceptionEnabled;
2828

2929
- (void) registerNetworkLogsListener:(NetworkListenerType)listenerType;
3030

ios/RNInstabug/InstabugNetworkLoggerBridge.m

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,11 @@ -(void)stopObserving {
6969
// Remove upstream listeners, stop unnecessary background tasks
7070
}
7171

72-
RCT_EXPORT_METHOD(isNativeInterceptionEnabled:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject) {
73-
resolve(@(IBGNetworkLogger.isNativeNetworkInterceptionFeatureEnabled));
74-
}
72+
RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isNativeInterceptionEnabled) {
73+
return @(IBGNetworkLogger.isNativeNetworkInterceptionFeatureEnabled);
74+
}
75+
76+
7577

7678
RCT_EXPORT_METHOD(registerNetworkLogsListener: (NetworkListenerType) listenerType) {
7779
switch (listenerType) {

ios/RNInstabug/InstabugReactBridge.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@
2626

2727
- (void)setEnabled:(BOOL)isEnabled;
2828

29-
- (void)init:(NSString *)token invocationEvents:(NSArray *)invocationEventsArray debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel useNativeNetworkInterception:(BOOL)useNativeNetworkInterception codePushVersion:(NSString *)codePushVersion;
29+
- (void)init:(NSString *)token invocationEvents:(NSArray *)invocationEventsArray debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel useNativeNetworkInterception:(BOOL)useNativeNetworkInterception codePushVersion:(NSString *)codePushVersion
30+
options:(nullable NSDictionary *)options;
3031

3132
- (void)setCodePushVersion:(NSString *)version;
3233

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ - (dispatch_queue_t)methodQueue {
4141
invocationEvents:(NSArray *)invocationEventsArray
4242
debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel
4343
useNativeNetworkInterception:(BOOL)useNativeNetworkInterception
44-
codePushVersion:(NSString *)codePushVersion) {
44+
codePushVersion:(NSString *)codePushVersion
45+
options:(nullable NSDictionary *)options
46+
) {
4547
IBGInvocationEvent invocationEvents = 0;
4648

4749
for (NSNumber *boxedValue in invocationEventsArray) {

0 commit comments

Comments
 (0)