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

[Feature] Track navigating away from the the APD outside of the app #4656

Open
1 task
thetif opened this issue Mar 30, 2023 · 2 comments
Open
1 task

[Feature] Track navigating away from the the APD outside of the app #4656

thetif opened this issue Mar 30, 2023 · 2 comments
Assignees
Labels
Development Issues for the dev team resolve medium

Comments

@thetif
Copy link
Contributor

thetif commented Mar 30, 2023

Description and related issues

Implement way to catch the following cases:

  • user closing the APD tab
  • user closing their browser
  • user clicking a link that opens in the same tab
  • user entering another url in the same tab

It looks like there is a window listener for this. But we need it across the application, maybe this could go in the Root component. Before the tab unloads the application call a closing APD action. This action should only be called if they are in a locked APD when they leave the application.

Example

useEffect(() => {
    window.addEventListener('beforeunload', alertUser)
    window.addEventListener('unload', handleTabClosing)
    return () => {
        window.removeEventListener('beforeunload', alertUser)
        window.removeEventListener('unload', handleTabClosing)
    }
})

const handleTabClosing = () => {
    removePlayerFromGame()
}

const alertUser = (event:any) => {
    event.preventDefault()
    event.returnValue = ''
}

Acceptance criteria

  • before leaving the application, call the closing APD action

Testing criteria

Given When Then Covered
user is inside a locked APD a user closes the tab the browser prevents the action long enough to call the close APD action
user is inside a locked APD a user closes the browser the browser prevents the action long enough to call the close APD action
user is inside a locked APD a user clicks a link that goes navigates to another site in the same tab the browser prevents the action long enough to call the close APD action
user is inside a locked APD a user changes the url to another site in the same tab the browser prevents the action long enough to call the close APD action
user is outside of a locked APD user closes the tab tab closes normally
user is outside of a locked APD user closes the browser browser closes normally
user is outside of a locked APD a user clicks a link that goes navigates to another site in the same tab the browser navigates normall
user is outside of a locked APD a user changes the url to another site in the same tab the browser navigates normally
@thetif thetif added the Development Issues for the dev team resolve label Mar 30, 2023
@thetif thetif changed the title [Feature] Track user closing tab or browser [Feature] Track navigating away from the the APD outside of the app Mar 31, 2023
@thetif thetif added the medium label Mar 31, 2023
@stephanieboydcms
Copy link

Good to go!

@jeromeleecms
Copy link
Contributor

Just a few clarification in the acceptance criteria

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development Issues for the dev team resolve medium
Projects
None yet
Development

No branches or pull requests

4 participants