fix: add channel and pageType
This commit is contained in:
8
auth.ts
8
auth.ts
@@ -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>
|
||||
|
||||
@@ -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",
|
||||
|
||||
@@ -108,5 +108,6 @@ query GetTrackingAccountPage($locale: String!, $uid: String!) {
|
||||
uid
|
||||
updated_at
|
||||
}
|
||||
title
|
||||
}
|
||||
}
|
||||
|
||||
@@ -199,6 +199,7 @@ const validateAccountTrackingData = z.object({
|
||||
updated_at: z.string(),
|
||||
created_at: z.string(),
|
||||
}),
|
||||
title: z.string().nullable(),
|
||||
}),
|
||||
})
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
1
types/auth.d.ts
vendored
@@ -27,6 +27,5 @@ declare module "next-auth" {
|
||||
sub: string
|
||||
email?: string
|
||||
login_with: string
|
||||
nonce?: string
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user