-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RUMM-886 setUserInfo(..., extraInfo)
added
#315
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -198,5 +198,8 @@ internal struct SpanEncoder { | |
let metaKey = "meta.\($0.key)" | ||
try container.encode($0.value, forKey: DynamicCodingKey(metaKey)) | ||
} | ||
try span.userInfo.extraInfo.forEach { | ||
try container.encode(EncodableValue($1), forKey: DynamicCodingKey("meta.usr.\($0)")) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This leads to all spans being rejected by Intake if the user extra attribute is not Datadog.setUserInfo(
id: "abcd-1234",
name: "foo",
email: "foo@example.com",
extraInfo: [
"is-registered": true
]
) As stated in this method comment: // NOTE: RUMM-299 only string values are supported for `meta.*` attributes Whatever we encode on |
||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -186,16 +186,16 @@ class LoggerTests: XCTestCase { | |
Datadog.setUserInfo(id: "abc-123", name: "Foo") | ||
logger.debug("message with user `id` and `name`") | ||
|
||
Datadog.setUserInfo(id: "abc-123", name: "Foo", email: "foo@example.com") | ||
logger.debug("message with user `id`, `name` and `email`") | ||
Datadog.setUserInfo(id: "abc-123", name: "Foo", email: "foo@example.com", extraInfo: ["extra_key": "extra_value"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because extraInfo: ["extra_string": "string_value", "extra_int": 42, "extra_bool": true] and document the expected encoding result in test assertions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i can't pass different types in a dict to |
||
logger.debug("message with user `id`, `name`, `email` and `extraInfo`") | ||
|
||
Datadog.setUserInfo(id: nil, name: nil, email: nil) | ||
logger.debug("message with no user info") | ||
|
||
let logMatchers = try LoggingFeature.waitAndReturnLogMatchers(count: 4) | ||
logMatchers[0].assertUserInfo(equals: nil) | ||
logMatchers[1].assertUserInfo(equals: (id: "abc-123", name: "Foo", email: nil)) | ||
logMatchers[2].assertUserInfo(equals: (id: "abc-123", name: "Foo", email: "foo@example.com")) | ||
logMatchers[1].assertUserInfo(equals: (id: "abc-123", name: "Foo", email: nil, extraInfo: nil)) | ||
logMatchers[2].assertUserInfo(equals: (id: "abc-123", name: "Foo", email: "foo@example.com", extraInfo: ["extra_key": "extra_value"])) | ||
logMatchers[3].assertUserInfo(equals: nil) | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,7 +445,12 @@ class RUMMonitorTests: XCTestCase { | |
directory: temporaryDirectory, | ||
dependencies: .mockWith( | ||
userInfoProvider: .mockWith( | ||
userInfo: UserInfo(id: "abc-123", name: "Foo", email: "foo@bar.com") | ||
userInfo: UserInfo( | ||
id: "abc-123", | ||
name: "Foo", | ||
email: "foo@bar.com", | ||
extraInfo: ["extra_key": "extra_value"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because extraInfo: ["extra_string": "string_value", "extra_int": 42, "extra_bool": true] and document the expected encoding result in test assertions. |
||
) | ||
) | ||
) | ||
) | ||
|
@@ -465,6 +470,9 @@ class RUMMonitorTests: XCTestCase { | |
|
||
let rumEventMatchers = try RUMFeature.waitAndReturnRUMEventMatchers(count: 11) | ||
let expectedUserInfo = RUMDataUSR(id: "abc-123", name: "Foo", email: "foo@bar.com") | ||
rumEventMatchers.forEach { event in | ||
event.jsonMatcher.assertValue(forKey: "context.usr.extra_key", equals: "extra_value") | ||
} | ||
try rumEventMatchers.forEachRUMEvent(ofType: RUMDataAction.self) { action in | ||
XCTAssertEqual(action.usr, expectedUserInfo) | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -335,8 +335,8 @@ class TracerTests: XCTestCase { | |
Datadog.setUserInfo(id: "abc-123", name: "Foo") | ||
tracer.startSpan(operationName: "span with user `id` and `name`").finish() | ||
|
||
Datadog.setUserInfo(id: "abc-123", name: "Foo", email: "foo@example.com") | ||
tracer.startSpan(operationName: "span with user `id`, `name` and `email`").finish() | ||
Datadog.setUserInfo(id: "abc-123", name: "Foo", email: "foo@example.com", extraInfo: ["extra_key": "extra_value"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because extraInfo: ["extra_string": "string_value", "extra_int": 42, "extra_bool": true] and document the expected encoding result in test assertions. |
||
tracer.startSpan(operationName: "span with user `id`, `name`, `email` and `extraInfo`").finish() | ||
|
||
Datadog.setUserInfo(id: nil, name: nil, email: nil) | ||
tracer.startSpan(operationName: "span with no user info").finish() | ||
|
@@ -353,10 +353,12 @@ class TracerTests: XCTestCase { | |
XCTAssertEqual(try spanMatchers[2].meta.userID(), "abc-123") | ||
XCTAssertEqual(try spanMatchers[2].meta.userName(), "Foo") | ||
XCTAssertEqual(try spanMatchers[2].meta.userEmail(), "foo@example.com") | ||
XCTAssertEqual(try spanMatchers[2].meta.custom(keyPath: "meta.usr.extra_key"), "extra_value") | ||
|
||
XCTAssertNil(try? spanMatchers[3].meta.userID()) | ||
XCTAssertNil(try? spanMatchers[3].meta.userName()) | ||
XCTAssertNil(try? spanMatchers[3].meta.userEmail()) | ||
XCTAssertNil(try? spanMatchers[3].meta.custom(keyPath: "meta.usr.extra_key")) | ||
} | ||
|
||
// MARK: - Sending carrier info | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This public API is missing the comment.