Skip to content

Commit

Permalink
fix: heatmaps unload listener
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Feb 14, 2025
1 parent 9e018fd commit acc0288
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/heatmaps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit acc0288

Please sign in to comment.