Skip to content

[WIP] - partial view updates implementation#3209

Draft
aleksandr-gringauz wants to merge 38 commits intodevelopfrom
aleksandr-gringauz/view-update-1
Draft

[WIP] - partial view updates implementation#3209
aleksandr-gringauz wants to merge 38 commits intodevelopfrom
aleksandr-gringauz/view-update-1

Conversation

@aleksandr-gringauz
Copy link
Contributor

@aleksandr-gringauz aleksandr-gringauz commented Mar 2, 2026

What does this PR do?

PoC implementation of partial view updates.

The algorithm is roughly the following (see the diff in RumViewScope.kt). For each ViewEvent that we create we:

  1. Apply the EventMapper provided by the customer.
  2. Compute the diff of this mapped event with the previous one. This diff is represented as ViewEventDiff object. In order to compute the diff of the ViewEvent respecting REPLACE/MERGE/APPEND rules from the RFC I created a KSP processor that generates the diffing code based on a special DiffConfig annotation. More info here.
  3. We map ViewEventDiff into the new ViewUpdate event introduced here. See ViewEventDiffMapper.
  4. We send the ViewUpdate event to the intake.

This PR doesn't address:

  1. tests
  2. benchmarks
  3. periodic sending of the full VIEW event.

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

Review checklist (to be filled by reviewers)

  • Feature or bugfix MUST have appropriate tests (unit, integration, e2e)
  • Make sure you discussed the feature or bugfix with the maintaining team in an Issue
  • Make sure each commit and the PR mention the Issue number (cf the CONTRIBUTING doc)

aleksandr-gringauz and others added 27 commits February 26, 2026 15:55
- Strip JSON serialization/deserialization and KDoc comments from RumViewState.kt
- Remove explicit public modifiers
- Add @Diff, @DiffMerge, @DiffAppend annotations to RumViewState fields
- Fix DiffProcessor to handle nullable @DiffMerge types with null guard
- Fix DiffProcessor to handle nullable @DiffAppend lists with orEmpty()
- Fix APPEND field type to strip nullability in generated data classes
- Add recursive @DiffMerge support in nested classes

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace verbose `if (x.exists) x.item else null` pattern with `x.get()`,
and add the `get()` method to `DiffOptional` to support this.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* Copyright 2016-Present Datadog, Inc.
*/

@file:DiffConfig(
Copy link
Contributor Author

@aleksandr-gringauz aleksandr-gringauz Mar 2, 2026

Choose a reason for hiding this comment

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

This is the configuration for the diff KSP. It describes that we need a diff function for ViewEvent (and its nested classes) and what strategies its different fields have.

ignore - it means that this field should always be present in a diff, even if it hasn't changed.
merge - corresponds to MERGE logic from the RFC.
append - APPEND logic for arrays.
diffMap - special case for feature flags (we include only new and changed values of the map of flags).

REPLACE strategy is the default one.

Here is the generated code to illustrate the idea: https://gist.github.com/aleksandr-gringauz/3e0c083be78b32323c436f633aa73ed4

It is pretty much what we are doing here by hand.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

upd

removed the KSP approach. Too complicated and the benefits aren't clear. New approach is here and here.

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.

1 participant