diff --git a/deploy/env.example b/deploy/env.example index 94b1b21..b765fc6 100644 --- a/deploy/env.example +++ b/deploy/env.example @@ -23,6 +23,10 @@ THIRDSHIFT_SCHEDULER_WEIGHT_REGION=5 NEXT_PUBLIC_BASE_PATH= NEXT_PUBLIC_THIRDSHIFT_API_BASE= +# Google Analytics 4 + Search Console (baked in at `next build`) +NEXT_PUBLIC_GA_MEASUREMENT_ID= +NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION= + # Optional: notify Dash via Cairo on waitlist submit (POST /v2/track). # Create with Cairo setup_product / create_write_key; leave unset to disable. CAIRO_HOST= diff --git a/web/console/app/layout.tsx b/web/console/app/layout.tsx index ab3e617..9523545 100644 --- a/web/console/app/layout.tsx +++ b/web/console/app/layout.tsx @@ -1,15 +1,28 @@ import type { Metadata } from "next"; +import { GoogleAnalytics } from "../components/GoogleAnalytics"; import "./globals.css"; +const siteUrl = "https://thirdshift.ani.computer"; + export const metadata: Metadata = { - title: "Thirdshift Console", - description: "Thirdshift alpha operator console and public network status" + metadataBase: new URL(siteUrl), + title: { + default: "Thirdshift Console", + template: "%s ยท Thirdshift" + }, + description: "Thirdshift alpha operator console and public network status", + verification: { + google: process.env.NEXT_PUBLIC_GOOGLE_SITE_VERIFICATION || undefined + } }; export default function RootLayout({ children }: { children: React.ReactNode }) { return ( - {children} + + + {children} + ); } diff --git a/web/console/app/robots.ts b/web/console/app/robots.ts new file mode 100644 index 0000000..a5e404e --- /dev/null +++ b/web/console/app/robots.ts @@ -0,0 +1,14 @@ +import type { MetadataRoute } from "next"; + +const siteUrl = "https://thirdshift.ani.computer"; + +export default function robots(): MetadataRoute.Robots { + return { + rules: { + userAgent: "*", + allow: "/" + }, + sitemap: `${siteUrl}/sitemap.xml`, + host: siteUrl + }; +} diff --git a/web/console/app/sitemap.ts b/web/console/app/sitemap.ts new file mode 100644 index 0000000..ae2a2e3 --- /dev/null +++ b/web/console/app/sitemap.ts @@ -0,0 +1,20 @@ +import type { MetadataRoute } from "next"; + +const siteUrl = "https://thirdshift.ani.computer"; + +export default function sitemap(): MetadataRoute.Sitemap { + return [ + { + url: `${siteUrl}/status`, + lastModified: new Date(), + changeFrequency: "daily", + priority: 1 + }, + { + url: siteUrl, + lastModified: new Date(), + changeFrequency: "weekly", + priority: 0.6 + } + ]; +} diff --git a/web/console/components/GoogleAnalytics.tsx b/web/console/components/GoogleAnalytics.tsx new file mode 100644 index 0000000..ae0ec8e --- /dev/null +++ b/web/console/components/GoogleAnalytics.tsx @@ -0,0 +1,25 @@ +import Script from "next/script"; + +/** + * GA4 loader. Measurement ID is baked in at build time via + * NEXT_PUBLIC_GA_MEASUREMENT_ID (Next inlines public env on `next build`). + */ +export function GoogleAnalytics() { + const measurementId = process.env.NEXT_PUBLIC_GA_MEASUREMENT_ID?.trim(); + if (!measurementId) { + return null; + } + return ( + <> + + + ); +} diff --git a/web/console/components/PublicStatusPage.tsx b/web/console/components/PublicStatusPage.tsx index 0eacf97..aa2930d 100644 --- a/web/console/components/PublicStatusPage.tsx +++ b/web/console/components/PublicStatusPage.tsx @@ -2,6 +2,7 @@ import { FormEvent, useEffect, useMemo, useRef, useState } from "react"; import { publicFetch, publicPost } from "../lib/api"; +import { trackEvent } from "../lib/analytics"; import { EarningsTicker } from "./EarningsTicker"; import { WorldMap } from "./WorldMap"; import { @@ -136,6 +137,10 @@ export function PublicStatusPage({ initialStatus }: { initialStatus?: PublicStat // to learn which addresses have already applied. setApplicationState("received"); setApplicationMessage(receivedText); + trackEvent("generate_lead", { + form_type: "waitlist", + model_id: activeModel || "none" + }); } catch (err) { setApplicationState("error"); setApplicationMessage(err instanceof Error ? err.message : "Request could not be sent"); diff --git a/web/console/lib/analytics.ts b/web/console/lib/analytics.ts new file mode 100644 index 0000000..c6ebe39 --- /dev/null +++ b/web/console/lib/analytics.ts @@ -0,0 +1,16 @@ +type Gtag = (...args: unknown[]) => void; + +declare global { + interface Window { + gtag?: Gtag; + dataLayer?: unknown[]; + } +} + +/** Fire a GA4 event when the measurement ID is present in the built bundle. */ +export function trackEvent(name: string, params?: Record) { + if (typeof window === "undefined" || typeof window.gtag !== "function") { + return; + } + window.gtag("event", name, params); +}