Skip to content

Commit 6df2366

Browse files
authored
✨ feat: enable INP subparts collection by default (#4371)
Co-authored-by: hugo.garridoysaez <hugo.garridoysaez@datadoghq.com>
1 parent 3a1e99d commit 6df2366

File tree

5 files changed

+53
-24
lines changed

5 files changed

+53
-24
lines changed

packages/core/src/tools/experimentalFeatures.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ export enum ExperimentalFeature {
2222
START_STOP_RESOURCE = 'start_stop_resource',
2323
USE_CHANGE_RECORDS = 'use_change_records',
2424
USE_INCREMENTAL_CHANGE_RECORDS = 'use_incremental_change_records',
25-
INP_SUBPARTS = 'inp_subparts',
2625
TOO_MANY_REQUESTS_INVESTIGATION = 'too_many_requests_investigation',
2726
COMPOSED_PATH_SELECTOR = 'composed_path_selector',
2827
}

packages/rum-core/src/domain/view/viewMetrics/trackInteractionToNextPaint.spec.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Duration, RelativeTime } from '@datadog/browser-core'
2-
import { elapsed, relativeNow, ExperimentalFeature, addExperimentalFeatures } from '@datadog/browser-core'
2+
import { elapsed, relativeNow } from '@datadog/browser-core'
33
import { registerCleanupTask } from '@datadog/browser-core/test'
44
import {
55
appendElement,
@@ -106,7 +106,7 @@ describe('trackInteractionToNextPaint', () => {
106106
value: 100 as Duration,
107107
targetSelector: undefined,
108108
time: 1 as RelativeTime,
109-
subParts: undefined,
109+
subParts: { inputDelay: 1099 as Duration, processingDuration: 0 as Duration, presentationDelay: 0 as Duration },
110110
})
111111
})
112112

@@ -122,7 +122,11 @@ describe('trackInteractionToNextPaint', () => {
122122
value: MAX_INP_VALUE,
123123
targetSelector: undefined,
124124
time: 1 as RelativeTime,
125-
subParts: undefined,
125+
subParts: {
126+
inputDelay: 1099 as Duration,
127+
processingDuration: 100 as Duration,
128+
presentationDelay: (MAX_INP_VALUE - 1199) as Duration,
129+
},
126130
})
127131
})
128132

@@ -139,7 +143,7 @@ describe('trackInteractionToNextPaint', () => {
139143
value: 98 as Duration,
140144
targetSelector: undefined,
141145
time: 98 as RelativeTime,
142-
subParts: undefined,
146+
subParts: { inputDelay: 1004 as Duration, processingDuration: 0 as Duration, presentationDelay: 0 as Duration },
143147
})
144148
})
145149

@@ -161,7 +165,7 @@ describe('trackInteractionToNextPaint', () => {
161165
value: 40 as Duration,
162166
targetSelector: undefined,
163167
time: 1 as RelativeTime,
164-
subParts: undefined,
168+
subParts: { inputDelay: 1099 as Duration, processingDuration: 0 as Duration, presentationDelay: 0 as Duration },
165169
})
166170
})
167171

@@ -179,7 +183,7 @@ describe('trackInteractionToNextPaint', () => {
179183
value: 100 as Duration,
180184
targetSelector: undefined,
181185
time: 100 as RelativeTime,
182-
subParts: undefined,
186+
subParts: { inputDelay: 1099 as Duration, processingDuration: 0 as Duration, presentationDelay: 0 as Duration },
183187
})
184188
})
185189

@@ -272,10 +276,6 @@ describe('trackInteractionToNextPaint', () => {
272276
})
273277

