forked from DataDog/dd-sdk-ios
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDDURLSessionDelegate+objc.swift
47 lines (43 loc) · 1.57 KB
/
DDURLSessionDelegate+objc.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
* Unless explicitly stated otherwise all files in this repository are licensed under the Apache License Version 2.0.
* This product includes software developed at Datadog (https://www.datadoghq.com/).
* Copyright 2019-Present Datadog, Inc.
*/
import Foundation
import DatadogCore
import DatadogInternal
@objc
@available(*, deprecated, message: "Use `URLSessionInstrumentation.enable(with:)` instead.")
open class DDNSURLSessionDelegate: NSObject, URLSessionTaskDelegate, URLSessionDataDelegate {
@objc
override public init() {
URLSessionInstrumentation.enable(
with: .init(
delegateClass: Self.self
),
in: CoreRegistry.default
)
super.init()
}
@objc
public init(additionalFirstPartyHostsWithHeaderTypes: [String: Set<DDTracingHeaderType>]) {
URLSessionInstrumentation.enable(
with: .init(
delegateClass: Self.self,
firstPartyHostsTracing: .traceWithHeaders(hostsWithHeaders: additionalFirstPartyHostsWithHeaderTypes.mapValues { tracingHeaderTypes in
return Set(tracingHeaderTypes.map { $0.swiftType })
})
),
in: CoreRegistry.default
)
super.init()
}
@objc
public convenience init(additionalFirstPartyHosts: Set<String>) {
self.init(
additionalFirstPartyHostsWithHeaderTypes: additionalFirstPartyHosts.reduce(into: [:], { partialResult, host in
partialResult[host] = [.datadog, .tracecontext]
})
)
}
}