-
Notifications
You must be signed in to change notification settings - Fork 3.9k
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
Add Activity service to calculate engaged time for amp-analytics #1818
Conversation
So far the Similar to the Let me know if there are suggestions, especially concerning:
|
|
Definitely understood. This PR is still a work in progress. I included at least the one test to demonstrate how the service is used. |
### TOTAL_ENGAGED_TIME | ||
|
||
Get the total time the user has been enagaged with the page since the page was | ||
loaded. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loaded, or became visible?
Might be good to be specific here.
cc @cramforce @avimehta for feedback on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Become visible in the current viewport I think is the more accepted definition
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, lets change this to "become visible in the viewport"
This looks like a reasonable start. Regarding whether the |
I'd love to help you guys out with this if you guys think that would be useful? |
Thanks @etlgfx. I'm working to get another commit out tonight or early tomorrow which contains the core functionality for the As was mentioned earlier, I need to take care of testing for this feature. Any input there would be greatly appreciated (e.g. what to test, where to test, how to ensure good test coverage). |
I pushed a new commit which fleshes out the total engaged time functionality. This went through several iterations before landing on only tracking total engaged time. In one version, all activity times were recorded (with 1 second resolution). This would have allowed for finding engaged time for an arbitrary time period but would require either recalculation of engaged time on each There is still more to do and I'd appreciate feedback on the functionality. In the mean time, I'll start working on tests before adding other activity listeners. |
@avimehta @cramforce I added another commit which includes functional tests for the |
b169868
to
5d5dedd
Compare
Brought things up to date with master. |
5d5dedd
to
1a77326
Compare
@avimehta @cramforce After the Travis check is complete, this PR is ready for review. |
Get the total time the user has been enagaged with the page since the page was | ||
loaded. | ||
|
||
For instance: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we don't need this example here, since that would always be zero.
cba1ca7
to
866a1bb
Compare
Ready for another pass. All PR comments are addressed in the first new commit. There were a few other minor changes in the second two commits. I'm planning to squash everything into one commit when we are satisfied with the updates. If it is preferred that I squash prior to another review, let me know. |
Ooops, hit "Close and Comment" instead of "comment". |
@britice It seems like this is feature complete? Can you confirm? |
Yes, this is complete. |
Please disallow unwhitelisted usage of Would be great if @avimehta could take a look! |
looking at it now. will respond in a couple of hours. |
this.unlistenFuncs_ = []; | ||
} | ||
|
||
cleanup_() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
curious about how this gets called. Also, docs for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not being called at this point. I saw cleanup_
functionality in other components and decided to set this up here as well. Since the activity tracking is intended to be available until the user leaves the page, it didn't seem necessary to ensure it was called anywhere.
I'll add the annotations for all the methods.
@cramforce overall the PR looks good to me. Since I am not an expert at the platform stuff, I'll defer to your lgtm. |
* @param {!Window} window | ||
* @return {!Promise<?Activity>} | ||
*/ | ||
export function activityForOrNull(win) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can delete this as it is never used.
LGTM. One comment. Please also squash commits. |
Added another commit to address a few more PR comments. I'll squash and force push momentarily. |
0c0b031
to
1e00784
Compare
This is ready when checks pass. |
Looks like this has gotten fairly far behind master. Let me know if I should rebase prior to merging. |
This method of tracking engagement is a bit different from what we're doing at Parse.ly, but it all makes sense to me. |
@emmett9001 Thanks for taking a look! Do you think Parsely would be able to use this implementation for AMP? Main goal is to make sure we have an implementation that's reasonable and works for all. Would you be good with merging this (and we can enhance further in the future)? |
1e00784
to
aa9d994
Compare
I brought this up to date with master. @rudygalfi @emmett9001 Is there any other input from Parsley that needs to be considered before this is merged? A previous update to Chartbeat's vendor config (#1986) is somewhat dependent on this PR so we'd like to see them combined for the next release. |
aa9d994
to
0db3ddf
Compare
@britice @rudygalfi This looks close enough to what Pasre.ly's currently doing that I think it's fine to merge. There may be some small changes I'm not noticing now that come up later, but I don't think any of them will require a major rewrite. |
Add Activity service to calculate engaged time for amp-analytics
Add new
Activity
service which can be used to track general user interaction on a page over time.The first goal of adding this service is to provide active engaged time heuristics for url replacement in amp-analytics. This will address issue #1296.
In order to collect active engaged time heuristics, user activity will need to be collected during the session. Given that user activity will be collected, there is a chance that the
Activity
service will also be able to expose additional data about general user interaction beyond total engaged time.