diff --git a/packages/fakeyou.com/src/utils/domainConfig.ts b/packages/fakeyou.com/src/utils/domainConfig.ts index b02f04ffbb..a37eade057 100644 --- a/packages/fakeyou.com/src/utils/domainConfig.ts +++ b/packages/fakeyou.com/src/utils/domainConfig.ts @@ -1,18 +1,24 @@ -type DomainConfig = Record; +export enum Website { + FakeYou, + StorytellerAi, +} + +export interface DomainConfig { + website: Website, + logo: string, + title: string, + link: string, +} const domainConfigs: Record = { - "storyteller.ai": { + "storyteller": { + website: Website.StorytellerAi, logo: "/fakeyou/Storyteller-Logo-1.png", title: "Storyteller AI", link: "https://storyteller.ai", }, - "fakeyou.com": { - logo: "/fakeyou/FakeYou-Logo-2.png", - title: "FakeYou", - link: "https://fakeyou.com", - }, - // Default to FakeYou.com - default: { + "fakeyou": { + website: Website.FakeYou, logo: "/fakeyou/FakeYou-Logo-2.png", title: "FakeYou", link: "https://fakeyou.com", @@ -20,16 +26,18 @@ const domainConfigs: Record = { }; export const getCurrentDomainConfig = (): DomainConfig => { - const currentHostname = window.location.hostname; + // Fast resolve without leaking domain details + switch (window.location.hostname) { + case "fakeyou.com": + return domainConfigs.fakeyou; + case "storyteller.ai": + return domainConfigs.storyteller; + } - const matchingConfigKey = Object.keys(domainConfigs).find( - key => currentHostname === key || currentHostname.endsWith(`.${key}`) - ); + if (window.location.hostname.includes("storyteller")) { + return domainConfigs.storyteller; + } - const domainConfig = - matchingConfigKey !== undefined - ? domainConfigs[matchingConfigKey] - : domainConfigs["default"]; - - return domainConfig; + // Default fallback + return domainConfigs.fakeyou; }; diff --git a/packages/fakeyou.com/src/v2/view/pages/landing/LandingPage.tsx b/packages/fakeyou.com/src/v2/view/pages/landing/LandingPage.tsx index 9f79c9f8d5..5f684760d6 100644 --- a/packages/fakeyou.com/src/v2/view/pages/landing/LandingPage.tsx +++ b/packages/fakeyou.com/src/v2/view/pages/landing/LandingPage.tsx @@ -19,6 +19,7 @@ import "./LandingPage.scss"; // import VstSectionV1 from "./components/VstSectionV1"; import VstSectionV2 from "./components/VstSectionV2"; import FakeYouLandingBody from "./fakeyou/FakeYouLandingBody"; +import { DomainConfig, Website } from "utils/domainConfig"; interface Props { sessionWrapper: SessionWrapper; @@ -35,16 +36,18 @@ interface Props { function LandingPage(props: Props) { usePrefixedDocumentTitle("FakeYou Celebrity Voice Generator"); + PosthogClient.recordPageview(); - const domain = useDomainConfig(); + + const domain : DomainConfig = useDomainConfig(); const isLoggedIn = props.sessionWrapper.isLoggedIn(); return ( <> - {domain.title === "Storyteller AI" && !isLoggedIn && } + {domain.website === Website.StorytellerAi && !isLoggedIn && } - {domain.title === "FakeYou" ? ( + {domain.website === Website.FakeYou ? ( <> {/* FAKEYOU.COM */} {!isLoggedIn && (