Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions deploy/env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
19 changes: 16 additions & 3 deletions web/console/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<html lang="en">
<body>{children}</body>
<body>
<GoogleAnalytics />
{children}
</body>
</html>
);
}
14 changes: 14 additions & 0 deletions web/console/app/robots.ts
Original file line number Diff line number Diff line change
@@ -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
};
}
20 changes: 20 additions & 0 deletions web/console/app/sitemap.ts
Original file line number Diff line number Diff line change
@@ -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
}
];
}
25 changes: 25 additions & 0 deletions web/console/components/GoogleAnalytics.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<Script src={`https://www.googletagmanager.com/gtag/js?id=${measurementId}`} strategy="afterInteractive" />
<Script id="google-analytics" strategy="afterInteractive">
{`
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '${measurementId}');
`}
</Script>
</>
);
}
5 changes: 5 additions & 0 deletions web/console/components/PublicStatusPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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");
Expand Down
16 changes: 16 additions & 0 deletions web/console/lib/analytics.ts
Original file line number Diff line number Diff line change
@@ -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<string, string | number | boolean | undefined>) {
if (typeof window === "undefined" || typeof window.gtag !== "function") {
return;
}
window.gtag("event", name, params);
}