No browser storage for referrals; the birth chart opens at the drawn chart
The share page stores nothing in the browser any more: the shared link that brought a visitor travels in its login link (/belepes?ref=...) to the Google, Apple and password sign-up. The backend counts the same visitor of a link once in half an hour, instead of a sessionStorage flag. The public birth chart scrolls to the drawn chart after a calculation and when coming back to the page. Tabs scrolled to themselves on every re-render of their parent when the address had a tab (#bolygok); they now react only to the tab ids and hash changes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -4,24 +4,13 @@ import { useEffect } from "react";
|
||||
|
||||
/**
|
||||
* Reports a visit of the share page from the visitor's browser. Link preview
|
||||
* robots do not run scripts, so only people are counted (the backend also
|
||||
* leaves out the sharer).
|
||||
* robots do not run scripts, so only people are counted; the backend leaves
|
||||
* out the sharer and counts the same visitor once in half an hour. Nothing is
|
||||
* stored in the browser (the sharer who brought a new user travels in the
|
||||
* login link instead).
|
||||
*/
|
||||
export function ShareVisit({ slug }: { slug: string }) {
|
||||
useEffect(() => {
|
||||
const key = `share-visit:${slug}`;
|
||||
try {
|
||||
// If they sign up later, the sharer who brought them is remembered.
|
||||
localStorage.setItem("sf_ref", slug);
|
||||
} catch {
|
||||
// storage blocked
|
||||
}
|
||||
try {
|
||||
if (sessionStorage.getItem(key)) return;
|
||||
sessionStorage.setItem(key, "1");
|
||||
} catch {
|
||||
// storage blocked: report anyway
|
||||
}
|
||||
fetch(`/api/v1/public/shares/${slug}/visit`, { method: "POST", credentials: "same-origin" }).catch(() => {});
|
||||
}, [slug]);
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user