-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RUMM-833 Add
DatadogSDKAlamofireExtension.podspec
- Loading branch information
Showing
3 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "DatadogSDKAlamofireExtension" | ||
s.module_name = "DatadogAlamofireExtension" | ||
s.version = "1.0.0" | ||
s.summary = "An Official Extensions of Datadog Swift SDK for Alamofire." | ||
|
||
s.homepage = "https://www.datadoghq.com" | ||
s.social_media_url = "https://twitter.com/datadoghq" | ||
|
||
s.license = { :type => "Apache", :file => 'LICENSE' } | ||
s.authors = { | ||
"Maciek Grzybowski" => "maciek.grzybowski@datadoghq.com", | ||
"Mert Buran" => "mert.buran@datadoghq.com" | ||
} | ||
|
||
s.swift_version = '5.1' | ||
s.ios.deployment_target = '11.0' | ||
|
||
s.source = { :git => "https://github.com/DataDog/dd-sdk-ios.git", :tag => s.version.to_s } | ||
|
||
s.source_files = ["Sources/DatadogExtensions/Alamofire/**/*.swift"] | ||
s.dependency 'DatadogSDK', '~> 1.4' | ||
s.dependency 'Alamofire', '~> 5.4' | ||
end |
29 changes: 29 additions & 0 deletions
29
Sources/DatadogExtensions/Alamofire/DatadogAlamofireExtension.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* 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-2020 Datadog, Inc. | ||
*/ | ||
|
||
import class Datadog.URLSessionInterceptor | ||
import Alamofire | ||
|
||
public class DDEventMonitor: EventMonitor { | ||
public func request(_ request: Request, didCreateTask task: URLSessionTask) { | ||
URLSessionInterceptor.shared?.taskCreated(task: task) | ||
} | ||
|
||
public func urlSession(_ session: URLSession, task: URLSessionTask, didFinishCollecting metrics: URLSessionTaskMetrics) { | ||
URLSessionInterceptor.shared?.taskMetricsCollected(task: task, metrics: metrics) | ||
} | ||
|
||
public func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?) { | ||
URLSessionInterceptor.shared?.taskCompleted(task: task, error: error) | ||
} | ||
} | ||
|
||
public class DDRequestInterceptor: RequestInterceptor { | ||
public func adapt(_ urlRequest: URLRequest, for session: Session, completion: @escaping (Result<URLRequest, Error>) -> Void) { | ||
let instrumentedRequest = URLSessionInterceptor.shared?.modify(request: urlRequest) | ||
completion(.success(instrumentedRequest ?? urlRequest)) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters