diff --git a/DatadogCore/Tests/DatadogObjc/DDDatadogTests.swift b/DatadogCore/Tests/DatadogObjc/DDDatadogTests.swift index 299bcc7130..edf7c6d112 100644 --- a/DatadogCore/Tests/DatadogObjc/DDDatadogTests.swift +++ b/DatadogCore/Tests/DatadogObjc/DDDatadogTests.swift @@ -92,6 +92,7 @@ class DDDatadogTests: XCTestCase { "attribute-string": "string value" ] ) + DDDatadog.addUserExtraInfo(["foo": "bar"]) XCTAssertEqual(userInfo.current.id, "id") XCTAssertEqual(userInfo.current.name, "name") XCTAssertEqual(userInfo.current.email, "email") @@ -99,6 +100,7 @@ class DDDatadogTests: XCTestCase { XCTAssertEqual(extraInfo["attribute-int"]?.value as? Int, 42) XCTAssertEqual(extraInfo["attribute-double"]?.value as? Double, 42.5) XCTAssertEqual(extraInfo["attribute-string"]?.value as? String, "string value") + XCTAssertEqual(extraInfo["foo"]?.value as? String, "bar") DDDatadog.setUserInfo(id: nil, name: nil, email: nil, extraInfo: [:]) XCTAssertNil(userInfo.current.id) diff --git a/DatadogCore/Tests/DatadogObjc/ObjcAPITests/DDDatadog+apiTests.m b/DatadogCore/Tests/DatadogObjc/ObjcAPITests/DDDatadog+apiTests.m index c1446779f2..81e074cbf0 100644 --- a/DatadogCore/Tests/DatadogObjc/ObjcAPITests/DDDatadog+apiTests.m +++ b/DatadogCore/Tests/DatadogObjc/ObjcAPITests/DDDatadog+apiTests.m @@ -33,6 +33,7 @@ - (void)testDDDatadog { [DDDatadog setVerbosityLevel:verbosity]; [DDDatadog setUserInfoWithId:@"" name:@"" email:@"" extraInfo:@{}]; + [DDDatadog addUserExtraInfo:@{}]; [DDDatadog setTrackingConsentWithConsent:[DDTrackingConsent notGranted]]; [DDDatadog clearAllData]; diff --git a/DatadogObjc/Sources/Datadog+objc.swift b/DatadogObjc/Sources/Datadog+objc.swift index bc2ae6167e..89235d987f 100644 --- a/DatadogObjc/Sources/Datadog+objc.swift +++ b/DatadogObjc/Sources/Datadog+objc.swift @@ -70,6 +70,11 @@ public class DDDatadog: NSObject { Datadog.setUserInfo(id: id, name: name, email: email, extraInfo: castAttributesToSwift(extraInfo)) } + @objc + public static func addUserExtraInfo(_ extraInfo: [String: Any]) { + Datadog.addUserExtraInfo(castAttributesToSwift(extraInfo)) + } + @objc public static func setTrackingConsent(consent: DDTrackingConsent) { Datadog.set(trackingConsent: consent.sdkConsent) diff --git a/api-surface-objc b/api-surface-objc index 3499bfbb0f..3e5ee14e91 100644 --- a/api-surface-objc +++ b/api-surface-objc @@ -25,6 +25,7 @@ public class DDDatadog: NSObject public static func setVerbosityLevel(_ verbosityLevel: DDSDKVerbosityLevel) public static func verbosityLevel() -> DDSDKVerbosityLevel public static func setUserInfo(id: String? = nil, name: String? = nil, email: String? = nil, extraInfo: [String: Any] = [:]) + public static func addUserExtraInfo(_ extraInfo: [String: Any]) public static func setTrackingConsent(consent: DDTrackingConsent) public static func clearAllData() public class DDSite: NSObject