diff --git a/CHANGELOG.md b/CHANGELOG.md index abda7ed70..f4ede5591 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,15 @@ # Changelog +## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v15.1.0...dev) + +### Added + +- Add support for ignoreFlagSecure to bypass SDK screenshot security protocols on Android. ([#1394](https://github.com/Instabug/Instabug-React-Native/pull/1394)) + +### Fixed + +- async initialization. ([#1427](https://github.com/Instabug/Instabug-React-Native/pull/1427)) + ## [15.0.1](https://github.com/Instabug/Instabug-React-Native/compare/v14.3.0...v15.0.1) ### Added diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabug.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabug.java index 9b6348ab4..7c0901936 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabug.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabug.java @@ -19,7 +19,8 @@ public class RNInstabug { private static RNInstabug instance; - private RNInstabug() {} + private RNInstabug() { + } public static RNInstabug getInstance() { @@ -36,14 +37,13 @@ public static RNInstabug getInstance() { /** * Initializes the SDK on the native side, which is useful for capturing startup issues specific to the native part of the app. * - * @param application The application context. + * @param application The application context. * @param applicationToken The app's identifying token, available on your dashboard. - * @param logLevel The level of detail in logs that you want to print. - *
Pick one of the log levels described in {@link LogLevel}. - * default logLevel is {@link LogLevel#ERROR}
- * @param InvocationEvent The events that trigger the SDK's user interface. - * Choose from the available events listed in {@link InstabugInvocationEvent}. - * + * @param logLevel The level of detail in logs that you want to print. + *Pick one of the log levels described in {@link LogLevel}. + * default logLevel is {@link LogLevel#ERROR}
+ * @param InvocationEvent The events that trigger the SDK's user interface. + * Choose from the available events listed in {@link InstabugInvocationEvent}. * @exampleHere's an example usage:
*
* RNInstabug.getInstance().init(
@@ -59,17 +59,24 @@ public void init(
@NonNull Application application,
@NonNull String applicationToken,
int logLevel,
+ Boolean ignoreSecureFlag,
@NonNull InstabugInvocationEvent... InvocationEvent
- ) {
+ ) {
try {
setBaseUrlForDeprecationLogs();
setCurrentPlatform();
- new Instabug.Builder(application, applicationToken)
+ Instabug.Builder builder = new Instabug.Builder(application, applicationToken)
.setInvocationEvents(InvocationEvent)
- .setSdkDebugLogsLevel(logLevel)
- .build();
+ .setSdkDebugLogsLevel(logLevel);
+
+ if (ignoreSecureFlag != null) {
+ builder.ignoreFlagSecure(ignoreSecureFlag);
+ }
+
+ builder.build();
+
// Temporarily disabling APM hot launches
APM.setHotAppLaunchEnabled(false);
@@ -80,15 +87,13 @@ public void init(
}
-
/**
* Initializes the SDK on the native side, which is useful for capturing startup issues specific to the native part of the app.
*
- * @param application The application context.
+ * @param application The application context.
* @param applicationToken The app's identifying token, available on your dashboard.
- * @param invocationEvent The events that trigger the SDK's user interface.
- * Choose from the available events listed in {@link InstabugInvocationEvent}.
- *
+ * @param invocationEvent The events that trigger the SDK's user interface.
+ * Choose from the available events listed in {@link InstabugInvocationEvent}.
* @example Here's an example usage:
*
* RNInstabug.getInstance().init(
@@ -104,7 +109,7 @@ public void init(
@NonNull String applicationToken,
@NonNull InstabugInvocationEvent... invocationEvent
) {
- init(application, applicationToken, LogLevel.ERROR, invocationEvent);
+ init(application, applicationToken, LogLevel.ERROR,null, invocationEvent);
}
@VisibleForTesting
@@ -160,6 +165,7 @@ public static class Builder {
* The events that trigger the SDK's user interface.
*/
private InstabugInvocationEvent[] invocationEvents;
+ private Boolean ignoreFlagSecure;
/**
@@ -210,6 +216,16 @@ public Builder setCodePushVersion(String codePushVersion) {
return this;
}
+ /**
+ * Sets flag to override SDK screenshot security behavior.
+ *
+ * @param ignoreFlagSecure flag to override SDK screenshot security behavior.
+ */
+ public Builder ignoreFlagSecure(boolean ignoreFlagSecure) {
+ this.ignoreFlagSecure = ignoreFlagSecure;
+ return this;
+ }
+
/**
* Sets the invocation triggering events for the SDK's user interface
*
@@ -237,6 +253,10 @@ public void build() {
instabugBuilder.setCodePushVersion(codePushVersion);
}
+ if (ignoreFlagSecure != null) {
+ instabugBuilder.ignoreFlagSecure(ignoreFlagSecure);
+ }
+
instabugBuilder.build();
// Temporarily disabling APM hot launches
diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java
index 17f48656f..21bcf4f44 100644
--- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java
+++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java
@@ -148,7 +148,8 @@ public void init(
final ReadableArray invocationEventValues,
final String logLevel,
final boolean useNativeNetworkInterception,
- @Nullable final String codePushVersion
+ @Nullable final String codePushVersion,
+ final ReadableMap map
) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
@@ -166,6 +167,10 @@ public void run() {
.setInvocationEvents(invocationEvents)
.setLogLevel(parsedLogLevel);
+ if (map!=null&&map.hasKey("ignoreAndroidSecureFlag")) {
+ builder.ignoreFlagSecure(map.getBoolean("ignoreAndroidSecureFlag"));
+ }
+
if (codePushVersion != null) {
if (Instabug.isBuilt()) {
Instabug.setCodePushVersion(codePushVersion);
diff --git a/android/src/test/java/com/instabug/reactlibrary/RNInstabugTest.java b/android/src/test/java/com/instabug/reactlibrary/RNInstabugTest.java
index df169df1e..625eab1c9 100644
--- a/android/src/test/java/com/instabug/reactlibrary/RNInstabugTest.java
+++ b/android/src/test/java/com/instabug/reactlibrary/RNInstabugTest.java
@@ -4,6 +4,7 @@
import static com.instabug.reactlibrary.util.GlobalMocks.reflected;
import static org.junit.Assert.assertEquals;
import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.mockConstruction;
@@ -62,18 +63,20 @@ public void testInitWithLogLevel() {
// Initializes Instabug with the correct token
assertEquals(token, actualToken);
when(mock.setSdkDebugLogsLevel(anyInt())).thenReturn(mock);
+ when(mock.ignoreFlagSecure(anyBoolean())).thenReturn(mock);
when(mock.setInvocationEvents(any())).thenReturn(mock);
});
- sut.init(mContext, token, logLevel, invocationEvents);
+ sut.init(mContext, token, logLevel, true, invocationEvents);
Instabug.Builder builder = mInstabugBuilder.constructed().get(0);
// Here we check that it has changed to verbose value of the `logLevel` property
verify(builder).setSdkDebugLogsLevel(LogLevel.VERBOSE);
verify(builder).setInvocationEvents(invocationEvents);
- verify(builder).build();
+ verify(builder).ignoreFlagSecure(true);
+ verify(builder).build();
verify(sut).setBaseUrlForDeprecationLogs();
@@ -95,7 +98,7 @@ public void testInitWithoutLogLevel() {
sut.init(mContext, token, invocationEvents);
- verify(sut).init(mContext, token, defaultLogLevel, invocationEvents);
+ verify(sut).init(mContext, token, defaultLogLevel, null,invocationEvents);
mInstabugBuilder.close();
}
diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m
index ded37c3af..34fe9cfe3 100644
--- a/examples/default/ios/InstabugTests/InstabugSampleTests.m
+++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m
@@ -75,7 +75,9 @@ - (void)testInit {
OCMStub([mock setCodePushVersion:codePushVersion]);
- [self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion];
+ [self.instabugBridge init:appToken invocationEvents:invocationEvents debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception codePushVersion:codePushVersion
+ options:nil
+ ];
OCMVerify([mock setCodePushVersion:codePushVersion]);
OCMVerify([self.mRNInstabug initWithToken:appToken invocationEvents:floatingButtonInvocationEvent debugLogsLevel:sdkDebugLogsLevel useNativeNetworkInterception:useNativeNetworkInterception]);
@@ -610,18 +612,18 @@ - (void) testIsW3CaughtHeaderEnabled {
- (void)testEnableAutoMasking {
id mock = OCMClassMock([Instabug class]);
-
+
NSArray *autoMaskingTypes = [NSArray arrayWithObjects:
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionLabels],
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionTextInputs],
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionMedia],
[NSNumber numberWithInteger:IBGAutoMaskScreenshotOptionMaskNothing],
nil];
-
+
OCMStub([mock setAutoMaskScreenshots:IBGAutoMaskScreenshotOptionLabels | IBGAutoMaskScreenshotOptionTextInputs | IBGAutoMaskScreenshotOptionMedia | IBGAutoMaskScreenshotOptionMaskNothing]);
-
+
[self.instabugBridge enableAutoMasking:autoMaskingTypes];
-
+
OCMVerify([mock setAutoMaskScreenshots:IBGAutoMaskScreenshotOptionLabels | IBGAutoMaskScreenshotOptionTextInputs | IBGAutoMaskScreenshotOptionMedia | IBGAutoMaskScreenshotOptionMaskNothing]);
}
diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx
index ceef8bc19..ad1c32579 100644
--- a/examples/default/src/App.tsx
+++ b/examples/default/src/App.tsx
@@ -1,5 +1,5 @@
-import React, { useEffect, useState } from 'react';
-import { ActivityIndicator, StyleSheet } from 'react-native';
+import React, { useEffect } from 'react';
+import { StyleSheet } from 'react-native';
import { GestureHandlerRootView } from 'react-native-gesture-handler';
import { NavigationContainer, useNavigationContainerRef } from '@react-navigation/native';
@@ -40,13 +40,11 @@ export const App: React.FC = () => {
const navigationRef = useNavigationContainerRef();
- const [isInstabugInitialized, setIsInstabugInitialized] = useState(false);
-
- const initializeInstabug = async () => {
+ const initializeInstabug = () => {
try {
SessionReplay.setSyncCallback((data) => shouldSyncSession(data));
- await Instabug.init({
+ Instabug.init({
token: 'deb1910a7342814af4e4c9210c786f35',
invocationEvents: [InvocationEvent.floatingButton],
debugLogsLevel: LogLevel.verbose,
@@ -55,21 +53,16 @@ export const App: React.FC = () => {
CrashReporting.setNDKCrashesEnabled(true);
Instabug.setReproStepsConfig({ all: ReproStepsMode.enabled });
-
- setIsInstabugInitialized(true); // Set to true after initialization
} catch (error) {
console.error('Instabug initialization failed:', error);
- setIsInstabugInitialized(true); // Proceed even if initialization fails
}
};
useEffect(() => {
- initializeInstabug().then(() => {
- NetworkLogger.setNetworkDataObfuscationHandler(async (networkData) => {
- networkData.url = `${networkData.url}/JS/Obfuscated`;
- return networkData;
- });
- // NetworkLogger.setRequestFilterExpression('false');
+ initializeInstabug();
+ NetworkLogger.setNetworkDataObfuscationHandler(async (networkData) => {
+ networkData.url = `${networkData.url}/JS/Obfuscated`;
+ return networkData;
});
});
@@ -80,10 +73,6 @@ export const App: React.FC = () => {
return unregisterListener;
}, [navigationRef]);
- if (!isInstabugInitialized) {
- return ;
- }
-
return (
diff --git a/ios/RNInstabug/InstabugNetworkLoggerBridge.h b/ios/RNInstabug/InstabugNetworkLoggerBridge.h
index 9673f8524..532f21d23 100644
--- a/ios/RNInstabug/InstabugNetworkLoggerBridge.h
+++ b/ios/RNInstabug/InstabugNetworkLoggerBridge.h
@@ -24,7 +24,7 @@ typedef NS_ENUM(NSInteger, NetworkListenerType) {
+------------------------------------------------------------------------+
*/
-- (void)isNativeInterceptionEnabled:(RCTPromiseResolveBlock _Nullable )resolve :(RCTPromiseRejectBlock _Nullable )reject;
+- (BOOL)isNativeInterceptionEnabled;
- (void) registerNetworkLogsListener:(NetworkListenerType)listenerType;
diff --git a/ios/RNInstabug/InstabugNetworkLoggerBridge.m b/ios/RNInstabug/InstabugNetworkLoggerBridge.m
index 16d71c814..2a2ddeb97 100644
--- a/ios/RNInstabug/InstabugNetworkLoggerBridge.m
+++ b/ios/RNInstabug/InstabugNetworkLoggerBridge.m
@@ -69,9 +69,11 @@ -(void)stopObserving {
// Remove upstream listeners, stop unnecessary background tasks
}
-RCT_EXPORT_METHOD(isNativeInterceptionEnabled:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject) {
- resolve(@(IBGNetworkLogger.isNativeNetworkInterceptionFeatureEnabled));
-}
+RCT_EXPORT_BLOCKING_SYNCHRONOUS_METHOD(isNativeInterceptionEnabled) {
+ return @(IBGNetworkLogger.isNativeNetworkInterceptionFeatureEnabled);
+}
+
+
RCT_EXPORT_METHOD(registerNetworkLogsListener: (NetworkListenerType) listenerType) {
switch (listenerType) {
diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h
index 1fe5505d3..45c075098 100644
--- a/ios/RNInstabug/InstabugReactBridge.h
+++ b/ios/RNInstabug/InstabugReactBridge.h
@@ -26,7 +26,8 @@
- (void)setEnabled:(BOOL)isEnabled;
-- (void)init:(NSString *)token invocationEvents:(NSArray *)invocationEventsArray debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel useNativeNetworkInterception:(BOOL)useNativeNetworkInterception codePushVersion:(NSString *)codePushVersion;
+- (void)init:(NSString *)token invocationEvents:(NSArray *)invocationEventsArray debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel useNativeNetworkInterception:(BOOL)useNativeNetworkInterception codePushVersion:(NSString *)codePushVersion
+options:(nullable NSDictionary *)options;
- (void)setCodePushVersion:(NSString *)version;
diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m
index a48851ba8..682896515 100644
--- a/ios/RNInstabug/InstabugReactBridge.m
+++ b/ios/RNInstabug/InstabugReactBridge.m
@@ -41,7 +41,9 @@ - (dispatch_queue_t)methodQueue {
invocationEvents:(NSArray *)invocationEventsArray
debugLogsLevel:(IBGSDKDebugLogsLevel)sdkDebugLogsLevel
useNativeNetworkInterception:(BOOL)useNativeNetworkInterception
- codePushVersion:(NSString *)codePushVersion) {
+ codePushVersion:(NSString *)codePushVersion
+ options:(nullable NSDictionary *)options
+ ) {
IBGInvocationEvent invocationEvents = 0;
for (NSNumber *boxedValue in invocationEventsArray) {
diff --git a/src/models/InstabugConfig.ts b/src/models/InstabugConfig.ts
index 614ade892..af1d6e841 100644
--- a/src/models/InstabugConfig.ts
+++ b/src/models/InstabugConfig.ts
@@ -19,6 +19,11 @@ export interface InstabugConfig {
*/
codePushVersion?: string;
+ /**
+ * An optional flag to override SDK screenshot security behavior.
+ */
+ ignoreAndroidSecureFlag?: boolean;
+
/**
* An optional network interception mode, this determines whether network interception
* is done in the JavaScript side or in the native Android and iOS SDK side.
diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts
index f7d582e70..fd4f17600 100644
--- a/src/modules/Instabug.ts
+++ b/src/modules/Instabug.ts
@@ -84,13 +84,13 @@ function reportCurrentViewForAndroid(screenName: string | null) {
* Should be called in constructor of the AppRegistry component
* @param config SDK configurations. See {@link InstabugConfig} for more info.
*/
-export const init = async (config: InstabugConfig) => {
+export const init = (config: InstabugConfig) => {
if (Platform.OS === 'android') {
// Add android feature flags listener for android
registerFeatureFlagsListener();
addOnFeatureUpdatedListener(config);
} else {
- isNativeInterceptionFeatureEnabled = await NativeNetworkLogger.isNativeInterceptionEnabled();
+ isNativeInterceptionFeatureEnabled = NativeNetworkLogger.isNativeInterceptionEnabled();
// Add app state listener to handle background/foreground transitions
addAppStateListener(async (nextAppState) => handleAppStateChange(nextAppState, config));
@@ -133,7 +133,6 @@ const handleAppStateChange = async (nextAppState: AppStateStatus, config: Instab
// Checks if the app has come to the foreground
if (['inactive', 'background'].includes(_currentAppState) && nextAppState === 'active') {
const isUpdated = await fetchApmNetworkFlags();
-
if (isUpdated) {
refreshAPMNetworkConfigs(config);
}
@@ -147,8 +146,7 @@ const handleAppStateChange = async (nextAppState: AppStateStatus, config: Instab
*/
const fetchApmNetworkFlags = async () => {
let isUpdated = false;
- const newNativeInterceptionFeatureEnabled =
- await NativeNetworkLogger.isNativeInterceptionEnabled();
+ const newNativeInterceptionFeatureEnabled = NativeNetworkLogger.isNativeInterceptionEnabled();
if (isNativeInterceptionFeatureEnabled !== newNativeInterceptionFeatureEnabled) {
isNativeInterceptionFeatureEnabled = newNativeInterceptionFeatureEnabled;
isUpdated = true;
@@ -275,6 +273,11 @@ const initializeNativeInstabug = (config: InstabugConfig) => {
shouldEnableNativeInterception &&
config.networkInterceptionMode === NetworkInterceptionMode.native,
config.codePushVersion,
+ config.ignoreAndroidSecureFlag != null
+ ? {
+ ignoreAndroidSecureFlag: config.ignoreAndroidSecureFlag,
+ }
+ : undefined,
);
};
diff --git a/src/native/NativeInstabug.ts b/src/native/NativeInstabug.ts
index 7032bbc07..c9c078f37 100644
--- a/src/native/NativeInstabug.ts
+++ b/src/native/NativeInstabug.ts
@@ -26,6 +26,9 @@ export interface InstabugNativeModule extends NativeModule {
debugLogsLevel: LogLevel,
useNativeNetworkInterception: boolean,
codePushVersion?: string,
+ options?: {
+ ignoreAndroidSecureFlag?: boolean;
+ },
): void;
show(): void;
diff --git a/src/native/NativeNetworkLogger.ts b/src/native/NativeNetworkLogger.ts
index 4162a0fbf..c38f11873 100644
--- a/src/native/NativeNetworkLogger.ts
+++ b/src/native/NativeNetworkLogger.ts
@@ -8,7 +8,7 @@ export enum NetworkListenerType {
}
export interface NetworkLoggerNativeModule extends NativeModule {
- isNativeInterceptionEnabled(): Promise;
+ isNativeInterceptionEnabled(): boolean;
registerNetworkLogsListener(type?: NetworkListenerType): void;
diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts
index f6e36d8e4..eeec8e8e4 100644
--- a/test/modules/Instabug.spec.ts
+++ b/test/modules/Instabug.spec.ts
@@ -69,8 +69,8 @@ describe('Instabug Module', () => {
expect(NativeInstabug.reportScreenChange).toBeCalledWith(screenName);
});
- it("componentDidAppearListener shouldn't call the native method reportScreenChange if first screen", async () => {
- await Instabug.init({
+ it("componentDidAppearListener shouldn't call the native method reportScreenChange if first screen", () => {
+ Instabug.init({
token: 'some-token',
invocationEvents: [InvocationEvent.none],
});
@@ -81,7 +81,7 @@ describe('Instabug Module', () => {
componentType: 'Component',
});
- await waitForExpect(() => {
+ waitForExpect(() => {
// Only first screen should be reported
expect(NativeInstabug.reportScreenChange).toBeCalledTimes(1);
expect(NativeInstabug.reportScreenChange).toBeCalledWith('Initial Screen');
@@ -89,6 +89,11 @@ describe('Instabug Module', () => {
});
it("componentDidAppearListener shouldn't call the native method reportScreenChange twice if same screen", (done) => {
+ Instabug.init({
+ token: 'some-token',
+ invocationEvents: [InvocationEvent.none],
+ });
+
Array(5).forEach(() => {
Instabug.componentDidAppearListener({
componentId: '1',
@@ -107,7 +112,7 @@ describe('Instabug Module', () => {
// 2. Second+ calls:
// The screen name is the same as _lastScreen (stored in 1st call)
// so it doesn't report a screen change
- expect(NativeInstabug.reportScreenChange).not.toBeCalled();
+ expect(NativeInstabug.reportScreenChange).toBeCalledTimes(1);
done();
}, 1500);
});
@@ -283,16 +288,17 @@ describe('Instabug Module', () => {
expect(onStateChangeMock).toHaveBeenCalledWith(mockNavigationContainerRef.getRootState());
});
- it('should call the native method init', async () => {
+ it('should call the native method init', () => {
const instabugConfig = {
token: 'some-token',
invocationEvents: [InvocationEvent.floatingButton, InvocationEvent.shake],
debugLogsLevel: LogLevel.debug,
codePushVersion: '1.1.0',
+ ignoreAndroidSecureFlag: true,
};
const usesNativeNetworkInterception = false;
- await Instabug.init(instabugConfig);
+ Instabug.init(instabugConfig);
expect(NetworkLogger.setEnabled).toBeCalledWith(true);
expect(NativeInstabug.init).toBeCalledTimes(1);
@@ -302,6 +308,7 @@ describe('Instabug Module', () => {
instabugConfig.debugLogsLevel,
usesNativeNetworkInterception,
instabugConfig.codePushVersion,
+ { ignoreAndroidSecureFlag: instabugConfig.ignoreAndroidSecureFlag },
);
});
@@ -314,22 +321,21 @@ describe('Instabug Module', () => {
expect(NativeInstabug.setCodePushVersion).toBeCalledWith(codePushVersion);
});
- it('init should disable JavaScript interceptor when using native interception mode', async () => {
+ it('init should disable JavaScript interceptor when using native interception mode', () => {
const instabugConfig = {
token: 'some-token',
invocationEvents: [InvocationEvent.floatingButton, InvocationEvent.shake],
debugLogsLevel: LogLevel.debug,
networkInterceptionMode: NetworkInterceptionMode.native,
codePushVersion: '1.1.0',
+ ignoreAndroidSecureFlag: true,
};
// Stubbing Network feature flags
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(true));
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(true);
jest.spyOn(NativeNetworkLogger, 'hasAPMNetworkPlugin').mockReturnValue(Promise.resolve(true));
- await Instabug.init(instabugConfig);
+ Instabug.init(instabugConfig);
if (Platform.OS === 'android') {
expect(NetworkLogger.setEnabled).not.toBeCalled();
@@ -353,6 +359,7 @@ describe('Instabug Module', () => {
// usesNativeNetworkInterception should be true when using native interception mode with iOS
true,
instabugConfig.codePushVersion,
+ { ignoreAndroidSecureFlag: instabugConfig.ignoreAndroidSecureFlag },
);
}
});
@@ -900,7 +907,7 @@ describe('Instabug Module', () => {
expect(NativeInstabug.willRedirectToStore).toBeCalledTimes(1);
});
- it('should register feature flag listener', async () => {
+ it('should register feature flag listener', () => {
const callback = jest.fn();
Instabug._registerFeatureFlagsChangeListener(callback);
@@ -939,10 +946,10 @@ describe('Instabug iOS initialization tests', () => {
jest.advanceTimersByTime(1000);
});
- it('should initialize correctly with javascript interception mode', async () => {
+ it('should initialize correctly with javascript interception mode', () => {
config.networkInterceptionMode = NetworkInterceptionMode.javascript;
- await Instabug.init(config);
+ Instabug.init(config);
expect(NativeNetworkLogger.isNativeInterceptionEnabled).toHaveBeenCalled();
expect(NetworkLogger.setEnabled).toHaveBeenCalledWith(true);
@@ -952,15 +959,14 @@ describe('Instabug iOS initialization tests', () => {
config.debugLogsLevel,
false, // Disable native interception
config.codePushVersion,
+ config.ignoreAndroidSecureFlag,
);
});
- it('should initialize correctly with native interception mode when [isNativeInterceptionEnabled] == ture', async () => {
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(true));
+ it('should initialize correctly with native interception mode when [isNativeInterceptionEnabled] == ture', () => {
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(true);
- await Instabug.init(config);
+ Instabug.init(config);
expect(NativeNetworkLogger.isNativeInterceptionEnabled).toHaveBeenCalled();
expect(NetworkLogger.setEnabled).toHaveBeenCalledWith(false);
@@ -970,15 +976,14 @@ describe('Instabug iOS initialization tests', () => {
config.debugLogsLevel,
true, // Enable native interception
config.codePushVersion,
+ config.ignoreAndroidSecureFlag,
);
});
- it('should disable native interception mode when user sets networkInterceptionMode to native and [isNativeInterceptionEnabled] == false', async () => {
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(false));
+ it('should disable native interception mode when user sets networkInterceptionMode to native and [isNativeInterceptionEnabled] == false', () => {
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(false);
- await Instabug.init(config);
+ Instabug.init(config);
expect(NativeNetworkLogger.isNativeInterceptionEnabled).toHaveBeenCalled();
expect(NetworkLogger.setEnabled).toHaveBeenCalled();
@@ -988,16 +993,15 @@ describe('Instabug iOS initialization tests', () => {
config.debugLogsLevel,
false, // Disable native interception
config.codePushVersion,
+ config.ignoreAndroidSecureFlag,
);
});
- it('should display error message when user sets networkInterceptionMode to native and [isNativeInterceptionEnabled] == false', async () => {
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(false));
+ it('should display error message when user sets networkInterceptionMode to native and [isNativeInterceptionEnabled] == false', () => {
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(false);
const logSpy = jest.spyOn(global.console, 'error');
- await Instabug.init(config);
+ Instabug.init(config);
expect(logSpy).toBeCalledTimes(1);
expect(logSpy).toBeCalledWith(
@@ -1020,9 +1024,9 @@ describe('Instabug Android initialization tests', () => {
};
});
- it('should initialize correctly with native interception enabled', async () => {
+ it('should initialize correctly with native interception enabled', () => {
config.networkInterceptionMode = NetworkInterceptionMode.native;
- await Instabug.init(config);
+ Instabug.init(config);
fakeTimer(() => {
expect(NativeInstabug.setOnFeaturesUpdatedListener).toHaveBeenCalled();
expect(NetworkLogger.setEnabled).toHaveBeenCalledWith(true);
@@ -1032,18 +1036,17 @@ describe('Instabug Android initialization tests', () => {
config.debugLogsLevel,
false, // always disable native interception to insure sending network logs to core (Bugs & Crashes).
config.codePushVersion,
+ { ignoreAndroidSecureFlag: config.ignoreAndroidSecureFlag },
);
});
});
- it('should show warning message when networkInterceptionMode == javascript and user added APM plugin', async () => {
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(true));
+ it('should show warning message when networkInterceptionMode == javascript and user added APM plugin', () => {
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(true);
jest.spyOn(NativeNetworkLogger, 'hasAPMNetworkPlugin').mockReturnValue(Promise.resolve(true));
const logSpy = jest.spyOn(global.console, 'warn');
- await Instabug.init(config);
+ Instabug.init(config);
fakeTimer(() => {
expect(logSpy).toBeCalledTimes(1);
expect(logSpy).toBeCalledWith(
@@ -1052,16 +1055,14 @@ describe('Instabug Android initialization tests', () => {
});
});
- it('should show error message when networkInterceptionMode == native and user did not add APM plugin', async () => {
+ it('should show error message when networkInterceptionMode == native and user did not add APM plugin', () => {
config.networkInterceptionMode = NetworkInterceptionMode.native;
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(true));
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(true);
jest.spyOn(NativeNetworkLogger, 'hasAPMNetworkPlugin').mockReturnValue(Promise.resolve(false));
const logSpy = jest.spyOn(global.console, 'error');
- await Instabug.init(config);
+ Instabug.init(config);
fakeTimer(() => {
expect(logSpy).toBeCalledTimes(1);
@@ -1071,16 +1072,14 @@ describe('Instabug Android initialization tests', () => {
});
});
- it('should show error message when networkInterceptionMode == native and user did not add APM plugin and the isNativeInterceptionEnabled is disabled', async () => {
+ it('should show error message when networkInterceptionMode == native and user did not add APM plugin and the isNativeInterceptionEnabled is disabled', () => {
config.networkInterceptionMode = NetworkInterceptionMode.native;
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(false));
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(false);
jest.spyOn(NativeNetworkLogger, 'hasAPMNetworkPlugin').mockReturnValue(Promise.resolve(false));
const logSpy = jest.spyOn(global.console, 'error');
- await Instabug.init(config);
+ Instabug.init(config);
fakeTimer(() => {
expect(logSpy).toBeCalledTimes(1);
@@ -1090,15 +1089,13 @@ describe('Instabug Android initialization tests', () => {
});
});
- it('should show error message when networkInterceptionMode == native and the isNativeInterceptionEnabled is disabled', async () => {
+ it('should show error message when networkInterceptionMode == native and the isNativeInterceptionEnabled is disabled', () => {
config.networkInterceptionMode = NetworkInterceptionMode.native;
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(false));
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(false);
jest.spyOn(NativeNetworkLogger, 'hasAPMNetworkPlugin').mockReturnValue(Promise.resolve(true));
const logSpy = jest.spyOn(global.console, 'error');
- await Instabug.init(config);
+ Instabug.init(config);
fakeTimer(() => {
expect(logSpy).toBeCalledTimes(1);
diff --git a/test/utils/InstabugUtils.spec.ts b/test/utils/InstabugUtils.spec.ts
index 11a5c8d1a..49ce13c58 100644
--- a/test/utils/InstabugUtils.spec.ts
+++ b/test/utils/InstabugUtils.spec.ts
@@ -273,11 +273,9 @@ describe('reportNetworkLog', () => {
it('reportNetworkLog should send network logs to native with the correct parameters on Android', async () => {
Platform.OS = 'android';
- jest
- .spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled')
- .mockReturnValue(Promise.resolve(false));
+ jest.spyOn(NativeNetworkLogger, 'isNativeInterceptionEnabled').mockReturnValue(false);
jest.spyOn(NativeNetworkLogger, 'hasAPMNetworkPlugin').mockReturnValue(Promise.resolve(false));
- await Instabug.init({ token: '', invocationEvents: [InvocationEvent.none] });
+ Instabug.init({ token: '', invocationEvents: [InvocationEvent.none] });
const requestHeaders = JSON.stringify(network.requestHeaders);
const responseHeaders = JSON.stringify(network.responseHeaders);