fix: refactor tracking requests
This commit is contained in:
@@ -2,7 +2,6 @@ import { Lang } from "@/constants/languages"
|
||||
import {
|
||||
GetAccountPage,
|
||||
GetAccountPageRefs,
|
||||
GetTrackingAccountPage,
|
||||
} from "@/lib/graphql/Query/AccountPage.graphql"
|
||||
import { request } from "@/lib/graphql/request"
|
||||
import { notFound } from "@/server/errors/trpc"
|
||||
@@ -19,7 +18,6 @@ import {
|
||||
type AccountPage,
|
||||
AccountPageDataRaw,
|
||||
AccountPageRefsDataRaw,
|
||||
AccountPageTackingData,
|
||||
validateAccountPageRefsSchema,
|
||||
validateAccountPageSchema,
|
||||
} from "./output"
|
||||
@@ -136,32 +134,18 @@ export const accountPageQueryRouter = router({
|
||||
content,
|
||||
} as AccountPage
|
||||
|
||||
return accountPage
|
||||
}),
|
||||
tracking: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
||||
const { lang, uid } = ctx
|
||||
|
||||
const response = await request<AccountPageTackingData>(
|
||||
GetTrackingAccountPage,
|
||||
{
|
||||
locale: lang,
|
||||
uid,
|
||||
}
|
||||
)
|
||||
|
||||
if (!response.data) {
|
||||
throw notFound(response)
|
||||
}
|
||||
|
||||
const accountTrackingData: TrackingSDKPageData = {
|
||||
pageId: response.data.account_page.system.uid,
|
||||
lang: response.data.account_page.system.locale as Lang,
|
||||
publishedDate: response.data.account_page.system.updated_at,
|
||||
createdDate: response.data.account_page.system.created_at,
|
||||
const tracking: TrackingSDKPageData = {
|
||||
pageId: validatedAccountPage.data.account_page.system.uid,
|
||||
lang: validatedAccountPage.data.account_page.system.locale as Lang,
|
||||
publishedDate: validatedAccountPage.data.account_page.system.updated_at,
|
||||
createdDate: validatedAccountPage.data.account_page.system.created_at,
|
||||
channel: TrackingChannelEnum["scandic-friends"],
|
||||
pageType: `member${response.data.account_page.title}page`,
|
||||
}
|
||||
|
||||
return accountTrackingData
|
||||
return {
|
||||
accountPage,
|
||||
tracking,
|
||||
}
|
||||
}),
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user