diff --git a/Sources/Bugsnag/BugsnagReporter.swift b/Sources/Bugsnag/BugsnagReporter.swift index 5473a6a..6569403 100644 --- a/Sources/Bugsnag/BugsnagReporter.swift +++ b/Sources/Bugsnag/BugsnagReporter.swift @@ -103,15 +103,14 @@ extension BugsnagReporter { eventRequestBody = nil } - var headerDict: [String : Any] = request.headers.reduce([:], { result, value in - var copy = result - copy[value.0] = value.1 - return copy - }) + var headerDict: [String : Any] = request.headers.reduce(into: [:]) { result, value in + result[value.0] = value.1 + } strip(keys: configuration.keyFilters, from: &headerDict) - let filteredHeaders: [(String, String)] = headerDict.map { - k, v in (k, v as! String) + let filteredHeaders: [(String, String)] = headerDict.compactMap { k, v in + guard let value = v as? String else { return nil } + return (k, value) } eventRequest = .init(