diff --git a/infra/stats.ts b/infra/stats.ts index 59dbb8d8a..67387ee5a 100644 --- a/infra/stats.ts +++ b/infra/stats.ts @@ -165,7 +165,7 @@ export const app = new sst.cloudflare.x.SolidStart("Stats", { domain: `stats.${domain}`, link: [database, EMAILOCTOPUS_API_KEY], environment: { - PUBLIC_URL: `https://stats.${domain}/stats`, + PUBLIC_URL: `https://${domain}/stats`, }, }) diff --git a/packages/console/app/src/lib/stats-proxy.ts b/packages/console/app/src/lib/stats-proxy.ts index 54b9893a5..c8c576ddc 100644 --- a/packages/console/app/src/lib/stats-proxy.ts +++ b/packages/console/app/src/lib/stats-proxy.ts @@ -8,7 +8,7 @@ export async function statsProxy(evt: APIEvent) { targetUrl.hostname = Resource.App.stage === "production" ? "stats.opencode.ai" : "stats.dev.opencode.ai" targetUrl.port = "" - if (targetUrl.pathname.startsWith("/stats/_build/")) { + if (targetUrl.pathname.startsWith("/stats/_build/") || targetUrl.pathname === "/stats/banner.png") { targetUrl.pathname = targetUrl.pathname.slice("/stats".length) } diff --git a/packages/stats/app/public/banner.png b/packages/stats/app/public/banner.png new file mode 100644 index 000000000..57579c32a Binary files /dev/null and b/packages/stats/app/public/banner.png differ diff --git a/packages/stats/app/src/asset/unfurl-rankings.png b/packages/stats/app/src/asset/unfurl-rankings.png deleted file mode 100644 index 872cb6073..000000000 Binary files a/packages/stats/app/src/asset/unfurl-rankings.png and /dev/null differ diff --git a/packages/stats/app/src/routes/index.tsx b/packages/stats/app/src/routes/index.tsx index 97763c232..3353fe850 100644 --- a/packages/stats/app/src/routes/index.tsx +++ b/packages/stats/app/src/routes/index.tsx @@ -11,7 +11,6 @@ import ibmPlexMonoMediumLatin1 from "@ibm/plex/IBM-Plex-Mono/fonts/split/woff2/I import ibmPlexMonoSemiBoldLatin1 from "@ibm/plex/IBM-Plex-Mono/fonts/split/woff2/IBMPlexMono-SemiBold-Latin1.woff2?url" import ibmPlexMonoBoldLatin1 from "@ibm/plex/IBM-Plex-Mono/fonts/split/woff2/IBMPlexMono-Bold-Latin1.woff2?url" import opencodeWordmarkDark from "../asset/logo-ornate-dark.svg" -import statsUnfurlRankings from "../asset/unfurl-rankings.png?url" import { getStatsHomeData, type CacheRatioEntry, @@ -42,7 +41,8 @@ const rangeLabels: Record = { } const statsHomeTitle = "OpenCode Stats" const statsHomeDescription = "OpenCode usage, market share, token cost, and session cost stats." -const statsHomeFallbackUrl = "https://stats.opencode.ai" +const statsHomeFallbackUrl = "https://opencode.ai/stats/" +const statsUnfurlPath = "banner.png" const statsUnfurlAlt = "OpenCode Stats wordmark on a dark patterned background" const headerLinks = [ { href: "#top-models", label: "Top Models" }, @@ -147,11 +147,11 @@ const getGitHubStars = query(async () => { export default function StatsHome() { const event = getRequestEvent() event?.response.headers.set("Cache-Control", "public, max-age=60, s-maxage=300, stale-while-revalidate=86400") - const statsHomeUrl = new URL( + const statsHomeUrl = getStatsHomeUrl( import.meta.env.BASE_URL, event?.request.url ?? (typeof window === "undefined" ? statsHomeFallbackUrl : window.location.href), - ).toString() - const statsUnfurlUrl = new URL(statsUnfurlRankings, statsHomeUrl).toString() + ) + const statsUnfurlUrl = new URL(statsUnfurlPath, statsHomeUrl).toString() const data = createAsync(() => getData()) const githubStars = createAsync(() => getGitHubStars()) const [themePreference, setThemePreference] = createSignal("system") @@ -217,6 +217,13 @@ export default function StatsHome() { ) } +function getStatsHomeUrl(base: string, requestUrl: string) { + const url = new URL(base, requestUrl) + if (url.hostname === "stats.opencode.ai") return "https://opencode.ai/stats/" + if (url.hostname === "stats.dev.opencode.ai") return "https://dev.opencode.ai/stats/" + return url.toString() +} + function isThemePreference(value: string | null): value is ThemePreference { return value === "dark" || value === "light" || value === "system" }