Skip to content
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
7 changes: 5 additions & 2 deletions FirebaseSessions/Sources/FirebaseSessions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ private enum GoogleDataTransportConfig {
}

// Initializes the SDK and begins the process of listening for lifecycle events and logging
// events. `logEventCallback` is invoked on a global background queue.
// events. The given `logEventCallback` is invoked on a global background queue by default,
// but configurable via `loggedEventCallbackQueue` for providing a higher priority queue
// during tests to reduce flakes.
init(appID: String, sessionGenerator: SessionGenerator, coordinator: SessionCoordinatorProtocol,
initiator: SessionInitiator, appInfo: ApplicationInfoProtocol, settings: SettingsProtocol,
loggedEventCallbackQueue: DispatchQueue = .global(qos: .background),
loggedEventCallback: @escaping @Sendable (Result<Void, FirebaseSessionsError>) -> Void) {
self.appID = appID

Expand Down Expand Up @@ -179,7 +182,7 @@ private enum GoogleDataTransportConfig {

// Wait until all subscriber promises have been fulfilled before
// doing any data collection.
all(self.subscriberPromises.values).then(on: .global(qos: .background)) { _ in
all(self.subscriberPromises.values).then(on: loggedEventCallbackQueue) { _ in
guard self.isAnyDataCollectionEnabled else {
loggedEventCallback(.failure(.DataCollectionError))
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ class FirebaseSessionsTestsBase: XCTestCase {
coordinator: mockCoordinator,
initiator: initiator,
appInfo: mockAppInfo,
settings: mockSettings) { result in
settings: mockSettings,
// Execute the callback on a higher priority queue to avoid test flakes.
loggedEventCallbackQueue: .global(qos: .userInteractive)) { result in
DispatchQueue.main.async {
// Provide the result for tests to test against
postLogEvent(result, subscriberSDKs)
Expand Down
Loading