File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -83,13 +83,26 @@ const normalizeUrl = (url: string) =>
8383 . replace ( / \/ m o c k \/ [ a - z 0 - 9 \- ] + / , '/mock' ) // Strip mock rule ids
8484 . replace ( / \? .* / , '' ) ; // Strip any query & hash params
8585
86+ const SINGLE_EVENT_CATEGORIES = [ "Interceptors" ] ;
87+ const seenLimitedEvents : string [ ] = [ ] ;
88+
8689export function trackEvent ( event : {
8790 category : string ,
8891 action : string ,
8992 value ?: string
9093} ) {
9194 if ( ! enabled ) return ;
9295
96+ if ( SINGLE_EVENT_CATEGORIES . includes ( event . category ) ) {
97+ const eventKey = `${ event . category } ${ event . action } ${ event . value } ` ;
98+
99+ // For events in these categories, we only want to log them once
100+ // per session. No need to track more detail than that, good to
101+ // avoid tracking unnecessary data where possible.
102+ if ( seenLimitedEvents . includes ( eventKey ) ) return ;
103+ else seenLimitedEvents . push ( eventKey ) ;
104+ }
105+
93106 const currentUrl = normalizeUrl ( location . href ) ;
94107
95108 posthog . capture ( `${ event . category } :${ event . action } ` , {
You can’t perform that action at this time.
0 commit comments