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

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

import TrackingSDKClient from "./Client"

import type { 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} />
    </>
  )
}
