fix: add channel and pageType

This commit is contained in:
Christel Westerberg
2024-07-15 09:34:55 +02:00
parent c96008fb78
commit 73cea4ba51
8 changed files with 12 additions and 13 deletions

View File

@@ -8,9 +8,10 @@ import type { NextAuthConfig, User } from "next-auth"
import type { OIDCConfig } from "next-auth/providers"
function getLoginType(user: User) {
if (user?.nonce) {
return LoginTypeEnum.MagicLink
}
// TODO: handle magic link, should be enough to just check for Nonce.
// if (user?.nonce) {
// return LoginTypeEnum.MagicLink
// }
if (user?.login_with.includes("@")) {
return LoginTypeEnum.Email
@@ -54,7 +55,6 @@ const customProvider = {
sub: profile.sub,
given_name: profile.given_name,
login_with: profile.login_with,
nonce: profile.nonce,
}
},
} satisfies OIDCConfig<User>

View File

@@ -46,9 +46,8 @@ function createSDKPageObject(trackingData: TrackingSDKData) {
event: "pageView",
pageInfo: {
pageName: segments.join("|"),
pageType: "contentpage",
pageId: trackingData.pageId,
channel: "",
channel: trackingData.channel,
siteSections,
domain,
siteversion: "new-web",

View File

@@ -108,5 +108,6 @@ query GetTrackingAccountPage($locale: String!, $uid: String!) {
uid
updated_at
}
title
}
}

View File

@@ -199,6 +199,7 @@ const validateAccountTrackingData = z.object({
updated_at: z.string(),
created_at: z.string(),
}),
title: z.string().nullable(),
}),
})

View File

@@ -159,6 +159,7 @@ export const accountPageQueryRouter = router({
publishedDate: response.data.account_page.system.updated_at,
createdDate: response.data.account_page.system.created_at,
channel: TrackingChannelEnum["scandic-friends"],
pageType: `member${response.data.account_page.title}page`,
}
return accountTrackingData

View File

@@ -252,6 +252,7 @@ export const loyaltyPageQueryRouter = router({
publishedDate: response.data.loyalty_page.system.updated_at,
createdDate: response.data.loyalty_page.system.created_at,
channel: TrackingChannelEnum["scandic-friends"],
pageType: "loyaltycontentpage",
}
return loyaltyTrackingData

1
types/auth.d.ts vendored
View File

@@ -27,6 +27,5 @@ declare module "next-auth" {
sub: string
email?: string
login_with: string
nonce?: string
}
}

View File

@@ -13,13 +13,14 @@ export type TrackingSDKPageData = {
createdDate: string
publishedDate: string
lang: Lang
pageType: string
channel: TrackingChannel
}
export enum LoginTypeEnum {
Email = "email",
MembershipNumber = "membership number",
MagicLink = "magic link",
// MagicLink = "magic link",
}
export type LoginType = keyof typeof LoginTypeEnum
@@ -37,12 +38,8 @@ export type TrackingSDKProps = {
userData: TrackingSDKUserData
}
export type TrackingSDKData = {
lang: Lang
export type TrackingSDKData = TrackingSDKPageData & {
pathName: string
pageId: string
publishedDate: string
createdDate: string
}
// Old tracking setup types: