Tracking WIP

This commit is contained in:
Linus Flood
2024-09-27 08:46:12 +02:00
parent 27159d739f
commit 54f094af86
19 changed files with 199 additions and 74 deletions

View File

@@ -46,6 +46,9 @@ export const accountPageSchema = z.object({
heading: z.string().nullable(),
title: z.string(),
url: z.string(),
page_settings: z.object({
tracking_page_name: z.string().nullable(),
}),
system: systemSchema.merge(
z.object({
created_at: z.string(),

View File

@@ -191,11 +191,16 @@ export const accountPageQueryRouter = router({
const tracking: TrackingSDKPageData = {
pageId: validatedAccountPage.data.account_page.system.uid,
lang: validatedAccountPage.data.account_page.system.locale as Lang,
domainLanguage: 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${parsedtitle}page`,
pageName:
validatedAccountPage.data.account_page.page_settings.tracking_page_name,
siteSections:
validatedAccountPage.data.account_page.page_settings.tracking_page_name, // Always the same as pageName for this page
}
return {

View File

@@ -18,6 +18,7 @@ import {
shortcutsRefsSchema,
shortcutsSchema,
} from "../schemas/blocks/shortcuts"
import { textColsRefsSchema, textColsSchema } from "../schemas/blocks/textCols"
import { tempImageVaultAssetSchema } from "../schemas/imageVault"
import {
contentRefsSchema as sidebarContentRefsSchema,
@@ -31,7 +32,6 @@ import {
import { systemSchema } from "../schemas/system"
import { ContentPageEnum } from "@/types/enums/contentPage"
import { textColsRefsSchema, textColsSchema } from "../schemas/blocks/textCols"
// Block schemas
export const contentPageCards = z
@@ -58,9 +58,11 @@ export const contentPageShortcuts = z
})
.merge(shortcutsSchema)
export const contentPageTextCols = z.object({
__typename: z.literal(ContentPageEnum.ContentStack.blocks.TextCols),
}).merge(textColsSchema)
export const contentPageTextCols = z
.object({
__typename: z.literal(ContentPageEnum.ContentStack.blocks.TextCols),
})
.merge(textColsSchema)
export const blocksSchema = z.discriminatedUnion("__typename", [
contentPageCards,
@@ -113,6 +115,9 @@ export const contentPageSchema = z.object({
updated_at: z.string(),
})
),
page_settings: z.object({
tracking_page_name: z.string().nullable(),
}),
}),
})

View File

@@ -63,11 +63,14 @@ export const contentPageQueryRouter = router({
const tracking: TrackingSDKPageData = {
pageId: contentPage.data.content_page.system.uid,
lang: contentPage.data.content_page.system.locale as Lang,
domainLanguage: contentPage.data.content_page.system.locale as Lang,
publishedDate: contentPage.data.content_page.system.updated_at,
createdDate: contentPage.data.content_page.system.created_at,
channel: TrackingChannelEnum["static-content-page"],
pageType: "staticcontentpage",
pageName: contentPage.data.content_page.page_settings.tracking_page_name,
siteSections:
contentPage.data.content_page.page_settings.tracking_page_name, // Always the same as pageName for this page
}
return {

View File

@@ -22,5 +22,8 @@ export const hotelPageSchema = z.object({
hotel_page_id: z.string(),
title: z.string(),
url: z.string(),
page_settings: z.object({
tracking_page_name: z.string().nullable(),
}),
}),
})

View File

@@ -178,6 +178,9 @@ export const loyaltyPageSchema = z.object({
updated_at: z.string(),
})
),
page_settings: z.object({
tracking_page_name: z.string().nullable(),
}),
})
.transform((data) => {
return {
@@ -187,6 +190,7 @@ export const loyaltyPageSchema = z.object({
preamble: data.preamble,
sidebar: data.sidebar ? data.sidebar : [],
system: data.system,
pageSettings: data.page_settings,
}
}),
})

View File

@@ -176,11 +176,13 @@ export const loyaltyPageQueryRouter = router({
const loyaltyTrackingData: TrackingSDKPageData = {
pageId: loyaltyPage.system.uid,
lang: loyaltyPage.system.locale as Lang,
domainLanguage: loyaltyPage.system.locale as Lang,
publishedDate: loyaltyPage.system.updated_at,
createdDate: loyaltyPage.system.created_at,
channel: TrackingChannelEnum["scandic-friends"],
pageType: "loyaltycontentpage",
pageName: loyaltyPage.pageSettings.tracking_page_name,
siteSections: loyaltyPage.pageSettings.tracking_page_name, // Always the same as pageName for this page
}
getLoyaltyPageSuccessCounter.add(1, metricsVariables)
console.info(