Skip to content

Commit

Permalink
Add addUserExtraInfo to ObjC API
Browse files Browse the repository at this point in the history
  • Loading branch information
0xnm committed Apr 26, 2024
1 parent 79943d3 commit 6276104
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions DatadogCore/Tests/DatadogObjc/DDDatadogTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,15 @@ 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")
let extraInfo = try XCTUnwrap(userInfo.current.extraInfo as? [String: AnyEncodable])
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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ - (void)testDDDatadog {
[DDDatadog setVerbosityLevel:verbosity];

[DDDatadog setUserInfoWithId:@"" name:@"" email:@"" extraInfo:@{}];
[DDDatadog addUserExtraInfo:@{}];
[DDDatadog setTrackingConsentWithConsent:[DDTrackingConsent notGranted]];

[DDDatadog clearAllData];
Expand Down
5 changes: 5 additions & 0 deletions DatadogObjc/Sources/Datadog+objc.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions api-surface-objc
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 6276104

Please sign in to comment.