diff --git a/apps/dashboard/src/app/layout.tsx b/apps/dashboard/src/app/layout.tsx index 063c81a5b47..b6ad3a7d64b 100644 --- a/apps/dashboard/src/app/layout.tsx +++ b/apps/dashboard/src/app/layout.tsx @@ -8,6 +8,7 @@ import NextTopLoader from "nextjs-toploader"; import { Suspense } from "react"; import { OrganizeContractsToProjectsBanner } from "../components/notices/AnnouncementBanner"; import { OpCreditsGrantedModalWrapperServer } from "../components/onboarding/OpCreditsGrantedModalWrapperServer"; +import { PosthogIdentifierServer } from "../components/wallets/PosthogIdentifierServer"; import { EnsureValidConnectedWalletLoginServer } from "./components/EnsureValidConnectedWalletLogin/EnsureValidConnectedWalletLoginServer"; import { PostHogProvider } from "./components/root-providers"; import { AppRouterProviders } from "./providers"; @@ -80,6 +81,9 @@ export default function RootLayout({ + + + - = { injected: "Injected", }; -export const PosthogIdentifier: React.FC = () => { +export const PosthogIdentifierClient: React.FC<{ + accountId: string | undefined; + accountAddress: string | undefined; +}> = ({ accountId, accountAddress }) => { const client = useThirdwebClient(); const account = useActiveAccount(); const chain = useActiveWalletChain(); @@ -43,10 +46,17 @@ export const PosthogIdentifier: React.FC = () => { // legitimate use-case // eslint-disable-next-line no-restricted-syntax useEffect(() => { - if (account?.address) { - posthog.identify(account.address); + if (accountAddress) { + posthog.identify(accountAddress); } - }, [account?.address]); + }, [accountAddress]); + + // eslint-disable-next-line no-restricted-syntax + useEffect(() => { + if (accountId) { + posthog.identify(accountId); + } + }, [accountId]); // legitimate use-case // eslint-disable-next-line no-restricted-syntax diff --git a/apps/dashboard/src/components/wallets/PosthogIdentifierServer.tsx b/apps/dashboard/src/components/wallets/PosthogIdentifierServer.tsx new file mode 100644 index 00000000000..dabd7524640 --- /dev/null +++ b/apps/dashboard/src/components/wallets/PosthogIdentifierServer.tsx @@ -0,0 +1,17 @@ +import { getRawAccount } from "../../app/account/settings/getAccount"; +import { getAuthTokenWalletAddress } from "../../app/api/lib/getAuthToken"; +import { PosthogIdentifierClient } from "./PosthogIdentifier"; + +export async function PosthogIdentifierServer() { + const [account, accountAddress] = await Promise.all([ + getRawAccount(), + getAuthTokenWalletAddress(), + ]); + + return ( + + ); +}