Skip to content

OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.

sdk: only send events if we have any

Carl-Gerhard Lindesvärdbbbc16be25f2
diff --git a/packages/sdk/index.ts b/packages/sdk/index.ts
index 4d00d9213..851582a67 100644
--- a/packages/sdk/index.ts
+++ b/packages/sdk/index.ts
@@ -111,8 +111,11 @@ class Batcher<T extends any> {
if(this.timer) {
clearTimeout(this.timer)
}
- this.callback(this.queue)
- this.queue = []
+
+ if(this.queue.length > 0) {
+ this.callback(this.queue)
+ this.queue = []
+ }
}
}