File tree Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Expand file tree Collapse file tree 4 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -902,6 +902,14 @@ interface INPAttribution {
902
902
*/
903
903
interactionTarget: string ;
904
904
905
+ /**
906
+ * A node identifying the element that the user first interacted with
907
+ * as part of the frame where the INP candidate interaction occurred.
908
+ * If `interactionTargetElement` is null, that generally means the
909
+ * element was removed from the DOM after the interaction.
910
+ */
911
+ interactionTargetElement? : Node ;
912
+
905
913
/**
906
914
* The time when the user first interacted during the frame where the INP
907
915
* candidate interaction occurred (if more than one interaction occurred
Original file line number Diff line number Diff line change @@ -236,9 +236,10 @@ const attributeINP = (metric: INPMetric): INPMetricWithAttribution => {
236
236
// https://bugs.chromium.org/p/chromium/issues/detail?id=1367329
237
237
// We also fallback to interactionTargetMap for when target removed from DOM
238
238
const firstEntryWithTarget = metric . entries . find ( ( entry ) => entry . target ) ;
239
- const interactionTarget = firstEntryWithTarget
240
- ? getSelector ( firstEntryWithTarget . target )
241
- : getSelector ( interactionTargetMap . get ( firstEntry . interactionId ) ) || '' ;
239
+ const interactionTargetElement =
240
+ firstEntryWithTarget ?. target ||
241
+ interactionTargetMap . get ( firstEntry . interactionId ) ;
242
+ const interactionTarget = getSelector ( interactionTargetElement ) ;
242
243
243
244
// Since entry durations are rounded to the nearest 8ms, we need to clamp
244
245
// the `nextPaintTime` value to be higher than the `processingEnd` or
@@ -254,6 +255,7 @@ const attributeINP = (metric: INPMetric): INPMetricWithAttribution => {
254
255
255
256
const attribution : INPAttribution = {
256
257
interactionTarget : interactionTarget ,
258
+ interactionTargetElement : interactionTargetElement ,
257
259
interactionType : firstEntry . name . startsWith ( 'key' ) ? 'keyboard' : 'pointer' ,
258
260
interactionTime : firstEntry . startTime ,
259
261
nextPaintTime : nextPaintTime ,
Original file line number Diff line number Diff line change @@ -38,6 +38,14 @@ export interface INPAttribution {
38
38
*/
39
39
interactionTarget : string ;
40
40
41
+ /**
42
+ * A node identifying the element that the user first interacted with
43
+ * as part of the frame where the INP candidate interaction occurred.
44
+ * If `interactionTargetElement` is null, that generally means the
45
+ * element was removed from the DOM after the interaction.
46
+ */
47
+ interactionTargetElement ?: Node ;
48
+
41
49
/**
42
50
* The time when the user first interacted during the frame where the INP
43
51
* candidate interaction occurred (if more than one interaction occurred
Original file line number Diff line number Diff line change @@ -668,10 +668,11 @@ describe('onINP()', async function () {
668
668
await stubVisibilityChange ( 'hidden' ) ;
669
669
await beaconCountIs ( 1 ) ;
670
670
671
- const [ inp1 ] = await getBeacons ( ) ;
671
+ const [ inp ] = await getBeacons ( ) ;
672
672
673
- assert . equal ( inp1 . attribution . interactionType , 'pointer' ) ;
674
- assert . equal ( inp1 . attribution . interactionTarget , '#reset' ) ;
673
+ assert . equal ( inp . attribution . interactionType , 'pointer' ) ;
674
+ assert . equal ( inp . attribution . interactionTarget , '#reset' ) ;
675
+ assert ( inp . attribution . interactionTargetElement ) ;
675
676
} ) ;
676
677
677
678
it ( 'includes LoAF entries if the browser supports it' , async function ( ) {
You can’t perform that action at this time.
0 commit comments