fix: improve typings
This commit is contained in:
@@ -1,22 +1,19 @@
|
||||
"use client"
|
||||
|
||||
import {
|
||||
SiteSectionObject,
|
||||
TrackingData,
|
||||
TrackingProps,
|
||||
WindowWithDataLayer,
|
||||
} from "@/types/components/tracking"
|
||||
import { usePathname, useSearchParams } from "next/navigation"
|
||||
import { useEffect } from "react"
|
||||
|
||||
declare const window: WindowWithDataLayer
|
||||
|
||||
function createPageObject(trackingData: TrackingData) {
|
||||
const [lang, ...segments] = trackingData.pathName
|
||||
.split("/")
|
||||
.filter((v: string) => v)
|
||||
|
||||
function getSiteSections(segments: string[]) {
|
||||
const sitesections: { [key: string]: string } = {}
|
||||
function getSiteSections(segments: string[]): SiteSectionObject {
|
||||
/*
|
||||
Adobe expects the properties sitesection1 - sitessection6, hence the for-loop below
|
||||
The segments ['explore-scandic', 'wifi'] should result in:
|
||||
@@ -29,8 +26,10 @@ function createPageObject(trackingData: TrackingData) {
|
||||
sitesection6: "explore-scandic|wifi||||",
|
||||
}
|
||||
*/
|
||||
const sitesections = {} as SiteSectionObject
|
||||
for (let i = 0; i < 6; i++) {
|
||||
const key = "sitesection" + (i + 1)
|
||||
const key = ("sitesection" + (i + 1)) as keyof SiteSectionObject
|
||||
|
||||
sitesections[key] = segments.slice(0, i + 1).join("|")
|
||||
if (i > 0 && !segments[i]) {
|
||||
sitesections[key] = sitesections[key].concat(
|
||||
|
||||
Reference in New Issue
Block a user