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:
Cameron Diver 2018-09-12 12:30:31 +01:00
parent 1ff94a04b5
commit 68a6b1aef1
No known key found for this signature in database
GPG Key ID: 69264F9C923F55C1

View File

@ -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 });