Skip to content

Commit daac434

Browse files
committed
Drop all dupe metrics
We're seeing lots of duplicate events for things like request sending, which just don't matter. Per-session detail is totally fine, and reduces overhead, cost, and unnecessary tracking (even though this is all anonymous anyway ofc).
1 parent 3dd0cfc commit daac434

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

src/metrics.ts

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,7 @@ const normalizeUrl = (url: string) =>
108108
.replace(/\/modify\/[a-z0-9\-]+/, '/modify') // Strip modify rule ids
109109
.replace(/\?.*/, ''); // Strip any query & hash params
110110

111-
const SINGLE_EVENT_CATEGORIES = ["Interceptors"];
112-
const seenLimitedEvents: string[] = [];
111+
const seenLimitedEvents = new Set<string>();
113112

114113
export function trackEvent(event: {
115114
category: string,
@@ -118,15 +117,11 @@ export function trackEvent(event: {
118117
}) {
119118
if (!enabled) return;
120119

121-
if (SINGLE_EVENT_CATEGORIES.includes(event.category)) {
122-
const eventKey = `${event.category}${event.action}${event.value}`;
123-
124-
// For events in these categories, we only want to log them once
125-
// per session. No need to track more detail than that, good to
126-
// avoid tracking unnecessary data where possible.
127-
if (seenLimitedEvents.includes(eventKey)) return;
128-
else seenLimitedEvents.push(eventKey);
129-
}
120+
// For each specific event, we only want to log it once per session. We want an outline of
121+
// usage (which features are popular) not a detailed log of everything that happens.
122+
const eventKey = `${event.category}${event.action}${event.value}`;
123+
if (seenLimitedEvents.has(eventKey)) return;
124+
seenLimitedEvents.add(eventKey);
130125

131126
const currentUrl = normalizeUrl(location.href);
132127

0 commit comments

Comments
 (0)