From e02062572ce0f3984102aba4e00849863212c232 Mon Sep 17 00:00:00 2001 From: kholood Date: Mon, 16 Jun 2025 15:11:39 +0300 Subject: [PATCH 1/8] chore(android): bump android sdk to v15.0.1 --- android/build.gradle | 2 +- android/native.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/android/build.gradle b/android/build.gradle index 1093a8f1d..806266ea1 100644 --- a/android/build.gradle +++ b/android/build.gradle @@ -57,7 +57,7 @@ android { minSdkVersion getExtOrDefault('minSdkVersion').toInteger() targetSdkVersion getExtOrDefault('targetSdkVersion').toInteger() versionCode 1 - versionName "14.3.0" + versionName "15.0.1" multiDexEnabled true ndk { abiFilters "armeabi-v7a", "x86" diff --git a/android/native.gradle b/android/native.gradle index 3241dc5f2..faa3246cd 100644 --- a/android/native.gradle +++ b/android/native.gradle @@ -1,5 +1,5 @@ project.ext.instabug = [ - version: '14.3.0' + version: '15.0.1' ] dependencies { From 2ce71a9726a3dbc959241ec74fa41edce71412c3 Mon Sep 17 00:00:00 2001 From: kholood Date: Mon, 16 Jun 2025 15:12:07 +0300 Subject: [PATCH 2/8] chore: bump android sdk to v15.0.1 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a93da7dd3..d39012128 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "instabug-reactnative", "description": "React Native plugin for integrating the Instabug SDK", - "version": "14.3.0", + "version": "15.0.1", "author": "Instabug (https://instabug.com)", "repository": "github:Instabug/Instabug-React-Native", "homepage": "https://www.instabug.com/platforms/react-native", From 0473fa4c4f02730f5be3a7c4f7dd1e1b3189ebfb Mon Sep 17 00:00:00 2001 From: kholood Date: Mon, 16 Jun 2025 16:31:44 +0300 Subject: [PATCH 3/8] chore(ios): bump SDK to v15.1.1 --- RNInstabug.podspec | 3 +-- examples/default/ios/Podfile | 3 +-- examples/default/ios/Podfile.lock | 14 ++++++-------- ios/native.rb | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/RNInstabug.podspec b/RNInstabug.podspec index b571a6c68..af69112cc 100644 --- a/RNInstabug.podspec +++ b/RNInstabug.podspec @@ -16,7 +16,6 @@ Pod::Spec.new do |s| s.source_files = "ios/**/*.{h,m,mm}" s.dependency 'React-Core' - # use_instabug!(s) - s.dependency 'Instabug' + use_instabug!(s) end diff --git a/examples/default/ios/Podfile b/examples/default/ios/Podfile index ea3be9c25..e0715d125 100644 --- a/examples/default/ios/Podfile +++ b/examples/default/ios/Podfile @@ -15,8 +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 - # add this line - pod 'Instabug', :podspec => 'https://ios-releases.instabug.com/custom/sanity/15.0.1/Instabug.podspec' + # Flags change depending on the env values. flags = get_default_flags() diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index 9cde707ae..95c860977 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -31,7 +31,7 @@ PODS: - hermes-engine (0.75.4): - hermes-engine/Pre-built (= 0.75.4) - hermes-engine/Pre-built (0.75.4) - - Instabug (15.0.1) + - Instabug (15.1.1) - instabug-reactnative-ndk (0.1.0): - DoubleConversion - glog @@ -1625,8 +1625,8 @@ PODS: - ReactCommon/turbomodule/bridging - ReactCommon/turbomodule/core - Yoga - - RNInstabug (14.3.0): - - Instabug + - RNInstabug (15.0.1): + - Instabug (= 15.1.1) - React-Core - RNReanimated (3.16.1): - DoubleConversion @@ -1770,7 +1770,6 @@ 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/sanity/15.0.1/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`) @@ -1851,6 +1850,7 @@ SPEC REPOS: trunk: - Google-Maps-iOS-Utils - GoogleMaps + - Instabug - OCMock - SocketRocket @@ -1868,8 +1868,6 @@ 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/sanity/15.0.1/Instabug.podspec instabug-reactnative-ndk: :path: "../node_modules/instabug-reactnative-ndk" RCT-Folly: @@ -2024,7 +2022,7 @@ SPEC CHECKSUMS: Google-Maps-iOS-Utils: f77eab4c4326d7e6a277f8e23a0232402731913a GoogleMaps: 032f676450ba0779bd8ce16840690915f84e57ac hermes-engine: ea92f60f37dba025e293cbe4b4a548fd26b610a0 - Instabug: 9e81b71be68626dafc74759f3458f7c5894dd2e1 + Instabug: 3e7af445c14d7823fcdecba223f09b5f7c0c6ce1 instabug-reactnative-ndk: d765ac289d56e8896398d02760d9abf2562fc641 OCMock: 589f2c84dacb1f5aaf6e4cec1f292551fe748e74 RCT-Folly: 4464f4d875961fce86008d45f4ecf6cef6de0740 @@ -2100,6 +2098,6 @@ SPEC CHECKSUMS: SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6 -PODFILE CHECKSUM: a1b532d67a1a86843e1f086101751ad55afa52da +PODFILE CHECKSUM: 7ba66a1c4b8d3aa601e023d871ce551f5fb63130 COCOAPODS: 1.14.0 diff --git a/ios/native.rb b/ios/native.rb index b09f2fd5f..41f497687 100644 --- a/ios/native.rb +++ b/ios/native.rb @@ -1,4 +1,4 @@ -$instabug = { :version => '15.0.1' } +$instabug = { :version => '15.1.1' } def use_instabug! (spec = nil) version = $instabug[:version] From 8daf577532848b27d85d50fc18f412d2dbbba226 Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 17 Jun 2025 12:34:07 +0300 Subject: [PATCH 4/8] chore: add changelog item --- CHANGELOG.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77f97581f..c562b0798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## [Unreleased](https://github.com/Instabug/Instabug-React-Native/compare/v14.3.0...dev) +## [15.0.1](https://github.com/Instabug/Instabug-React-Native/compare/v14.3.0...v15.0.1) ### Added @@ -12,6 +12,12 @@ - Add support for network spans. ([#1394](https://github.com/Instabug/Instabug-React-Native/pull/1394)) +### Changed + +- Bump Instabug iOS SDK to v15.1.1 ([#1402](https://github.com/Instabug/Instabug-React-Native/pull/1402)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/15.1.1). + +- Bump Instabug Android SDK to v15.0.1 ([#1402](https://github.com/Instabug/Instabug-React-Native/pull/1402)). [See release notes](https://github.com/Instabug/Instabug-Android/releases/tag/v15.0.1). + ### Fixed - Not sending the inComplete xhrRequest. ([#1365](https://github.com/Instabug/Instabug-React-Native/pull/1365)) From 9d2f982e008a08d8f372b14d7001c8ddb4d6c034 Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 17 Jun 2025 12:37:17 +0300 Subject: [PATCH 5/8] chore: fix sync_generated_files CI job --- examples/default/ios/Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index 95c860977..b6e9bb6bc 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -2090,7 +2090,7 @@ SPEC CHECKSUMS: ReactCommon: 6a952e50c2a4b694731d7682aaa6c79bc156e4ad RNCClipboard: 2821ac938ef46f736a8de0c8814845dde2dcbdfb RNGestureHandler: 511250b190a284388f9dd0d2e56c1df76f14cfb8 - RNInstabug: a038636a8fb8e078e69d3c51fca38396fa1ffdab + RNInstabug: f17d4e6c679fbc921f2692c223a1c21395589cc5 RNReanimated: f42a5044d121d68e91680caacb0293f4274228eb RNScreens: c7ceced6a8384cb9be5e7a5e88e9e714401fd958 RNSVG: 8b1a777d54096b8c2a0fd38fc9d5a454332bbb4d From acbeb9c79b352f9ec5f4a656eebd7017c24c5820 Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 1 Jul 2025 15:41:23 +0300 Subject: [PATCH 6/8] chore: fix plugin version --- examples/default/android/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/default/android/build.gradle b/examples/default/android/build.gradle index 5729e78c9..6ca76372e 100644 --- a/examples/default/android/build.gradle +++ b/examples/default/android/build.gradle @@ -24,7 +24,7 @@ buildscript { classpath("com.android.tools.build:gradle:8.1.0") classpath("com.facebook.react:react-native-gradle-plugin") classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion") - classpath("com.instabug.library:instabug-plugin:14.1.0.6273967-SNAPSHOT") + classpath("com.instabug.library:instabug-plugin:15.0.1") } } From 83c5b9e3daddf54e013ca77661bfa774e0cd9ebc Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 1 Jul 2025 15:59:06 +0300 Subject: [PATCH 7/8] 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 256e72abd36e1315bd4d5053ec4be379367e489d, reversing changes made to 196b481b53051e02dabb060d7acba39d122bb063. * 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 ef8710e2887797f1ac0e6d25a5d617ee98a24250. * chore: edit a change log * chore: update test cases titles --- CHANGELOG.md | 2 + .../com/instabug/reactlibrary/Constants.java | 2 +- .../RNInstabugReactnativeModule.java | 28 ++++++-- .../RNInstabugReactnativeModuleTest.java | 17 ++++- .../ios/InstabugTests/InstabugSampleTests.m | 19 ++++++ examples/default/src/App.tsx | 2 +- ios/RNInstabug/InstabugReactBridge.h | 1 + ios/RNInstabug/InstabugReactBridge.m | 4 ++ ios/RNInstabug/Util/IBGNetworkLogger+CP.h | 1 + src/modules/Instabug.ts | 13 ++-- src/modules/NetworkLogger.ts | 28 ++++++-- src/native/NativeInstabug.ts | 7 +- src/utils/FeatureFlags.ts | 11 ++- src/utils/InstabugConstants.ts | 4 +- test/mocks/mockInstabug.ts | 3 +- test/modules/Instabug.spec.ts | 14 ++-- test/modules/NetworkLogger.spec.ts | 67 +++++++++++-------- 17 files changed, 159 insertions(+), 64 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c562b0798..dca024748 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ - Add support for network spans. ([#1394](https://github.com/Instabug/Instabug-React-Native/pull/1394)) +- Add respect to backend network body limit. ([#1397](https://github.com/Instabug/Instabug-React-Native/pull/1397)) + ### Changed - Bump Instabug iOS SDK to v15.1.1 ([#1402](https://github.com/Instabug/Instabug-React-Native/pull/1402)). [See release notes](https://github.com/Instabug/Instabug-iOS/releases/tag/15.1.1). diff --git a/android/src/main/java/com/instabug/reactlibrary/Constants.java b/android/src/main/java/com/instabug/reactlibrary/Constants.java index 9f1a0cf35..f5b584700 100644 --- a/android/src/main/java/com/instabug/reactlibrary/Constants.java +++ b/android/src/main/java/com/instabug/reactlibrary/Constants.java @@ -13,7 +13,7 @@ final class Constants { final static String IBG_ON_FEATURES_UPDATED_CALLBACK = "IBGOnFeatureUpdatedCallback"; final static String IBG_NETWORK_LOGGER_HANDLER = "IBGNetworkLoggerHandler"; - final static String IBG_ON_NEW_W3C_FLAGS_UPDATE_RECEIVED_CALLBACK = "IBGOnNewW3CFlagsUpdateReceivedCallback"; + final static String IBG_ON_FEATURE_FLAGS_UPDATE_RECEIVED_CALLBACK = "IBGOnNewFeatureFlagsUpdateReceivedCallback"; final static String IBG_SESSION_REPLAY_ON_SYNC_CALLBACK_INVOCATION = "IBGSessionReplayOnSyncCallback"; diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 991dc9725..17f48656f 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -1159,10 +1159,10 @@ public void run() { } /** - * Register a listener for W3C flags value change + * Register a listener for feature flags value change */ @ReactMethod - public void registerW3CFlagsChangeListener() { + public void registerFeatureFlagsChangeListener() { MainThreadHandler.runOnMainThread(new Runnable() { @Override @@ -1175,8 +1175,9 @@ public void invoke(@NonNull CoreFeaturesState featuresState) { params.putBoolean("isW3ExternalTraceIDEnabled", featuresState.isW3CExternalTraceIdEnabled()); params.putBoolean("isW3ExternalGeneratedHeaderEnabled", featuresState.isAttachingGeneratedHeaderEnabled()); params.putBoolean("isW3CaughtHeaderEnabled", featuresState.isAttachingCapturedHeaderEnabled()); + params.putInt("networkBodyLimit",featuresState.getNetworkLogCharLimit()); - sendEvent(Constants.IBG_ON_NEW_W3C_FLAGS_UPDATE_RECEIVED_CALLBACK, params); + sendEvent(Constants.IBG_ON_FEATURE_FLAGS_UPDATE_RECEIVED_CALLBACK, params); } }); } catch (Exception e) { @@ -1306,7 +1307,7 @@ public void run() { } }); } - /** + /** * Sets the auto mask screenshots types. * @@ -1331,4 +1332,23 @@ public void run() { }); } + + /** + * Get network body size limit + */ + @ReactMethod + public void getNetworkBodyMaxSize(Promise promise) { + + MainThreadHandler.runOnMainThread(new Runnable() { + @Override + public void run() { + try { + promise.resolve(InternalCore.INSTANCE.get_networkLogCharLimit()); + } catch (Exception e) { + e.printStackTrace(); + promise.resolve(false); + } + } + }); + } } diff --git a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java index 3083410f3..f4f6f9bc1 100644 --- a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java +++ b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java @@ -686,9 +686,22 @@ public void testEnableAutoMasking(){ String maskTextInputs = "textInputs"; String maskMedia = "media"; String maskNone = "none"; - + rnModule.enableAutoMasking(JavaOnlyArray.of(maskLabel, maskMedia, maskTextInputs,maskNone)); - + mockInstabug.verify(() -> Instabug.setAutoMaskScreenshotsTypes(MaskingType.LABELS,MaskingType.MEDIA,MaskingType.TEXT_INPUTS,MaskingType.MASK_NOTHING)); } + + @Test + public void testGetNetworkBodyMaxSize_resolvesPromiseWithExpectedValue() { + Promise promise = mock(Promise.class); + InternalCore internalAPM = mock(InternalCore.class); + int expected = 10240; + when(internalAPM.get_networkLogCharLimit()).thenReturn(expected); + + rnModule.getNetworkBodyMaxSize(promise); + + verify(promise).resolve(expected); + } + } diff --git a/examples/default/ios/InstabugTests/InstabugSampleTests.m b/examples/default/ios/InstabugTests/InstabugSampleTests.m index 76b4cbc0c..ded37c3af 100644 --- a/examples/default/ios/InstabugTests/InstabugSampleTests.m +++ b/examples/default/ios/InstabugTests/InstabugSampleTests.m @@ -634,4 +634,23 @@ - (void)testSetNetworkLogBodyEnabled { OCMVerify([mock setLogBodyEnabled:isEnabled]); } +- (void)testGetNetworkBodyMaxSize { + id mock = OCMClassMock([IBGNetworkLogger class]); + double expectedValue = 10240.0; + + OCMStub([mock getNetworkBodyMaxSize]).andReturn(expectedValue); + + XCTestExpectation *expectation = [self expectationWithDescription:@"Call resolve block"]; + RCTPromiseResolveBlock resolve = ^(NSNumber *result) { + XCTAssertEqual(result.doubleValue, expectedValue); + [expectation fulfill]; + }; + + [self.instabugBridge getNetworkBodyMaxSize:resolve :nil]; + [self waitForExpectationsWithTimeout:1.0 handler:nil]; + + OCMVerify(ClassMethod([mock getNetworkBodyMaxSize])); +} + + @end diff --git a/examples/default/src/App.tsx b/examples/default/src/App.tsx index 122002857..ceef8bc19 100644 --- a/examples/default/src/App.tsx +++ b/examples/default/src/App.tsx @@ -50,7 +50,7 @@ export const App: React.FC = () => { token: 'deb1910a7342814af4e4c9210c786f35', invocationEvents: [InvocationEvent.floatingButton], debugLogsLevel: LogLevel.verbose, - networkInterceptionMode: NetworkInterceptionMode.native, + networkInterceptionMode: NetworkInterceptionMode.javascript, }); CrashReporting.setNDKCrashesEnabled(true); diff --git a/ios/RNInstabug/InstabugReactBridge.h b/ios/RNInstabug/InstabugReactBridge.h index 8d6efcf69..1fe5505d3 100644 --- a/ios/RNInstabug/InstabugReactBridge.h +++ b/ios/RNInstabug/InstabugReactBridge.h @@ -140,5 +140,6 @@ w3cExternalTraceAttributes:(NSDictionary * _Nullable)w3cExternalTraceAttributes; - (void)removeAllFeatureFlags; - (void)setNetworkLogBodyEnabled:(BOOL)isEnabled; - (void)enableAutoMasking:(NSArray *)autoMaskingTypes; +- (void)getNetworkBodyMaxSize:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject; @end diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index a2c75aa55..a48851ba8 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -452,6 +452,10 @@ + (BOOL)iOSVersionIsLessThan:(NSString *)iOSVersion { [Instabug setAutoMaskScreenshots: autoMaskingOptions]; }; +RCT_EXPORT_METHOD(getNetworkBodyMaxSize:(RCTPromiseResolveBlock)resolve :(RCTPromiseRejectBlock)reject) { + resolve(@(IBGNetworkLogger.getNetworkBodyMaxSize)); +} + RCT_EXPORT_METHOD(setNetworkLogBodyEnabled:(BOOL)isEnabled) { IBGNetworkLogger.logBodyEnabled = isEnabled; } diff --git a/ios/RNInstabug/Util/IBGNetworkLogger+CP.h b/ios/RNInstabug/Util/IBGNetworkLogger+CP.h index d0fd44992..b5e923f84 100644 --- a/ios/RNInstabug/Util/IBGNetworkLogger+CP.h +++ b/ios/RNInstabug/Util/IBGNetworkLogger+CP.h @@ -61,6 +61,7 @@ NS_ASSUME_NONNULL_BEGIN + (void)setCPRequestAsyncObfuscationHandler:(void (^)(NSURLRequest * requestToBeObfuscated, void (^ completion)(NSURLRequest * obfuscatedRequest)))asyncObfuscationHandler; + (void)setCPRequestFilteringHandler:(void (^)(NSURLRequest * request, void (^completion)(BOOL keep)))requestFilteringHandler; + (void)setCPResponseFilteringHandler:(void (^)(NSURLResponse * response, void (^comppletion)(BOOL keep)))responseFilteringHandler; ++ (double)getNetworkBodyMaxSize; @end diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts index 1bcd5bf8b..f7d582e70 100644 --- a/src/modules/Instabug.ts +++ b/src/modules/Instabug.ts @@ -16,7 +16,7 @@ import type { NavigationAction, NavigationState as NavigationStateV4 } from 'rea import type { InstabugConfig } from '../models/InstabugConfig'; import Report from '../models/Report'; import { emitter, NativeEvents, NativeInstabug } from '../native/NativeInstabug'; -import { registerW3CFlagsListener } from '../utils/FeatureFlags'; +import { registerFeatureFlagsListener } from '../utils/FeatureFlags'; import { AutoMaskingType, ColorTheme, @@ -87,7 +87,7 @@ function reportCurrentViewForAndroid(screenName: string | null) { export const init = async (config: InstabugConfig) => { if (Platform.OS === 'android') { // Add android feature flags listener for android - registerW3CFlagsListener(); + registerFeatureFlagsListener(); addOnFeatureUpdatedListener(config); } else { isNativeInterceptionFeatureEnabled = await NativeNetworkLogger.isNativeInterceptionEnabled(); @@ -871,20 +871,21 @@ export const componentDidAppearListener = (event: ComponentDidAppearEvent) => { }; /** - * Sets listener to W3ExternalTraceID flag changes + * Sets listener to feature flag changes * @param handler A callback that gets the update value of the flag */ -export const _registerW3CFlagsChangeListener = ( +export const _registerFeatureFlagsChangeListener = ( handler: (payload: { isW3ExternalTraceIDEnabled: boolean; isW3ExternalGeneratedHeaderEnabled: boolean; isW3CaughtHeaderEnabled: boolean; + networkBodyLimit: number; }) => void, ) => { - emitter.addListener(NativeEvents.ON_W3C_FLAGS_CHANGE, (payload) => { + emitter.addListener(NativeEvents.ON_FEATURE_FLAGS_CHANGE, (payload) => { handler(payload); }); - NativeInstabug.registerW3CFlagsChangeListener(); + NativeInstabug.registerFeatureFlagsChangeListener(); }; /** diff --git a/src/modules/NetworkLogger.ts b/src/modules/NetworkLogger.ts index 8de927c66..4bd334f56 100644 --- a/src/modules/NetworkLogger.ts +++ b/src/modules/NetworkLogger.ts @@ -45,7 +45,9 @@ export const setEnabled = (isEnabled: boolean) => { xhr.setOnDoneCallback(async (network) => { // eslint-disable-next-line no-new-func const predicate = Function('network', 'return ' + _requestFilterExpression); + if (!predicate(network)) { + const MAX_NETWORK_BODY_SIZE_IN_BYTES = await NativeInstabug.getNetworkBodyMaxSize(); try { if (_networkDataObfuscationHandler) { network = await _networkDataObfuscationHandler(network); @@ -57,14 +59,28 @@ export const setEnabled = (isEnabled: boolean) => { return; } } - if (network.requestBodySize > InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES) { - network.requestBody = InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE; - Logger.warn('IBG-RN:', InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE); + if (network.requestBodySize > MAX_NETWORK_BODY_SIZE_IN_BYTES) { + network.requestBody = `${InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE}${ + MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024 + } Kb`; + Logger.warn( + 'IBG-RN:', + `${InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE}${ + MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024 + } Kb`, + ); } - if (network.responseBodySize > InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES) { - network.responseBody = InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE; - Logger.warn('IBG-RN:', InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE); + if (network.responseBodySize > MAX_NETWORK_BODY_SIZE_IN_BYTES) { + network.responseBody = `${InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE}${ + MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024 + } Kb`; + Logger.warn( + 'IBG-RN:', + `${InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE}${ + MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024 + } Kb`, + ); } if (network.requestBody && isContentTypeNotAllowed(network.requestContentType)) { diff --git a/src/native/NativeInstabug.ts b/src/native/NativeInstabug.ts index c9204a4c5..7032bbc07 100644 --- a/src/native/NativeInstabug.ts +++ b/src/native/NativeInstabug.ts @@ -152,11 +152,12 @@ export interface InstabugNativeModule extends NativeModule { isW3CaughtHeaderEnabled(): Promise; - // W3C Feature Flags Listener for Android - registerW3CFlagsChangeListener(): void; + // Feature Flags Listener for Android + registerFeatureFlagsChangeListener(): void; setOnFeaturesUpdatedListener(handler?: (params: any) => void): void; // android only enableAutoMasking(autoMaskingTypes: AutoMaskingType[]): void; + getNetworkBodyMaxSize(): Promise; } export const NativeInstabug = NativeModules.Instabug; @@ -164,7 +165,7 @@ export const NativeInstabug = NativeModules.Instabug; export enum NativeEvents { PRESENDING_HANDLER = 'IBGpreSendingHandler', IBG_ON_FEATURES_UPDATED_CALLBACK = 'IBGOnFeatureUpdatedCallback', - ON_W3C_FLAGS_CHANGE = 'IBGOnNewW3CFlagsUpdateReceivedCallback', + ON_FEATURE_FLAGS_CHANGE = 'IBGOnNewFeatureFlagsUpdateReceivedCallback', } export const emitter = new NativeEventEmitter(NativeInstabug); diff --git a/src/utils/FeatureFlags.ts b/src/utils/FeatureFlags.ts index 479ab7ba4..f9c644e99 100644 --- a/src/utils/FeatureFlags.ts +++ b/src/utils/FeatureFlags.ts @@ -1,18 +1,20 @@ import { NativeInstabug } from '../native/NativeInstabug'; -import { _registerW3CFlagsChangeListener } from '../modules/Instabug'; +import { _registerFeatureFlagsChangeListener } from '../modules/Instabug'; export const FeatureFlags = { isW3ExternalTraceID: () => NativeInstabug.isW3ExternalTraceIDEnabled(), isW3ExternalGeneratedHeader: () => NativeInstabug.isW3ExternalGeneratedHeaderEnabled(), isW3CaughtHeader: () => NativeInstabug.isW3CaughtHeaderEnabled(), + networkLogLimit: () => NativeInstabug.getNetworkBodyMaxSize(), }; -export const registerW3CFlagsListener = () => { - _registerW3CFlagsChangeListener( +export const registerFeatureFlagsListener = () => { + _registerFeatureFlagsChangeListener( (res: { isW3ExternalTraceIDEnabled: boolean; isW3ExternalGeneratedHeaderEnabled: boolean; isW3CaughtHeaderEnabled: boolean; + networkBodyLimit: number; }) => { FeatureFlags.isW3ExternalTraceID = async () => { return res.isW3ExternalTraceIDEnabled; @@ -23,6 +25,9 @@ export const registerW3CFlagsListener = () => { FeatureFlags.isW3CaughtHeader = async () => { return res.isW3CaughtHeaderEnabled; }; + FeatureFlags.networkLogLimit = async () => { + return res.networkBodyLimit; + }; }, ); }; diff --git a/src/utils/InstabugConstants.ts b/src/utils/InstabugConstants.ts index 5d576c15b..4d8fca486 100644 --- a/src/utils/InstabugConstants.ts +++ b/src/utils/InstabugConstants.ts @@ -4,9 +4,9 @@ const InstabugConstants = { // TODO: dyanmically get the max size from the native SDK and update the error message to reflect the dynamic size. MAX_NETWORK_BODY_SIZE_IN_BYTES: 1024 * 10, // 10 KB MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE: - 'The response body has not been logged because it exceeds the maximum size of 10 Kb', + 'The response body has not been logged because it exceeds the maximum size of ', MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE: - 'The request body has not been logged because it exceeds the maximum size of 10 Kb', + 'The request body has not been logged because it exceeds the maximum size of ', SET_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE: 'IBG-RN: Expected key and value passed to setUserAttribute to be of type string', REMOVE_USER_ATTRIBUTES_ERROR_TYPE_MESSAGE: diff --git a/test/mocks/mockInstabug.ts b/test/mocks/mockInstabug.ts index 05d817b35..391a00a38 100644 --- a/test/mocks/mockInstabug.ts +++ b/test/mocks/mockInstabug.ts @@ -72,10 +72,11 @@ const mockInstabug: InstabugNativeModule = { isW3ExternalTraceIDEnabled: jest.fn(), isW3ExternalGeneratedHeaderEnabled: jest.fn(), isW3CaughtHeaderEnabled: jest.fn(), - registerW3CFlagsChangeListener: jest.fn(), + registerFeatureFlagsChangeListener: jest.fn(), setNetworkLogBodyEnabled: jest.fn(), setOnFeaturesUpdatedListener: jest.fn(), enableAutoMasking: jest.fn(), + getNetworkBodyMaxSize: jest.fn().mockResolvedValue(10240), // 10 KB }; export default mockInstabug; diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts index 904cefb7d..f6e36d8e4 100644 --- a/test/modules/Instabug.spec.ts +++ b/test/modules/Instabug.spec.ts @@ -900,19 +900,19 @@ describe('Instabug Module', () => { expect(NativeInstabug.willRedirectToStore).toBeCalledTimes(1); }); - it('should register W3C flag listener', async () => { + it('should register feature flag listener', async () => { const callback = jest.fn(); - Instabug._registerW3CFlagsChangeListener(callback); + Instabug._registerFeatureFlagsChangeListener(callback); - expect(NativeInstabug.registerW3CFlagsChangeListener).toBeCalledTimes(1); + expect(NativeInstabug.registerFeatureFlagsChangeListener).toBeCalledTimes(1); }); - it('should invoke callback on emitting the event IBGOnNewW3CFlagsUpdateReceivedCallback', () => { + it('should invoke callback on emitting the event IBGOnNewFeatureFlagsUpdateReceivedCallback', () => { const callback = jest.fn(); - Instabug._registerW3CFlagsChangeListener(callback); - emitter.emit(NativeEvents.ON_W3C_FLAGS_CHANGE); + Instabug._registerFeatureFlagsChangeListener(callback); + emitter.emit(NativeEvents.ON_FEATURE_FLAGS_CHANGE); - expect(emitter.listenerCount(NativeEvents.ON_W3C_FLAGS_CHANGE)).toBe(1); + expect(emitter.listenerCount(NativeEvents.ON_FEATURE_FLAGS_CHANGE)).toBe(1); expect(callback).toHaveBeenCalled(); }); diff --git a/test/modules/NetworkLogger.spec.ts b/test/modules/NetworkLogger.spec.ts index be567b8d1..3c95024a5 100644 --- a/test/modules/NetworkLogger.spec.ts +++ b/test/modules/NetworkLogger.spec.ts @@ -77,22 +77,23 @@ describe('NetworkLogger Module', () => { expect(Interceptor.disableInterception).toBeCalledTimes(1); }); - it('should report the network log', () => { + it('should report the network log', async () => { Interceptor.setOnDoneCallback = jest .fn() - .mockImplementation((callback) => callback(clone(network))); + .mockImplementation(async (callback) => await callback(clone(network))); - NetworkLogger.setEnabled(true); + await NetworkLogger.setEnabled(true); expect(reportNetworkLog).toBeCalledTimes(1); expect(reportNetworkLog).toBeCalledWith(network); + expect(NativeInstabug.getNetworkBodyMaxSize).toBeCalledTimes(1); }); it('should send log network when setNetworkDataObfuscationHandler is set', async () => { const randomString = '28930q938jqhd'; Interceptor.setOnDoneCallback = jest .fn() - .mockImplementation((callback) => callback(clone(network))); + .mockImplementation(async (callback) => await callback(clone(network))); NetworkLogger.setNetworkDataObfuscationHandler((networkData) => { networkData.requestHeaders.token = randomString; return Promise.resolve(networkData); @@ -168,7 +169,7 @@ describe('NetworkLogger Module', () => { consoleSpy.mockRestore(); }); - it('should omit request body if its content type is not allowed', () => { + it('should omit request body if its content type is not allowed', async () => { const consoleWarn = jest.spyOn(Logger, 'warn').mockImplementation(); jest.mocked(isContentTypeNotAllowed).mockReturnValueOnce(true); @@ -179,9 +180,9 @@ describe('NetworkLogger Module', () => { Interceptor.setOnDoneCallback = jest .fn() - .mockImplementation((callback) => callback(networkData)); + .mockImplementation(async (callback) => await callback(networkData)); - NetworkLogger.setEnabled(true); + await NetworkLogger.setEnabled(true); expect(reportNetworkLog).toHaveBeenCalledWith({ ...networkData, @@ -193,7 +194,7 @@ describe('NetworkLogger Module', () => { consoleWarn.mockRestore(); }); - it('should omit response body if its content type is not allowed', () => { + it('should omit response body if its content type is not allowed', async () => { const consoleWarn = jest.spyOn(Logger, 'warn').mockImplementation(); jest.mocked(isContentTypeNotAllowed).mockReturnValueOnce(true); @@ -204,9 +205,9 @@ describe('NetworkLogger Module', () => { Interceptor.setOnDoneCallback = jest .fn() - .mockImplementation((callback) => callback(networkData)); + .mockImplementation(async (callback) => await callback(networkData)); - NetworkLogger.setEnabled(true); + await NetworkLogger.setEnabled(true); expect(reportNetworkLog).toHaveBeenCalledWith({ ...networkData, @@ -218,23 +219,26 @@ describe('NetworkLogger Module', () => { consoleWarn.mockRestore(); }); - it('should omit request body if its size exceeds the maximum allowed size', () => { + it('should omit request body if its size exceeds the maximum allowed size', async () => { const consoleWarn = jest.spyOn(Logger, 'warn').mockImplementation(); + const MAX_NETWORK_BODY_SIZE_IN_BYTES = await NativeInstabug.getNetworkBodyMaxSize(); const networkData = { ...network, - requestBodySize: InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES + 1, + requestBodySize: MAX_NETWORK_BODY_SIZE_IN_BYTES + 1, }; Interceptor.setOnDoneCallback = jest .fn() - .mockImplementation((callback) => callback(networkData)); + .mockImplementation(async (callback) => await callback(networkData)); - NetworkLogger.setEnabled(true); + await NetworkLogger.setEnabled(true); expect(reportNetworkLog).toHaveBeenCalledWith({ ...networkData, - requestBody: InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE, + requestBody: `${InstabugConstants.MAX_REQUEST_BODY_SIZE_EXCEEDED_MESSAGE}${ + MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024 + } Kb`, }); expect(consoleWarn).toBeCalledTimes(1); @@ -242,38 +246,43 @@ describe('NetworkLogger Module', () => { consoleWarn.mockRestore(); }); - it('should not omit request body if its size does not exceed the maximum allowed size', () => { + it('should not omit request body if its size does not exceed the maximum allowed size', async () => { + const MAX_NETWORK_BODY_SIZE_IN_BYTES = await NativeInstabug.getNetworkBodyMaxSize(); + const networkData = { ...network, - requestBodySize: InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES, + requestBodySize: MAX_NETWORK_BODY_SIZE_IN_BYTES, }; Interceptor.setOnDoneCallback = jest .fn() - .mockImplementation((callback) => callback(networkData)); + .mockImplementation(async (callback) => await callback(networkData)); - NetworkLogger.setEnabled(true); + await NetworkLogger.setEnabled(true); expect(reportNetworkLog).toHaveBeenCalledWith(networkData); }); - it('should omit response body if its size exceeds the maximum allowed size', () => { + it('should omit response body if its size exceeds the maximum allowed size', async () => { const consoleWarn = jest.spyOn(Logger, 'warn').mockImplementation(); + const MAX_NETWORK_BODY_SIZE_IN_BYTES = await NativeInstabug.getNetworkBodyMaxSize(); const networkData = { ...network, - responseBodySize: InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES + 1, + responseBodySize: MAX_NETWORK_BODY_SIZE_IN_BYTES + 1, }; Interceptor.setOnDoneCallback = jest .fn() - .mockImplementation((callback) => callback(networkData)); + .mockImplementation(async (callback) => await callback(networkData)); - NetworkLogger.setEnabled(true); + await NetworkLogger.setEnabled(true); expect(reportNetworkLog).toHaveBeenCalledWith({ ...networkData, - responseBody: InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE, + responseBody: `${InstabugConstants.MAX_RESPONSE_BODY_SIZE_EXCEEDED_MESSAGE}${ + MAX_NETWORK_BODY_SIZE_IN_BYTES / 1024 + } Kb`, }); expect(consoleWarn).toBeCalledTimes(1); @@ -281,17 +290,19 @@ describe('NetworkLogger Module', () => { consoleWarn.mockRestore(); }); - it('should not omit response body if its size does not exceed the maximum allowed size', () => { + it('should not omit response body if its size does not exceed the maximum allowed size', async () => { + const MAX_NETWORK_BODY_SIZE_IN_BYTES = await NativeInstabug.getNetworkBodyMaxSize(); + const networkData = { ...network, - responseBodySize: InstabugConstants.MAX_NETWORK_BODY_SIZE_IN_BYTES, + responseBodySize: MAX_NETWORK_BODY_SIZE_IN_BYTES, }; Interceptor.setOnDoneCallback = jest .fn() - .mockImplementation((callback) => callback(networkData)); + .mockImplementation(async (callback) => await callback(networkData)); - NetworkLogger.setEnabled(true); + await NetworkLogger.setEnabled(true); expect(reportNetworkLog).toHaveBeenCalledWith(networkData); }); From 8a1d095133434fc6960c637b88868aaf4d25dfeb Mon Sep 17 00:00:00 2001 From: kholood Date: Tue, 1 Jul 2025 16:51:12 +0300 Subject: [PATCH 8/8] chore: fix CI job --- examples/default/ios/Podfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/default/ios/Podfile.lock b/examples/default/ios/Podfile.lock index b6e9bb6bc..0d7d7a1ff 100644 --- a/examples/default/ios/Podfile.lock +++ b/examples/default/ios/Podfile.lock @@ -2098,6 +2098,6 @@ SPEC CHECKSUMS: SocketRocket: abac6f5de4d4d62d24e11868d7a2f427e0ef940d Yoga: 055f92ad73f8c8600a93f0e25ac0b2344c3b07e6 -PODFILE CHECKSUM: 7ba66a1c4b8d3aa601e023d871ce551f5fb63130 +PODFILE CHECKSUM: 837b933596e1616ff02cc206bb17dee4f611fdbc COCOAPODS: 1.14.0