Skip to content

Commit

Permalink
Add new fields for Web Vitals attribution and other performance data
Browse files Browse the repository at this point in the history
  • Loading branch information
sethfowler-datadog committed Dec 23, 2024
1 parent 81c3d74 commit 3df6d79
Show file tree
Hide file tree
Showing 5 changed files with 333 additions and 0 deletions.
88 changes: 88 additions & 0 deletions lib/cjs/generated/rum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,10 @@ export declare type RumViewEvent = CommonProperties & ViewContainerSchema & {
};
[k: string]: unknown;
};
/**
* Performance data. (Web Vitals, etc.)
*/
performance?: RumPerformanceData;
[k: string]: unknown;
};
/**
Expand Down Expand Up @@ -1487,3 +1491,87 @@ export interface RumPerfMetric {
readonly metric_max?: number;
[k: string]: unknown;
}
/**
* Schema for RUM performance data (Web Vitals, etc.)
*/
export interface RumPerformanceData {
/**
* Cumulative Layout Shift
*/
readonly cls?: {
/**
* Total layout shift score that occurred on the view
*/
readonly score: number;
/**
* Timestamp in ns of the largest layout shift contributing to CLS
*/
readonly timestamp: number;
/**
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS
*/
readonly target_selector: string;
[k: string]: unknown;
};
/**
* First Contentful Paint
*/
readonly fcp?: {
/**
* Timestamp in ns of the first rendering
*/
readonly timestamp: number;
[k: string]: unknown;
};
/**
* First Input Delay
*/
readonly fid?: {
/**
* Duration in ns of the first input event delay
*/
readonly duration: number;
/**
* Timestamp in ns of the first input event
*/
readonly timestamp: number;
/**
* CSS selector path of the first input target element
*/
readonly target_selector: string;
[k: string]: unknown;
};
/**
* Interaction to Next Paint
*/
readonly inp?: {
/**
* Longest duration in ns between an interaction and the next paint
*/
readonly duration: number;
/**
* Timestamp in ns of the start of the INP interaction
*/
readonly timestamp: number;
/**
* CSS selector path of the interacted element for the INP interaction
*/
readonly target_selector: string;
[k: string]: unknown;
};
/**
* Largest Contentful Paint
*/
readonly lcp?: {
/**
* Timestamp in ns of the largest contentful paint
*/
readonly timestamp: number;
/**
* CSS selector path of the largest contentful paint element
*/
readonly target_selector: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
88 changes: 88 additions & 0 deletions lib/esm/generated/rum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,10 @@ export declare type RumViewEvent = CommonProperties & ViewContainerSchema & {
};
[k: string]: unknown;
};
/**
* Performance data. (Web Vitals, etc.)
*/
performance?: RumPerformanceData;
[k: string]: unknown;
};
/**
Expand Down Expand Up @@ -1487,3 +1491,87 @@ export interface RumPerfMetric {
readonly metric_max?: number;
[k: string]: unknown;
}
/**
* Schema for RUM performance data (Web Vitals, etc.)
*/
export interface RumPerformanceData {
/**
* Cumulative Layout Shift
*/
readonly cls?: {
/**
* Total layout shift score that occurred on the view
*/
readonly score: number;
/**
* Timestamp in ns of the largest layout shift contributing to CLS
*/
readonly timestamp: number;
/**
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS
*/
readonly target_selector: string;
[k: string]: unknown;
};
/**
* First Contentful Paint
*/
readonly fcp?: {
/**
* Timestamp in ns of the first rendering
*/
readonly timestamp: number;
[k: string]: unknown;
};
/**
* First Input Delay
*/
readonly fid?: {
/**
* Duration in ns of the first input event delay
*/
readonly duration: number;
/**
* Timestamp in ns of the first input event
*/
readonly timestamp: number;
/**
* CSS selector path of the first input target element
*/
readonly target_selector: string;
[k: string]: unknown;
};
/**
* Interaction to Next Paint
*/
readonly inp?: {
/**
* Longest duration in ns between an interaction and the next paint
*/
readonly duration: number;
/**
* Timestamp in ns of the start of the INP interaction
*/
readonly timestamp: number;
/**
* CSS selector path of the interacted element for the INP interaction
*/
readonly target_selector: string;
[k: string]: unknown;
};
/**
* Largest Contentful Paint
*/
readonly lcp?: {
/**
* Timestamp in ns of the largest contentful paint
*/
readonly timestamp: number;
/**
* CSS selector path of the largest contentful paint element
*/
readonly target_selector: string;
[k: string]: unknown;
};
[k: string]: unknown;
}
24 changes: 24 additions & 0 deletions samples/rum-events/view.json
Original file line number Diff line number Diff line change
Expand Up @@ -99,5 +99,29 @@
},
"privacy": {
"replay_level": "mask"
},
"performance": {
"cls": {
"score": 0.1,
"timestamp": 2000,
"target_selector": "#foo"
},
"fcp": {
"timestamp": 420725000
},
"fid": {
"duration": 20000000,
"timestamp": 20000000,
"target_selector": "#foo"
},
"inp": {
"duration": 20000000,
"timestamp": 20000000,
"target_selector": "#foo"
},
"lcp": {
"timestamp": 20000000,
"target_selector": "#foo"
}
}
}
129 changes: 129 additions & 0 deletions schemas/rum/_perf-data-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
{
"$schema": "http://json-schema.org/draft-07/schema",
"$id": "rum/_perf-data-schema.json",
"title": "RumPerformanceData",
"type": "object",
"description": "Schema for RUM performance data (Web Vitals, etc.)",
"properties": {
"cls": {
"type": "object",
"description": "Cumulative Layout Shift",
"required": ["score", "timestamp", "target_selector"],
"properties": {
"score": {
"type": "number",
"description": "Total layout shift score that occurred on the view",
"$comment": "Replaces the deprecated `view.cumulative_layout_shift` field",
"minimum": 0,
"readOnly": true
},
"timestamp": {
"type": "integer",
"description": "Timestamp in ns of the largest layout shift contributing to CLS",
"$comment": "Replaces the deprecated `view.cumulative_layout_shift_time` field",
"minimum": 0,
"readOnly": true
},
"target_selector": {
"type": "string",
"description": "CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS",
"$comment": "Replaces the deprecated `view.cumulative_layout_shift_target_selector` field",
"readOnly": true
}
},
"readOnly": true
},
"fcp": {
"type": "object",
"description": "First Contentful Paint",
"required": ["timestamp"],
"properties": {
"timestamp": {
"type": "integer",
"description": "Timestamp in ns of the first rendering",
"$comment": "Replaces the deprecated `view.first_contentful_paint` field",
"minimum": 0,
"readOnly": true
}
},
"readOnly": true
},
"fid": {
"type": "object",
"description": "First Input Delay",
"required": ["duration", "timestamp", "target_selector"],
"properties": {
"duration": {
"type": "integer",
"description": "Duration in ns of the first input event delay",
"$comment": "Replaces the deprecated `view.first_input_delay` field",
"minimum": 0,
"readOnly": true
},
"timestamp": {
"type": "integer",
"description": "Timestamp in ns of the first input event",
"$comment": "Replaces the deprecated `view.first_input_time` field",
"minimum": 0,
"readOnly": true
},
"target_selector": {
"type": "string",
"description": "CSS selector path of the first input target element",
"$comment": "Replaces the deprecated `view.first_input_target_selector` field",
"readOnly": true
}
},
"readOnly": true
},
"inp": {
"type": "object",
"description": "Interaction to Next Paint",
"required": ["duration", "timestamp", "target_selector"],
"properties": {
"duration": {
"type": "integer",
"description": "Longest duration in ns between an interaction and the next paint",
"$comment": "Replaces the deprecated `view.interaction_to_next_paint` field",
"minimum": 0,
"readOnly": true
},
"timestamp": {
"type": "integer",
"description": "Timestamp in ns of the start of the INP interaction",
"$comment": "Replaces the deprecated `view.interaction_to_next_paint_time` field",
"minimum": 0,
"readOnly": true
},
"target_selector": {
"type": "string",
"description": "CSS selector path of the interacted element for the INP interaction",
"$comment": "Replaces the deprecated `view.interaction_to_next_paint_target_selector` field",
"readOnly": true
}
},
"readOnly": true
},
"lcp": {
"type": "object",
"description": "Largest Contentful Paint",
"required": ["timestamp", "target_selector"],
"properties": {
"timestamp": {
"type": "integer",
"description": "Timestamp in ns of the largest contentful paint",
"$comment": "Replaces the deprecated `view.largest_contentful_paint` field",
"minimum": 0,
"readOnly": true
},
"target_selector": {
"type": "string",
"description": "CSS selector path of the largest contentful paint element",
"$comment": "Replaces the deprecated `view.largest_contentful_paint_target_selector` field",
"readOnly": true
}
},
"readOnly": true
}
}
}
4 changes: 4 additions & 0 deletions schemas/rum/view-schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,10 @@
"readOnly": true
}
}
},
"performance": {
"description": "Performance data. (Web Vitals, etc.)",
"allOf": [{ "$ref": "_perf-data-schema.json" }]
}
}
}
Expand Down

0 comments on commit 3df6d79

Please sign in to comment.