fix: disambiguate repeated-target event timing
This commit is contained in:
@@ -30,6 +30,7 @@ export interface ScriptedActionSample {
|
||||
id: string;
|
||||
target: string;
|
||||
dispatchTime: number;
|
||||
captureEndTime: number | null;
|
||||
acknowledgementCount: number;
|
||||
mutationTime: number | null;
|
||||
doubleRafTime: number | null;
|
||||
@@ -111,6 +112,7 @@ export const evaluateEventToNextPaint = (
|
||||
entry.target === action.target
|
||||
&& entry.startTime >= action.dispatchTime
|
||||
&& entry.startTime <= action.dispatchTime + 500
|
||||
&& (action.captureEndTime === null || entry.startTime < action.captureEndTime)
|
||||
));
|
||||
if (matching.length === 0) return 16;
|
||||
const groups = new Map<number, number>();
|
||||
@@ -270,7 +272,9 @@ export const installAuthorizedPerformanceInstrumentation = async (): Promise<voi
|
||||
for (const entry of list.getEntries()) {
|
||||
const timed = entry as PerformanceEntry & { interactionId?: number; target?: Node | null };
|
||||
for (const record of actionRecords.values()) {
|
||||
if (timed.target === record.element) {
|
||||
if (timed.target === record.element
|
||||
&& timed.startTime >= record.dispatchTime
|
||||
&& (record.captureEndTime === null || timed.startTime < record.captureEndTime)) {
|
||||
(record.eventEntries as EventTimingSample[]).push({
|
||||
target: record.id,
|
||||
startTime: timed.startTime,
|
||||
@@ -360,10 +364,15 @@ export const installAuthorizedPerformanceInstrumentation = async (): Promise<voi
|
||||
if (!exactActionIds.has(id) || actionRecords.has(id)) throw new Error('The performance action is invalid or duplicated.');
|
||||
const element = document.querySelector(selector);
|
||||
if (!(element instanceof Element)) throw new Error('The performance action target is unavailable.');
|
||||
const dispatchTime = performance.now();
|
||||
for (const record of actionRecords.values()) {
|
||||
if (record.element === element && record.captureEndTime === null) record.captureEndTime = dispatchTime;
|
||||
}
|
||||
actionRecords.set(id, {
|
||||
id,
|
||||
target: id,
|
||||
dispatchTime: performance.now(),
|
||||
dispatchTime,
|
||||
captureEndTime: null,
|
||||
acknowledgementCount: 0,
|
||||
mutationTime: null,
|
||||
doubleRafTime: null,
|
||||
|
||||
Reference in New Issue
Block a user