Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Barry Pollard <[email protected]>
  • Loading branch information
rviscomi and tunetheweb authored Jan 23, 2024
1 parent 9daa907 commit 529d991
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/attribution/onINP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,15 @@ const attributeINP = (metric: INPMetric): void => {
);
})[0];

// Currently Chrome can return a null target for certain event types
// (especially pointer events). As the event target should be the same
// for all events in the same interaction, we pick the first non-null one.
// TODO: remove when 1367329 is resolved
// https://bugs.chromium.org/p/chromium/issues/detail?id=1367329
const targetEntry = metric.entries.find(entry => entry.target);
const firstTargetEntry = metric.entries.find(entry => entry.target);

(metric as INPMetricWithAttribution).attribution = {
eventTarget: getSelector(targetEntry?.target),
eventTarget: getSelector(firstTargetEntry?.target),
eventType: longestEntry.name,
eventTime: longestEntry.startTime,
eventEntry: longestEntry,
Expand Down

0 comments on commit 529d991

Please sign in to comment.