-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1520 from DataDog/release/2.4.0
Release 2.4.0
- Loading branch information
Showing
128 changed files
with
2,883 additions
and
2,065 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
Large diffs are not rendered by default.
Oops, something went wrong.
139 changes: 139 additions & 0 deletions
139
Datadog/IntegrationUnitTests/Public/WebLogIntegrationTests.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,139 @@ | ||
/* | ||
* 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 XCTest | ||
|
||
#if !os(tvOS) | ||
import WebKit | ||
import DatadogLogs | ||
@testable import DatadogRUM | ||
import DatadogWebViewTracking | ||
|
||
class WebLogIntegrationTests: XCTestCase { | ||
// swiftlint:disable implicitly_unwrapped_optional | ||
private var core: DatadogCoreProxy! // swiftlint:disable:this implicitly_unwrapped_optional | ||
private var controller: WKUserContentControllerMock! | ||
// swiftlint:enable implicitly_unwrapped_optional | ||
|
||
override func setUp() { | ||
core = DatadogCoreProxy( | ||
context: .mockWith( | ||
env: "test", | ||
version: "1.1.1", | ||
serverTimeOffset: 123 | ||
) | ||
) | ||
|
||
controller = WKUserContentControllerMock() | ||
let configuration = WKWebViewConfiguration() | ||
configuration.userContentController = controller | ||
let webView = WKWebView(frame: .zero, configuration: configuration) | ||
WebViewTracking.enable(webView: webView, in: core) | ||
} | ||
|
||
override func tearDown() { | ||
core.flushAndTearDown() | ||
core = nil | ||
controller = nil | ||
} | ||
|
||
func testWebLogIntegration() throws { | ||
// Given | ||
Logs.enable(in: core) | ||
|
||
let body = """ | ||
{ | ||
"eventType": "log", | ||
"event": { | ||
"date" : \(1635932927012), | ||
"status": "debug", | ||
"message": "message", | ||
"session_id": "0110cab4-7471-480e-aa4e-7ce039ced355", | ||
"view": { | ||
"referrer": "", | ||
"url": "https://datadoghq.dev/browser-sdk-test-playground" | ||
} | ||
} | ||
} | ||
""" | ||
|
||
// When | ||
controller.send(body: body) | ||
controller.flush() | ||
|
||
// Then | ||
let logMatcher = try XCTUnwrap(core.waitAndReturnLogMatchers().first) | ||
try logMatcher.assertItFullyMatches(jsonString: """ | ||
{ | ||
"date": \(1_635_932_927_012 + 123.toInt64Milliseconds), | ||
"ddtags": "version:1.1.1,env:test", | ||
"message": "message", | ||
"session_id": "0110cab4-7471-480e-aa4e-7ce039ced355", | ||
"status": "debug", | ||
"view": { | ||
"referrer": "", | ||
"url": "https://datadoghq.dev/browser-sdk-test-playground" | ||
}, | ||
} | ||
""" | ||
) | ||
} | ||
|
||
func testWebLogWithRUMIntegration() throws { | ||
// Given | ||
let randomApplicationID: String = .mockRandom() | ||
let randomUUID: UUID = .mockRandom() | ||
|
||
Logs.enable(in: core) | ||
RUM.enable(with: .mockWith(applicationID: randomApplicationID) { | ||
$0.uuidGenerator = RUMUUIDGeneratorMock(uuid: randomUUID) | ||
}, in: core) | ||
|
||
let body = """ | ||
{ | ||
"eventType": "log", | ||
"event": { | ||
"date" : \(1635932927012), | ||
"status": "debug", | ||
"message": "message", | ||
"session_id": "0110cab4-7471-480e-aa4e-7ce039ced355", | ||
"view": { | ||
"referrer": "", | ||
"url": "https://datadoghq.dev/browser-sdk-test-playground" | ||
} | ||
} | ||
} | ||
""" | ||
|
||
// When | ||
RUMMonitor.shared(in: core).startView(key: "web-view") | ||
controller.send(body: body) | ||
controller.flush() | ||
|
||
// Then | ||
let expectedUUID = randomUUID.uuidString.lowercased() | ||
let logMatcher = try XCTUnwrap(core.waitAndReturnLogMatchers().first) | ||
try logMatcher.assertItFullyMatches(jsonString: """ | ||
{ | ||
"date": \(1_635_932_927_012 + 123.toInt64Milliseconds), | ||
"ddtags": "version:1.1.1,env:test", | ||
"message": "message", | ||
"application_id": "\(randomApplicationID)", | ||
"session_id": "\(expectedUUID)", | ||
"view.id": "\(expectedUUID)", | ||
"status": "debug", | ||
"view": { | ||
"referrer": "", | ||
"url": "https://datadoghq.dev/browser-sdk-test-playground" | ||
}, | ||
} | ||
""" | ||
) | ||
} | ||
} | ||
|
||
#endif | ||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "DatadogAlamofireExtension" | ||
s.version = "2.3.0" | ||
s.version = "2.4.0" | ||
s.summary = "An Official Extensions of Datadog Swift SDK for Alamofire." | ||
|
||
s.homepage = "https://www.datadoghq.com" | ||
|
@@ -14,7 +14,7 @@ Pod::Spec.new do |s| | |
"Maciej Burda" => "[email protected]" | ||
} | ||
|
||
s.swift_version = '5.8.0' | ||
s.swift_version = '5.7.1' | ||
s.ios.deployment_target = '11.0' | ||
s.tvos.deployment_target = '11.0' | ||
|
||
|
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
Pod::Spec.new do |s| | ||
s.name = "DatadogCore" | ||
s.version = "2.3.0" | ||
s.version = "2.4.0" | ||
s.summary = "Official Datadog Swift SDK for iOS." | ||
|
||
s.homepage = "https://www.datadoghq.com" | ||
|
@@ -14,7 +14,7 @@ Pod::Spec.new do |s| | |
"Maciej Burda" => "[email protected]" | ||
} | ||
|
||
s.swift_version = '5.8.0' | ||
s.swift_version = '5.7.1' | ||
s.ios.deployment_target = '11.0' | ||
s.tvos.deployment_target = '11.0' | ||
|
||
|
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
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
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
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
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// GENERATED FILE: Do not edit directly | ||
|
||
internal let __sdkVersion = "2.3.0" | ||
internal let __sdkVersion = "2.4.0" |
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
Oops, something went wrong.