mirror of
https://github.com/balena-os/balena-supervisor.git
synced 2024-12-24 15:56:40 +00:00
fix: Use throttle not debounce when ensuring we don't spam mixpanel
Debounce will mean that in certain cases, the events will never be sent, whereas with throttle we can be sure that it will be sent a minimum amount per time slice. Change-type: patch Signed-off-by: Cameron Diver <cameron@resin.io>
This commit is contained in:
parent
1ff94a04b5
commit
68a6b1aef1
@ -86,12 +86,12 @@ export class EventTracker {
|
||||
}
|
||||
|
||||
properties = this.assignDefaultProperties(properties);
|
||||
this.debouncedLogger(event)(properties);
|
||||
this.throttleddLogger(event)(properties);
|
||||
}
|
||||
|
||||
private debouncedLogger = memoizee((event: string) => {
|
||||
private throttleddLogger = memoizee((event: string) => {
|
||||
// Call this function at maximum once every minute
|
||||
return _.debounce((properties) => {
|
||||
return _.throttle((properties) => {
|
||||
this.client.track(event, properties);
|
||||
}, eventDebounceTime, { leading: true });
|
||||
}, { primitive: true });
|
||||
|
Loading…
Reference in New Issue
Block a user