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) =>
83
83
. replace ( / \/ m o c k \/ [ a - z 0 - 9 \- ] + / , '/mock' ) // Strip mock rule ids
84
84
. replace ( / \? .* / , '' ) ; // Strip any query & hash params
85
85
86
+ const SINGLE_EVENT_CATEGORIES = [ "Interceptors" ] ;
87
+ const seenLimitedEvents : string [ ] = [ ] ;
88
+
86
89
export function trackEvent ( event : {
87
90
category : string ,
88
91
action : string ,
89
92
value ?: string
90
93
} ) {
91
94
if ( ! enabled ) return ;
92
95
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
+
93
106
const currentUrl = normalizeUrl ( location . href ) ;
94
107
95
108
posthog . capture ( `${ event . category } :${ event . action } ` , {
You can’t perform that action at this time.
0 commit comments