Skip to content
Open
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion RNInstabug.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,6 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm}"

s.dependency 'React-Core'
use_instabug!(s)
# use_instabug!(s)
s.dependency 'Instabug'
end
2 changes: 1 addition & 1 deletion android/native.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
project.ext.instabug = [
version: '14.0.0'
version: '14.0.0.6407912-SNAPSHOT'
]

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1148,7 +1148,26 @@ public void run() {
}
});
}

/**
* Enables or disables network logs sensitive information auto masking.
* @param isEnabled A boolean to enable/disable auto masking.
*/
@ReactMethod
public void setAutoMaskingEnabled(final boolean isEnabled) {
MainThreadHandler.runOnMainThread(new Runnable() {
@Override
public void run() {
try {
if(isEnabled)
Instabug.setNetworkAutoMaskingState(Feature.State.ENABLED);
else
Instabug.setNetworkAutoMaskingState(Feature.State.DISABLED);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
/**
* Map between the exported JS constant and the arg key in {@link ArgsRegistry}.
* The constant name and the arg key should match to be able to resolve the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,4 +635,23 @@ public void testWillRedirectToStore() {
// then
mockInstabug.verify(() -> Instabug.willRedirectToStore());
}

@Test
public void testEnableAutoMasking() {
// when
rnModule.setAutoMaskingEnabled(true);

// then
mockInstabug.verify(() -> Instabug.setNetworkAutoMaskingState(Feature.State.ENABLED));
}

@Test
public void testDisableAutoMasking() {
// when
rnModule.setAutoMaskingEnabled(false);

// then
mockInstabug.verify(() -> Instabug.setNetworkAutoMaskingState(Feature.State.DISABLED));
}

}
9 changes: 9 additions & 0 deletions examples/default/ios/InstabugTests/InstabugSampleTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -541,4 +541,13 @@ - (void)testRemoveAllFeatureFlags {
OCMVerify([mock removeAllFeatureFlags]);
}

- (void)testSetAutoMaskingEnabled {
id mock = OCMClassMock([IBGNetworkLogger class]);
BOOL isEnabled = true;

OCMStub([mock setAutoMaskingEnabled:isEnabled]);
[self.instabugBridge setAutoMaskingEnabled:isEnabled];
OCMVerify([mock setAutoMaskingEnabled:isEnabled]);
}

@end
1 change: 1 addition & 0 deletions examples/default/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ target 'InstabugExample' do
config = use_native_modules!
rn_maps_path = '../node_modules/react-native-maps'
pod 'react-native-google-maps', :path => rn_maps_path
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec'
# Flags change depending on the env values.
flags = get_default_flags()

Expand Down
12 changes: 7 additions & 5 deletions examples/default/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1603,7 +1603,7 @@ PODS:
- ReactCommon/turbomodule/core
- Yoga
- RNInstabug (14.0.0):
- Instabug (= 14.0.0)
- Instabug
- React-Core
- RNReanimated (3.16.1):
- DoubleConversion
Expand Down Expand Up @@ -1747,6 +1747,7 @@ DEPENDENCIES:
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
- Instabug (from `https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec`)
- instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`)
- OCMock
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
Expand Down Expand Up @@ -1825,7 +1826,6 @@ SPEC REPOS:
trunk:
- Google-Maps-iOS-Utils
- GoogleMaps
- Instabug
- OCMock
- SocketRocket

Expand All @@ -1843,6 +1843,8 @@ EXTERNAL SOURCES:
hermes-engine:
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
:tag: hermes-2024-08-15-RNv0.75.1-4b3bf912cc0f705b51b71ce1a5b8bd79b93a451b
Instabug:
:podspec: https://ios-releases.instabug.com/custom/feature-MOB-16541-NetworkAutoMaskAPI/14.0.0/Instabug.podspec
instabug-reactnative-ndk:
:path: "../node_modules/instabug-reactnative-ndk"
RCT-Folly:
Expand Down Expand Up @@ -1993,7 +1995,7 @@ SPEC CHECKSUMS:
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0
Instabug: a0beffc01658773e2fac549845782f8937707dc4
Instabug: 3fa42ac8b4350cb632df724b14a86ebdb875aad9
instabug-reactnative-ndk: d765ac289d56e8896398d02760d9abf2562fc641
OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
Expand Down Expand Up @@ -2059,14 +2061,14 @@ SPEC CHECKSUMS:
ReactCommon: 6a952e50c2a4b694731d7682aaa6c79bc156e4ad
RNCClipboard: 2821ac938ef46f736a8de0c8814845dde2dcbdfb
RNGestureHandler: 511250b190a284388f9dd0d2e56c1df76f14cfb8
RNInstabug: eaa8cde2bcd3c8e757c6dd5c0d33a20814f9658a
RNInstabug: 520f214ffe48a265a1f4a405f535aedb87b61784
RNReanimated: f42a5044d121d68e91680caacb0293f4274228eb
RNScreens: c7ceced6a8384cb9be5e7a5e88e9e714401fd958
RNSVG: 8b1a777d54096b8c2a0fd38fc9d5a454332bbb4d
RNVectorIcons: 6382277afab3c54658e9d555ee0faa7a37827136
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6

PODFILE CHECKSUM: 63bf073bef3872df95ea45e7c9c023a331ebb3c3
PODFILE CHECKSUM: 1e70e06083f879bc88e5c9ddc8e550797003ede5

COCOAPODS: 1.14.0
1 change: 1 addition & 0 deletions ios/RNInstabug/InstabugReactBridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,5 @@
- (void)addFeatureFlags:(NSDictionary *)featureFlagsMap;
- (void)removeFeatureFlags:(NSArray *)featureFlags;
- (void)removeAllFeatureFlags;
- (void)setAutoMaskingEnabled:(BOOL)isEnabled;
@end
3 changes: 3 additions & 0 deletions ios/RNInstabug/InstabugReactBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@ - (dispatch_queue_t)methodQueue {
RCT_EXPORT_METHOD(willRedirectToStore){
[Instabug willRedirectToAppStore];
}
RCT_EXPORT_METHOD(setAutoMaskingEnabled:(BOOL)isEnabled) {
IBGNetworkLogger.autoMaskingEnabled = isEnabled;
}

- (NSDictionary *)constantsToExport {
return ArgsRegistry.getAll;
Expand Down
10 changes: 10 additions & 0 deletions src/modules/NetworkLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { RequestHandler } from '@apollo/client';
import InstabugConstants from '../utils/InstabugConstants';
import xhr, { NetworkData, ProgressCallback } from '../utils/XhrNetworkInterceptor';
import { reportNetworkLog, isContentTypeNotAllowed } from '../utils/InstabugUtils';
import { NativeInstabug } from '../native/NativeInstabug';

export type { NetworkData };

Expand Down Expand Up @@ -101,3 +102,12 @@ export const apolloLinkRequestHandler: RequestHandler = (operation, forward) =>

return forward(operation);
};

/**
* Sets whether network logs sensitive information should be masked.
* It is disabled by default.
* @param isEnabled
*/
export const setAutoMaskingEnabled = (isEnabled: boolean) => {
NativeInstabug.setAutoMaskingEnabled(isEnabled);
};
1 change: 1 addition & 0 deletions src/native/NativeInstabug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export interface InstabugNativeModule extends NativeModule {
): void;

setNetworkLoggingEnabled(isEnabled: boolean): void;
setAutoMaskingEnabled(isEnabled: boolean): void;

// Repro Steps APIs //
setReproStepsConfig(
Expand Down
1 change: 1 addition & 0 deletions test/mocks/mockInstabug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ const mockInstabug: InstabugNativeModule = {
addFileAttachmentWithDataToReport: jest.fn(),
setNetworkLoggingEnabled: jest.fn(),
willRedirectToStore: jest.fn(),
setAutoMaskingEnabled: jest.fn(),
};

export default mockInstabug;
8 changes: 8 additions & 0 deletions test/modules/NetworkLogger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as NetworkLogger from '../../src/modules/NetworkLogger';
import Interceptor from '../../src/utils/XhrNetworkInterceptor';
import { isContentTypeNotAllowed, reportNetworkLog } from '../../src/utils/InstabugUtils';
import InstabugConstants from '../../src/utils/InstabugConstants';
import { NativeInstabug } from '../../src/native/NativeInstabug';

const clone = <T>(obj: T): T => {
return JSON.parse(JSON.stringify(obj));
Expand Down Expand Up @@ -276,4 +277,11 @@ describe('NetworkLogger Module', () => {

expect(reportNetworkLog).toHaveBeenCalledWith(networkData);
});

it('should call the native method setAutoMaskingEnabled', () => {
NetworkLogger.setAutoMaskingEnabled(true);

expect(NativeInstabug.setAutoMaskingEnabled).toBeCalledTimes(1);
expect(NativeInstabug.setAutoMaskingEnabled).toBeCalledWith(true);
});
});