274278
describe('INP subparts', () => {
275-
beforeEach(() => {
276-
addExperimentalFeatures([ExperimentalFeature.INP_SUBPARTS])
277-
})
278-
279279
it('should not include subparts when INP is 0', () => {
280280
startINPTracking()
281281
interactionCountMock.setInteractionCount(1 as Duration)

packages/rum-core/src/domain/view/viewMetrics/trackInteractionToNextPaint.ts

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Duration, RelativeTime } from '@datadog/browser-core'
2-
import { elapsed, ExperimentalFeature, isExperimentalFeatureEnabled, noop, ONE_MINUTE } from '@datadog/browser-core'
2+
import { elapsed, noop, ONE_MINUTE } from '@datadog/browser-core'
33
import type { RumFirstInputTiming, RumPerformanceEventTiming } from '../../../browser/performanceObservable'
44
import {
55
createPerformanceObservable,
@@ -70,9 +70,7 @@ export function trackInteractionToNextPaint(
7070

7171
const { getViewInteractionCount, stopViewInteractionCount } = trackViewInteractionCount(viewLoadingType)
7272
const longestInteractions = trackLongestInteractions(getViewInteractionCount)
73-
const subPartsTracker = isExperimentalFeatureEnabled(ExperimentalFeature.INP_SUBPARTS)
74-
? createSubPartsTracker(longestInteractions)
75-
: null
73+
const subPartsTracker = createSubPartsTracker(longestInteractions)
7674
const firstInputSubscription = createPerformanceObservable(configuration, {
7775
type: RumPerformanceEntryType.FIRST_INPUT,
7876
buffered: true,
@@ -94,10 +92,10 @@ export function trackInteractionToNextPaint(
9492
entry.startTime <= viewEnd
9593
) {
9694
longestInteractions.process(entry)
97-
subPartsTracker?.process(entry)
95+
subPartsTracker.process(entry)
9896
}
9997
}
100-
subPartsTracker?.pruneUntracked()
98+
subPartsTracker.pruneUntracked()
10199
const candidate = longestInteractions.estimateP98Interaction()
102100
if (candidate) {
103101
updateCurrentInp(candidate)
@@ -121,9 +119,7 @@ export function trackInteractionToNextPaint(
121119
}
122120
// Recomputed on every batch: the group for the p98 interaction may have been updated
123121
// with new min/max timing even when the p98 identity (duration, startTime) is unchanged.
124-
if (subPartsTracker) {
125-
currentInp.subParts = subPartsTracker.computeSubParts(candidate, sanitizeInpValue(currentInp.duration))
126-
}
122+
currentInp.subParts = subPartsTracker.computeSubParts(candidate, sanitizeInpValue(currentInp.duration))
127123
}
128124

129125
return {
@@ -150,7 +146,7 @@ export function trackInteractionToNextPaint(
150146
stop: () => {
151147
eventSubscription.unsubscribe()
152148
firstInputSubscription.unsubscribe()
153-
subPartsTracker?.stop()
149+
subPartsTracker.stop()
154150
},
155151
}
156152
}

packages/rum-core/src/rumEvent.types.ts

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ export type RumActionEvent = CommonProperties &
141141
* CSS selector path of the target element
142142
*/
143143
readonly selector?: string
144+
/**
145+
* Selector data based on the click event composed path
146+
*/
147+
readonly composed_path_selector?: string
144148
/**
145149
* Width of the target element (in pixels)
146150
*/
@@ -499,6 +503,16 @@ export type RumErrorEvent = CommonProperties &
499503
readonly feature_flags?: {
500504
[k: string]: unknown
501505
}
506+
/**
507+
* Internal properties
508+
*/
509+
readonly _dd?: {
510+
/**
511+
* Profiling context
512+
*/
513+
profiling?: ProfilingInternalContextSchema
514+
[k: string]: unknown
515+
}
502516
[k: string]: unknown
503517
}
504518
/**
@@ -1115,6 +1129,16 @@ export type RumVitalEventCommonProperties = CommonProperties &
11151129
readonly description?: string
11161130
[k: string]: unknown
11171131
}
1132+
/**
1133+
* Internal properties
1134+
*/
1135+
readonly _dd?: {
1136+
/**
1137+
* Profiling context
1138+
*/
1139+
profiling?: ProfilingInternalContextSchema
1140+
[k: string]: unknown
1141+
}
11181142
[k: string]: unknown
11191143
}
11201144
/**
@@ -1278,6 +1302,16 @@ export interface CommonProperties {
12781302
readonly name?: string
12791303
[k: string]: unknown
12801304
}
1305+
/**
1306+
* Tab properties
1307+
*/
1308+
readonly tab?: {
1309+
/**
1310+
* UUID of the browser tab
1311+
*/
1312+
readonly id: string
1313+
[k: string]: unknown
1314+
}
12811315
/**
12821316
* Device connectivity properties
12831317
*/
@@ -1869,7 +1903,7 @@ export interface ViewProperties {
18691903
/**
18701904
* Number of frustrations that occurred on the view
18711905
*/
1872-
readonly count?: number
1906+
readonly count: number
18731907
[k: string]: unknown
18741908
}
18751909
/**
@@ -2107,7 +2141,7 @@ export interface ViewPerformanceData {
21072141
/**
21082142
* Event handler execution time
21092143
*/
2110-
readonly processing_time: number
2144+
readonly processing_duration: number
21112145
/**
21122146
* Rendering time happening after processing
21132147
*/

0 commit comments

Comments
 (0)