feat: add tracking to account pages
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import TrackingSDK from "@/components/Current/TrackingSDK"
|
||||
import Content from "@/components/MyPages/AccountPage/Content"
|
||||
import Title from "@/components/TempDesignSystem/Text/Title"
|
||||
import { getIntl } from "@/i18n"
|
||||
@@ -18,6 +19,9 @@ export default async function MyPages({
|
||||
return null
|
||||
}
|
||||
|
||||
const accountPageTracking =
|
||||
await serverClient().contentstack.accountPage.tracking()
|
||||
|
||||
return (
|
||||
<main className={styles.blocks}>
|
||||
<Title>{accountPage.heading}</Title>
|
||||
@@ -26,6 +30,7 @@ export default async function MyPages({
|
||||
) : (
|
||||
<p>{formatMessage({ id: "No content published" })}</p>
|
||||
)}
|
||||
<TrackingSDK pageData={accountPageTracking} />
|
||||
</main>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -50,7 +50,7 @@ export default async function Profile({ params }: PageArgs<LangParams>) {
|
||||
<div className={styles.item}>
|
||||
<CalendarIcon color="burgundy" />
|
||||
<Body color="burgundy" textTransform="bold">
|
||||
{formatMessage({ id: "Date of birth" })}
|
||||
{formatMessage({ id: "Date of Birth" })}
|
||||
</Body>
|
||||
<Body color="burgundy">{user.dateOfBirth}</Body>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import "../profileLayout.css"
|
||||
|
||||
export default function EditProfilePage() {
|
||||
return null
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import TrackingSDK from "@/components/Current/TrackingSDK"
|
||||
|
||||
export default async function EditProfilePage() {
|
||||
const accountPageTracking =
|
||||
await serverClient().contentstack.accountPage.tracking()
|
||||
|
||||
return <TrackingSDK pageData={accountPageTracking} />
|
||||
}
|
||||
|
||||
@@ -1,5 +1,12 @@
|
||||
import "./profileLayout.css"
|
||||
|
||||
export default function ProfilePage() {
|
||||
return null
|
||||
import { serverClient } from "@/lib/trpc/server"
|
||||
|
||||
import TrackingSDK from "@/components/Current/TrackingSDK"
|
||||
|
||||
export default async function ProfilePage() {
|
||||
const accountPageTracking =
|
||||
await serverClient().contentstack.accountPage.tracking()
|
||||
|
||||
return <TrackingSDK pageData={accountPageTracking} />
|
||||
}
|
||||
|
||||
@@ -99,3 +99,14 @@ query GetFiNoSvUrlsAccountPage($uid: String!) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
query GetTrackingAccountPage($locale: String!, $uid: String!) {
|
||||
account_page(locale: $locale, uid: $uid) {
|
||||
system {
|
||||
locale
|
||||
created_at
|
||||
uid
|
||||
updated_at
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,3 +189,17 @@ export const validateAccountPageRefsSchema = z.object({
|
||||
export type AccountPageRefsDataRaw = z.infer<
|
||||
typeof validateAccountPageRefsSchema
|
||||
>
|
||||
|
||||
//Tracking
|
||||
const validateAccountTrackingData = z.object({
|
||||
account_page: z.object({
|
||||
system: z.object({
|
||||
uid: z.string(),
|
||||
locale: z.string(),
|
||||
updated_at: z.string(),
|
||||
created_at: z.string(),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
export type AccountPageTackingData = z.infer<typeof validateAccountTrackingData>
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
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"
|
||||
@@ -17,12 +19,17 @@ import {
|
||||
type AccountPage,
|
||||
AccountPageDataRaw,
|
||||
AccountPageRefsDataRaw,
|
||||
AccountPageTackingData,
|
||||
validateAccountPageRefsSchema,
|
||||
validateAccountPageSchema,
|
||||
} from "./output"
|
||||
import { getConnections } from "./utils"
|
||||
|
||||
import { ContentEntries } from "@/types/components/myPages/myPage/enums"
|
||||
import {
|
||||
TrackingChannelEnum,
|
||||
TrackingSDKPageData,
|
||||
} from "@/types/components/tracking"
|
||||
import { Embeds } from "@/types/requests/embeds"
|
||||
import { Edges } from "@/types/requests/utils/edges"
|
||||
import { RTEDocument } from "@/types/rte/node"
|
||||
@@ -131,4 +138,29 @@ export const accountPageQueryRouter = router({
|
||||
|
||||
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,
|
||||
channel: TrackingChannelEnum["scandic-friends"],
|
||||
}
|
||||
|
||||
return accountTrackingData
|
||||
}),
|
||||
})
|
||||
|
||||
@@ -417,3 +417,17 @@ export const validateLoyaltyPageRefsSchema = z.object({
|
||||
export type LoyaltyPageRefsDataRaw = z.infer<
|
||||
typeof validateLoyaltyPageRefsSchema
|
||||
>
|
||||
|
||||
//Tracking
|
||||
const validateLoyaltyTrackingData = z.object({
|
||||
loyalty_page: z.object({
|
||||
system: z.object({
|
||||
uid: z.string(),
|
||||
locale: z.string(),
|
||||
updated_at: z.string(),
|
||||
created_at: z.string(),
|
||||
}),
|
||||
}),
|
||||
})
|
||||
|
||||
export type LoyaltyPageTackingData = z.infer<typeof validateLoyaltyTrackingData>
|
||||
|
||||
@@ -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"],
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user