Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: heatmaps unload listener #1736

Merged
merged 2 commits into from
Feb 14, 2025
Merged

fix: heatmaps unload listener #1736

merged 2 commits into from
Feb 14, 2025

Conversation

pauldambra
Copy link
Member

fixes #1735

we shouldn't be setting up listeners in the constructor anyway since we can init heatmaps and not be enabled

so, moves into the setup method, and binds this

Copy link

vercel bot commented Feb 14, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview Feb 14, 2025 10:27am

@pauldambra pauldambra requested a review from a team February 14, 2025 10:16
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR fixes an issue with the heatmaps unload listener where the flush method was being called with an incorrect this context, causing "undefined buffer" errors during page unload.

  • Moved beforeunload event listener from constructor to _setupListeners() in src/heatmaps.ts
  • Added proper bind(this) to flush method in event listener to ensure correct context
  • Improved initialization flow by only setting up listeners when heatmaps are enabled
  • Prevents potential undefined buffer access by moving listener setup out of constructor

1 file(s) reviewed, no comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

github-actions bot commented Feb 14, 2025

Size Change: +110 B (0%)

Total Size: 3.3 MB

Filename Size Change
dist/array.full.es5.js 267 kB +11 B (0%)
dist/array.full.js 370 kB +11 B (0%)
dist/array.full.no-external.js 369 kB +11 B (0%)
dist/array.js 183 kB +11 B (+0.01%)
dist/array.no-external.js 181 kB +11 B (+0.01%)
dist/main.js 183 kB +11 B (+0.01%)
dist/module.full.js 370 kB +11 B (0%)
dist/module.full.no-external.js 369 kB +11 B (0%)
dist/module.js 183 kB +11 B (+0.01%)
dist/module.no-external.js 181 kB +11 B (+0.01%)
ℹ️ View Unchanged
Filename Size
dist/all-external-dependencies.js 216 kB
dist/customizations.full.js 13.8 kB
dist/dead-clicks-autocapture.js 14.5 kB
dist/exception-autocapture.js 9.51 kB
dist/external-scripts-loader.js 2.64 kB
dist/recorder-v2.js 115 kB
dist/recorder.js 115 kB
dist/surveys-preview.js 69.4 kB
dist/surveys.js 72.4 kB
dist/tracing-headers.js 1.76 kB
dist/web-vitals.js 10.4 kB

compressed-size-action

@pauldambra pauldambra added the bump patch Bump patch version when this PR gets merged label Feb 14, 2025
@pauldambra pauldambra merged commit e05d884 into main Feb 14, 2025
28 checks passed
@pauldambra pauldambra deleted the fix/heatmaps-unload-listener branch February 14, 2025 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump patch Bump patch version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Calling flush on undefined in heatmaps
2 participants