AW-483-484-485-fix-bugs

This commit is contained in:
Daniil Chemerkin 2025-07-28 22:30:37 +00:00
parent ded38f67ef
commit 24731122fa
7 changed files with 37 additions and 11 deletions

View File

@ -13,7 +13,8 @@ export interface PayloadCreate {
source: string, // Type: string source: string, // Type: string
sign: boolean, // Type: boolean sign: boolean, // Type: boolean
signDate: string | undefined, // Type: string, ISO Date signDate: string | undefined, // Type: string, ISO Date
utm: IUTM // Type: { [key: string]: string } - Optional utm: IUTM, // Type: { [key: string]: string } - Optional
domain: string // Type: string
} }
export interface PayloadUpdate { export interface PayloadUpdate {

View File

@ -225,7 +225,12 @@ function App(): JSX.Element {
if (isPageAvailable) { if (isPageAvailable) {
const utm = parseQueryParams(); const utm = parseQueryParams();
dispatch(actions.utm.update(utm)); console.log('App component - parsed UTM on page:', location.pathname, utm);
// Only update UTM if there are new parameters and they're not empty
if (Object.keys(utm).length > 0) {
console.log('App component - dispatching UTM update:', utm);
dispatch(actions.utm.update(utm));
}
} }
}, [dispatch, location.pathname]); }, [dispatch, location.pathname]);

View File

@ -20,6 +20,8 @@ import { EUnleashFlags, useUnleash } from "@/hooks/ab/unleash/useUnleash";
import { IFunnelPaymentVariant } from "@/api/resources/Session"; import { IFunnelPaymentVariant } from "@/api/resources/Session";
import { useFunnel } from "@/hooks/funnel/useFunnel"; import { useFunnel } from "@/hooks/funnel/useFunnel";
const environments = import.meta.env;
interface IPaymentPageProps { interface IPaymentPageProps {
isSinglePayment?: boolean; isSinglePayment?: boolean;
className?: string; className?: string;
@ -50,7 +52,7 @@ function PaymentPage({
funnel, funnel,
paymentPlacement, paymentPlacement,
onError, onError,
onSuccess, // onSuccess,
onBack, onBack,
onPopState, onPopState,
}: IPaymentPageProps) { }: IPaymentPageProps) {
@ -114,7 +116,10 @@ function PaymentPage({
currency, currency,
value: ((activeProduct?.trialPrice || 100) / 100).toFixed(2), value: ((activeProduct?.trialPrice || 100) / 100).toFixed(2),
}); });
onSuccess?.(); // onSuccess?.();
const redirectUrl = `${environments.AURA_NEW_SITE_URL}/auth/callback?jwtToken=${token}&nextUrl=/ap`;
return window.location.replace(redirectUrl);
} }
function onModalClosed(): void { function onModalClosed(): void {

1
src/env.d.ts vendored
View File

@ -12,4 +12,5 @@ interface ImportMetaEnv {
AURA_GA_MEASUREMENT_ID: string, AURA_GA_MEASUREMENT_ID: string,
AURA_UNLEASH_URL: string, AURA_UNLEASH_URL: string,
AURA_UNLEASH_CLIENT_KEY: string, AURA_UNLEASH_CLIENT_KEY: string,
AURA_NEW_SITE_URL: string,
} }

View File

@ -27,17 +27,21 @@ export const useSession = () => {
sessionId: session[source], sessionId: session[source],
status: "old" status: "old"
} }
}; }
try { try {
const sessionFromServer = await api.createSession({ const sessionParams = {
feature, feature,
locale: language, locale: language,
timezone, timezone,
source, source,
sign: checked, sign: checked,
signDate: dateOfCheck.length ? dateOfCheck : undefined, signDate: dateOfCheck.length ? dateOfCheck : undefined,
utm utm,
}); domain: window.location.hostname
};
console.log('Creating session with parameters:', sessionParams);
const sessionFromServer = await api.createSession(sessionParams);
console.log('Session creation response:', sessionFromServer);
if (sessionFromServer?.sessionId?.length && sessionFromServer?.status === "success") { if (sessionFromServer?.sessionId?.length && sessionFromServer?.status === "success") {
dispatch(actions.session.update({ dispatch(actions.session.update({
session: sessionFromServer.sessionId, session: sessionFromServer.sessionId,
@ -46,13 +50,14 @@ export const useSession = () => {
localStorage.setItem(`${source}_sessionId`, sessionFromServer.sessionId); localStorage.setItem(`${source}_sessionId`, sessionFromServer.sessionId);
return sessionFromServer return sessionFromServer
} }
console.error('Session creation failed - invalid response:', sessionFromServer);
setIsError(true); setIsError(true);
return { return {
status: "error", status: "error",
sessionId: "" sessionId: ""
} }
} catch (error) { } catch (error) {
console.log(error) console.error('Session creation failed with error:', error);
setIsError(true); setIsError(true);
return { return {
status: "error", status: "error",

View File

@ -24,12 +24,22 @@ import HeadData from "./utils/Helmet";
import Clarity from '@microsoft/clarity'; import Clarity from '@microsoft/clarity';
import { InitializationProvider } from "./initialization"; import { InitializationProvider } from "./initialization";
import { getSourceByPathname } from "./utils/source.utils"; import { getSourceByPathname } from "./utils/source.utils";
import { parseQueryParams } from "./services/url";
import { actions } from "./store";
pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.js`; pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.js`;
const environments = import.meta.env; const environments = import.meta.env;
const init = async () => { const init = async () => {
// Parse UTM parameters from URL at initialization
const utm = parseQueryParams();
console.log('UTM parameters parsed at init:', utm);
if (Object.keys(utm).length > 0) {
console.log('Dispatching UTM update:', utm);
store.dispatch(actions.utm.update(utm));
}
await setLanguage(); await setLanguage();
const api = createApi(); const api = createApi();

View File

@ -12,8 +12,7 @@ const utmSlice = createSlice({
initialState, initialState,
reducers: { reducers: {
update(state, action: PayloadAction<IUTM>) { update(state, action: PayloadAction<IUTM>) {
state = action.payload return { ...state, ...action.payload }
return state
}, },
}, },
extraReducers: (builder) => builder.addCase('reset', () => initialState) extraReducers: (builder) => builder.addCase('reset', () => initialState)