feat: add tracking to account pages

This commit is contained in:
Christel Westerberg
2024-07-11 11:12:08 +02:00
parent a8a67d5e35
commit 546679387f
9 changed files with 106 additions and 11 deletions

View File

@@ -1,3 +1,4 @@
import { Lang } from "@/constants/languages"
import {
GetLoyaltyPage,
GetLoyaltyPageRefs,
@@ -19,6 +20,7 @@ import { removeEmptyObjects } from "../../utils"
import {
LoyaltyPage,
type LoyaltyPageRefsDataRaw,
LoyaltyPageTackingData,
validateLoyaltyPageRefsSchema,
validateLoyaltyPageSchema,
} from "./output"
@@ -232,10 +234,13 @@ export const loyaltyPageQueryRouter = router({
tracking: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
const { lang, uid } = ctx
const response = await request<any>(GetTrackingLoyaltyPage, {
locale: lang,
uid,
})
const response = await request<LoyaltyPageTackingData>(
GetTrackingLoyaltyPage,
{
locale: lang,
uid,
}
)
if (!response.data) {
throw notFound(response)
@@ -243,8 +248,8 @@ export const loyaltyPageQueryRouter = router({
const loyaltyTrackingData: TrackingSDKPageData = {
pageId: response.data.loyalty_page.system.uid,
lang: response.data.loyalty_page.system.locale,
publishedDate: response.data.loyalty_page.system.published_at,
lang: response.data.loyalty_page.system.locale as Lang,
publishedDate: response.data.loyalty_page.system.updated_at,
createdDate: response.data.loyalty_page.system.created_at,
channel: TrackingChannelEnum["scandic-friends"],
}