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 authored Dec 24, 2024
1 parent 828bb13 commit 67601c9
Show file tree
Hide file tree
Showing 5 changed files with 381 additions and 36 deletions.
112 changes: 100 additions & 12 deletions lib/cjs/generated/rum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,51 +772,51 @@ export declare type RumViewEvent = CommonProperties & ViewContainerSchema & {
*/
readonly time_spent: number;
/**
* Duration in ns to the first rendering
* Duration in ns to the first rendering (deprecated in favor of `view.performance.fcp.timestamp`)
*/
readonly first_contentful_paint?: number;
/**
* Duration in ns to the largest contentful paint
* Duration in ns to the largest contentful paint (deprecated in favor of `view.performance.lcp.timestamp`)
*/
readonly largest_contentful_paint?: number;
/**
* CSS selector path of the largest contentful paint element
* CSS selector path of the largest contentful paint element (deprecated in favor of `view.performance.lcp.target_selector`)
*/
readonly largest_contentful_paint_target_selector?: string;
/**
* Duration in ns of the first input event delay
* Duration in ns of the first input event delay (deprecated in favor of `view.performance.fid.duration`)
*/
readonly first_input_delay?: number;
/**
* Duration in ns to the first input
* Duration in ns to the first input (deprecated in favor of `view.performance.fid.timestamp`)
*/
readonly first_input_time?: number;
/**
* CSS selector path of the first input target element
* CSS selector path of the first input target element (deprecated in favor of `view.performance.fid.target_selector`)
*/
readonly first_input_target_selector?: string;
/**
* Longest duration in ns between an interaction and the next paint
* Longest duration in ns between an interaction and the next paint (deprecated in favor of `view.performance.inp.duration`)
*/
readonly interaction_to_next_paint?: number;
/**
* Duration in ns between start of the view and start of the INP
* Duration in ns between start of the view and start of the INP (deprecated in favor of `view.performance.inp.timestamp`)
*/
readonly interaction_to_next_paint_time?: number;
/**
* CSS selector path of the interacted element corresponding to INP
* CSS selector path of the interacted element corresponding to INP (deprecated in favor of `view.performance.inp.target_selector`)
*/
readonly interaction_to_next_paint_target_selector?: string;
/**
* Total layout shift score that occurred on the view
* Total layout shift score that occurred on the view (deprecated in favor of `view.performance.cls.score`)
*/
readonly cumulative_layout_shift?: number;
/**
* Duration in ns between start of the view and start of the largest layout shift contributing to CLS
* Duration in ns between start of the view and start of the largest layout shift contributing to CLS (deprecated in favor of `view.performance.cls.timestamp`)
*/
readonly cumulative_layout_shift_time?: number;
/**
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS (deprecated in favor of `view.performance.cls.target_selector`)
*/
readonly cumulative_layout_shift_target_selector?: string;
/**
Expand Down Expand Up @@ -1085,6 +1085,10 @@ export declare type RumViewEvent = CommonProperties & ViewContainerSchema & {
};
[k: string]: unknown;
};
/**
* Performance data. (Web Vitals, etc.)
*/
performance?: ViewPerformanceData;
[k: string]: unknown;
};
/**
Expand Down Expand Up @@ -1487,3 +1491,87 @@ export interface RumPerfMetric {
readonly metric_max?: number;
[k: string]: unknown;
}
/**
* Schema for view-level RUM performance data (Web Vitals, etc.)
*/
export interface ViewPerformanceData {
/**
* 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;
}
112 changes: 100 additions & 12 deletions lib/esm/generated/rum.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -772,51 +772,51 @@ export declare type RumViewEvent = CommonProperties & ViewContainerSchema & {
*/
readonly time_spent: number;
/**
* Duration in ns to the first rendering
* Duration in ns to the first rendering (deprecated in favor of `view.performance.fcp.timestamp`)
*/
readonly first_contentful_paint?: number;
/**
* Duration in ns to the largest contentful paint
* Duration in ns to the largest contentful paint (deprecated in favor of `view.performance.lcp.timestamp`)
*/
readonly largest_contentful_paint?: number;
/**
* CSS selector path of the largest contentful paint element
* CSS selector path of the largest contentful paint element (deprecated in favor of `view.performance.lcp.target_selector`)
*/
readonly largest_contentful_paint_target_selector?: string;
/**
* Duration in ns of the first input event delay
* Duration in ns of the first input event delay (deprecated in favor of `view.performance.fid.duration`)
*/
readonly first_input_delay?: number;
/**
* Duration in ns to the first input
* Duration in ns to the first input (deprecated in favor of `view.performance.fid.timestamp`)
*/
readonly first_input_time?: number;
/**
* CSS selector path of the first input target element
* CSS selector path of the first input target element (deprecated in favor of `view.performance.fid.target_selector`)
*/
readonly first_input_target_selector?: string;
/**
* Longest duration in ns between an interaction and the next paint
* Longest duration in ns between an interaction and the next paint (deprecated in favor of `view.performance.inp.duration`)
*/
readonly interaction_to_next_paint?: number;
/**
* Duration in ns between start of the view and start of the INP
* Duration in ns between start of the view and start of the INP (deprecated in favor of `view.performance.inp.timestamp`)
*/
readonly interaction_to_next_paint_time?: number;
/**
* CSS selector path of the interacted element corresponding to INP
* CSS selector path of the interacted element corresponding to INP (deprecated in favor of `view.performance.inp.target_selector`)
*/
readonly interaction_to_next_paint_target_selector?: string;
/**
* Total layout shift score that occurred on the view
* Total layout shift score that occurred on the view (deprecated in favor of `view.performance.cls.score`)
*/
readonly cumulative_layout_shift?: number;
/**
* Duration in ns between start of the view and start of the largest layout shift contributing to CLS
* Duration in ns between start of the view and start of the largest layout shift contributing to CLS (deprecated in favor of `view.performance.cls.timestamp`)
*/
readonly cumulative_layout_shift_time?: number;
/**
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS
* CSS selector path of the first element (in document order) of the largest layout shift contributing to CLS (deprecated in favor of `view.performance.cls.target_selector`)
*/
readonly cumulative_layout_shift_target_selector?: string;
/**
Expand Down Expand Up @@ -1085,6 +1085,10 @@ export declare type RumViewEvent = CommonProperties & ViewContainerSchema & {
};
[k: string]: unknown;
};
/**
* Performance data. (Web Vitals, etc.)
*/
performance?: ViewPerformanceData;
[k: string]: unknown;
};
/**
Expand Down Expand Up @@ -1487,3 +1491,87 @@ export interface RumPerfMetric {
readonly metric_max?: number;
[k: string]: unknown;
}
/**
* Schema for view-level RUM performance data (Web Vitals, etc.)
*/
export interface ViewPerformanceData {
/**
* 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"
}
}
}
Loading

0 comments on commit 67601c9

Please sign in to comment.