Skip to content

Commit c668f3b

Browse files
authored
feat: respect be network body limit (#1397)
* chore(ios): add respect BE network body limit custom build * feat(ios): add getNetworkBodyMaxSize API * feat:add getNetworkBodyMaxSize API * chore(android): add respect network body limit snapshot * chore(ios): sync pdfile.lock * Revert "Merge pull request #1388 from Instabug/refactor/replace-reflection" This reverts commit 256e72a, reversing changes made to 196b481. * feat(android): add getNetworkBodyMaxSize API * feat:add feature flag change listener for android * chore: fix sync_generated_files CI job * feat(ios): add getNetworkBodyMaxSize API * chore: add change log * Revert duplicate "feat(ios): add getNetworkBodyMaxSize API" This reverts commit ef8710e. * chore: edit a change log * chore: update test cases titles
1 parent bea6429 commit c668f3b

File tree

21 files changed

+166
-71
lines changed

21 files changed

+166
-71
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
- Add support for network spans. ([#1394](https://github.com/Instabug/Instabug-React-Native/pull/1394))
1414

15+
- Add respect to backend network body limit. ([#1397](https://github.com/Instabug/Instabug-React-Native/pull/1397))
16+
1517
### Fixed
1618

1719
- Not sending the inComplete xhrRequest. ([#1365](https://github.com/Instabug/Instabug-React-Native/pull/1365))

android/native.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
project.ext.instabug = [
2-
version: '14.3.0'
2+
version: '14.3.0.6760192-SNAPSHOT'
33
]
44

55
dependencies {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ final class Constants {
1313
final static String IBG_ON_FEATURES_UPDATED_CALLBACK = "IBGOnFeatureUpdatedCallback";
1414
final static String IBG_NETWORK_LOGGER_HANDLER = "IBGNetworkLoggerHandler";
1515

16-
final static String IBG_ON_NEW_W3C_FLAGS_UPDATE_RECEIVED_CALLBACK = "IBGOnNewW3CFlagsUpdateReceivedCallback";
16+
final static String IBG_ON_FEATURE_FLAGS_UPDATE_RECEIVED_CALLBACK = "IBGOnNewFeatureFlagsUpdateReceivedCallback";
1717

1818
final static String IBG_SESSION_REPLAY_ON_SYNC_CALLBACK_INVOCATION = "IBGSessionReplayOnSyncCallback";
1919

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

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1159,10 +1159,10 @@ public void run() {
11591159
}
11601160

11611161
/**
1162-
* Register a listener for W3C flags value change
1162+
* Register a listener for feature flags value change
11631163
*/
11641164
@ReactMethod
1165-
public void registerW3CFlagsChangeListener() {
1165+
public void registerFeatureFlagsChangeListener() {
11661166

11671167
MainThreadHandler.runOnMainThread(new Runnable() {
11681168
@Override
@@ -1175,8 +1175,9 @@ public void invoke(@NonNull CoreFeaturesState featuresState) {
11751175
params.putBoolean("isW3ExternalTraceIDEnabled", featuresState.isW3CExternalTraceIdEnabled());
11761176
params.putBoolean("isW3ExternalGeneratedHeaderEnabled", featuresState.isAttachingGeneratedHeaderEnabled());
11771177
params.putBoolean("isW3CaughtHeaderEnabled", featuresState.isAttachingCapturedHeaderEnabled());
1178+
params.putInt("networkBodyLimit",featuresState.getNetworkLogCharLimit());
11781179

1179-
sendEvent(Constants.IBG_ON_NEW_W3C_FLAGS_UPDATE_RECEIVED_CALLBACK, params);
1180+
sendEvent(Constants.IBG_ON_FEATURE_FLAGS_UPDATE_RECEIVED_CALLBACK, params);
11801181
}
11811182
});
11821183
} catch (Exception e) {
@@ -1306,7 +1307,7 @@ public void run() {
13061307
}
13071308
});
13081309
}
1309-
/**
1310+
13101311
/**
13111312
* Sets the auto mask screenshots types.
13121313
*
@@ -1331,4 +1332,23 @@ public void run() {
13311332

13321333
});
13331334
}
1335+
1336+
/**
1337+
* Get network body size limit
1338+
*/
1339+
@ReactMethod
1340+
public void getNetworkBodyMaxSize(Promise promise) {
1341+
1342+
MainThreadHandler.runOnMainThread(new Runnable() {
1343+
@Override
1344+
public void run() {
1345+
try {
1346+
promise.resolve(InternalCore.INSTANCE.get_networkLogCharLimit());
1347+
} catch (Exception e) {
1348+
e.printStackTrace();
1349+
promise.resolve(false);
1350+
}
1351+
}
1352+
});
1353+
}
13341354
}

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -686,9 +686,22 @@ public void testEnableAutoMasking(){
686686
String maskTextInputs = "textInputs";
687687
String maskMedia = "media";
688688
String maskNone = "none";
689-
689+
690690
rnModule.enableAutoMasking(JavaOnlyArray.of(maskLabel, maskMedia, maskTextInputs,maskNone));
691-
691+
692692
mockInstabug.verify(() -> Instabug.setAutoMaskScreenshotsTypes(MaskingType.LABELS,MaskingType.MEDIA,MaskingType.TEXT_INPUTS,MaskingType.MASK_NOTHING));
693693
}
694+
695+
@Test
696+
public void testGetNetworkBodyMaxSize_resolvesPromiseWithExpectedValue() {
697+
Promise promise = mock(Promise.class);
698+
InternalCore internalAPM = mock(InternalCore.class);
699+
int expected = 10240;
700+
when(internalAPM.get_networkLogCharLimit()).thenReturn(expected);
701+
702+
rnModule.getNetworkBodyMaxSize(promise);
703+
704+
verify(promise).resolve(expected);
705+
}
706+
694707
}

examples/default/android/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ buildscript {
2424
classpath("com.android.tools.build:gradle:8.1.0")
2525
classpath("com.facebook.react:react-native-gradle-plugin")
2626
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion")
27-
classpath("com.instabug.library:instabug-plugin:14.1.0.6273967-SNAPSHOT")
27+
classpath("com.instabug.library:instabug-plugin:14.3.0.6760192-SNAPSHOT")
2828
}
2929
}
3030

examples/default/ios/InstabugTests/InstabugSampleTests.m

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -634,4 +634,23 @@ - (void)testSetNetworkLogBodyEnabled {
634634
OCMVerify([mock setLogBodyEnabled:isEnabled]);
635635
}
636636

637+
- (void)testGetNetworkBodyMaxSize {
638+
id mock = OCMClassMock([IBGNetworkLogger class]);
639+
double expectedValue = 10240.0;
640+
641+
OCMStub([mock getNetworkBodyMaxSize]).andReturn(expectedValue);
642+
643+
XCTestExpectation *expectation = [self expectationWithDescription:@"Call resolve block"];
644+
RCTPromiseResolveBlock resolve = ^(NSNumber *result) {
645+
XCTAssertEqual(result.doubleValue, expectedValue);
646+
[expectation fulfill];
647+
};
648+
649+
[self.instabugBridge getNetworkBodyMaxSize:resolve :nil];
650+
[self waitForExpectationsWithTimeout:1.0 handler:nil];
651+
652+
OCMVerify(ClassMethod([mock getNetworkBodyMaxSize]));
653+
}
654+
655+
637656
@end

examples/default/ios/Podfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ target 'InstabugExample' do
1616
rn_maps_path = '../node_modules/react-native-maps'
1717
pod 'react-native-google-maps', :path => rn_maps_path
1818
# add this line
19-
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/sanity/15.0.1/Instabug.podspec'
19+
pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/feature-expose_network_limit-expose_body_limit/15.0.1/Instabug.podspec'
2020
# Flags change depending on the env values.
2121
flags = get_default_flags()
2222

examples/default/ios/Podfile.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,7 +1770,7 @@ DEPENDENCIES:
17701770
- fmt (from `../node_modules/react-native/third-party-podspecs/fmt.podspec`)
17711771
- glog (from `../node_modules/react-native/third-party-podspecs/glog.podspec`)
17721772
- hermes-engine (from `../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec`)
1773-
- Instabug (from `https://ios-releases.instabug.com/custom/sanity/15.0.1/Instabug.podspec`)
1773+
- Instabug (from `https://ios-releases.instabug.com/custom/feature-expose_network_limit-expose_body_limit/15.0.1/Instabug.podspec`)
17741774
- instabug-reactnative-ndk (from `../node_modules/instabug-reactnative-ndk`)
17751775
- OCMock
17761776
- RCT-Folly (from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`)
@@ -1869,7 +1869,7 @@ EXTERNAL SOURCES:
18691869
:podspec: "../node_modules/react-native/sdks/hermes-engine/hermes-engine.podspec"
18701870
:tag: hermes-2024-08-15-RNv0.75.1-4b3bf912cc0f705b51b71ce1a5b8bd79b93a451b
18711871
Instabug:
1872-
:podspec: https://ios-releases.instabug.com/custom/sanity/15.0.1/Instabug.podspec
1872+
:podspec: https://ios-releases.instabug.com/custom/feature-expose_network_limit-expose_body_limit/15.0.1/Instabug.podspec
18731873
instabug-reactnative-ndk:
18741874
:path: "../node_modules/instabug-reactnative-ndk"
18751875
RCT-Folly:
@@ -2024,7 +2024,7 @@ SPEC CHECKSUMS:
20242024
Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a
20252025
GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac
20262026
hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0
2027-
Instabug: 9e81b71be68626dafc74759f3458f7c5894dd2e1
2027+
Instabug: ba6587d15ad5e3ffa265afc8174ff83af4eed29d
20282028
instabug-reactnative-ndk: d765ac289d56e8896398d02760d9abf2562fc641
20292029
OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74
20302030
RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740
@@ -2100,6 +2100,6 @@ SPEC CHECKSUMS:
21002100
SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d
21012101
Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6
21022102

2103-
PODFILE CHECKSUM: a1b532d67a1a86843e1f086101751ad55afa52da
2103+
PODFILE CHECKSUM: f7f8d2b03a0b566cb0f5b4b422469af0a1a278b1
21042104

21052105
COCOAPODS: 1.14.0

examples/default/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export const App: React.FC = () => {
5050
token: 'deb1910a7342814af4e4c9210c786f35',
5151
invocationEvents: [InvocationEvent.floatingButton],
5252
debugLogsLevel: LogLevel.verbose,
53-
networkInterceptionMode: NetworkInterceptionMode.native,
53+
networkInterceptionMode: NetworkInterceptionMode.javascript,
5454
});
5555

5656
CrashReporting.setNDKCrashesEnabled(true);

0 commit comments

Comments
 (0)