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
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
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
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(),
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(),
@@ -56,6 +53,9 @@ export const accountPageSchema = z.object({
})
),
}),
trackingProps: z.object({
url: z.string(),
}),
})
const accountPageDynamicContentRefs = z

View File

@@ -197,10 +197,7 @@ export const accountPageQueryRouter = router({
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
pageName: validatedAccountPage.data.trackingProps.url,
}
return {

View File

@@ -144,9 +144,9 @@ export const contentPageSchema = z.object({
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,
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
pageName: contentPage.data.trackingProps.url,
}
return {

View File

@@ -22,8 +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(),
}),
}),
trackingProps: z.object({
url: z.string(),
}),
})

View File

@@ -178,9 +178,6 @@ export const loyaltyPageSchema = z.object({
updated_at: z.string(),
})
),
page_settings: z.object({
tracking_page_name: z.string().nullable(),
}),
})
.transform((data) => {
return {
@@ -190,7 +187,9 @@ export const loyaltyPageSchema = z.object({
preamble: data.preamble,
sidebar: data.sidebar ? data.sidebar : [],
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,
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
pageName: validatedLoyaltyPage.data.trackingProps.url,
}
getLoyaltyPageSuccessCounter.add(1, metricsVariables)
console.info(

View File

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

View File

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