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

#1785 Logging when Audit page and Validation page are visible #2222

Merged
merged 10 commits into from
Sep 16, 2020

Conversation

shokiami
Copy link
Collaborator

@shokiami shokiami commented Sep 1, 2020

Resolves #1785

This PR makes it so that any visibility change of the audit and validation page are logged to the database.

Audit Task Interaction Table Example Entries:
Screen Shot 2020-09-01 at 1 57 01 PM

Validation Task Interaction Table Example Entries:
Screen Shot 2020-09-01 at 1 52 54 PM

@shokiami
Copy link
Collaborator Author

shokiami commented Sep 4, 2020

@misaugstad I just wanted to let you know that, from my testing, I found that the visibilitychange event listener triggers whenever the webpage is fully obscured from view (e.g. when the user goes into another browser tab, hides the entire browser behind another application, or enters a different desktop), but not if any part of the webpage is visible (e.g. the user fills the screen with applications but the corner of the webpage is still barely visible).

@misaugstad
Copy link
Member

@shokiami do you know if there are alternatives that also take into account if the browser is partially hidden. Or is just out of focus is what we are really looking for.

@misaugstad
Copy link
Member

Like what you have sounds good, I would just expect there to be a way to know if our browser window is in focus or not

@shokiami
Copy link
Collaborator Author

@misaugstad
Boom! It's working perfectly. I finally managed to get the focus/blur event listeners to work. Sorry that took so long; it took me a while to figure out that it was supposed to be window.addEventListener not document.addEventListener 😅. Anyhow, here is what the audit task interactions table looks like after a bunch of clicking in and out of the webpage:
Screen Shot 2020-09-11 at 5 27 18 PM
Please let me know if you would like me to change the wording or the format of the entries.

@misaugstad
Copy link
Member

I think the only change I would want would be to include whether it is now in/out of focus in the action name instead of the note.

@shokiami
Copy link
Collaborator Author

@misaugstad What do you think?
Screen Shot 2020-09-12 at 6 35 32 PM

@@ -176,6 +176,13 @@ function Main (params) {
}
svl.popUpMessage = new PopUpMessage(svl.form, svl.storage, svl.taskContainer, svl.tracker, svl.user, svl.onboardingModel, svl.ui.popUpMessage);

// Logs when the webpage's visiblity changes.
Copy link
Member

Choose a reason for hiding this comment

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

When you first add the event listeners, can you first do a check for whether the page is in/out of focus and log that?

@@ -176,6 +176,13 @@ function Main (params) {
}
svl.popUpMessage = new PopUpMessage(svl.form, svl.storage, svl.taskContainer, svl.tracker, svl.user, svl.onboardingModel, svl.ui.popUpMessage);

// Logs when the webpage's visiblity changes.
window.addEventListener("focus", function(event) {
svl.tracker.push("GainedFocus")
Copy link
Member

Choose a reason for hiding this comment

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

Can you change it to PageGainedFocus and PageLostFocus

@misaugstad
Copy link
Member

Do you know if this works on mobile?

@misaugstad
Copy link
Member

Then can you edit this wiki page with the appropriate checkmark or X for mobile use?

@shokiami
Copy link
Collaborator Author

@misaugstad
Please let me know what you think of my edits!
Also, it seems to be working for mobile. However, there is one issue: it logs twice when the page gains visibility (I don't know why).
Screen Shot 2020-09-15 at 3 28 01 PM

@misaugstad
Copy link
Member

I'm assuming you're using an iPhone? I am as well and am getting the same bug. Seems to be a webkit bug so it is not on us. I think the only issue I found with your code was that the first PageGainedFocus log on the validation page has the mission_id as null. So I think you just want to wait to add the listeners and do that initial check for page focus until the mission id has been initialized. Working well on the audit page!

@shokiami
Copy link
Collaborator Author

@misaugstad How does that look?

Copy link
Member

@misaugstad misaugstad left a comment

Choose a reason for hiding this comment

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

Looks good!

@misaugstad misaugstad merged commit 1f75112 into develop Sep 16, 2020
@misaugstad misaugstad deleted the 1785-log-page-visibility branch September 16, 2020 20:51
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