Skip to content

♻️ Reorganize rum schemas to work around optional "view" property issues#315

Merged
BenoitZugmeyer merged 14 commits into
masterfrom
benoit/reorganize-rum-schemas
Oct 27, 2025
Merged

♻️ Reorganize rum schemas to work around optional "view" property issues#315
BenoitZugmeyer merged 14 commits into
masterfrom
benoit/reorganize-rum-schemas

Conversation

@BenoitZugmeyer

@BenoitZugmeyer BenoitZugmeyer commented Oct 22, 2025

Copy link
Copy Markdown
Member

Motivation

PR #306 introduced a change in the rum-events-schemas (making the view event property optional for the "App Launch" vital) that is causing some issues within the Browser.

Even though the view property was marked as "required" on events that requires it, this is badly supported by the json-schema-to-typescript and the view property was still optional on some events (ex: long task, resource...).

On top of this, even if the typescript generation did work correctly, the RumEvents union that is exposed to customers via beforeSend would still have an optional view property since it includes the "App Launch" vital. That would be a breaking change for customers using typescript. In the following example, TypeScript would raise a "'event.view' is possibly 'undefined'." error:

DD_RUM.init({
  beforeSend(event) {
    event.view.url = removeSensitiveData(url)
  }
})

Related Browser SDK PR based on this change: DataDog/browser-sdk#3923

Changes

To work around this issue, this PR changes how vital schema are declared. Instead of using a single schema for the vital event and a different schema for the vital property, it declares one schema for each type of vital event.

This allows to tweak each vital event independently, and make the view property optional only on the App Launch vital.

This also allows to expose a different RumEvent union to be consumed by mobile and browser. For browser, the RumEvent union does not include the App Launch vital event, so all events have a required view property.

Finally, it adds a workaround to make sure the TypeScript generation makes view properties required when needed. It adds a validation rule to make sure this workaround is always enforced.

The first two commits are just small maintenance changes related to vital events.

@BenoitZugmeyer
BenoitZugmeyer marked this pull request as ready for review October 22, 2025 15:26
@BenoitZugmeyer
BenoitZugmeyer requested review from a team as code owners October 22, 2025 15:26
@BenoitZugmeyer BenoitZugmeyer changed the title ♻️ reorganize rum schemas ♻️ Reorganize rum schemas to work around optional "view" property issues Oct 22, 2025
/**
* Contains the newly added wireframes.
*/
readonly adds: {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❓ Question : Why this property is not optional anymore ?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Ah good catch. This happened when I did this change. I think the intent was to make it required but it never worked (at least with json-schema-to-typescript). Let's wait for a Mobile review to know more.

@thomas-lebeau thomas-lebeau left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess besides the browser SDK, the mobile SDK might also need to update something to account for the mobile/browser schema split.
Any other consumer of these schema we should be aware?

Comment on lines +1246 to +1248
view: {
[k: string]: unknown;
};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

❓ question: ‏Is it desired to open the view object to any other keys?

I wonder if defining views like this in the different schema will help for this (and for readability?)

"view": {
-  "type": "object"
+  "$ref": "_common-schema.json#/properties/view"
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Interesting! I did the change.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Although to answer your question:

Is it desired to open the view object to any other keys?

This is already the case. We don't use additionalProperties so it defaults to true everywhere.

Although, json-schema-to-typescript has a new option to set the default to false, so we could consider getting rid of those [k: string]: unknown. Not sure how breaking this would be though 🤔

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This breaks our generator, we don't support such notation and it fails to find the ref file :/

thomas-lebeau
thomas-lebeau previously approved these changes Oct 23, 2025
@BenoitZugmeyer

Copy link
Copy Markdown
Member Author

I guess besides the browser SDK, the mobile SDK might also need to update something to account for the mobile/browser schema split. Any other consumer of these schema we should be aware?

web-ui depends on the generated typescript files, but not the json schema. I'm not aware of other consumers.

Comment thread rum-events-format.json Outdated
@BenoitZugmeyer
BenoitZugmeyer force-pushed the benoit/reorganize-rum-schemas branch 7 times, most recently from d193496 to 372f451 Compare October 23, 2025 12:34
@aleksandr-gringauz

aleksandr-gringauz commented Oct 23, 2025

Copy link
Copy Markdown
Contributor

I checked the new schema in dd-sdk-android.

There is only one problem - https://github.com/DataDog/rum-events-format/pull/308/files#r2454900600

It isn't related to this PR.

The changes from this PR work.

@BenoitZugmeyer
BenoitZugmeyer force-pushed the benoit/reorganize-rum-schemas branch from 372f451 to 8dc1826 Compare October 23, 2025 12:37
@BenoitZugmeyer
BenoitZugmeyer force-pushed the benoit/reorganize-rum-schemas branch from 8dc1826 to 8743014 Compare October 24, 2025 08:17
…ion"

This reverts commit 415b2d2.

Mobile SDKs don't support this syntax
iOS SDK does not support `anyOf` at this level.
To simplify things a bit, the iOS SDK will use
`schemas/rum-events-mobile-schema.json` and
`schemas/session-replay-mobile-format.json` as entrypoints instead of
`rum-events-format.json` and `session-replay-mobile-format.json`.

To accommodate this change, this commit includes the telemetry events in
the rum mobile entry point.

This commit also clarifies how all this is used in the DataDog
ecosystem.
simaoseica-dd
simaoseica-dd previously approved these changes Oct 24, 2025

@simaoseica-dd simaoseica-dd left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Validated in iOS! 👌
It makes sense to have different RUM schemas for browser and mobile. ty!

rgaignault
rgaignault previously approved these changes Oct 24, 2025
Comment thread README.md Outdated

It is also possible to specify the exact commit hash to use, e.g:
- The [iOS SDK](https://github.com/DataDog/dd-sdk-ios/) generates native data models based on
`./schemas/rum-events-mobile-schema.json`] and `./schemas/session-replay-mobile-schema.json`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🥜 nitpick:

Suggested change
`./schemas/rum-events-mobile-schema.json`] and `./schemas/session-replay-mobile-schema.json`.
`./schemas/rum-events-mobile-schema.json` and `./schemas/session-replay-mobile-schema.json`.

thomas-lebeau
thomas-lebeau previously approved these changes Oct 24, 2025
@BenoitZugmeyer
BenoitZugmeyer merged commit fe242fe into master Oct 27, 2025
10 of 11 checks passed
@BenoitZugmeyer
BenoitZugmeyer deleted the benoit/reorganize-rum-schemas branch October 27, 2025 08:15
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.

6 participants