@@ -19,9 +19,14 @@ export class PostHogWrapper {
19
19
) { }
20
20
21
21
capture ( eventName : string , properties ?: Properties ) {
22
+ if ( shouldIgnoreEvent ( eventName , properties ) ) return ;
22
23
const context = this . eventContext . getAll ( ) ;
23
24
const newProperties = { ...context , ...properties } ;
24
- this . _instance ?. capture ( eventName , newProperties ) ;
25
+ const skipClientRateLimiting =
26
+ eventName === 'tauri_command' && properties ?. command !== undefined ;
27
+ this . _instance ?. capture ( eventName , newProperties , {
28
+ skip_client_rate_limiting : skipClientRateLimiting
29
+ } ) ;
25
30
}
26
31
27
32
captureOnboarding ( event : OnboardingEvent , error ?: unknown ) {
@@ -99,6 +104,35 @@ export class PostHogWrapper {
99
104
}
100
105
}
101
106
107
+ type EventDescription = {
108
+ name : string ;
109
+ command : string ;
110
+ } ;
111
+
112
+ const HIGH_VOLUME_EVENTS : EventDescription [ ] = [
113
+ { name : 'tauri_command' , command : 'stack_details' }
114
+ ] ;
115
+
116
+ const MID_VOLUME_EVENTS : EventDescription [ ] = [
117
+ { name : 'tauri_command' , command : 'get_base_branch_data' } ,
118
+ { name : 'tauri_command' , command : 'fetch_from_remotes' }
119
+ ] ;
120
+
121
+ function shouldIgnoreEvent ( eventName : string , properties : Properties | undefined ) : boolean {
122
+ if ( HIGH_VOLUME_EVENTS . some ( ( e ) => e . name === eventName && e . command === properties ?. command ) ) {
123
+ if ( Math . random ( ) < 0.95 ) {
124
+ return true ;
125
+ }
126
+ }
127
+
128
+ if ( MID_VOLUME_EVENTS . some ( ( e ) => e . name === eventName && e . command === properties ?. command ) ) {
129
+ if ( Math . random ( ) < 0.5 ) {
130
+ return true ;
131
+ }
132
+ }
133
+ return false ;
134
+ }
135
+
102
136
export enum OnboardingEvent {
103
137
ConfirmedAnalytics = 'onboarding_confirmed_analytics' ,
104
138
AddLocalProject = 'onboarding_add_local_project' ,
0 commit comments