From 68a6b1aef1298911ab059689eba82ce6e0a7f1f4 Mon Sep 17 00:00:00 2001 From: Cameron Diver Date: Wed, 12 Sep 2018 12:30:31 +0100 Subject: [PATCH] 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 --- src/event-tracker.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/event-tracker.ts b/src/event-tracker.ts index e446a265..bc3e285a 100644 --- a/src/event-tracker.ts +++ b/src/event-tracker.ts @@ -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 });