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

Test out fetch-with-keepalive on plausible.io #5005

Merged
merged 2 commits into from
Jan 23, 2025
Merged

Conversation

macobo
Copy link
Contributor

@macobo macobo commented Jan 22, 2025

Fetch with keepalive is a
widely-supported which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.

We're hoping it will improve event capture rates for pageleave and pageview events when the user closes the tab

To use it, we also need to start using fetch (with fallback to xhr).

For extra safety, we will only deploy this on plausible.io initially. This will ensure that if there are issues we will be able to react without affecting any other customers.

I tested this locally by adding temporary logging to the script:

  1. Modifying lib/plausible_web/templates/layout/_tracking.html.heex to track locally
  2. Making fetch the default and running the test suite.

Companion PR: plausible/docs#579

TODO after this PR:

  • Companion docs PR
  • Purge bunny cache
  • Make fetch the default request method without data-property

Fetch with keepalive is a
[widely-supported](https://developer.mozilla.org/en-US/docs/Web/API/Request/keepalive)
which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.

We're hoping it will improve event capture rates for `pageleave` and
`pageview` events when the user closes the tab

To use it, we also need to start using `fetch` (with fallback to xhr).

For extra safety, we will only deploy this on `plausible.io` initially.
This will ensure that if there are issues we will be able to react
without affecting any other customers.

TODO after this PR:
- [ ] Companion docs PR
- [ ] Purge bunny cache
- [ ] Make fetch the default request method without data-property
Copy link
Contributor

@RobertJoonas RobertJoonas left a comment

Choose a reason for hiding this comment

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

👍

@macobo macobo added this pull request to the merge queue Jan 23, 2025
Merged via the queue into master with commit 585c85b Jan 23, 2025
9 checks passed
macobo added a commit to plausible/website that referenced this pull request Jan 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants