Skip to content

Commit 2558988

Browse files
authored
Merge pull request #36 from JonDevOps/claude/tor-notice
Opt-in analytics, Tor notice and /tor page, Terms checkbox at sign-up
2 parents ca48509 + f9b6568 commit 2558988

12 files changed

Lines changed: 334 additions & 17 deletions

File tree

‎next.config.js‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
// Functions), App Check's reCAPTCHA, Google Analytics, and the Discord and
44
// YouTube embeds. Images can come from any https address, since profile
55
// pictures are links members add.
6-
// w3Develops' Tor onion service (issue #345), which proxies to this site
6+
// w3Develops' Tor onion service (issue #345), which proxies to this site.
7+
// The same address is in src/lib/onion.ts.
78
const ONION_HOST = 'byexy3vcngbhih4hbp4ssfefum2liaegw4hn4mm3q5apetxtgz4bq2yd.onion';
89

910
const CONTENT_SECURITY_POLICY = [

‎src/app/cookies/page.tsx‎

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,32 @@ const storage = [
3030
howLong: 'Until you clear site data',
3131
needed: 'No',
3232
},
33+
{
34+
name: 'reCAPTCHA (App Check)',
35+
where: 'Browser storage and Google cookies',
36+
why: 'Checks that requests to our database come from the real site, not bots.',
37+
howLong: 'Set by Google',
38+
needed: 'Yes',
39+
},
40+
{
41+
name: 'w3-consent-*, w3-dismissed-*',
42+
where: 'Browser storage (localStorage)',
43+
why: 'Remembers your cookie choice, that you read the Tor notice, and notices you closed.',
44+
howLong: 'Until you clear site data',
45+
needed: 'Yes',
46+
},
3347
];
3448

