fix(SW-2659): pass input to userTrackingInfo since lang needs to be passed from client
This commit is contained in:
committed by
Michael Zetterberg
parent
8cb63c4947
commit
aaffcba94a
@@ -7,6 +7,7 @@ import { trpc } from "@/lib/trpc/client"
|
|||||||
import useRouterTransitionStore from "@/stores/router-transition"
|
import useRouterTransitionStore from "@/stores/router-transition"
|
||||||
import useTrackingStore from "@/stores/tracking"
|
import useTrackingStore from "@/stores/tracking"
|
||||||
|
|
||||||
|
import useLang from "@/hooks/useLang"
|
||||||
import { useSessionId } from "@/hooks/useSessionId"
|
import { useSessionId } from "@/hooks/useSessionId"
|
||||||
import { promiseWithTimeout } from "@/utils/promiseWithTimeout"
|
import { promiseWithTimeout } from "@/utils/promiseWithTimeout"
|
||||||
import { createSDKPageObject, trackPageView } from "@/utils/tracking"
|
import { createSDKPageObject, trackPageView } from "@/utils/tracking"
|
||||||
@@ -31,11 +32,12 @@ export const useTrackHardNavigation = ({
|
|||||||
paymentInfo,
|
paymentInfo,
|
||||||
ancillaries,
|
ancillaries,
|
||||||
}: TrackingSDKProps) => {
|
}: TrackingSDKProps) => {
|
||||||
|
const lang = useLang()
|
||||||
const {
|
const {
|
||||||
data: userTrackingData,
|
data: userTrackingData,
|
||||||
isPending,
|
isPending,
|
||||||
isError,
|
isError,
|
||||||
} = trpc.user.userTrackingInfo.useQuery()
|
} = trpc.user.userTrackingInfo.useQuery({ lang })
|
||||||
|
|
||||||
const sessionId = useSessionId()
|
const sessionId = useSessionId()
|
||||||
const pathName = usePathname()
|
const pathName = usePathname()
|
||||||
@@ -93,11 +95,12 @@ export const useTrackSoftNavigation = ({
|
|||||||
paymentInfo,
|
paymentInfo,
|
||||||
ancillaries,
|
ancillaries,
|
||||||
}: TrackingSDKProps) => {
|
}: TrackingSDKProps) => {
|
||||||
|
const lang = useLang()
|
||||||
const {
|
const {
|
||||||
data: userTrackingData,
|
data: userTrackingData,
|
||||||
isPending,
|
isPending,
|
||||||
isError,
|
isError,
|
||||||
} = trpc.user.userTrackingInfo.useQuery()
|
} = trpc.user.userTrackingInfo.useQuery({ lang })
|
||||||
|
|
||||||
const [status, setStatus] = useState<TransitionStatus>(
|
const [status, setStatus] = useState<TransitionStatus>(
|
||||||
TransitionStatusEnum.NotRun
|
TransitionStatusEnum.NotRun
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import { Lang } from "@/constants/languages"
|
|||||||
import { signUpSchema } from "@/components/Forms/Signup/schema"
|
import { signUpSchema } from "@/components/Forms/Signup/schema"
|
||||||
|
|
||||||
// Query
|
// Query
|
||||||
|
export const userTrackingInput = z.object({
|
||||||
|
lang: z.nativeEnum(Lang).optional(),
|
||||||
|
})
|
||||||
export const staysInput = z
|
export const staysInput = z
|
||||||
.object({
|
.object({
|
||||||
cursor: z
|
cursor: z
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import {
|
|||||||
friendTransactionsInput,
|
friendTransactionsInput,
|
||||||
getSavedPaymentCardsInput,
|
getSavedPaymentCardsInput,
|
||||||
staysInput,
|
staysInput,
|
||||||
|
userTrackingInput,
|
||||||
} from "./input"
|
} from "./input"
|
||||||
import { getFriendTransactionsSchema } from "./output"
|
import { getFriendTransactionsSchema } from "./output"
|
||||||
import {
|
import {
|
||||||
@@ -124,7 +125,12 @@ export const userQueryRouter = router({
|
|||||||
const membershipLevel = getFriendsMembership(verifiedData.data.loyalty)
|
const membershipLevel = getFriendsMembership(verifiedData.data.loyalty)
|
||||||
return membershipLevel
|
return membershipLevel
|
||||||
}),
|
}),
|
||||||
userTrackingInfo: safeProtectedProcedure.query(async function ({ ctx }) {
|
userTrackingInfo: safeProtectedProcedure
|
||||||
|
.input(userTrackingInput)
|
||||||
|
.query(async function ({ ctx, input }) {
|
||||||
|
const { lang } = input
|
||||||
|
const language = lang || ctx.lang
|
||||||
|
|
||||||
const userTrackingInfoCounter = createCounter("user", "userTrackingInfo")
|
const userTrackingInfoCounter = createCounter("user", "userTrackingInfo")
|
||||||
const metricsUserTrackingInfo = userTrackingInfoCounter.init()
|
const metricsUserTrackingInfo = userTrackingInfoCounter.init()
|
||||||
|
|
||||||
@@ -156,7 +162,7 @@ export const userQueryRouter = router({
|
|||||||
const previousStaysData = await getPreviousStays(
|
const previousStaysData = await getPreviousStays(
|
||||||
ctx.session.token.access_token,
|
ctx.session.token.access_token,
|
||||||
1,
|
1,
|
||||||
ctx.lang
|
language
|
||||||
)
|
)
|
||||||
if (!previousStaysData) {
|
if (!previousStaysData) {
|
||||||
metricsUserTrackingInfo.success({
|
metricsUserTrackingInfo.success({
|
||||||
|
|||||||
Reference in New Issue
Block a user