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

📦 chore(turso): add current-visitors module for tracking and managing… #737

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

spences10
Copy link
Owner

No description provided.

… current visitors

📦 chore(turso): add session-management module for creating and updating user sessions
📦 chore(turso): add queries-for-stuff.sql file for storing SQL queries related to various stuff
📦 chore(turso): update schema.sql to include new tables for user sessions and current visitors
This commit adds a new server route to handle the POST request for ending a session. The route receives the session ID from the request body and updates the `user_session` table in the database to mark the session as ended. It also calculates the session duration based on the session start time.

🚀 feat(setup-send-beacon.js): add script to send session data on page unload

This commit adds a new JavaScript file `setup-send-beacon.js` that sets up a `beforeunload` event listener. When the page is about to be unloaded, it retrieves the session data from a cookie, sends it to the `/session-end` endpoint using the `navigator.sendBeacon()` method, and deletes the session cookie. This ensures that the session data is sent to the server even if the user closes the page or navigates away.
…user IP address

✨ feat(app.html): add setup-send-beacon.js script to enable sending beacon requests for analytics
🐛 fix(hooks.server.ts): add user_session handle to handle user session data, including creating or updating session, tracking current visitors, and setting session cookie
Copy link

vercel bot commented Dec 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
scottspence-com ✅ Ready (Inspect) Visit Preview 💬 Add feedback Dec 22, 2023 6:36pm

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.

None yet

1 participant