Merge pull request #744 from resin-io/throttle-not-debounce

fix: Use throttle not debounce when ensuring we don't spam mixpanel
This commit is contained in:
CameronDiver 2018-09-12 12:41:49 +01:00 committed by GitHub
commit 5e396e26b9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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