From 2f91165f64ac97bdf2a62fd458af31d044e805e7 Mon Sep 17 00:00:00 2001 From: Abdelhamid Nasser <38096011+abdelhamid-f-nasser@users.noreply.github.com> Date: Thu, 14 Sep 2023 21:20:00 +0300 Subject: [PATCH] fix(ios): disable auto capturing of native network logs (#1018) Jira ID: INSD-9944 --- ios/RNInstabug/InstabugReactBridge.m | 16 +++++++++------- ios/RNInstabug/Util/IBGNetworkLogger+CP.h | 11 +++++++++++ 2 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 ios/RNInstabug/Util/IBGNetworkLogger+CP.h diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index a279b77f1..c9e86dab3 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -16,6 +16,7 @@ #import #import #import +#import "Util/IBGNetworkLogger+CP.h" @interface Instabug (PrivateWillSendAPI) + (void)setWillSendReportHandler_private:(void(^)(IBGReport *report, void(^reportCompletionHandler)(IBGReport *)))willSendReportHandler_private; @@ -53,12 +54,13 @@ - (dispatch_queue_t)methodQueue { for (NSNumber *boxedValue in invocationEventsArray) { invocationEvents |= [boxedValue intValue]; } + [IBGNetworkLogger disableAutomaticCapturingOfNetworkLogs]; [Instabug startWithToken:token invocationEvents:invocationEvents]; [Instabug setSdkDebugLogsLevel:sdkDebugLogsLevel]; RCTAddLogFunction(InstabugReactLogFunction); RCTSetLogThreshold(RCTLogLevelInfo); - + IBGNetworkLogger.enabled = YES; // Temporarily disabling APM hot launches @@ -72,7 +74,7 @@ - (dispatch_queue_t)methodQueue { [[Instabug class] performSelector:setPrivateApiSEL]; } else { [[Instabug class] performSelector:setPrivateApiSEL withObject:param]; - + } } } @@ -349,7 +351,7 @@ - (dispatch_queue_t)methodQueue { int32_t errorCode = [networkData[@"errorCode"] integerValue]; int64_t startTime = [networkData[@"startTime"] integerValue] * 1000; int64_t duration = [networkData[@"duration"] doubleValue] * 1000; - + NSString* gqlQueryName = nil; NSString* serverErrorMessage = nil; if (networkData[@"gqlQueryName"] != [NSNull null]) { @@ -360,12 +362,12 @@ - (dispatch_queue_t)methodQueue { } SEL networkLogSEL = NSSelectorFromString(@"addNetworkLogWithUrl:method:requestBody:requestBodySize:responseBody:responseBodySize:responseCode:requestHeaders:responseHeaders:contentType:errorDomain:errorCode:startTime:duration:gqlQueryName:serverErrorMessage:"); - + if([[IBGNetworkLogger class] respondsToSelector:networkLogSEL]) { NSInvocation *inv = [NSInvocation invocationWithMethodSignature:[[IBGNetworkLogger class] methodSignatureForSelector:networkLogSEL]]; [inv setSelector:networkLogSEL]; [inv setTarget:[IBGNetworkLogger class]]; - + [inv setArgument:&(url) atIndex:2]; [inv setArgument:&(method) atIndex:3]; [inv setArgument:&(requestBody) atIndex:4]; @@ -436,7 +438,7 @@ - (void) setBaseUrlForDeprecationLogs { [inv setTarget:[Instabug class]]; IBGPlatform platform = IBGPlatformReactNative; [inv setArgument:&(platform) atIndex:2]; - + [inv invoke]; } } @@ -469,7 +471,7 @@ void RNIBGLog(IBGLogLevel logLevel, NSString *format, ...) { { NSString *formatString = @"Instabug - REACT LOG: %@"; NSString *log = RCTFormatLog([NSDate date], level, fileName, lineNumber, message); - + switch(level) { case RCTLogLevelTrace: RNIBGLog(IBGLogLevelVerbose, formatString, log); diff --git a/ios/RNInstabug/Util/IBGNetworkLogger+CP.h b/ios/RNInstabug/Util/IBGNetworkLogger+CP.h new file mode 100644 index 000000000..ae5d32d66 --- /dev/null +++ b/ios/RNInstabug/Util/IBGNetworkLogger+CP.h @@ -0,0 +1,11 @@ +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface IBGNetworkLogger (CP) + ++ (void)disableAutomaticCapturingOfNetworkLogs; + +@end + +NS_ASSUME_NONNULL_END