-
Notifications
You must be signed in to change notification settings - Fork 133
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 #1808 from DataDog/release/2.11.0
Release `2.11.0`
- Loading branch information
Showing
210 changed files
with
4,814 additions
and
1,434 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.
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
93 changes: 93 additions & 0 deletions
93
Datadog/IntegrationUnitTests/SessionReplay/WebRecordIntegrationTests.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,93 @@ | ||
/* | ||
* 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 TestUtilities | ||
@testable import DatadogRUM | ||
@testable import DatadogWebViewTracking | ||
@_spi(Internal) @testable import DatadogSessionReplay | ||
|
||
class WebRecordIntegrationTests: 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 testWebRecordIntegration() throws { | ||
// Given | ||
let webView = WKWebView() | ||
let randomApplicationID: String = .mockRandom() | ||
let randomUUID: UUID = .mockRandom() | ||
let randomBrowserViewID: UUID = .mockRandom() | ||
|
||
SessionReplay.enable(with: SessionReplay.Configuration(replaySampleRate: 100), in: core) | ||
RUM.enable(with: .mockWith(applicationID: randomApplicationID) { | ||
$0.uuidGenerator = RUMUUIDGeneratorMock(uuid: randomUUID) | ||
}, in: core) | ||
|
||
let body = """ | ||
{ | ||
"eventType": "record", | ||
"event": { | ||
"timestamp" : \(1635932927012), | ||
"type": 2 | ||
}, | ||
"view": { "id": "\(randomBrowserViewID.uuidString.lowercased())" } | ||
} | ||
""" | ||
|
||
// When | ||
RUMMonitor.shared(in: core).startView(key: "web-view") | ||
controller.send(body: body, from: webView) | ||
controller.flush() | ||
|
||
// Then | ||
let segments = try core.waitAndReturnEventsData(ofFeature: SessionReplayFeature.name) | ||
.map { try SegmentJSON($0, source: .ios) } | ||
let segment = try XCTUnwrap(segments.first) | ||
|
||
let expectedUUID = randomUUID.uuidString.lowercased() | ||
let expectedSlotID = String(webView.hash) | ||
|
||
XCTAssertEqual(segment.applicationID, randomApplicationID) | ||
XCTAssertEqual(segment.sessionID, expectedUUID) | ||
XCTAssertEqual(segment.viewID, randomBrowserViewID.uuidString.lowercased()) | ||
|
||
let record = try XCTUnwrap(segment.records.first) | ||
DDAssertDictionariesEqual(record, [ | ||
"timestamp": 1_635_932_927_012 + 123.toInt64Milliseconds, | ||
"type": 2, | ||
"slotId": expectedSlotID | ||
]) | ||
} | ||
} | ||
|
||
#endif |
Oops, something went wrong.