♻️ Reorganize rum schemas to work around optional "view" property issues#315
Conversation
I couldn't find where those files are used. As they are just aliases on `schemas/...`, it should be fine to remove theme.
Also clean some schemas to make the validation pass.
| /** | ||
| * Contains the newly added wireframes. | ||
| */ | ||
| readonly adds: { |
There was a problem hiding this comment.
❓ Question : Why this property is not optional anymore ?
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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?
| view: { | ||
| [k: string]: unknown; | ||
| }; |
There was a problem hiding this comment.
❓ 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"
}There was a problem hiding this comment.
Interesting! I did the change.
There was a problem hiding this comment.
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 🤔
There was a problem hiding this comment.
This breaks our generator, we don't support such notation and it fails to find the ref file :/
|
d193496 to
372f451
Compare
|
I checked the new schema in 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. |
372f451 to
8dc1826
Compare
This partially reverts commit 8184858.
8dc1826 to
8743014
Compare
…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
left a comment
There was a problem hiding this comment.
Validated in iOS! 👌
It makes sense to have different RUM schemas for browser and mobile. ty!
|
|
||
| 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`. |
There was a problem hiding this comment.
🥜 nitpick:
| `./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`. |
616a1b8
Motivation
PR #306 introduced a change in the rum-events-schemas (making the
viewevent property optional for the "App Launch" vital) that is causing some issues within the Browser.Even though the
viewproperty was marked as "required" on events that requires it, this is badly supported by thejson-schema-to-typescriptand theviewproperty was still optional on some events (ex: long task, resource...).On top of this, even if the typescript generation did work correctly, the
RumEventsunion that is exposed to customers viabeforeSendwould still have an optionalviewproperty 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: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
vitalproperty, it declares one schema for each type of vital event.This allows to tweak each vital event independently, and make the
viewproperty optional only on theApp Launchvital.This also allows to expose a different
RumEventunion to be consumed by mobile and browser. For browser, theRumEventunion does not include theApp Launchvital event, so all events have a requiredviewproperty.Finally, it adds a workaround to make sure the TypeScript generation makes
viewproperties 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.