3549
export default function CookiesPage() {
3650
return (
3751
<LegalPage
3852
icon={<Cookie className="h-10 w-10" />}
3953
title="Cookies"
40-
lastUpdated="November 2, 2026"
54+
lastUpdated="November 12, 2026"
4155
intro={
4256
<p>
43-
We use a small amount of browser storage to keep you signed in, and Google Analytics to count visits. That's
44-
it. There are no advertising cookies, no social media trackers, and nothing that follows you around the web.
57+
We use a small amount of browser storage to keep you signed in and keep out bots, and, only if you allow it,
58+
Google Analytics to count visits. That's it. There are no advertising cookies, no social media trackers, and nothing that follows you around the web.
4559
</p>
4660
}
4761
>
@@ -88,9 +102,15 @@ export default function CookiesPage() {
88102
</LegalSection>
89103

90104
<LegalSection
91-
title="Turning them off"
92-
summary="Block the optional ones and the site still works. Block the sign-in storage and you'll just need to sign in again."
105+
title="Your choice"
106+
summary="Google Analytics is off until you allow it. Change your mind any time with Cookie settings at the bottom of every page."
93107
>
108+
<p>
109+
The first time you visit, we ask whether Google Analytics may count your visits. Until you say yes, it
110+
doesn't load and sets no cookies. If your browser sends Global Privacy Control, we treat that as a no and
111+
don't ask. You can change your answer any time with <strong>Cookie settings</strong> at the bottom of every
112+
page; saying no later stops Analytics and deletes its cookies.
113+
</p>
94114
<p>
95115
You can block or delete cookies and site data in your browser's settings, or use a content blocker. Blocking
96116
Google Analytics won't change anything about how w3Develops works for you. If you block all site storage,

‎src/app/layout.tsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Header from "@/components/layout/header";
99
import EmailVerificationBanner from "@/components/EmailVerificationBanner";
1010
import Footer from "@/components/layout/footer";
1111
import AnnouncementBanner from "@/components/AnnouncementBanner";
12+
import ConsentBanner from "@/components/ConsentBanner";
1213
import { HOME_DESCRIPTION, HOME_TITLE, SITE_NAME, SITE_URL, sharePreview } from "@/lib/site-pages";
1314
import JsonLd from "@/components/JsonLd";
1415
import ErrorReporter from "@/components/ErrorReporter";
@@ -125,6 +126,7 @@ export default function RootLayout({
125126
{children}
126127
</main>
127128
<Footer />
129+
<ConsentBanner />
128130
<Toaster />
129131
</FirebaseClientProvider>
130132
</body>

‎src/app/privacy/page.tsx‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default function PrivacyPage() {
1313
<LegalPage
1414
icon={<ShieldCheck className="h-10 w-10" />}
1515
title="Privacy Policy"
16-
lastUpdated="November 7, 2026"
16+
lastUpdated="November 12, 2026"
1717
intro={
1818
<>
1919
<p>
@@ -56,8 +56,8 @@ export default function PrivacyPage() {
5656
</li>
5757
<li>
5858
<strong>Basic technical information.</strong> Like almost every website, our hosting keeps short-lived
59-
server logs (such as IP address and browser type) so we can keep the site secure and fix bugs. We also use
60-
Google Analytics to count visits. See <Link href="/cookies" className={linkClass}>our cookie page</Link> for
59+
server logs (such as IP address and browser type) so we can keep the site secure and fix bugs. If you allow
60+
it in the cookie banner, we also use Google Analytics to count visits. See <Link href="/cookies" className={linkClass}>our cookie page</Link> for
6161
details.
6262
</li>
6363
</ul>
@@ -138,8 +138,9 @@ export default function PrivacyPage() {
138138
group's work still makes sense.
139139
</li>
140140
<li>
141-
<strong>Opt out of analytics:</strong> block analytics in your browser or with a content blocker. The site
142-
works the same without it.
141+
<strong>Analytics is opt-in:</strong> Google Analytics stays off unless you allow it in the cookie banner,
142+
and you can change your mind any time with Cookie settings at the bottom of every page. If your browser
143+
sends Global Privacy Control, we treat it as a no. The site works the same without analytics.
143144
</li>
144145
</ul>
145146
<p>

‎src/app/signup/page.tsx‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ function SignupPageContent() {
9696
const [usernameError, setUsernameError] = useState<string | null>(null);
9797
// New members confirm they meet the minimum age in the Terms of Use
9898
const [isOldEnough, setIsOldEnough] = useState(false);
99+
const [agreesToTerms, setAgreesToTerms] = useState(false);
99100
const [isUsernameChecking, setIsUsernameChecking] = useState(false);
100101
const [isUsernameAvailable, setIsUsernameAvailable] = useState<boolean | null>(null);
101102
const [isSubmitting, setIsSubmitting] = useState(false);
@@ -183,6 +184,10 @@ function SignupPageContent() {
183184
toast({ variant: "destructive", title: "Age requirement", description: "You need to be 13 or older to join w3Develops." });
184185
return;
185186
}
187+
if (needsAgeCheck && !agreesToTerms) {
188+
toast({ variant: "destructive", title: "Terms of Use", description: "Please agree to the Terms of Use and Privacy Policy to join." });
189+
return;
190+
}
186191

187192

188193
setIsSubmitting(true);
@@ -347,7 +352,18 @@ function SignupPageContent() {
347352
</div>
348353
)}
349354

350-
<Button type="submit" className="w-full" disabled={isSubmitting || (needsUsername && !isUsernameAvailable) || (needsTimezone && !timezone) || (needsAgeCheck && !isOldEnough)}>
355+
{needsAgeCheck && (
356+
<div className="flex items-start gap-2">
357+
<Checkbox id="agreeTerms" checked={agreesToTerms} onCheckedChange={checked => setAgreesToTerms(!!checked)} disabled={isSubmitting} className="mt-0.5" />
358+
<Label htmlFor="agreeTerms" className="text-sm font-normal leading-snug">
359+
I agree to the{' '}
360+
<Link href="/terms" target="_blank" className="underline">Terms of Use</Link> and{' '}
361+
<Link href="/privacy" target="_blank" className="underline">Privacy Policy</Link>
362+
</Label>
363+
</div>
364+
)}
365+
366+
<Button type="submit" className="w-full" disabled={isSubmitting || (needsUsername && !isUsernameAvailable) || (needsTimezone && !timezone) || (needsAgeCheck && (!isOldEnough || !agreesToTerms))}>
351367
{isSubmitting ? 'Creating Account...' : isFinishing ? 'Finish' : 'Create Account'}
352368
</Button>
353369
</form>

‎src/app/tor/page.tsx‎

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import type { Metadata } from 'next';
2+
import Link from 'next/link';
3+
import { Shield } from 'lucide-react';
4+
import { LegalPage, LegalSection } from '@/components/LegalPage';
5+
import { ONION_ADDRESS } from '@/lib/onion';
6+
import { pageMetadata } from '@/lib/site-pages';
7+
8+
export const metadata: Metadata = pageMetadata('/tor');
9+
10+
const linkClass = 'text-primary underline';
11+
12+
export default function TorPage() {
13+
return (
14+
<LegalPage
15+
icon={<Shield className="h-10 w-10" />}
16+
title="Using w3Develops over Tor"
17+
lastUpdated="November 12, 2026"
18+
intro={
19+
<p>
20+
w3Develops has an onion address, so you can visit through the Tor network without revealing your IP address.
21+
Here&apos;s what that protects, and what it doesn&apos;t.
22+
</p>
23+
}
24+
>
25+
<LegalSection title="Our onion address" summary="Open it in Tor Browser. Check it matches exactly.">
26+
<p className="font-mono break-all rounded-md bg-muted p-3">http://{ONION_ADDRESS}</p>
27+
<p>
28+
Tor Browser also offers this address automatically on w3develops.org, with a &quot;.onion available&quot;
29+
button in the address bar.
30+
</p>
31+
</LegalSection>
32+
33+
<LegalSection title="What Tor protects" summary="Your IP address and location are hidden from us and from Google.">
34+
<p>
35+
When you use the onion address, your connection goes through the Tor network, so neither w3Develops nor the
36+
services the site uses can see your real IP address or where you are.
37+
</p>
38+
</LegalSection>
39+
40+
<LegalSection title="What it doesn't" summary="Pages still load Google services, and signing in links what you do to your account.">
41+
<p>The onion site is the same w3Develops, and it still uses:</p>
42+
<ul className="list-disc pl-6 space-y-1">
43+
<li><strong>Firebase</strong> (by Google) for sign-in and our database. Your browser talks to Google&apos;s servers directly, over Tor.</li>
44+
<li><strong>reCAPTCHA</strong> (by Google), which checks that visitors aren&apos;t bots.</li>
45+
<li><strong>Google Analytics</strong>, only if you allow it in the cookie banner. It&apos;s off unless you say yes.</li>
46+
</ul>
47+
<p>
48+
Google can see that someone is using w3Develops, but not who you are, unless you sign in. If you sign in, what
49+
you do on the site is linked to your account, just like on w3develops.org. You can browse without an account.
50+
</p>
51+
<p>
52+
Tor Browser&apos;s &quot;Safest&quot; security level turns off JavaScript, which most of w3Develops needs.
53+
The &quot;Safer&quot; level works.
54+
</p>
55+
</LegalSection>
56+
57+
<LegalSection title="More">
58+
<p>
59+
Our <Link href="/privacy" className={linkClass}>Privacy Policy</Link> and{' '}
60+
<Link href="/cookies" className={linkClass}>Cookies</Link> pages cover everything we store. Our{' '}
61+
<Link href="/warrant-canary" className={linkClass}>warrant canary</Link> is signed with PGP. Questions? Email{' '}
62+
<a href="mailto:privacy@w3develops.org" className={linkClass}>privacy@w3develops.org</a>.
63+
</p>
64+
</LegalSection>
65+
</LegalPage>
66+
);
67+
}

‎src/components/ConsentBanner.tsx‎

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
'use client';
2+
3+
import { useEffect, useState } from 'react';
4+
import Link from 'next/link';
5+
import { Button } from '@/components/ui/button';
6+
import { firebaseConfig } from '@/firebase/config';
7+
import {
8+
OPEN_SETTINGS_EVENT, acceptTorNotice, isOnionHost, onConsentChange, savedAnalyticsChoice,
9+
sendsGlobalPrivacyControl, setAnalyticsChoice, shouldAskAboutAnalytics, torNoticeAccepted,
10+
} from '@/lib/consent';
11+
12+
type Showing = 'tor' | 'analytics' | 'settings' | null;
13+
14+
/** Which notice to show: the Tor notice first (on the onion address), then the analytics question */
15+
function pick(): Showing {
16+
if (isOnionHost() && !torNoticeAccepted()) return 'tor';
17+
if (shouldAskAboutAnalytics()) return 'analytics';
18+
return null;
19+
}
20+
21+
/**
22+
* The privacy notices at the bottom of the page. On the Tor onion address,
23+
* visitors first accept a notice about the Google services the site uses.
24+
* Everyone is asked once whether Google Analytics may count their visits
25+
* (it stays off until they accept); the footer's Cookie settings link opens
26+
* it again. Renders nothing on the server, so pages hydrate cleanly.
27+
*/
28+
export default function ConsentBanner() {
29+
const [showing, setShowing] = useState<Showing>(null);
30+
31+
useEffect(() => {
32+
// Read in the browser after hydration: the choices live in localStorage
33+
const update = () => setShowing(current => current === 'settings' ? current : pick());
34+
const timer = window.setTimeout(update, 0);
35+
const stop = onConsentChange(update);
36+
const open = () => setShowing('settings');
37+
window.addEventListener(OPEN_SETTINGS_EVENT, open);
38+
return () => {
39+
window.clearTimeout(timer);
40+
stop();
41+
window.removeEventListener(OPEN_SETTINGS_EVENT, open);
42+
};
43+
}, []);
44+
45+
if (!showing) return null;
46+
47+
const choose = (choice: 'granted' | 'denied') => {
48+
setAnalyticsChoice(choice, firebaseConfig.measurementId);
49+
setShowing(pick());
50+
};
51+
52+
if (showing === 'tor') {
53+
return (
54+
<div role="dialog" aria-modal="true" aria-labelledby="tor-notice-title" className="fixed inset-0 z-[100] flex items-end sm:items-center justify-center bg-black/60 p-4">
55+
<div className="w-full max-w-lg rounded-lg border bg-background p-5 shadow-lg space-y-3">
56+
<h2 id="tor-notice-title" className="text-lg font-semibold">You&apos;re visiting w3Develops over Tor</h2>
57+
<p className="text-sm text-muted-foreground">
58+
Tor hides your IP address and location from us and from Google. But this site still loads Google services:
59+
Firebase (sign-in and our database) and reCAPTCHA, which checks you&apos;re not a bot. Google can
60+
see that someone is using w3Develops, and if you sign in, what you do is linked to your account.
61+
</p>
62+
<p className="text-sm text-muted-foreground">
63+
You can browse without an account. <Link href="/tor" className="underline">Read more about using w3Develops over Tor</Link>.
64+
</p>
65+
<div className="flex justify-end">
66+
<Button onClick={acceptTorNotice}>I understand, continue</Button>
67+
</div>
68+
</div>
69+
</div>
70+
);
71+
}
72+
73+
const current = savedAnalyticsChoice();
74+
return (
75+
<div role="region" aria-label="Cookie choices" className="fixed bottom-0 inset-x-0 z-[90] p-3 sm:p-4">
76+
<div className="mx-auto max-w-3xl rounded-lg border bg-background p-4 shadow-lg sm:flex sm:items-center sm:gap-4 space-y-3 sm:space-y-0">
77+
<p className="text-sm text-muted-foreground flex-1">
78+
We use Google Analytics to count visits, which sets cookies. It stays off unless you allow it. Sign-in and our
79+
bot check are needed for the site to work. <Link href="/cookies" className="underline">Cookies</Link>
80+
{' · '}<Link href="/privacy" className="underline">Privacy</Link>
81+
{showing === 'settings' && (
82+
<span className="block mt-1 text-xs">
83+
Now: {current === 'granted' ? 'allowed' : current === 'denied' ? 'off' : sendsGlobalPrivacyControl() ? 'off (your browser sends Global Privacy Control)' : 'off'}.
84+
</span>
85+
)}
86+
</p>
87+
<div className="flex gap-2 shrink-0">
88+
<Button variant="outline" size="sm" onClick={() => choose('denied')}>Reject</Button>
89+
<Button size="sm" onClick={() => choose('granted')}>Allow analytics</Button>
90+
</div>
91+
</div>
92+
</div>
93+
);
94+
}
95+
96+
/** The footer's Cookie settings link, which reopens the banner */
97+
export function CookieSettingsButton({ className }: { className?: string }) {
98+
return (
99+
<button type="button" className={className} onClick={() => window.dispatchEvent(new Event(OPEN_SETTINGS_EVENT))}>
100+
Cookie settings
101+
</button>
102+
);
103+
}

‎src/components/layout/footer.tsx‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
'use client';
33

44
import { Github, Youtube, Facebook, Instagram, Linkedin, Twitter, Podcast } from 'lucide-react';
5+
import { CookieSettingsButton } from '@/components/ConsentBanner';
56
import Link from 'next/link';
67

78
// Corrected SVGs for icons ensuring centering and brand accuracy
@@ -97,6 +98,7 @@ export default function Footer() {
9798
<Link href="/privacy" className="text-primary hover:underline">Privacy Policy</Link>
9899
<Link href="/terms" className="text-primary hover:underline">Terms of Use</Link>
99100
<Link href="/cookies" className="text-primary hover:underline">Cookies</Link>
101+
<CookieSettingsButton className="text-primary hover:underline text-left" />
100102
<Link href="/newsletter" className="text-primary hover:underline">Newsletter</Link>
101103
<Link href="/donate" className="text-primary hover:underline">Donate</Link>
102104
<Link href="/marketplace" className="text-primary hover:underline">Marketplace</Link>
@@ -108,8 +110,7 @@ export default function Footer() {
108110
<Link href="/code-of-conduct" className="text-primary hover:underline">Code of Conduct</Link>
109111
<Link href="/time-converter" className="text-primary hover:underline">Time Converter</Link>
110112
<Link href="/warrant-canary" className="text-primary hover:underline">Warrant Canary</Link>
111-
{/* The Tor onion service (issue #345); the same address is in next.config.js */}
112-
<a href="http://byexy3vcngbhih4hbp4ssfefum2liaegw4hn4mm3q5apetxtgz4bq2yd.onion" className="text-primary hover:underline" title="byexy3vcngbhih4hbp4ssfefum2liaegw4hn4mm3q5apetxtgz4bq2yd.onion (open in Tor Browser)">Tor (.onion)</a>
113+
<Link href="/tor" className="text-primary hover:underline">Tor (.onion)</Link>
113114
</div>
114115
</div>
115116

‎src/firebase/initialize-app.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { connectFirestoreEmulator, getFirestore, initializeFirestore } from 'fir
55
import { connectFunctionsEmulator, getFunctions, type Functions } from 'firebase/functions';
66
import { connectStorageEmulator, getStorage, type FirebaseStorage } from 'firebase/storage';
77
import { getAnalytics, isSupported } from 'firebase/analytics';
8+
import { whenAnalyticsAllowed } from '@/lib/consent';
89
import { initializeAppCheck, ReCaptchaEnterpriseProvider } from 'firebase/app-check';
910

1011
let appCheckStarted = false;
@@ -94,9 +95,10 @@ export function getSdks(firebaseApp: FirebaseApp) {
9495
connectAuthEmulator(auth, `http://127.0.0.1:${authEmulatorPort}`, { disableWarnings: true });
9596
}
9697

97-
// Conditionally initialize Analytics only on the client and if supported.
98-
const analytics = typeof window !== 'undefined' && firebaseConfig.measurementId
99-
? isSupported().then(yes => yes ? getAnalytics(app) : null)
98+
// Analytics starts only in the browser, and only once the visitor accepts
99+
// it in the cookie banner (src/lib/consent.ts)
100+
const analytics = typeof window !== 'undefined' && firebaseConfig.measurementId
101+
? whenAnalyticsAllowed().then(() => isSupported()).then(yes => yes ? getAnalytics(app) : null)
100102
: Promise.resolve(null);
101103

102104
return {

0 commit comments

Comments
 (0)