diff --git a/Sentry.xcodeproj/project.pbxproj b/Sentry.xcodeproj/project.pbxproj index d9b882c183b..c4fe3a79665 100644 --- a/Sentry.xcodeproj/project.pbxproj +++ b/Sentry.xcodeproj/project.pbxproj @@ -164,8 +164,6 @@ 630C01941EC3402C00C52CEF /* SentryKSCrashReportConverterTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 630C01931EC3402C00C52CEF /* SentryKSCrashReportConverterTests.m */; }; 630C01961EC341D600C52CEF /* Resources in Resources */ = {isa = PBXBuildFile; fileRef = 630C01951EC341D600C52CEF /* Resources */; }; 631501BB1EE6F30B00512C5B /* SentrySwizzleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 631501BA1EE6F30B00512C5B /* SentrySwizzleTests.m */; }; - 631E6D331EBC679C00712345 /* SentryQueueableRequestManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 631E6D311EBC679C00712345 /* SentryQueueableRequestManager.h */; }; - 631E6D341EBC679C00712345 /* SentryQueueableRequestManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 631E6D321EBC679C00712345 /* SentryQueueableRequestManager.m */; }; 632331F62404FFA8008D91D6 /* SentryScopeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 632331F52404FFA8008D91D6 /* SentryScopeTests.m */; }; 632331F9240506DF008D91D6 /* SentryScope+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = 632331F7240506DF008D91D6 /* SentryScope+Private.h */; }; 63295AF51EF3C7DB002D4490 /* SentryNSDictionarySanitize.h in Headers */ = {isa = PBXBuildFile; fileRef = 63295AF31EF3C7DB002D4490 /* SentryNSDictionarySanitize.h */; settings = {ATTRIBUTES = (Private, ); }; }; @@ -508,7 +506,6 @@ 7BAF3DCE243DCBFE008A5414 /* SentryTransportFactory.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BAF3DCD243DCBFE008A5414 /* SentryTransportFactory.m */; }; 7BAF3DD2243DD05C008A5414 /* SentryTransportInitializerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BAF3DD1243DD05C008A5414 /* SentryTransportInitializerTests.swift */; }; 7BAF3DD4243DD40F008A5414 /* SentryTransportFactory.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BAF3DD3243DD40F008A5414 /* SentryTransportFactory.h */; }; - 7BAF3DD92440AEC8008A5414 /* SentryRequestManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 7BAF3DD82440AEC8008A5414 /* SentryRequestManager.h */; }; 7BB42EF124F3B7B700D7B39A /* SentrySession+Equality.m in Sources */ = {isa = PBXBuildFile; fileRef = 7BB42EF024F3B7B700D7B39A /* SentrySession+Equality.m */; }; 7BB6550D253EEB3900887E87 /* SentryUserFeedbackTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BB6550C253EEB3900887E87 /* SentryUserFeedbackTests.swift */; }; 7BB7E7C729267A28004BF96B /* EmptyIntegration.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7BB7E7C629267A28004BF96B /* EmptyIntegration.swift */; }; @@ -1068,6 +1065,8 @@ FA67DD182DDBD4EA00896B02 /* UIImageHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCED2DDBD4EA00896B02 /* UIImageHelper.swift */; }; FA67DD192DDBD4EA00896B02 /* SwizzleClassNameExclude.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA67DCD52DDBD4EA00896B02 /* SwizzleClassNameExclude.swift */; }; FA8A36182DEAA1EB0058D883 /* SentryThread+Private.h in Headers */ = {isa = PBXBuildFile; fileRef = FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */; }; + FA90FAA22E06503E008CAAE8 /* SentryQueueableRequestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA90FAA12E065038008CAAE8 /* SentryQueueableRequestManager.swift */; }; + FA90FAA42E0654D2008CAAE8 /* RequestManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = FA90FAA32E0654CB008CAAE8 /* RequestManager.swift */; }; FAEC270E2DF3526000878871 /* SentryUserFeedback.swift in Sources */ = {isa = PBXBuildFile; fileRef = FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */; }; FAEC273D2DF3933A00878871 /* NSData+Unzip.m in Sources */ = {isa = PBXBuildFile; fileRef = FAEC273C2DF3933200878871 /* NSData+Unzip.m */; }; /* End PBXBuildFile section */ @@ -1314,8 +1313,6 @@ 630C01931EC3402C00C52CEF /* SentryKSCrashReportConverterTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryKSCrashReportConverterTests.m; sourceTree = ""; }; 630C01951EC341D600C52CEF /* Resources */ = {isa = PBXFileReference; lastKnownFileType = folder; path = Resources; sourceTree = ""; }; 631501BA1EE6F30B00512C5B /* SentrySwizzleTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentrySwizzleTests.m; sourceTree = ""; }; - 631E6D311EBC679C00712345 /* SentryQueueableRequestManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SentryQueueableRequestManager.h; path = include/SentryQueueableRequestManager.h; sourceTree = ""; }; - 631E6D321EBC679C00712345 /* SentryQueueableRequestManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SentryQueueableRequestManager.m; sourceTree = ""; }; 632331F52404FFA8008D91D6 /* SentryScopeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SentryScopeTests.m; sourceTree = ""; }; 632331F7240506DF008D91D6 /* SentryScope+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryScope+Private.h"; path = "include/SentryScope+Private.h"; sourceTree = ""; }; 63295AF31EF3C7DB002D4490 /* SentryNSDictionarySanitize.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryNSDictionarySanitize.h; path = include/SentryNSDictionarySanitize.h; sourceTree = ""; }; @@ -1690,7 +1687,6 @@ 7BAF3DD1243DD05C008A5414 /* SentryTransportInitializerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryTransportInitializerTests.swift; sourceTree = ""; }; 7BAF3DD3243DD40F008A5414 /* SentryTransportFactory.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryTransportFactory.h; path = include/SentryTransportFactory.h; sourceTree = ""; }; 7BAF3DD6243DD4A1008A5414 /* TestConstants.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestConstants.swift; sourceTree = ""; }; - 7BAF3DD82440AEC8008A5414 /* SentryRequestManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SentryRequestManager.h; path = include/SentryRequestManager.h; sourceTree = ""; }; 7BB42EEF24F3B7B700D7B39A /* SentrySession+Equality.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "SentrySession+Equality.h"; sourceTree = ""; }; 7BB42EF024F3B7B700D7B39A /* SentrySession+Equality.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "SentrySession+Equality.m"; sourceTree = ""; }; 7BB6550C253EEB3900887E87 /* SentryUserFeedbackTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedbackTests.swift; sourceTree = ""; }; @@ -2316,6 +2312,8 @@ FA67DCEF2DDBD4EA00896B02 /* URLSessionTaskHelper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = URLSessionTaskHelper.swift; sourceTree = ""; }; FA67DCF22DDBD4EA00896B02 /* SwiftDescriptor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftDescriptor.swift; sourceTree = ""; }; FA8A36172DEAA1EB0058D883 /* SentryThread+Private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = "SentryThread+Private.h"; path = "include/SentryThread+Private.h"; sourceTree = ""; }; + FA90FAA12E065038008CAAE8 /* SentryQueueableRequestManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryQueueableRequestManager.swift; sourceTree = ""; }; + FA90FAA32E0654CB008CAAE8 /* RequestManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RequestManager.swift; sourceTree = ""; }; FAEC270D2DF3526000878871 /* SentryUserFeedback.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SentryUserFeedback.swift; sourceTree = ""; }; FAEC273C2DF3933200878871 /* NSData+Unzip.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSData+Unzip.m"; sourceTree = ""; }; FAEC273E2DF393E000878871 /* NSData+Unzip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "NSData+Unzip.h"; sourceTree = ""; }; @@ -2501,9 +2499,6 @@ 630435FD1EBCA9D900C4D3FA /* SentryNSURLRequest.m */, 7B5CAF7427F5A67C00ED0DB6 /* SentryNSURLRequestBuilder.h */, 7B5CAF7627F5A68C00ED0DB6 /* SentryNSURLRequestBuilder.m */, - 7BAF3DD82440AEC8008A5414 /* SentryRequestManager.h */, - 631E6D311EBC679C00712345 /* SentryQueueableRequestManager.h */, - 631E6D321EBC679C00712345 /* SentryQueueableRequestManager.m */, 638DC99E1EBC6B6400A66E41 /* SentryRequestOperation.h */, 638DC99F1EBC6B6400A66E41 /* SentryRequestOperation.m */, D4291A672DD61A3F00772088 /* SentryDispatchQueueProviderProtocol.h */, @@ -4248,6 +4243,8 @@ D856272A2A374A6800FB8062 /* Tools */ = { isa = PBXGroup; children = ( + FA90FAA12E065038008CAAE8 /* SentryQueueableRequestManager.swift */, + FA90FAA32E0654CB008CAAE8 /* RequestManager.swift */, FA67DCC02DDBD4C800896B02 /* SentryLog+Configure.swift */, ); path = Tools; @@ -4687,7 +4684,6 @@ 63FE70D120DA4C1000CDBAE8 /* SentryCrashMonitorContext.h in Headers */, 63B818F91EC34639002FDF4C /* SentryDebugMeta.h in Headers */, 6360850D1ED2AFE100E8599E /* SentryBreadcrumb.h in Headers */, - 7BAF3DD92440AEC8008A5414 /* SentryRequestManager.h in Headers */, 62862B1C2B1DDBC8009B16E3 /* SentryDelayedFrame.h in Headers */, 627E7589299F6FE40085504D /* SentryInternalDefines.h in Headers */, 7BE3C77B2446111500A38442 /* SentryRateLimitParser.h in Headers */, @@ -4742,7 +4738,6 @@ 84DEE8762B69AD6400A7BC17 /* SentryLaunchProfiling.h in Headers */, D8ACE3CE2762187D00F5A213 /* SentryFileIOTracker.h in Headers */, 03F84D2427DD414C008FE43F /* SentryCompiler.h in Headers */, - 631E6D331EBC679C00712345 /* SentryQueueableRequestManager.h in Headers */, 33EB2A922C341300004FED3D /* Sentry.h in Headers */, 7B3398632459C14000BD9C96 /* SentryEnvelopeRateLimit.h in Headers */, 6304360A1EC0595B00C4D3FA /* SentryNSDataUtils.h in Headers */, @@ -5257,7 +5252,6 @@ 7B0DC730288698F70039995F /* NSMutableDictionary+Sentry.m in Sources */, 628094742D39584C00B3F18B /* SentryUserCodable.swift in Sources */, 7BD4BD4527EB29F50071F4FF /* SentryClientReport.m in Sources */, - 631E6D341EBC679C00712345 /* SentryQueueableRequestManager.m in Sources */, 7B8713B426415BAA006D6004 /* SentryAppStartTracker.m in Sources */, 7BDB03BB2513652900BAE198 /* SentryDispatchQueueWrapper.m in Sources */, D8739D142BEE5049007D2F66 /* SentryRRWebSpanEvent.swift in Sources */, @@ -5473,6 +5467,7 @@ 7B6D1261265F784000C9BE4B /* PrivateSentrySDKOnly.mm in Sources */, 63BE85711ECEC6DE00DC44F5 /* SentryDateUtils.m in Sources */, D451ED5D2D92ECD200C9BEA8 /* SentryOnDemandReplayError.swift in Sources */, + FA90FAA22E06503E008CAAE8 /* SentryQueueableRequestManager.swift in Sources */, 7BD4BD4927EB2A5D0071F4FF /* SentryDiscardedEvent.m in Sources */, 628308612D50ADAC00EAEF77 /* SentryRequestCodable.swift in Sources */, 03F84D3827DD4191008FE43F /* SentryBacktrace.cpp in Sources */, @@ -5588,6 +5583,7 @@ 7BC9A20628F41781001E7C4C /* SentryMeasurementUnit.m in Sources */, 63FE71A020DA4C1100CDBAE8 /* SentryCrashInstallation.m in Sources */, 63FE713520DA4C1100CDBAE8 /* SentryCrashMemory.c in Sources */, + FA90FAA42E0654D2008CAAE8 /* RequestManager.swift in Sources */, 629194A92D51F976000F7C6B /* SentryDebugMetaCodable.swift in Sources */, 63FE714520DA4C1100CDBAE8 /* SentryCrashObjC.c in Sources */, 63FE710520DA4C1000CDBAE8 /* SentryAsyncSafeLog.c in Sources */, diff --git a/Sources/Sentry/SentryQueueableRequestManager.m b/Sources/Sentry/SentryQueueableRequestManager.m deleted file mode 100644 index 660c1bb86b5..00000000000 --- a/Sources/Sentry/SentryQueueableRequestManager.m +++ /dev/null @@ -1,65 +0,0 @@ -#import "SentryQueueableRequestManager.h" -#import "SentryLog.h" -#import "SentryRequestOperation.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface SentryQueueableRequestManager () - -@property (nonatomic, strong) NSOperationQueue *queue; -@property (nonatomic, strong) NSURLSession *session; - -@end - -@implementation SentryQueueableRequestManager - -- (instancetype)initWithSession:(NSURLSession *)session -{ - self = [super init]; - if (self) { - self.session = session; - self.queue = [[NSOperationQueue alloc] init]; - self.queue.name = @"io.sentry.QueueableRequestManager.OperationQueue"; - self.queue.maxConcurrentOperationCount = 3; - } - return self; -} - -- (BOOL)isReady -{ -#if SENTRY_TEST || SENTRY_TEST_CI - // force every envelope to be cached in UI tests so we can inspect what the SDK would've sent - // for a given operation - if ([NSProcessInfo.processInfo.environment[@"--io.sentry.sdk-environment"] - isEqualToString:@"ui-tests"]) { - return NO; - } -#elif DEBUG - if ([NSProcessInfo.processInfo.arguments - containsObject:@"--io.sentry.disable-http-transport"]) { - return NO; - } -#endif // SENTRY_TEST || SENTRY_TEST_CI - - // We always have at least one operation in the queue when calling this - return self.queue.operationCount <= 1; -} - -- (void)addRequest:(NSURLRequest *)request - completionHandler:(_Nullable SentryRequestOperationFinished)completionHandler -{ - SentryRequestOperation *operation = [[SentryRequestOperation alloc] - initWithSession:self.session - request:request - completionHandler:^(NSHTTPURLResponse *_Nullable response, NSError *_Nullable error) { - SENTRY_LOG_DEBUG(@"Queued requests: %@", @(self.queue.operationCount - 1)); - if (completionHandler) { - completionHandler(response, error); - } - }]; - [self.queue addOperation:operation]; -} - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/SentrySpotlightTransport.m b/Sources/Sentry/SentrySpotlightTransport.m index fc2aacc6f82..a53bc78ae89 100644 --- a/Sources/Sentry/SentrySpotlightTransport.m +++ b/Sources/Sentry/SentrySpotlightTransport.m @@ -8,6 +8,7 @@ #import "SentryNSURLRequestBuilder.h" #import "SentryOptions.h" #import "SentrySerialization.h" +#import "SentrySwift.h" #import "SentryTransport.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/SentryTransportFactory.m b/Sources/Sentry/SentryTransportFactory.m index 983d76a27f6..08da53da288 100644 --- a/Sources/Sentry/SentryTransportFactory.m +++ b/Sources/Sentry/SentryTransportFactory.m @@ -6,12 +6,12 @@ #import "SentryHttpTransport.h" #import "SentryNSURLRequestBuilder.h" #import "SentryOptions.h" -#import "SentryQueueableRequestManager.h" #import "SentryRateLimitParser.h" #import "SentryRateLimits.h" #import "SentryRetryAfterHeaderParser.h" #import "SentrySpotlightTransport.h" +#import "SentrySwift.h" #import "SentryTransport.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/include/SentryHttpTransport.h b/Sources/Sentry/include/SentryHttpTransport.h index fbf0e1f0656..18a9b850c12 100644 --- a/Sources/Sentry/include/SentryHttpTransport.h +++ b/Sources/Sentry/include/SentryHttpTransport.h @@ -2,12 +2,12 @@ #import "SentryEnvelopeRateLimit.h" #import "SentryFileManager.h" #import "SentryRateLimits.h" -#import "SentryRequestManager.h" #import "SentryTransport.h" @class SentryDispatchQueueWrapper; @class SentryNSURLRequestBuilder; @class SentryOptions; +@protocol SentryRequestManager; NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/include/SentryPrivate.h b/Sources/Sentry/include/SentryPrivate.h index 9c9954a47f9..447f87a2b1b 100644 --- a/Sources/Sentry/include/SentryPrivate.h +++ b/Sources/Sentry/include/SentryPrivate.h @@ -21,6 +21,7 @@ #import "SentryNSDictionarySanitize.h" #import "SentryProfiler+Private.h" #import "SentryRandom.h" +#import "SentryRequestOperation.h" #import "SentryScreenshot.h" #import "SentrySdkInfo.h" #import "SentrySerialization.h" diff --git a/Sources/Sentry/include/SentryQueueableRequestManager.h b/Sources/Sentry/include/SentryQueueableRequestManager.h deleted file mode 100644 index 6bcf066481d..00000000000 --- a/Sources/Sentry/include/SentryQueueableRequestManager.h +++ /dev/null @@ -1,10 +0,0 @@ -#import "SentryDefines.h" -#import "SentryRequestManager.h" - -NS_ASSUME_NONNULL_BEGIN - -@interface SentryQueueableRequestManager : NSObject - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/include/SentryRequestManager.h b/Sources/Sentry/include/SentryRequestManager.h deleted file mode 100644 index 6cc16dc8ade..00000000000 --- a/Sources/Sentry/include/SentryRequestManager.h +++ /dev/null @@ -1,17 +0,0 @@ -#import - -NS_ASSUME_NONNULL_BEGIN - -NS_SWIFT_NAME(RequestManager) -@protocol SentryRequestManager - -@property (nonatomic, readonly, getter=isReady) BOOL ready; - -- (instancetype)initWithSession:(NSURLSession *)session; - -- (void)addRequest:(NSURLRequest *)request - completionHandler:(_Nullable SentryRequestOperationFinished)completionHandler; - -@end - -NS_ASSUME_NONNULL_END diff --git a/Sources/Sentry/include/SentryRequestOperation.h b/Sources/Sentry/include/SentryRequestOperation.h index 461072c6513..729282fc5d6 100644 --- a/Sources/Sentry/include/SentryRequestOperation.h +++ b/Sources/Sentry/include/SentryRequestOperation.h @@ -1,5 +1,5 @@ #import "SentryAsynchronousOperation.h" -#import "SentryQueueableRequestManager.h" +#import "SentryDefines.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Sentry/include/SentrySpotlightTransport.h b/Sources/Sentry/include/SentrySpotlightTransport.h index 4cc93b34500..04506e97c2d 100644 --- a/Sources/Sentry/include/SentrySpotlightTransport.h +++ b/Sources/Sentry/include/SentrySpotlightTransport.h @@ -1,10 +1,10 @@ #import "SentryDefines.h" -#import "SentryRequestManager.h" #import "SentryTransport.h" @class SentryDispatchQueueWrapper; @class SentryNSURLRequestBuilder; @class SentryOptions; +@protocol SentryRequestManager; NS_ASSUME_NONNULL_BEGIN diff --git a/Sources/Swift/Tools/RequestManager.swift b/Sources/Swift/Tools/RequestManager.swift new file mode 100644 index 00000000000..dfea941749a --- /dev/null +++ b/Sources/Swift/Tools/RequestManager.swift @@ -0,0 +1,10 @@ +@objc(SentryRequestManager) +@_spi(Private) public protocol RequestManager { + + var isReady: Bool { get } + + init(session: URLSession) + + @objc(addRequest:completionHandler:) + func add(_ request: URLRequest, completionHandler: ((HTTPURLResponse?, Error?) -> Void)?) +} diff --git a/Sources/Swift/Tools/SentryQueueableRequestManager.swift b/Sources/Swift/Tools/SentryQueueableRequestManager.swift new file mode 100644 index 00000000000..49f6d11ea8b --- /dev/null +++ b/Sources/Swift/Tools/SentryQueueableRequestManager.swift @@ -0,0 +1,39 @@ +@_implementationOnly import _SentryPrivate + +@objc @_spi(Private) public final class SentryQueueableRequestManager: NSObject, RequestManager { + private let session: URLSession + private let queue: OperationQueue + + @objc + public init(session: URLSession) { + self.session = session + self.queue = OperationQueue() + self.queue.name = "io.sentry.QueueableRequestManager.OperationQueue" + self.queue.maxConcurrentOperationCount = 3 + } + + public var isReady: Bool { + #if SENTRY_TEST || SENTRY_TEST_CI + // force every envelope to be cached in UI tests so we can inspect what the SDK would've sent + // for a given operation + if ProcessInfo.processInfo.environment["--io.sentry.sdk-environment"] == "ui-tests" { + return false + } + #elseif DEBUG + if ProcessInfo.processInfo.arguments.contains("--io.sentry.disable-http-transport") { + return false + } + #endif // SENTRY_TEST || SENTRY_TEST_CI + + // We always have at least one operation in the queue when calling this + return self.queue.operationCount <= 1 + } + + public func add(_ request: URLRequest, completionHandler: SentryRequestOperationFinished?) { + let operation = SentryRequestOperation(session: self.session, request: request) { response, error in + SentryLog.debug("Queued requests: \(self.queue.operationCount - 1)") + completionHandler?(response, error) + } + self.queue.addOperation(operation) + } +} diff --git a/Tests/SentryTests/Networking/SentryTransportFactoryTests.swift b/Tests/SentryTests/Networking/SentryTransportFactoryTests.swift index fddba41351a..54adbc227bf 100644 --- a/Tests/SentryTests/Networking/SentryTransportFactoryTests.swift +++ b/Tests/SentryTests/Networking/SentryTransportFactoryTests.swift @@ -1,4 +1,4 @@ -import Sentry +@_spi(Private) import Sentry import SentryTestUtils import XCTest diff --git a/Tests/SentryTests/Networking/TestRequestManager.swift b/Tests/SentryTests/Networking/TestRequestManager.swift index db8654a636a..dd41bf82e90 100644 --- a/Tests/SentryTests/Networking/TestRequestManager.swift +++ b/Tests/SentryTests/Networking/TestRequestManager.swift @@ -1,7 +1,7 @@ import Foundation import SentryTestUtils -public class TestRequestManager: NSObject, RequestManager { +class TestRequestManager: NSObject, RequestManager { private var nextResponse: () -> HTTPURLResponse? = { return nil } var nextError: NSError?