Skip to content

feat: stop capturing network body #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 10, 2025
Merged
Show file tree
Hide file tree
Changes from all 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
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## [Unreleased](https://github.com/Instabug/Instabug-Flutter/compare/v14.0.0...dev)

### Added

- Add support enable/disable capturing network body. ([#561](https://github.com/Instabug/Instabug-Flutter/pull/561))

## [14.1.0](https://github.com/Instabug/Instabug-Flutter/compare/v14.0.0...v14.1.0) (January 2, 2025)

### Changed
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ android {
}

dependencies {
api 'com.instabug.library:instabug:14.1.0'
api 'com.instabug.library:instabug:14.2.0.6639544-SNAPSHOT'
testImplementation 'junit:junit:4.13.2'
testImplementation "org.mockito:mockito-inline:3.12.1"
testImplementation "io.mockk:mockk:1.13.13"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -492,4 +492,14 @@ public Map<String, Boolean> isW3CFeatureFlagsEnabled() {
public void willRedirectToStore() {
Instabug.willRedirectToStore();
}


@Override
public void setNetworkLogBodyEnabled(@NonNull Boolean isEnabled) {
try {
Instabug.setNetworkLogBodyEnabled(isEnabled);
} catch (Exception e) {
e.printStackTrace();
}
}
}
14 changes: 14 additions & 0 deletions android/src/test/java/com/instabug/flutter/InstabugApiTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -643,4 +643,18 @@ public void isW3CFeatureFlagsEnabled() {
assertEquals(isW3cCaughtHeaderEnabled, flags.get("isW3cCaughtHeaderEnabled"));

}

@Test
public void testSetNetworkLogBodyEnabled() {
api.setNetworkLogBodyEnabled(true);

mInstabug.verify(() -> Instabug.setNetworkLogBodyEnabled(true));
}

@Test
public void testSetNetworkLogBodyDisabled() {
api.setNetworkLogBodyEnabled(false);

mInstabug.verify(() -> Instabug.setNetworkLogBodyEnabled(false));
}
}
9 changes: 9 additions & 0 deletions example/ios/InstabugTests/InstabugApiTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,15 @@ - (void)testWillRedirectToAppStore {
OCMVerify([self.mInstabug willRedirectToAppStore]);
}

- (void)testSetNetworkLogBodyEnabled {
NSNumber *isEnabled = @1;
FlutterError *error;

[self.api setNetworkLogBodyEnabledIsEnabled:isEnabled error:&error];

XCTAssertTrue(IBGNetworkLogger.logBodyEnabled);
}

- (void)testNetworkLogWithW3Caught {
NSString *url = @"https://example.com";
NSString *requestBody = @"hi";
Expand Down
1 change: 1 addition & 0 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe

flutter_ios_podfile_setup
target 'Runner' do
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-stop-network-body-base/14.2.0/Instabug.podspec'
use_frameworks!
use_modular_headers!

Expand Down
14 changes: 8 additions & 6 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
PODS:
- Flutter (1.0.0)
- Instabug (14.1.0)
- Instabug (14.2.0)
- instabug_flutter (14.0.0):
- Flutter
- Instabug (= 14.1.0)
- Instabug (= 14.2.0)
- OCMock (3.6)

DEPENDENCIES:
- Flutter (from `Flutter`)
- Instabug (from `https://ios-releases.instabug.com/custom/feature-stop-network-body-base/14.2.0/Instabug.podspec`)
- instabug_flutter (from `.symlinks/plugins/instabug_flutter/ios`)
- OCMock (= 3.6)

SPEC REPOS:
trunk:
- Instabug
- OCMock

EXTERNAL SOURCES:
Flutter:
:path: Flutter
Instabug:
:podspec: https://ios-releases.instabug.com/custom/feature-stop-network-body-base/14.2.0/Instabug.podspec
instabug_flutter:
:path: ".symlinks/plugins/instabug_flutter/ios"

SPEC CHECKSUMS:
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
Instabug: 8cbca8974168c815658133e2813f5ac3a36f8e20
instabug_flutter: a24751dfaedd29475da2af062d3e19d697438f72
Instabug: fb30e419f172a2c405fad1d2d4c42ae64ea10877
instabug_flutter: d689490b2b63ac341d75a3061ee35edc1c9d8b75
OCMock: 5ea90566be239f179ba766fd9fbae5885040b992

PODFILE CHECKSUM: 8f7552fd115ace1988c3db54a69e4a123c448f84
PODFILE CHECKSUM: 338614a69defdc536fc63f92095b4984aab6080e

COCOAPODS: 1.16.2
5 changes: 4 additions & 1 deletion ios/Classes/Modules/InstabugApi.m
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,9 @@ - (void)registerFeatureFlagChangeListenerWithError:(FlutterError * _Nullable __a
};
return result;
}

- (void)setNetworkLogBodyEnabledIsEnabled:(NSNumber *)isEnabled
error:(FlutterError *_Nullable *_Nonnull)error {
IBGNetworkLogger.logBodyEnabled = [isEnabled boolValue];
}

@end
2 changes: 1 addition & 1 deletion ios/instabug_flutter.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ Pod::Spec.new do |s|
s.pod_target_xcconfig = { 'OTHER_LDFLAGS' => '-framework "Flutter" -framework "Instabug"'}

s.dependency 'Flutter'
s.dependency 'Instabug', '14.1.0'
s.dependency 'Instabug', '14.2.0'
end

6 changes: 6 additions & 0 deletions lib/src/modules/network_logger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,10 @@ class NetworkLogger {
}
return null;
}

/// Enables or disables network body logs capturing.
/// [boolean] isEnabled
static Future<void> setNetworkLogBodyEnabled(bool isEnabled) async {
return _host.setNetworkLogBodyEnabled(isEnabled);
}
}
2 changes: 2 additions & 0 deletions pigeons/instabug.api.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,6 @@ abstract class InstabugHostApi {
Map<String, bool> isW3CFeatureFlagsEnabled();

void willRedirectToStore();

void setNetworkLogBodyEnabled(bool isEnabled);
}
10 changes: 10 additions & 0 deletions test/network_logger_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,14 @@ void main() {
await logger.networkLog(networkData);
expect(networkData.requestHeaders['traceparent'], 'test');
});

test('[setNetworkLogBodyEnabled] should call host method', () async {
const enabled = true;

await NetworkLogger.setNetworkLogBodyEnabled(enabled);

verify(
mInstabugHost.setNetworkLogBodyEnabled(enabled),
).called(1);
});
}