Skip to content

Commit 6989474

Browse files
committed
PR Feedback.
1 parent 1530c61 commit 6989474

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

packages/telemetry/browser-telemetry/src/collectors/dom/KeypressCollector.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const THROTTLE_TIME_MS = 1000;
99
const INPUT_TAG_NAMES = ['INPUT', 'TEXTAREA'];
1010

1111
/**
12-
* Collects mouse click events and adds them as breadcrumbs.
12+
* Collects key press events and adds them as breadcrumbs.
1313
*/
1414
export default class KeypressCollector implements Collector {
1515
private _destination?: Recorder;
@@ -53,10 +53,12 @@ export default class KeypressCollector implements Collector {
5353
}
5454

5555
private _shouldDeduplicate(crumb: Breadcrumb): boolean {
56-
// TODO: Consider de-duplication at the dom level.
56+
// If this code every is demonstrably a performance issue, then we may be able to implement
57+
// some scheme to de-duplicate these via some DOM mechanism. Like adding a debounce annotation
58+
// of some kind.
5759
if (this._lastEvent) {
5860
const timeDiff = Math.abs(crumb.timestamp - this._lastEvent.timestamp);
59-
return this._lastEvent.message === crumb.message && timeDiff <= THROTTLE_TIME_MS;
61+
return timeDiff <= THROTTLE_TIME_MS && this._lastEvent.message === crumb.message;
6062
}
6163
return false;
6264
}

0 commit comments

Comments
 (0)