This commit is contained in:
Linus Flood
2024-10-08 11:08:21 +02:00
parent 4de247ab50
commit a0ad4dffac
13 changed files with 31 additions and 43 deletions

View File

@@ -20,9 +20,9 @@ query GetAccountPage($locale: String!, $uid: String!) {
created_at created_at
updated_at updated_at
} }
page_settings { }
tracking_page_name trackingProps: account_page(locale: "en", uid: $uid) {
} url
} }
} }

View File

@@ -42,9 +42,9 @@ query GetContentPage($locale: String!, $uid: String!) {
created_at created_at
updated_at updated_at
} }
page_settings { }
tracking_page_name trackingProps: content_page(locale: "en", uid: $uid) {
} url
} }
} }

View File

@@ -31,9 +31,9 @@ query GetHotelPage($locale: String!, $uid: String!) {
} }
} }
} }
page_settings { }
tracking_page_name trackingProps: hotel_page(locale: "en", uid: $uid) {
} url
} }
} }

View File

@@ -33,9 +33,9 @@ query GetLoyaltyPage($locale: String!, $uid: String!) {
created_at created_at
updated_at updated_at
} }
page_settings { }
tracking_page_name trackingProps: loyalty_page(locale: "en", uid: $uid) {
} url
} }
} }

View File

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

View File

@@ -197,10 +197,7 @@ export const accountPageQueryRouter = router({
createdDate: validatedAccountPage.data.account_page.system.created_at, createdDate: validatedAccountPage.data.account_page.system.created_at,
channel: TrackingChannelEnum["scandic-friends"], channel: TrackingChannelEnum["scandic-friends"],
pageType: `member${parsedtitle}page`, pageType: `member${parsedtitle}page`,
pageName: pageName: validatedAccountPage.data.trackingProps.url,
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 { return {

View File

@@ -144,9 +144,9 @@ export const contentPageSchema = z.object({
updated_at: z.string(), updated_at: z.string(),
}) })
), ),
page_settings: z.object({ }),
tracking_page_name: z.string().nullable(), trackingProps: z.object({
}), url: z.string(),
}), }),
}) })

View File

@@ -68,9 +68,7 @@ export const contentPageQueryRouter = router({
createdDate: contentPage.data.content_page.system.created_at, createdDate: contentPage.data.content_page.system.created_at,
channel: TrackingChannelEnum["static-content-page"], channel: TrackingChannelEnum["static-content-page"],
pageType: "staticcontentpage", pageType: "staticcontentpage",
pageName: contentPage.data.content_page.page_settings.tracking_page_name, pageName: contentPage.data.trackingProps.url,
siteSections:
contentPage.data.content_page.page_settings.tracking_page_name, // Always the same as pageName for this page
} }
return { return {

View File

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

View File

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

View File

@@ -181,8 +181,7 @@ export const loyaltyPageQueryRouter = router({
createdDate: loyaltyPage.system.created_at, createdDate: loyaltyPage.system.created_at,
channel: TrackingChannelEnum["scandic-friends"], channel: TrackingChannelEnum["scandic-friends"],
pageType: "loyaltycontentpage", pageType: "loyaltycontentpage",
pageName: loyaltyPage.pageSettings.tracking_page_name, pageName: validatedLoyaltyPage.data.trackingProps.url,
siteSections: loyaltyPage.pageSettings.tracking_page_name, // Always the same as pageName for this page
} }
getLoyaltyPageSuccessCounter.add(1, metricsVariables) getLoyaltyPageSuccessCounter.add(1, metricsVariables)
console.info( console.info(

View File

@@ -19,7 +19,7 @@ export type TrackingSDKPageData = {
siteVersion?: "new-web" siteVersion?: "new-web"
pageName: string | null pageName: string | null
domain?: string domain?: string
siteSections: string | null siteSections?: string
pageLoadTime?: number // Page load time in seconds pageLoadTime?: number // Page load time in seconds
} }

View File

@@ -39,17 +39,12 @@ export function trackLoginClick(position: TrackingPosition) {
export function createSDKPageObject( export function createSDKPageObject(
trackingData: TrackingSDKData trackingData: TrackingSDKData
): TrackingSDKData { ): TrackingSDKData {
const [lang, ...segments] = trackingData.pathName const siteSections =
.split("/") trackingData.pageName?.split("/").slice(1).join("|") ?? ""
.filter((seg: string) => seg)
const joinedSegments = segments.join("|")
return { return {
...trackingData, ...trackingData,
domain: window.location.host, domain: window.location.host,
pageName: trackingData.pageName ?? joinedSegments, siteSections: siteSections,
siteSections: trackingData.siteSections ?? joinedSegments,
domainLanguage: trackingData.domainLanguage ?? lang,
} }
} }