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

View File

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

View File

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

View File

@@ -199,6 +199,7 @@ const validateAccountTrackingData = z.object({
updated_at: z.string(), updated_at: z.string(),
created_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, publishedDate: response.data.account_page.system.updated_at,
createdDate: response.data.account_page.system.created_at, createdDate: response.data.account_page.system.created_at,
channel: TrackingChannelEnum["scandic-friends"], channel: TrackingChannelEnum["scandic-friends"],
pageType: `member${response.data.account_page.title}page`,
} }
return accountTrackingData return accountTrackingData

View File

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

1
types/auth.d.ts vendored
View File

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

View File

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