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

RUMM-1077 Prevent discarding RUM View events #415

Merged
merged 5 commits into from
Feb 22, 2021

Conversation

acgh
Copy link
Contributor

@acgh acgh commented Feb 17, 2021

What and why?

My understanding is that the view event opens a parent-child relationship with the subsequent Error/Resource/Action events, and dropping a view event would cause "leaks" of Error/Resource/Action events.
Thus a solution is to forbid dropping view events while keeping the ability to redact their properties and drop "children" events.

How?

In this PR we change the RUMViewEventMapper API to statically prevent from dropping RUMViewEvent by requiring a non-optional return type.

As this is statically enforced, we also remove a few checks in existing test cases as they would not compile nor make sense anymore.

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

@acgh acgh requested a review from a team as a code owner February 17, 2021 19:15
@acgh acgh requested a review from xgouchet February 17, 2021 19:16
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.

Looks good 👌.

Could you also add a change suggestion in the PR with RUM docs update? We should add a note there, that returning nil is impossible for view events.

@acgh acgh self-assigned this Feb 18, 2021
public func setRUMViewEventMapper(_ mapper: @escaping (RUMViewEvent) -> RUMViewEvent?) -> Builder {
/// - Parameter mapper: the closure taking `RUMViewEvent` as input and expecting `RUMViewEvent` as output.
/// The implementation should obtain a mutable version of the `RUMViewEvent`, modify it and return it.
/// Note that the mapper intentionally prevents from returning a `nil` to drop the `RUMViewEvent` entirely, this ensures that all `RUMViewEvent` are sent to Datadog.
Copy link
Contributor

Choose a reason for hiding this comment

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

if i were a user, that could be a bit confusing to me
i have ViewPredicate where I can keep or drop views and then i also have viewEventMapper which intentionally prevents me from dropping them.

i have a dilemma here:

  1. if we mention ViewPredicate here and how it's different than viewMapper, etc. this may be even more confusing in case the user never saw ViewPredicate API before
  2. if we don't mention it, this may be still confusing if the user is already aware of ViewPredicate API

what do you think about that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those are good points and that can look confusing.

My understanding is that the ViewPredicate gives an opportunity to drop views already, and downstream the RUMViewEventMapper will be fed with events based on views that have been already filtered.
Before that PR, we give the opportunity (again) to drop view related data at the RUMViewEventMapper, I think it can create a confusing pipeline (the other way around regarding your concerns).

My point is that ViewPredicate let's the user code filter out views, there will be no events for already filtered out views and RUMViewEventMapper will only receive events for views that have been chosen already.

Does that make sense?

That being said, maybe it would help to mention the UIKitRUMViewsPredicate here for context.

Copy link
Member

Choose a reason for hiding this comment

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

I'd vote for mentioning the UIKitRUMViewsPredicate in there.

Using this scrubbing API to ignore particular UIViewControllers from being tracked is a misuse of the SDK APIs. It means the user doesn't understand the SDK auto instrumentation & scrubbing APIs well and we should guide him towards the success.

That said, this change to "view events cannot be dropped" makes the contract between auto instrumentation & scrubbing APIs even more solid and puts the user on pathway to success.

@acgh acgh merged commit 9378fe7 into master Feb 22, 2021
@acgh acgh deleted the acgh/RUMM-1077-viewevent-data-scrubbing branch February 22, 2021 16:08
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