Skip to content

Commit

Permalink
Merge pull request #1598 from DataDog/hotfix/2.5.1
Browse files Browse the repository at this point in the history
Hotfix `2.5.1`
  • Loading branch information
ncreated committed Dec 20, 2023
2 parents aa66234 + b2ce0fd commit 7559cdd
Show file tree
Hide file tree
Showing 19 changed files with 99 additions and 26 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Unreleased

# 2.5.1 / 20-12-2023

- [BUGFIX] Fix `view.time_spent` in RUM view events. See [#1596][]

# 2.5.0 / 08-11-2023

- [BUGFIX] Optimize Session Replay diffing algorithm. See [#1524][]
Expand Down Expand Up @@ -557,6 +561,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO
[#1529]: https://github.com/DataDog/dd-sdk-ios/pull/1529
[#1533]: https://github.com/DataDog/dd-sdk-ios/pull/1533
[#1536]: https://github.com/DataDog/dd-sdk-ios/pull/1536
[#1596]: https://github.com/DataDog/dd-sdk-ios/pull/1596
[@00fa9a]: https://github.com/00FA9A
[@britton-earnin]: https://github.com/Britton-Earnin
[@hengyu]: https://github.com/Hengyu
Expand Down
2 changes: 1 addition & 1 deletion DatadogAlamofireExtension.podspec
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.5.0"
s.version = "2.5.1"
s.summary = "An Official Extensions of Datadog Swift SDK for Alamofire."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogCore.podspec
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.5.0"
s.version = "2.5.1"
s.summary = "Official Datadog Swift SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogCore/Sources/Versioning.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// GENERATED FILE: Do not edit directly

internal let __sdkVersion = "2.5.0"
internal let __sdkVersion = "2.5.1"
2 changes: 1 addition & 1 deletion DatadogCrashReporting.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogCrashReporting"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Official Datadog Crash Reporting SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogInternal.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogInternal"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Datadog Internal Package. This module is not for public use."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogLogs.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogLogs"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Datadog Logs Module."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogObjc.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogObjc"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Official Datadog Objective-C SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogRUM.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogRUM"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Datadog Real User Monitoring Module."

s.homepage = "https://www.datadoghq.com"
Expand Down
7 changes: 5 additions & 2 deletions DatadogRUM/Sources/RUMMonitor/Scopes/RUMViewScope.swift
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,12 @@ internal class RUMViewScope: RUMScope, RUMContextProvider {
}
didReceiveStartCommand = true
needsViewUpdate = true
case let command as RUMStartViewCommand where !identity.equals(command.identity):
case let command as RUMStartViewCommand where !identity.equals(command.identity) && isActiveView:
// This gets effective in case when the user didn't end the view explicitly.
// If the view is flagged as "active" but another view is started, we know it needs to be
// deactivated. This is achieved by setting `isActiveView` to `false` and sending one more view update.
isActiveView = false
needsViewUpdate = true // sanity update (in case if the user forgets to end this View)
needsViewUpdate = true
case let command as RUMStopViewCommand where identity.equals(command.identity):
isActiveView = false
needsViewUpdate = true
Expand Down
81 changes: 73 additions & 8 deletions DatadogRUM/Tests/RUMMonitor/Scopes/RUMViewScopeTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class RUMViewScopeTests: XCTestCase {
XCTAssertEqual(event.dd.replayStats?.recordsCount, 1)
}

func testWhenInitialViewHasCconfiguredSource_itSendsViewUpdateEventWithConfiguredSource() throws {
func testWhenInitialViewHasConfiguredSource_itSendsViewUpdateEventWithConfiguredSource() throws {
// GIVEN
let currentTime: Date = .mockDecember15th2019At10AMUTC()
let source = String.mockAnySource()
Expand Down Expand Up @@ -603,6 +603,8 @@ class RUMViewScopeTests: XCTestCase {
}

func testGivenViewWithPendingResources_whenItGetsStopped_itDoesNotFinishUntilResourcesComplete() throws {
let viewStartTime = Date()
var currentTime = viewStartTime
let scope = RUMViewScope(
isInitialView: .mockRandom(),
parent: parent,
Expand All @@ -612,47 +614,51 @@ class RUMViewScopeTests: XCTestCase {
name: .mockAny(),
attributes: [:],
customTimings: [:],
startTime: Date(),
startTime: currentTime,
serverTimeOffset: .zero
)

// given
XCTAssertTrue(
scope.process(
command: RUMStartViewCommand.mockWith(identity: mockViewIdentity),
command: RUMStartViewCommand.mockWith(time: currentTime, identity: mockViewIdentity),
context: context,
writer: writer
)
)
currentTime.addTimeInterval(1)
XCTAssertTrue(
scope.process(
command: RUMStartResourceCommand.mockWith(resourceKey: "/resource/1"),
command: RUMStartResourceCommand.mockWith(resourceKey: "/resource/1", time: currentTime),
context: context,
writer: writer
)
)
currentTime.addTimeInterval(1)
XCTAssertTrue(
scope.process(
command: RUMStartResourceCommand.mockWith(resourceKey: "/resource/2"),
command: RUMStartResourceCommand.mockWith(resourceKey: "/resource/2", time: currentTime),
context: context,
writer: writer
)
)

// when
currentTime.addTimeInterval(1)
XCTAssertTrue(
scope.process(
command: RUMStopViewCommand.mockWith(identity: mockViewIdentity),
command: RUMStopViewCommand.mockWith(time: currentTime, identity: mockViewIdentity),
context: context,
writer: writer
),
"The View should be kept alive as its Resources haven't yet finished loading"
)

// then
currentTime.addTimeInterval(1)
XCTAssertTrue(
scope.process(
command: RUMStopResourceCommand.mockWith(resourceKey: "/resource/1"),
command: RUMStopResourceCommand.mockWith(resourceKey: "/resource/1", time: currentTime),
context: context,
writer: writer
),
Expand All @@ -662,9 +668,11 @@ class RUMViewScopeTests: XCTestCase {
var event = try XCTUnwrap(writer.events(ofType: RUMViewEvent.self).last)
XCTAssertTrue(event.view.isActive ?? false, "View should stay active")

currentTime.addTimeInterval(1)
let lastResourceCompletionTime = currentTime
XCTAssertFalse(
scope.process(
command: RUMStopResourceWithErrorCommand.mockWithErrorMessage(resourceKey: "/resource/2"),
command: RUMStopResourceWithErrorCommand.mockWithErrorMessage(resourceKey: "/resource/2", time: currentTime),
context: context,
writer: writer
),
Expand All @@ -675,6 +683,63 @@ class RUMViewScopeTests: XCTestCase {
XCTAssertEqual(event.view.resource.count, 1, "View should record 1 successful Resource")
XCTAssertEqual(event.view.error.count, 1, "View should record 1 error due to second Resource failure")
XCTAssertFalse(event.view.isActive ?? true, "View should be inactive")
XCTAssertEqual(event.view.timeSpent, lastResourceCompletionTime.timeIntervalSince(viewStartTime).toInt64Nanoseconds, "View should last until the last resource completes")
}

func testGivenViewWithUnfinishedResources_whenNextViewsAreStarted_itNoLongerUpdatesTimeSpent() throws {
let view1StartTime = Date()
var currentTime = view1StartTime
let view1 = "view1".asRUMViewIdentity()

let scope = RUMViewScope(
isInitialView: .mockRandom(),
parent: parent,
dependencies: .mockAny(),
identity: view1,
path: .mockAny(),
name: .mockAny(),
attributes: [:],
customTimings: [:],
startTime: currentTime,
serverTimeOffset: .zero
)

// given
XCTAssertTrue(
scope.process(
command: RUMStartViewCommand.mockWith(time: currentTime, identity: view1),
context: context,
writer: writer
)
)
currentTime.addTimeInterval(1)
XCTAssertTrue(
scope.process(
command: RUMStartResourceCommand.mockWith(resourceKey: "/dangling/resource", time: currentTime),
context: context,
writer: writer
)
)

// when (start 2 next views)
currentTime.addTimeInterval(1)
let nextViewStartTime = currentTime
var nextViewStartCommand = RUMStartViewCommand.mockWith(time: currentTime, identity: String.mockRandom().asRUMViewIdentity())
XCTAssertTrue(
scope.process(command: nextViewStartCommand, context: context, writer: writer),
"The View should be kept alive as `/dangling/resource` haven't yet finished loading"
)
currentTime.addTimeInterval(1)
nextViewStartCommand = RUMStartViewCommand.mockWith(time: currentTime, identity: String.mockRandom().asRUMViewIdentity())
XCTAssertTrue(
scope.process(command: nextViewStartCommand, context: context, writer: writer),
"The View should be kept alive as `/dangling/resource` haven't yet finished loading"
)

let lastEvent = try XCTUnwrap(writer.events(ofType: RUMViewEvent.self).last)
XCTAssertEqual(lastEvent.view.resource.count, 0, "View should record no resources as `/dangling/resource` never finished")
XCTAssertEqual(lastEvent.view.isActive, true, "View should remain active because it has pending resource")
XCTAssertEqual(lastEvent.view.timeSpent, nextViewStartTime.timeIntervalSince(view1StartTime).toInt64Nanoseconds, "View should last until next view was started")
}

// MARK: - User Action Tracking
Expand Down
2 changes: 1 addition & 1 deletion DatadogSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogSDK"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Official Datadog Swift SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogSDKAlamofireExtension.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogSDKAlamofireExtension"
s.module_name = "DatadogAlamofireExtension"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "An Official Extensions of Datadog Swift SDK for Alamofire."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogSDKCrashReporting.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogSDKCrashReporting"
s.module_name = "DatadogCrashReporting"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Official Datadog Crash Reporting SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogSDKObjc.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|
s.name = "DatadogSDKObjc"
s.module_name = "DatadogObjc"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Official Datadog Objective-C SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogSessionReplay.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogSessionReplay"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Official Datadog Session Replay SDK for iOS."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogTrace.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogTrace"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Datadog Trace Module."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion DatadogWebViewTracking.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "DatadogWebViewTracking"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Datadog WebView Tracking Module."

s.homepage = "https://www.datadoghq.com"
Expand Down
2 changes: 1 addition & 1 deletion TestUtilities.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "TestUtilities"
s.version = "2.5.0"
s.version = "2.5.1"
s.summary = "Datadog Testing Utilities. This module is for internal testing and should not be published."

s.homepage = "https://www.datadoghq.com"
Expand Down

0 comments on commit 7559cdd

Please sign in to comment.