Skip to content

Commit faf8688

Browse files
committed
feat: stop capturing network body
1 parent 461eee5 commit faf8688

File tree

11 files changed

+92
-1
lines changed

11 files changed

+92
-1
lines changed

.lh/examples/default/ios/Podfile.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"sourceFile": "examples/default/ios/Podfile",
3+
"activeCommit": 0,
4+
"commits": [
5+
{
6+
"activePatchIndex": 0,
7+
"patches": [
8+
{
9+
"date": 1744018366442,
10+
"content": "Index: \n===================================================================\n--- \n+++ \n"
11+
}
12+
],
13+
"date": 1744018366442,
14+
"name": "Commit-0",
15+
"content": "require_relative '../node_modules/react-native/scripts/react_native_pods'\n\nrequire_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'\n\nplatform :ios, '13.4'\nprepare_react_native_project!\n\nlinkage = ENV['USE_FRAMEWORKS']\nif linkage != nil\n Pod::UI.puts \"Configuring Pod with #{linkage}ally linked Frameworks\".green\n use_frameworks! :linkage => linkage.to_sym\nend\n\ntarget 'InstabugExample' do\n config = use_native_modules!\n rn_maps_path = '../node_modules/react-native-maps'\n pod 'react-native-google-maps', :path => rn_maps_path\n # Flags change depending on the env values.\n flags = get_default_flags()\n\n use_react_native!(\n :path => config[:reactNativePath],\n # Hermes is now enabled by default. Disable by setting this flag to false.\n # Upcoming versions of React Native may rely on get_default_flags(), but\n # we make it explicit here to aid in the React Native upgrade process.\n :hermes_enabled => flags[:hermes_enabled],\n :fabric_enabled => flags[:fabric_enabled],\n # An absolute path to your application root.\n :app_path => \"#{Pod::Config.instance.installation_root}/..\"\n )\n\n target 'InstabugTests' do\n inherit! :complete\n pod 'OCMock'\n end\n\n post_install do |installer|\n react_native_post_install(\n installer,\n # Set `mac_catalyst_enabled` to `true` in order to apply patches\n # necessary for Mac Catalyst builds\n :mac_catalyst_enabled => false\n )\n end\nend\n"
16+
}
17+
]
18+
}

.lh/examples/default/ios/Podfile.lock.json

Lines changed: 34 additions & 0 deletions
Large diffs are not rendered by default.

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -675,5 +675,15 @@ public void testEnableAutoMasking(){
675675
rnModule.enableAutoMasking(JavaOnlyArray.of(maskLabel, maskMedia, maskTextInputs,maskNone));
676676

677677
mockInstabug.verify(() -> Instabug.setAutoMaskScreenshotsTypes(MaskingType.LABELS,MaskingType.MEDIA,MaskingType.TEXT_INPUTS,MaskingType.MASK_NOTHING));
678+
@Test
679+
public void testSetNetworkLogBodyEnabled() {
680+
rnModule.setNetworkLogBodyEnabled(true);
681+
mockInstabug.verify(() -> Instabug.setNetworkLogBodyEnabled(true));
682+
}
683+
684+
@Test
685+
public void testSetNetworkLogBodyDisables() {
686+
rnModule.setNetworkLogBodyEnabled(false);
687+
mockInstabug.verify(() -> Instabug.setNetworkLogBodyEnabled(false));
678688
}
679689
}

examples/default/ios/InstabugTests/InstabugSampleTests.m

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,13 @@ - (void)testEnableAutoMasking {
623623
[self.instabugBridge enableAutoMasking:autoMaskingTypes];
624624

625625
OCMVerify([mock setAutoMaskScreenshots:IBGAutoMaskScreenshotOptionLabels | IBGAutoMaskScreenshotOptionTextInputs | IBGAutoMaskScreenshotOptionMedia | IBGAutoMaskScreenshotOptionMaskNothing]);
626+
- (void)testSetNetworkLogBodyEnabled {
627+
id mock = OCMClassMock([IBGNetworkLogger class]);
628+
BOOL isEnabled = YES;
629+
630+
OCMStub([mock setLogBodyEnabled:isEnabled]);
631+
[self.instabugBridge setNetworkLogBodyEnabled:isEnabled];
632+
OCMVerify([mock setLogBodyEnabled:isEnabled]);
626633
}
627634

628635
@end

examples/default/ios/Podfile.lock

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,6 @@ SPEC REPOS:
18471847
trunk:
18481848
- Google-Maps-iOS-Utils
18491849
- GoogleMaps
1850-
- Instabug
18511850
- OCMock
18521851
- SocketRocket
18531852

ios/RNInstabug/InstabugReactBridge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,5 +139,6 @@ w3cExternalTraceAttributes:(NSDictionary * _Nullable)w3cExternalTraceAttributes;
139139
- (void)removeFeatureFlags:(NSArray *)featureFlags;
140140
- (void)removeAllFeatureFlags;
141141
- (void)enableAutoMasking:(NSArray *)autoMaskingTypes;
142+
- (void)setNetworkLogBodyEnabled:(BOOL)isEnabled;
142143

143144
@end

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,4 +451,7 @@ + (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion {
451451
[Instabug setAutoMaskScreenshots: autoMaskingOptions];
452452

453453
};
454+
RCT_EXPORT_METHOD(setNetworkLogBodyEnabled:(BOOL)isEnabled) {
455+
IBGNetworkLogger.logBodyEnabled = isEnabled;
456+
}
454457
@end

src/modules/NetworkLogger.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import xhr, { NetworkData, ProgressCallback } from '../utils/XhrNetworkIntercept
55
import { isContentTypeNotAllowed, reportNetworkLog } from '../utils/InstabugUtils';
66
import { InstabugRNConfig } from '../utils/config';
77
import { Logger } from '../utils/logger';
8+
import { NativeInstabug } from '../native/NativeInstabug';
89

910
export type { NetworkData };
1011

@@ -114,3 +115,11 @@ export const apolloLinkRequestHandler: RequestHandler = (operation, forward) =>
114115

115116
return forward(operation);
116117
};
118+
119+
/**
120+
* Sets whether network body logs will be captured or not.
121+
* @param isEnabled
122+
*/
123+
export const setNetworkLogBodyEnabled = (isEnabled: boolean) => {
124+
NativeInstabug.setNetworkLogBodyEnabled(isEnabled);
125+
};

src/native/NativeInstabug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ export interface InstabugNativeModule extends NativeModule {
7373
): void;
7474

7575
setNetworkLoggingEnabled(isEnabled: boolean): void;
76+
setNetworkLogBodyEnabled(isEnabled: boolean): void;
7677

7778
// Repro Steps APIs //
7879
setReproStepsConfig(

test/mocks/mockInstabug.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const mockInstabug: InstabugNativeModule = {
7474
isW3CaughtHeaderEnabled: jest.fn(),
7575
registerW3CFlagsChangeListener: jest.fn(),
7676
enableAutoMasking: jest.fn(),
77+
setNetworkLogBodyEnabled: jest.fn(),
7778
};
7879

7980
export default mockInstabug;

0 commit comments

Comments
 (0)