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
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ extension SegmentDestination.UploadTaskInfo {

if let application = UIApplication.safeShared {
let taskIdentifier = application.beginBackgroundTask { [self] in
self.task.suspend()
self.task.cancel()
self.cleanup?()
}
self.taskID = taskIdentifier.rawValue
Expand Down
4 changes: 4 additions & 0 deletions Sources/Segment/Plugins/SegmentDestination.swift
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ public class SegmentDestination: DestinationPlugin {
}

analytics.log(message: "Processed: \(url.lastPathComponent)")
// the upload we have here has just finished.
// make sure it gets removed and it's cleanup() called rather
// than waiting on the next flush to come around.
self.cleanupUploads()
}
// we have a legit upload in progress now, so add it to our list.
if let upload = uploadTask {
Expand Down
3 changes: 2 additions & 1 deletion Sources/Segment/Utilities/HTTPClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,11 @@ extension HTTPClient {
configuration.allowsCellularAccess = true
configuration.timeoutIntervalForResource = 30
configuration.timeoutIntervalForRequest = 60
configuration.httpMaximumConnectionsPerHost = 2
configuration.httpAdditionalHeaders = ["Content-Type": "application/json; charset=utf-8",
"Authorization": "Basic \(Self.authorizationHeaderForWriteKey(writeKey))",
"User-Agent": "analytics-ios/\(Analytics.version())"]
let session = URLSession.init(configuration: configuration, delegate: nil, delegateQueue: nil)
let session = URLSession(configuration: configuration, delegate: nil, delegateQueue: nil)
return session
}
}