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

feat: Allow sending automatic pageleave with manual pageview #1165

Merged

Conversation

robbie-c
Copy link
Member

@robbie-c robbie-c commented May 7, 2024

Changes

Currently if you disable capture_pageview, there's no way to enable sending pageleave events automatically when the page closes.

Some people would like to do this! e.g. in nextjs you need to manually send pageview events, as this is done in a framework-specific way, but you might still want to send pageleave event when the page closes, and this is not framework-specific so could be done automatically.

To keep backwards compatibility, this is off by default. The new default value for capture_pageleave is 'if_capture_pageview'.

The only users who would see a difference in behaviour are people who explicitly set:

capture_pageview: false
capture_pageleave: true

Checklist

  • Tests for new code (see advice on the tests we use)
  • Accounted for the impact of any changes across different browsers
  • Accounted for backwards compatibility of any changes (no breaking changes in posthog-js!)

Copy link

vercel bot commented May 7, 2024

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

Name Status Preview Updated (UTC)
posthog-js ✅ Ready (Inspect) Visit Preview May 7, 2024 9:21am

Copy link
Collaborator

@benjackwhite benjackwhite left a comment

Choose a reason for hiding this comment

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

Nice solution!

Copy link

github-actions bot commented May 7, 2024

Size Change: +548 B (0%)

Total Size: 973 kB

Filename Size Change
dist/array.full.js 234 kB +137 B (0%)
dist/array.js 131 kB +137 B (0%)
dist/es.js 131 kB +137 B (0%)
dist/module.js 132 kB +137 B (0%)
ℹ️ View Unchanged
Filename Size
dist/exception-autocapture.js 12.2 kB
dist/recorder-v2.js 108 kB
dist/recorder.js 108 kB
dist/surveys-module-previews.js 57.2 kB
dist/surveys.js 58.8 kB

compressed-size-action

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bump minor Bump minor version when this PR gets merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants