Open
Conversation
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.
Completed Creating Session ID for Users
Team Member Name: Kyla
Summary
Added a component to be added to the layout of every page that calls a session hook to use an existing session ID if it exists or to create a new one if not. This ID is then accessible by any component in the tree.
Code Changes
hooks/useSession.ts: Created a hook that checks if there is an existing user session ID. If it doesn't exist, a unique UUID is created and saved to the browser's storage.components/AnalyticsProvider.tsx: Created a component that calls the custom useSession hook and shares the returned session ID, allowing it be accessed by any component in the tree.layout.tsx: ImportedAnalyticsProviderand wrapped theNavBarand{children}in anAnalyticsProvidercomponent.Type of Change
Checklist
Testing
To test, I checked if the session ID was stored in the browser storage when I visited the app on my browser. I also checked if a different session ID was stored if the tab was closed and the page was reopened.
To test if it could be accessed by components on the page, I created a test button component that printed the session ID in the console and added it to the homepage. I clicked this button to see if the correct session ID was printed in the console, and the functionality is demonstrated in the video linked below. I deleted the button and restored the homepage before pushing.
Video
https://drive.google.com/file/d/1iZGqOJcsffgZD9oq6OAynj4N8-qVw4Vw/view?usp=sharing