From acc02889e93d30c77376cd499a29a03398c487bc Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Fri, 14 Feb 2025 10:15:30 +0000 Subject: [PATCH] fix: heatmaps unload listener --- src/heatmaps.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/heatmaps.ts b/src/heatmaps.ts index b708a369c..b651ebe86 100644 --- a/src/heatmaps.ts +++ b/src/heatmaps.ts @@ -59,8 +59,6 @@ export class Heatmaps { constructor(instance: PostHog) { this.instance = instance this._enabledServerSide = !!this.instance.persistence?.props[HEATMAPS_ENABLED_SERVER_SIDE] - - addEventListener(window, 'beforeunload', this.flush) } public get flushIntervalMilliseconds(): number { @@ -130,6 +128,8 @@ export class Heatmaps { return } + addEventListener(window, 'beforeunload', this.flush.bind(this)) + addEventListener(document, 'click', (e) => this._onClick((e || window?.event) as MouseEvent), { capture: true }) addEventListener(document, 'mousemove', (e) => this._onMouseMove((e || window?.event) as MouseEvent), { capture: true,