import { getUserTracking } from "@/lib/trpc/memoizedRequests"
import { serverClient } from "@/lib/trpc/server"

import RouterTransition from "@/components/TrackingSDK/RouterTransition"

import TrackingSDKClient from "./Client"

import { TrackingSDKPageData } from "@/types/components/tracking"

export const preloadUserTracking = () => {
  void getUserTracking()
}

export default async function TrackingSDK({
  pageData,
}: {
  pageData: TrackingSDKPageData
}) {
  const userTrackingData = await getUserTracking()

  return (
    <>
      <TrackingSDKClient pageData={pageData} userData={userTrackingData} />
      <RouterTransition pageData={pageData} userData={userTrackingData} />
    </>
  )
}
