Skip to content

Commit

Permalink
Allow providing custom URLSession used internally for network requests
Browse files Browse the repository at this point in the history
Fixes #215
  • Loading branch information
Jeehut committed Dec 13, 2024
1 parent 359a1df commit ffc8780
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/TelemetryDeck/Signals/SignalManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ private extension SignalManager {
self.configuration.logHandler?.log(.debug, message: messageString)
}

let task = URLSession.shared.dataTask(with: urlRequest, completionHandler: completionHandler)
let task = self.configuration.urlSession.dataTask(with: urlRequest, completionHandler: completionHandler)
task.resume()
}
}
Expand Down
7 changes: 7 additions & 0 deletions Sources/TelemetryDeck/TelemetryClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ public final class TelemetryManagerConfiguration: @unchecked Sendable {
}
}

/// A customizable `URLSession` used for network requests within TelemetryDeck.
///
/// This property allows you to override the default `URLSession.shared` for cases where
/// a custom session configuration is needed (e.g., for network interception, caching strategies,
/// or debugging). If not set, the `URLSession.shared` instance will be used.
public var urlSession: URLSession = URLSession.shared

@available(*, deprecated, message: "Please use the testMode property instead")
public var sendSignalsInDebugConfiguration: Bool = false

Expand Down

0 comments on commit ffc8780

Please sign in to comment.