A click proves little, so the first visit of a shared link now earns a question (once per user) instead of a natal analysis. A natal analysis is earned by bringing a new user: the share page remembers the link, the Google sign-up sends it, and when that user makes their own chart the sharer gets one, at most three (referrals table, referral_reward). This is off until sign-up opens (REFERRAL_REWARDS, default false). The share button and its small print follow; /v1/me tells what was earned. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
29 lines
831 B
TypeScript
29 lines
831 B
TypeScript
"use client";
|
|
|
|
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).
|
|
*/
|
|
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;
|
|
}
|