From 7f66da30ae6d7ad194c2847d2e8a224d612c486d Mon Sep 17 00:00:00 2001 From: Nikita Ogorodnikov Date: Tue, 18 Jun 2024 10:39:50 +0200 Subject: [PATCH] Allow disabling app hang monitoring in ObjC API --- CHANGELOG.md | 3 +++ .../Tests/DatadogObjc/DDRUMConfigurationTests.swift | 8 +++++++- DatadogObjc/Sources/RUM/RUM+objc.swift | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 283ebe244d..eadb4d480d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ # Unreleased +- [IMPROVEMENT] Allow disabling app hang monitoring in ObjC API. See [#1908][] + # 2.13.0 / 13-06-2024 - [IMPROVEMENT] Bump `IPHONEOS_DEPLOYMENT_TARGET` and `TVOS_DEPLOYMENT_TARGET` from 11 to 12. See [#1891][] @@ -684,6 +686,7 @@ Release `2.0` introduces breaking changes. Follow the [Migration Guide](MIGRATIO [#1835]: https://github.com/DataDog/dd-sdk-ios/pull/1835 [#1886]: https://github.com/DataDog/dd-sdk-ios/pull/1886 [#1898]: https://github.com/DataDog/dd-sdk-ios/pull/1898 +[#1908]: https://github.com/DataDog/dd-sdk-ios/pull/1908 [@00fa9a]: https://github.com/00FA9A [@britton-earnin]: https://github.com/Britton-Earnin [@hengyu]: https://github.com/Hengyu diff --git a/DatadogCore/Tests/DatadogObjc/DDRUMConfigurationTests.swift b/DatadogCore/Tests/DatadogObjc/DDRUMConfigurationTests.swift index 9cb9201af7..6468bbe483 100644 --- a/DatadogCore/Tests/DatadogObjc/DDRUMConfigurationTests.swift +++ b/DatadogCore/Tests/DatadogObjc/DDRUMConfigurationTests.swift @@ -107,12 +107,18 @@ class DDRUMConfigurationTests: XCTestCase { } func testAppHangThreshold() { - let random: TimeInterval = .mockRandom() + let random: TimeInterval = .mockRandom(min: 0.01, max: .greatestFiniteMagnitude) objc.appHangThreshold = random XCTAssertEqual(objc.appHangThreshold, random) XCTAssertEqual(swift.appHangThreshold, random) } + func testAppHangThresholdDisable() { + objc.appHangThreshold = 0 + XCTAssertEqual(objc.appHangThreshold, 0) + XCTAssertEqual(swift.appHangThreshold, nil) + } + func testVitalsUpdateFrequency() { objc.vitalsUpdateFrequency = .frequent XCTAssertEqual(swift.vitalsUpdateFrequency, .frequent) diff --git a/DatadogObjc/Sources/RUM/RUM+objc.swift b/DatadogObjc/Sources/RUM/RUM+objc.swift index 6f2e8cd113..3410fe3b93 100644 --- a/DatadogObjc/Sources/RUM/RUM+objc.swift +++ b/DatadogObjc/Sources/RUM/RUM+objc.swift @@ -378,7 +378,7 @@ public class DDRUMConfiguration: NSObject { } @objc public var appHangThreshold: TimeInterval { - set { swiftConfig.appHangThreshold = newValue } + set { swiftConfig.appHangThreshold = newValue == 0 ? nil : newValue } get { swiftConfig.appHangThreshold ?? 0 } }