From 7b6c0c67bb60126c222c9a48bcfc7633e4e8b161 Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Mon, 19 Feb 2024 13:41:50 +0100 Subject: [PATCH 1/5] fix: update page tracking properties --- components/Current/Tracking.tsx | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/components/Current/Tracking.tsx b/components/Current/Tracking.tsx index b7ec2c22f..074c7e203 100644 --- a/components/Current/Tracking.tsx +++ b/components/Current/Tracking.tsx @@ -40,19 +40,19 @@ function createPageObject(trackingData: TrackingData) { return sitesections } const sitesections = getSiteSections(segments) - const { host: domain, href: pageurl } = window.location - + const { host: domain, href: fullurl, origin } = window.location const page_obj = { - pagename: trackingData.pageName, - pagetype: trackingData.pageType, - pageurl, // is window.location.href viable? + pagename: segments.join('|'), + pagetype: 'contentpage', + pageurl: origin + trackingData.pathName, + fullurl, createDate: trackingData.createdDate, publishDate: trackingData.publishedDate, - domain, // is window.location.host viable? + domain, errorcode: null, // handle querystring: trackingData.queryString || "", pageid: trackingData.pageId, - sessionid: "", // base on what? + // sessionid: "", // base on what? domainlanguage: lang, hotelbrand: "scandic", siteversion: "new-web", @@ -70,15 +70,6 @@ export default function Tracking({ pageData }: TrackingProps) { const pageObject = createPageObject(trackingData) window.datalayer.page = pageObject - - // NOTE: Is this irrelevant för drop 1? - // var user_obj = { - // loginstatus: "", - // memberid: "", - // memberlevel: "", - // } - - // datalayer.user = user_obj; }, [pathName, queryString, pageData]) return null From a7780c84a1cdfb2191b6428f9321fe985e251b56 Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Mon, 19 Feb 2024 15:12:38 +0100 Subject: [PATCH 2/5] chore: remove unused tracking properties and types --- app/[lang]/(live-current)/current-content-page/page.tsx | 2 -- lib/graphql/Query/CurrentBlockPage.graphql | 1 - types/components/tracking.ts | 4 ---- types/requests/currentBlockPage.ts | 2 -- types/requests/utils/typename.ts | 4 ---- 5 files changed, 13 deletions(-) diff --git a/app/[lang]/(live-current)/current-content-page/page.tsx b/app/[lang]/(live-current)/current-content-page/page.tsx index f94f93c7e..e014119e5 100644 --- a/app/[lang]/(live-current)/current-content-page/page.tsx +++ b/app/[lang]/(live-current)/current-content-page/page.tsx @@ -38,8 +38,6 @@ export default async function CurrentContentPage({ } const pageData = response.data.all_current_blocks_page.items[0] const trackingData = { - pageName: pageData.title, - pageType: pageData.__typename, publishedDate: pageData.system.updated_at, createdDate: pageData.system.created_at, pageId: pageData.system.uid, diff --git a/lib/graphql/Query/CurrentBlockPage.graphql b/lib/graphql/Query/CurrentBlockPage.graphql index 0a5315f78..b275b328f 100644 --- a/lib/graphql/Query/CurrentBlockPage.graphql +++ b/lib/graphql/Query/CurrentBlockPage.graphql @@ -10,7 +10,6 @@ query GetCurrentBlockPage($locale: String!, $url: String!) { all_current_blocks_page(limit: 1, locale: $locale, where: { url: $url }) { items { - __typename aside { __typename ...ContactAside diff --git a/types/components/tracking.ts b/types/components/tracking.ts index e717a55f3..8c2f3ccbd 100644 --- a/types/components/tracking.ts +++ b/types/components/tracking.ts @@ -3,8 +3,6 @@ export type TrackingProps = { pageId: string createdDate: string publishedDate: string - pageName: string - pageType: string } } @@ -12,8 +10,6 @@ export type TrackingData = { pathName: string queryString: string pageId: string - pageName: string - pageType: string publishedDate: string createdDate: string } diff --git a/types/requests/currentBlockPage.ts b/types/requests/currentBlockPage.ts index 3611485a6..2cf493f75 100644 --- a/types/requests/currentBlockPage.ts +++ b/types/requests/currentBlockPage.ts @@ -11,7 +11,6 @@ import type { AllRequestResponse } from "./utils/all" import type { AsideTypenameEnum, Typename, - PagesTypenameEnum, } from "./utils/typename" export type Asides = @@ -34,7 +33,6 @@ export type Breadcrumbs = { } export type BlockPage = { - __typename: PagesTypenameEnum.CurrentBlocksPage aside: Asides[] blocks: Blocks[] breadcrumbs: Breadcrumbs diff --git a/types/requests/utils/typename.ts b/types/requests/utils/typename.ts index 6781408c7..5c59848bf 100644 --- a/types/requests/utils/typename.ts +++ b/types/requests/utils/typename.ts @@ -11,10 +11,6 @@ export enum BlocksTypenameEnum { CurrentBlocksPageBlocksText = "CurrentBlocksPageBlocksText", } -export enum PagesTypenameEnum { - CurrentBlocksPage = "CurrentBlocksPage", -} - export type BlocksTypename = keyof typeof BlocksTypenameEnum export type Typename = T & { From c19f235e5f4c9dc00c0b0f747e612e46f2c8296a Mon Sep 17 00:00:00 2001 From: Arvid Norlin Date: Wed, 21 Feb 2024 15:10:14 +0100 Subject: [PATCH 3/5] refactor: read ADOBE_SCRIPTS_SRC from env --- .env.local.example | 3 ++- components/Current/AdobeScript.tsx | 14 +++----------- env/server.ts | 2 ++ 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/.env.local.example b/.env.local.example index 0592f3b4a..5b058d208 100644 --- a/.env.local.example +++ b/.env.local.example @@ -3,4 +3,5 @@ CMS_API_KEY="" CMS_ENVIRONMENT="development" CMS_URL="https://eu-graphql.contentstack.com/stacks/${CMS_API_KEY}?environment=${CMS_ENVIRONMENT}" CMS_PREVIEW_URL="https://graphql-preview.contentstack.com/stacks/${CMS_API_KEY}?environment=${CMS_ENVIRONMENT}"; -CMS_PREVIEW_TOKEN="" \ No newline at end of file +CMS_PREVIEW_TOKEN="" +ADOBE_SCRIPT_SRC="" \ No newline at end of file diff --git a/components/Current/AdobeScript.tsx b/components/Current/AdobeScript.tsx index b52508b2d..197347235 100644 --- a/components/Current/AdobeScript.tsx +++ b/components/Current/AdobeScript.tsx @@ -2,22 +2,14 @@ import { env } from "@/env/server" import Script from "next/script" -const scriptScrs = { - // TODO: decide on naming and environments (development vs. test vs. staging etc) - development: "", - test: "https://assets.adobedtm.com/c1bd08b1e4e7/d64a7c1f5f17/launch-84c70d82a50c-staging.min.js", - production: - "https://assets.adobedtm.com/c1bd08b1e4e7/d64a7c1f5f17/launch-e56085bbe998.min.js", -} - export default function AdobeScript() { - return ( + return env.ADOBE_SCRIPT_SRC ? ( <> - diff --git a/components/Current/AdobeScript.tsx b/components/Current/AdobeScript.tsx index 197347235..949cdb567 100644 --- a/components/Current/AdobeScript.tsx +++ b/components/Current/AdobeScript.tsx @@ -3,13 +3,5 @@ import { env } from "@/env/server" import Script from "next/script" export default function AdobeScript() { - return env.ADOBE_SCRIPT_SRC ? ( - <> - -