-
Notifications
You must be signed in to change notification settings - Fork 134
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
Fix RUM events to support sending correctly configured source
value
#832
Conversation
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.
All looks good 👍. I left one nice-to-have feedback on moving the mock definition to other file.
static func mockAnySource() -> String { | ||
return ["ios", "android", "browser", "ios", "react-native", "flutter"].randomElement()! | ||
} |
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 is rather RUM-specific mock than Foundation mock, hence FoundationMocks
is IMO not the best place for this. How about moving this next to existing RUMErrorEvent.Error.SourceType
mock in RUMDataModelMocks.swift
?
extension RUMErrorEvent.Error.SourceType: RandomMockable { |
Following this segregation will pay off nicely when we'll be extracting modules for V2 (both in implementation and tests).
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.
Yeah, good call. I'll move it.
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.
Looks good 👍
Minor nit: I see you are using Source.init(rawValue: ...)
in several places, better to do Source(rawValue: ...)
func testGivenStartedView_whenCrossPlatformErrorIsAdded_itSendsCorrectErrorEvent() throws { | ||
var currentTime: Date = .mockDecember15th2019At10AMUTC() | ||
|
||
let scope: RUMViewScope = .mockWith(parent: parent, dependencies: dependencies) | ||
let customSource = String.mockAnySource() | ||
let expectedSource = RUMErrorEvent.Source.init(rawValue: customSource) |
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.
/nit
let expectedSource = RUMErrorEvent.Source.init(rawValue: customSource) | |
let expectedSource = RUMErrorEvent.Source(rawValue: customSource) |
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.
👍 Sometimes tab completion is not your friend, especially when switching languages :)
|
||
XCTAssertTrue( | ||
scope.process(command: RUMStartViewCommand.mockAny()) | ||
) | ||
|
||
currentTime.addTimeInterval(1) | ||
|
||
let customSourceType = String.mockAnySource() | ||
let expectedSourceType = RUMErrorSourceType.init(rawValue: customSourceType) |
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.
/nit
let expectedSourceType = RUMErrorSourceType.init(rawValue: customSourceType) | |
let expectedSourceType = RUMErrorSourceType(rawValue: customSourceType) |
Fixes RUMM-2162 PR Feedback Move source mocking, fix use of .init over constructors.
326d6df
to
ae560c2
Compare
What and why?
The React Native and Flutter SDKs set the
_dd.source
additional property to have that change thesource
property of events. However, all of the RUM events were still only even usingios
as the source. This should fix it so that, if a value is provided to the the_dd.source
attribute map, that source is sent to RUMMFixes RUMM-2162
Review checklist
Custom CI job configuration (optional)