Skip to content
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

Merged
merged 1 commit into from
Apr 28, 2022

Conversation

fuzzybinary
Copy link
Member

@fuzzybinary fuzzybinary commented Apr 27, 2022

What and why?

The React Native and Flutter SDKs set the _dd.source additional property to have that change the source property of events. However, all of the RUM events were still only even using ios 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 RUMM

Fixes RUMM-2162

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)
  • Make sure each commit and the PR mention the Issue number or JIRA reference
  • Add CHANGELOG entry for user facing changes

Custom CI job configuration (optional)

  • Run unit tests
  • Run integration tests
  • Run smoke tests

@fuzzybinary fuzzybinary requested a review from a team as a code owner April 27, 2022 21:05
Copy link
Member

@ncreated ncreated left a 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.

Comment on lines 233 to 235
static func mockAnySource() -> String {
return ["ios", "android", "browser", "ios", "react-native", "flutter"].randomElement()!
}
Copy link
Member

@ncreated ncreated Apr 28, 2022

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).

Copy link
Member Author

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.

Copy link
Member

@maxep maxep left a 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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/nit

Suggested change
let expectedSource = RUMErrorEvent.Source.init(rawValue: customSource)
let expectedSource = RUMErrorEvent.Source(rawValue: customSource)

Copy link
Member Author

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/nit

Suggested change
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.
@fuzzybinary fuzzybinary force-pushed the jward/RUMM-2162-custom-source branch from 326d6df to ae560c2 Compare April 28, 2022 13:50
@fuzzybinary fuzzybinary merged commit af33756 into develop Apr 28, 2022
@fuzzybinary fuzzybinary deleted the jward/RUMM-2162-custom-source branch April 28, 2022 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants