Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/core/src/domain/telemetry/telemetryEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,18 @@ export interface CommonTelemetryProperties {
* Model of the device
*/
model?: string
/**
* Number of device processors
*/
readonly processor_count?: number
/**
* Total RAM in megabytes
*/
readonly total_ram?: number
/**
* Whether the device is considered a low RAM device (Android)
*/
readonly is_low_ram_device?: boolean
[k: string]: unknown
}
/**
Expand Down
39 changes: 18 additions & 21 deletions packages/rum-core/src/rumEvent.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export type RumActionEvent = CommonProperties &
/**
* View properties
*/
readonly view: {
readonly view?: {
/**
* Is the action starting in the foreground (focus in browser)
*/
Expand Down Expand Up @@ -175,9 +175,6 @@ export type RumTransitionEvent = CommonProperties & {
* RUM event type
*/
readonly type: 'transition'
view: {
[k: string]: unknown
}
/**
* Stream properties
*/
Expand Down Expand Up @@ -482,7 +479,7 @@ export type RumErrorEvent = CommonProperties &
/**
* View properties
*/
readonly view: {
readonly view?: {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this right? Is now the view optional?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's intended -- it comes from Téo's PR here. I don't have a full understanding of the context, though. It's not part of my changes; it just came along because Téo's changes hadn't been pulled into this repo yet.

/**
* Is the error starting in the foreground (focus in browser)
*/
Expand All @@ -507,9 +504,6 @@ export type RumLongTaskEvent = CommonProperties &
* RUM event type
*/
readonly type: 'long_task'
view: {
[k: string]: unknown
}
/**
* Long Task properties
*/
Expand Down Expand Up @@ -634,9 +628,6 @@ export type RumResourceEvent = CommonProperties &
* RUM event type
*/
readonly type: 'resource'
view: {
[k: string]: unknown
}
/**
* Resource properties
*/
Expand Down Expand Up @@ -841,7 +832,7 @@ export type RumResourceEvent = CommonProperties &
/**
* Type of the GraphQL operation
*/
readonly operationType: 'query' | 'mutation' | 'subscription'
readonly operationType?: 'query' | 'mutation' | 'subscription'
/**
* Name of the GraphQL operation
*/
Expand Down Expand Up @@ -1329,13 +1320,10 @@ export type RumVitalEvent = RumVitalDurationEvent | RumVitalOperationStepEvent
* Schema for a duration vital event.
*/
export type RumVitalDurationEvent = RumVitalEventCommonProperties & {
view: {
[k: string]: unknown
}
/**
* Vital properties
*/
readonly vital: {
readonly vital?: {
/**
* Type of the vital.
*/
Expand Down Expand Up @@ -1381,13 +1369,10 @@ export type RumVitalEventCommonProperties = CommonProperties &
* Schema for a vital operation step event.
*/
export type RumVitalOperationStepEvent = RumVitalEventCommonProperties & {
view: {
[k: string]: unknown
}
/**
* Vital properties
*/
readonly vital: {
readonly vital?: {
/**
* Type of the vital.
*/
Expand Down Expand Up @@ -1484,7 +1469,7 @@ export interface CommonProperties {
/**
* View properties
*/
readonly view?: {
readonly view: {
/**
* UUID of the view
*/
Expand Down Expand Up @@ -1699,6 +1684,18 @@ export interface CommonProperties {
* Current screen brightness level (0.0 to 1.0).
*/
readonly brightness_level?: number
/**
* Number of device processors
*/
readonly processor_count?: number
/**
* Total RAM in megabytes
*/
readonly total_ram?: number
/**
* Whether the device is considered a low RAM device (Android)
*/
readonly is_low_ram_device?: boolean
[k: string]: unknown
}
/**
Expand Down
173 changes: 173 additions & 0 deletions packages/rum/src/types/sessionReplay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type BrowserRecord =
| ViewEndRecord
| VisualViewportRecord
| FrustrationRecord
| BrowserChangeRecord
/**
* Browser-specific. Schema of a Record type which contains the full snapshot of a screen.
*/
Expand Down Expand Up @@ -333,6 +334,178 @@ export type FrustrationRecord = SlotSupportedCommonRecordSchema & {
recordIds: number[]
}
}
/**
* Browser-specific. Schema of a record type which represents changes using a compact encoding. (Experimental; subject to change.)
*/
export type BrowserChangeRecord = SlotSupportedCommonRecordSchema & {
/**
* The type of this Record.
*/
readonly type: 12
data: Change[]
id?: number
}
/**
* Browser-specific. Schema representing an individual change within a BrowserChangeData collection.
*/
export type Change =
| [0, ...AddStringChange[]]
| [1, ...AddNodeChange[]]
| [2, ...RemoveNodeChange[]]
| [3, ...AttributeChange[]]
| [4, ...TextChange[]]
| [5, ...SizeChange[]]
| [6, ...ScrollPositionChange[]]
| [7, ...AdoptedStyleSheetsChange[]]
/**
* Browser-specific. Schema representing the addition of a string to the string table.
*/
export type AddStringChange = string
/**
* Browser-specific. Schema representing the addition of a new node to the document.
*/
export type AddNodeChange =
| AddCDataSectionNodeChange
| AddDocTypeNodeChange
| AddDocumentNodeChange
| AddDocumentFragmentNodeChange
| AddElementNodeChange
| AddShadowRootNodeChange
| AddTextNodeChange
/**
* Schema representing the addition of a new #cdata-section node.
*
* @minItems 2
*/
export type AddCDataSectionNodeChange = [InsertionPoint, '#cdata-section' | StringReference]
/**
* Browser-specific. Schema representing the insertion point of a node which is being added to the document.
*/
export type InsertionPoint =
| AppendChildInsertionPoint
| InsertAfterPreviousInsertionPoint
| InsertBeforeInsertionPoint
| RootInsertionPoint
/**
* A positive integer insertion point. Inserting a node at positive integer N indicates that the new node's parent is the node with an id N lower than the new node, and that we should insert the new node at the end of its parent's child list, as if the DOM method appendChild() was being used.
*/
export type AppendChildInsertionPoint = number
/**
* A zero insertion point. Inserting a node at zero indicates that the new node should be inserted after the node with an id one lower than the new node, as if the DOM method after() is being used. Using a zero insertion point repeatedly is thus a quick way to insert a sequence of sibling elements.
*/
export type InsertAfterPreviousInsertionPoint = 0
/**
* A negative integer insertion point. Inserting a node at negative integer -N indicates that the new node's next sibling is the node with an id N lower than the new node, and that we should insert the new node before its next sibling, as if the DOM method insertBefore() was being used.
*/
export type InsertBeforeInsertionPoint = number
/**
* A null insertion point, indicating that the node should be inserted at the root of the document.
*/
export type RootInsertionPoint = null
/**
* Browser-specific. Schema representing a string, expressed as an index into the string table.
*/
export type StringReference = number
/**
* Schema representing the addition of a new #doctype node, using the format [#doctype, name, public ID, system ID].
*
* @minItems 5
*/
export type AddDocTypeNodeChange = [
InsertionPoint,
'#doctype' | StringReference,
StringOrStringReference,
StringOrStringReference,
StringOrStringReference,
]
/**
* Browser-specific. Schema representing a string, either expressed as a literal or as an index into the string table.
*/
export type StringOrStringReference = string | StringReference
/**
* Schema representing the addition of a new #document node.
*
* @minItems 2
*/
export type AddDocumentNodeChange = [InsertionPoint, '#document' | StringReference]
/**
* Schema representing the addition of a new #document-fragment node.
*
* @minItems 2
*/
export type AddDocumentFragmentNodeChange = [InsertionPoint, '#document-fragment' | StringReference]
/**
* Schema representing the addition of a new element node.
*
* @minItems 2
*/
export type AddElementNodeChange = [InsertionPoint, string | StringReference, ...AttributeAssignment[]]
/**
* Schema representing an assignment of a value to an attribute. The format is [name, value].
*
* @minItems 2
*/
export type AttributeAssignment = [StringOrStringReference, StringOrStringReference]
/**
* Schema representing the addition of a new #shadow-root node.
*
* @minItems 2
*/
export type AddShadowRootNodeChange = [InsertionPoint, '#shadow-root' | StringReference]
/**
* Schema representing the addition of a new #text node.
*
* @minItems 3
*/
export type AddTextNodeChange = [InsertionPoint, '#text' | StringReference, StringOrStringReference]
/**
* Browser-specific. Schema representing the removal of a node from the document.
*/
export type RemoveNodeChange = number
/**
* Browser-specific. Schema representing a change to an node's attributes.
*
* @minItems 1
*/
export type AttributeChange = [NodeId, ...AttributeAssignmentOrDeletion[]]
/**
* Browser-specific. Schema representing the ID of a DOM node.
*/
export type NodeId = number
/**
* Schema representing a change to an attribute, either by assignment of a new value or by deletion of the attribute.
*/
export type AttributeAssignmentOrDeletion = AttributeAssignment | AttributeDeletion
/**
* Schema representing the deletion of an attribute.
*
* @minItems 1
*/
export type AttributeDeletion = [StringOrStringReference]
/**
* Browser-specific. Schema representing a change to the text content of a #text node.
*
* @minItems 2
*/
export type TextChange = [NodeId, StringOrStringReference]
/**
* Browser-specific. Schema representing a change in an element's size.
*
* @minItems 3
*/
export type SizeChange = [NodeId, number, number]
/**
* Browser-specific. Schema representing a scroll position change.
*
* @minItems 3
*/
export type ScrollPositionChange = [NodeId, number, number]
/**
* Browser-specific. Schema representing a change to the adopted stylesheets of a document or shadow DOM subtree.
*
* @minItems 1
*/
export type AdoptedStyleSheetsChange = [NodeId, ...StyleSheet[]]

/**
* Schema of a Session Replay Segment context.
Expand Down
26 changes: 26 additions & 0 deletions packages/rum/src/types/sessionReplayConstants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export const RecordType: {
ViewEnd: SessionReplay.ViewEndRecord['type']
VisualViewport: SessionReplay.VisualViewportRecord['type']
FrustrationRecord: SessionReplay.FrustrationRecord['type']
Change: SessionReplay.BrowserChangeRecord['type']
} = {
FullSnapshot: 2,
IncrementalSnapshot: 3,
Expand All @@ -16,6 +17,7 @@ export const RecordType: {
ViewEnd: 7,
VisualViewport: 8,
FrustrationRecord: 9,
Change: 12,
} as const

export type RecordType = (typeof RecordType)[keyof typeof RecordType]
Expand All @@ -38,6 +40,30 @@ export const NodeType: {

export type NodeType = (typeof NodeType)[keyof typeof NodeType]

// ChangeTypeId evaluates to Id if [Id, ...Data[]] is a valid variant of Change;
// otherwise, it triggers a compile-time error.
type ChangeTypeId<Id, Data> = [Id, ...Data[]] extends SessionReplay.Change ? Id : never

export const ChangeType: {
AddString: ChangeTypeId<0, SessionReplay.AddStringChange>
AddNode: ChangeTypeId<1, SessionReplay.AddNodeChange>
RemoveNode: ChangeTypeId<2, SessionReplay.RemoveNodeChange>
Attribute: ChangeTypeId<3, SessionReplay.AttributeChange>
Text: ChangeTypeId<4, SessionReplay.TextChange>
Size: ChangeTypeId<5, SessionReplay.SizeChange>
ScrollPosition: ChangeTypeId<6, SessionReplay.ScrollPositionChange>
AdoptedStyleSheets: ChangeTypeId<7, SessionReplay.AdoptedStyleSheetsChange>
} = {
AddString: 0,
AddNode: 1,
RemoveNode: 2,
Attribute: 3,
Text: 4,
Size: 5,
ScrollPosition: 6,
AdoptedStyleSheets: 7,
} as const

export const IncrementalSource: {
Mutation: SessionReplay.BrowserMutationData['source']
MouseMove: Exclude<SessionReplay.MousemoveData['source'], 6>
Expand Down
2 changes: 1 addition & 1 deletion rum-events-format
Submodule rum-events-format updated 44 files
+154 −1 lib/cjs/generated/browserSessionReplay.d.ts
+19 −22 lib/cjs/generated/rum.d.ts
+154 −1 lib/cjs/generated/sessionReplay.d.ts
+12 −0 lib/cjs/generated/telemetry.d.ts
+154 −1 lib/esm/generated/browserSessionReplay.d.ts
+19 −22 lib/esm/generated/rum.d.ts
+154 −1 lib/esm/generated/sessionReplay.d.ts
+12 −0 lib/esm/generated/telemetry.d.ts
+70 −0 samples/session-replay/browser/record/change-record.json
+16 −1 schemas/rum/_common-schema.json
+0 −1 schemas/rum/_stream-schema.json
+1 −1 schemas/rum/action-schema.json
+1 −1 schemas/rum/error-schema.json
+1 −4 schemas/rum/long_task-schema.json
+1 −5 schemas/rum/resource-schema.json
+1 −4 schemas/rum/transition-schema.json
+1 −1 schemas/rum/view-schema.json
+0 −1 schemas/rum/vital-app-launch-schema.json
+0 −4 schemas/rum/vital-duration-schema.json
+0 −4 schemas/rum/vital-operation-step-schema.json
+32 −0 schemas/session-replay/browser/change-record-schema.json
+109 −0 schemas/session-replay/browser/changes/add-node-change-schema.json
+7 −0 schemas/session-replay/browser/changes/add-string-change-schema.json
+12 −0 schemas/session-replay/browser/changes/adopted-stylesheets-change-schema.json
+12 −0 schemas/session-replay/browser/changes/attribute-change-schema.json
+7 −0 schemas/session-replay/browser/changes/attributes/attribute-assignment-or-deletion-schema.json
+13 −0 schemas/session-replay/browser/changes/attributes/attribute-assignment-schema.json
+10 −0 schemas/session-replay/browser/changes/attributes/attribute-deletion-schema.json
+64 −0 schemas/session-replay/browser/changes/change-schema.json
+8 −0 schemas/session-replay/browser/changes/node-references/append-child-insertion-point-schema.json
+7 −0 schemas/session-replay/browser/changes/node-references/insert-after-previous-insertion-point-schema.json
+8 −0 schemas/session-replay/browser/changes/node-references/insert-before-insertion-point-schema.json
+12 −0 schemas/session-replay/browser/changes/node-references/insertion-point-schema.json
+8 −0 schemas/session-replay/browser/changes/node-references/node-id-schema.json
+7 −0 schemas/session-replay/browser/changes/node-references/root-insertion-point-schema.json
+7 −0 schemas/session-replay/browser/changes/remove-node-change-schema.json
+20 −0 schemas/session-replay/browser/changes/scroll-position-change-schema.json
+20 −0 schemas/session-replay/browser/changes/size-change-schema.json
+13 −0 schemas/session-replay/browser/changes/string-references/string-or-string-reference-schema.json
+8 −0 schemas/session-replay/browser/changes/string-references/string-reference-schema.json
+13 −0 schemas/session-replay/browser/changes/text-change-schema.json
+3 −0 schemas/session-replay/browser/record-schema.json
+15 −0 schemas/telemetry/_common-schema.json
+10 −4 scripts/validate.mjs
1 change: 1 addition & 0 deletions scripts/check-schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ runMain(() => {
printLog('Regenerating schemas...')
command`scripts/cli build_json2type`.run()
command`node scripts/generate-schema-types.ts`.run()
command`yarn format -w`.run()

printLog('Checking untracked changes...')
const diff = command`git diff --color`.run()
Expand Down