feat: add tracking to account pages
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
import { serverClient } from "@/lib/trpc/server"
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
|
|
||||||
|
import TrackingSDK from "@/components/Current/TrackingSDK"
|
||||||
import Content from "@/components/MyPages/AccountPage/Content"
|
import Content from "@/components/MyPages/AccountPage/Content"
|
||||||
import Title from "@/components/TempDesignSystem/Text/Title"
|
import Title from "@/components/TempDesignSystem/Text/Title"
|
||||||
import { getIntl } from "@/i18n"
|
import { getIntl } from "@/i18n"
|
||||||
@@ -18,6 +19,9 @@ export default async function MyPages({
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const accountPageTracking =
|
||||||
|
await serverClient().contentstack.accountPage.tracking()
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<main className={styles.blocks}>
|
<main className={styles.blocks}>
|
||||||
<Title>{accountPage.heading}</Title>
|
<Title>{accountPage.heading}</Title>
|
||||||
@@ -26,6 +30,7 @@ export default async function MyPages({
|
|||||||
) : (
|
) : (
|
||||||
<p>{formatMessage({ id: "No content published" })}</p>
|
<p>{formatMessage({ id: "No content published" })}</p>
|
||||||
)}
|
)}
|
||||||
|
<TrackingSDK pageData={accountPageTracking} />
|
||||||
</main>
|
</main>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ export default async function Profile({ params }: PageArgs<LangParams>) {
|
|||||||
<div className={styles.item}>
|
<div className={styles.item}>
|
||||||
<CalendarIcon color="burgundy" />
|
<CalendarIcon color="burgundy" />
|
||||||
<Body color="burgundy" textTransform="bold">
|
<Body color="burgundy" textTransform="bold">
|
||||||
{formatMessage({ id: "Date of birth" })}
|
{formatMessage({ id: "Date of Birth" })}
|
||||||
</Body>
|
</Body>
|
||||||
<Body color="burgundy">{user.dateOfBirth}</Body>
|
<Body color="burgundy">{user.dateOfBirth}</Body>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
import "../profileLayout.css"
|
import "../profileLayout.css"
|
||||||
|
|
||||||
export default function EditProfilePage() {
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
return null
|
|
||||||
|
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"
|
import "./profileLayout.css"
|
||||||
|
|
||||||
export default function ProfilePage() {
|
import { serverClient } from "@/lib/trpc/server"
|
||||||
return null
|
|
||||||
|
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<
|
export type AccountPageRefsDataRaw = z.infer<
|
||||||
typeof validateAccountPageRefsSchema
|
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 {
|
import {
|
||||||
GetAccountPage,
|
GetAccountPage,
|
||||||
GetAccountPageRefs,
|
GetAccountPageRefs,
|
||||||
|
GetTrackingAccountPage,
|
||||||
} from "@/lib/graphql/Query/AccountPage.graphql"
|
} from "@/lib/graphql/Query/AccountPage.graphql"
|
||||||
import { request } from "@/lib/graphql/request"
|
import { request } from "@/lib/graphql/request"
|
||||||
import { notFound } from "@/server/errors/trpc"
|
import { notFound } from "@/server/errors/trpc"
|
||||||
@@ -17,12 +19,17 @@ import {
|
|||||||
type AccountPage,
|
type AccountPage,
|
||||||
AccountPageDataRaw,
|
AccountPageDataRaw,
|
||||||
AccountPageRefsDataRaw,
|
AccountPageRefsDataRaw,
|
||||||
|
AccountPageTackingData,
|
||||||
validateAccountPageRefsSchema,
|
validateAccountPageRefsSchema,
|
||||||
validateAccountPageSchema,
|
validateAccountPageSchema,
|
||||||
} from "./output"
|
} from "./output"
|
||||||
import { getConnections } from "./utils"
|
import { getConnections } from "./utils"
|
||||||
|
|
||||||
import { ContentEntries } from "@/types/components/myPages/myPage/enums"
|
import { ContentEntries } from "@/types/components/myPages/myPage/enums"
|
||||||
|
import {
|
||||||
|
TrackingChannelEnum,
|
||||||
|
TrackingSDKPageData,
|
||||||
|
} from "@/types/components/tracking"
|
||||||
import { Embeds } from "@/types/requests/embeds"
|
import { Embeds } from "@/types/requests/embeds"
|
||||||
import { Edges } from "@/types/requests/utils/edges"
|
import { Edges } from "@/types/requests/utils/edges"
|
||||||
import { RTEDocument } from "@/types/rte/node"
|
import { RTEDocument } from "@/types/rte/node"
|
||||||
@@ -131,4 +138,29 @@ export const accountPageQueryRouter = router({
|
|||||||
|
|
||||||
return 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,
|
||||||
|
channel: TrackingChannelEnum["scandic-friends"],
|
||||||
|
}
|
||||||
|
|
||||||
|
return accountTrackingData
|
||||||
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -417,3 +417,17 @@ export const validateLoyaltyPageRefsSchema = z.object({
|
|||||||
export type LoyaltyPageRefsDataRaw = z.infer<
|
export type LoyaltyPageRefsDataRaw = z.infer<
|
||||||
typeof validateLoyaltyPageRefsSchema
|
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 {
|
import {
|
||||||
GetLoyaltyPage,
|
GetLoyaltyPage,
|
||||||
GetLoyaltyPageRefs,
|
GetLoyaltyPageRefs,
|
||||||
@@ -19,6 +20,7 @@ import { removeEmptyObjects } from "../../utils"
|
|||||||
import {
|
import {
|
||||||
LoyaltyPage,
|
LoyaltyPage,
|
||||||
type LoyaltyPageRefsDataRaw,
|
type LoyaltyPageRefsDataRaw,
|
||||||
|
LoyaltyPageTackingData,
|
||||||
validateLoyaltyPageRefsSchema,
|
validateLoyaltyPageRefsSchema,
|
||||||
validateLoyaltyPageSchema,
|
validateLoyaltyPageSchema,
|
||||||
} from "./output"
|
} from "./output"
|
||||||
@@ -232,10 +234,13 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
tracking: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
tracking: contentstackExtendedProcedureUID.query(async ({ ctx }) => {
|
||||||
const { lang, uid } = ctx
|
const { lang, uid } = ctx
|
||||||
|
|
||||||
const response = await request<any>(GetTrackingLoyaltyPage, {
|
const response = await request<LoyaltyPageTackingData>(
|
||||||
locale: lang,
|
GetTrackingLoyaltyPage,
|
||||||
uid,
|
{
|
||||||
})
|
locale: lang,
|
||||||
|
uid,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
if (!response.data) {
|
if (!response.data) {
|
||||||
throw notFound(response)
|
throw notFound(response)
|
||||||
@@ -243,8 +248,8 @@ export const loyaltyPageQueryRouter = router({
|
|||||||
|
|
||||||
const loyaltyTrackingData: TrackingSDKPageData = {
|
const loyaltyTrackingData: TrackingSDKPageData = {
|
||||||
pageId: response.data.loyalty_page.system.uid,
|
pageId: response.data.loyalty_page.system.uid,
|
||||||
lang: response.data.loyalty_page.system.locale,
|
lang: response.data.loyalty_page.system.locale as Lang,
|
||||||
publishedDate: response.data.loyalty_page.system.published_at,
|
publishedDate: response.data.loyalty_page.system.updated_at,
|
||||||
createdDate: response.data.loyalty_page.system.created_at,
|
createdDate: response.data.loyalty_page.system.created_at,
|
||||||
channel: TrackingChannelEnum["scandic-friends"],
|
channel: TrackingChannelEnum["scandic-friends"],
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user