Share reward and less robot load on shared links
CI / test (push) Successful in 1m9s
CI / build (push) Successful in 5m9s
CI / deploy (push) Skipped

The first visit of a shared link by someone else earns the sharer one free
natal analysis, once per user. The share page reports visits from the
visitor's browser; robots, the logged-in sharer and the address the link was
made at do not count. The share button is a proper card that says so in small
print; /v1/me tells whether the reward is used up.

Robots: reading a share writes nothing (view_count counts people only), the
frontend keeps shared content for five minutes (cleared when a link is
revoked), and robots.txt turns away the known AI crawlers while leaving the
link preview robots alone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
feco
2026-11-19 09:26:06 +00:00
co-authored by Claude Opus 5.5
parent c7600608d3
commit 19df36369c
16 changed files with 370 additions and 23 deletions
@@ -0,0 +1,22 @@
"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 (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;
}