✨[amp-analytics] Introduce Session ID concept and SESSION_ID macro#34521
Merged
micajuine-ho merged 7 commits intoampproject:mainfrom Jun 18, 2021
Merged
✨[amp-analytics] Introduce Session ID concept and SESSION_ID macro#34521micajuine-ho merged 7 commits intoampproject:mainfrom
micajuine-ho merged 7 commits intoampproject:mainfrom
Conversation
bfb89f8 to
c300ed7
Compare
Contributor
Author
|
/cc @jridgewell for bundle size check |
Contributor
Author
|
@rebeccanthomas PTAL |
jridgewell
approved these changes
Jun 2, 2021
Contributor
Author
|
@rebeccanthomas @alanorozco PTAL when you can |
alanorozco
reviewed
Jun 16, 2021
| /** | ||
| * Checks if a session has expired | ||
| * @param {SessionInfoDef} session | ||
| * @return {!Promise} |
Member
There was a problem hiding this comment.
Suggested change
| * @return {!Promise} | |
| * @return {boolean} |
Consider making it a standalone function as well.
Contributor
Author
There was a problem hiding this comment.
What's the benefit of doing so?
Member
There was a problem hiding this comment.
@micajuine-ho It's more flexible to use a function when the instance state is not looked at. You can move functions around, use them outside a specific class, and they get DCE'd more easily.
alanorozco
approved these changes
Jun 17, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #29324
Partial for #33990
A Session Id is per user per domain per vendor persisted for 30 minutes (extended each time
session_idis used) in localStorage, via the Storage API, on both the origin and within the viewer.The Session Id value is a low entropy pseudorandom number from 0-9999.
This PR introduces this concept and creates the manager to store/retrieve this information (
SessionManager) along with theSESSION_IDmacro only to be used byamp-analytics. The session manager is a service installed byamp-analyticsand shared between allamp-analyticselements, similar to theLinker. We store the session information under the keyamp-session:+${vendorType}. We also keep the accessed session information in memory to avoid reading from localStorage each timeSESSION_IDis used/extended.Following PRs will add additional Session Analytics for each session (see #33990), stored under the same key in localStorage.