Skip to content

Commit 813aee6

Browse files
mormubisclaudealeksandr-gringauz
authored
feat: add view_update event type (#355)
* feat(rum): add view_update event type and _view-properties shared schema Implements the view_update event type per the approved RFC on RUM Event Format limitations. The new event carries only changed view fields, eliminating the 50-90% redundant data sent with every full view update. Key changes: - Add schemas/rum/_view-properties.json: shared optional view-specific properties (no required fields) composed by both view and view_update - Add schemas/rum/view_update-schema.json: standalone schema (no _common-schema.json ref) with minimal required set: type, application.id, session.id, view.id, _dd.document_version - Refactor schemas/rum/view-schema.json to reference _view-properties.json, slimming its last allOf block to type and _dd.document_version only - Add view_update to oneOf in rum-events-schema.json, rum-events-browser-schema.json, and rum-events-mobile-schema.json - Add samples/rum-events/view_update.json sample event - Regenerate TypeScript types: RumViewUpdateEvent exported in lib/generated/rum.ts Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(rum): align account.id required and rebuild with tsc 5.9.3 Two fixes for failing CI checks: 1. ios-sdk-test: The Swift code generator creates a single shared RUMAccount struct across all event schemas. view_update had account.id as optional while all other events (via _common-schema.json) have it required, causing an inconsistency error. Adding required: ["id"] to account in view_update-schema.json resolves the conflict. 2. check-is-built: Local node_modules had tsc 4.7.4 (stale, pre-yarn-install) while yarn.lock pins tsc 5.9.3. The two versions emit different declaration file syntax (export declare type vs export type), causing the committed lib/ files to not match CI's build output. Rebuilding with the correct tsc 5.9.3 after running yarn install fixes the mismatch. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(rum): align view_update shared struct definitions with _common-schema The iOS Swift code generator requires all uses of a named struct (Session, View, OS, Device) across event schemas to have identical field definitions. Four conflicts remained after the previous fix: - Device.locale/locales/timeZone: descriptions in _common-schema.json use U+2019 (curly right single quote) while view_update used plain ASCII apostrophes (U+0027). Fixed by copying the exact characters. - Session: _common-schema requires both id and type; view_update only required id. Added type to session.required. - View: _common-schema requires id and url; view_update only required id. Added url to view.required and updated the sample accordingly. - OS: _common-schema requires name, version, version_major; view_update had no required fields. Added the matching required array. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(rum): apply prettier formatting to view_update files Python's json.dump produced non-Prettier-compliant formatting in view_update-schema.json and view_update.json. Running yarn format -w to fix. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(rum): copy exact device descriptions from _common-schema.json Previous fix over-replaced ASCII apostrophes with U+2019 in device descriptions, converting example quote chars around 'en-US' and 'Europe/Berlin' as well. _common-schema.json only uses U+2019 for possessive apostrophes (user's, device's), not for example quotes. Copying descriptions verbatim from _common-schema.json to ensure byte-identical strings and resolve the Swift shared struct conflict. Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> * fix(rum): address review feedback on view_update schema - view_update: use _common-schema.json directly; session.type, view.url and _dd.format_version are required alongside the delta payload - view_update: make date required; remove required on sub-object fields (connectivity.status, display.viewport dims, os fields) that block partial updates - view-schema: restore required constraints removed by refactor (view.time_spent, action/error/resource.count, privacy.replay_level, display.scroll fields) - view-schema: move view-specific _dd properties (page_states, replay_stats, cls, configuration, profiling) out of _view-properties and into view-schema to eliminate _dd namespace collision with view_update - sample: update view_update.json to reflect minimal delta payload * fix: move required constraints into _view-properties.json to avoid Android generator merge conflict The Android SDK model generator cannot merge Enum with Primitive(type=STRING). Previously, view-schema.json had typed stubs for privacy.replay_level and display.scroll.* properties that conflicted with their enum/typed definitions in _view-properties.json when the Android generator resolved the allOf merge. Move the required constraints directly into _view-properties.json and remove the typed property stubs from view-schema.json's inline allOf block. This eliminates the merge conflict entirely since _view-properties.json is a single source of truth for these properties. * fix: replace empty stubs with typed stubs to fix Android generator crash The Android schema generator does not support empty {} schema definitions (all-null JsonDefinition). The view-schema.json stubs for time_spent ({}) and action/error/resource ({ required: [count] }) caused the generator to crash with 'Unsupported schema definition'. - Replace {} and bare-required stubs with typed stubs ({ type: integer } and { type: object }) so the generator sees a concrete type to work with - Move required:[count] for action/error/resource into _view-properties.json alongside their property definitions, per reviewer suggestion The outer view.required:[time_spent,action,error,resource] stays in view-schema.json since view_update uses _view-properties.json and those fields must remain optional for delta events. * refactor: remove redundant property type stubs from view-schema.json * Revert "refactor: remove redundant property type stubs from view-schema.json" This reverts commit 9fa7961. * fix required in some places (#360) * fix build * rename _view-properties.json to _view-properties-schema.json to match naming convention --------- Co-authored-by: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com> Co-authored-by: Sasha Gringauz <aleksandr.gringauz@datadoghq.com>
1 parent 5622f2a commit 813aee6

9 files changed

Lines changed: 1958 additions & 1795 deletions

File tree

lib/cjs/generated/rum.d.ts

Lines changed: 709 additions & 670 deletions
Large diffs are not rendered by default.

lib/esm/generated/rum.d.ts

Lines changed: 709 additions & 670 deletions
Large diffs are not rendered by default.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"type": "view_update",
3+
"date": 1712345678901,
4+
"application": { "id": "ac8218cf-498b-4d33-bd44-151095959547" },
5+
"session": { "id": "cacbf45c-3a05-48ce-b066-d76349460599", "type": "user" },
6+
"view": {
7+
"id": "623d50fd-75cf-4025-97d2-e51ff94171f6",
8+
"url": "https://example.com/home",
9+
"time_spent": 245512755000
10+
},
11+
"_dd": { "document_version": 2, "format_version": 2 }
12+
}

schemas/rum-events-browser-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
{
2424
"$ref": "rum/view-schema.json"
2525
},
26+
{
27+
"$ref": "rum/view_update-schema.json"
28+
},
2629
{
2730
"title": "RumVitalEvent",
2831
"oneOf": [

schemas/rum-events-mobile-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020
{
2121
"$ref": "rum/view-schema.json"
2222
},
23+
{
24+
"$ref": "rum/view_update-schema.json"
25+
},
2326
{
2427
"title": "RumVitalEvent",
2528
"oneOf": [

schemas/rum-events-schema.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
{
2424
"$ref": "rum/view-schema.json"
2525
},
26+
{
27+
"$ref": "rum/view_update-schema.json"
28+
},
2629
{
2730
"title": "RumVitalEvent",
2831
"oneOf": [

0 commit comments

Comments
 (0)