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 batching after page navigation #915

Merged
merged 6 commits into from
Aug 1, 2023
Merged

Fix batching after page navigation #915

merged 6 commits into from
Aug 1, 2023

Conversation

danieljackins
Copy link
Contributor

@danieljackins danieljackins commented Aug 1, 2023

This PR addresses a bug where if a user navigated to another page and then back, batching no longer worked. This was due to the 'pageUnloaded' variable never being set back to false.

  • I've included a changeset (psst. run yarn changeset. Read about changesets here).

@changeset-bot
Copy link

changeset-bot bot commented Aug 1, 2023

🦋 Changeset detected

Latest commit: 92e118c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@segment/analytics-next Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@@ -7,23 +7,23 @@
*
* adapted from https://stackoverflow.com/questions/3239834/window-onbeforeunload-not-working-on-the-ipad/52864508#52864508,
*/
export const onPageLeave = (cb: (...args: unknown[]) => void) => {
export const onPageChange = (cb: (...args: boolean[]) => void) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:
This sig says that there are multiple bool args.
Type signature should just be (unloaded: boolean) => void

@@ -91,10 +91,10 @@ export default function batch(
}, timeout)
}

onPageLeave(() => {
pageUnloaded = true
onPageChange((unloaded: boolean) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: No need to put "boolean" here; that should be part of the fn signature type

@danieljackins danieljackins merged commit 7072377 into master Aug 1, 2023
3 checks passed
@danieljackins danieljackins deleted the batch-fix branch August 1, 2023 19:29
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