From 1f7fdf794959abed7b66e948eeb535e17da69203 Mon Sep 17 00:00:00 2001 From: gofnnp Date: Thu, 7 Aug 2025 19:35:27 +0400 Subject: [PATCH] remove-metric-from-success-payment remove metrics from /payment/success --- ...Metrics.module.scss => Button.module.scss} | 0 .../(payment)/payment/success/Button.tsx | 24 +++ .../(payment)/payment/success/Metrics.tsx | 195 ------------------ .../(payment)/payment/success/page.tsx | 22 +- 4 files changed, 27 insertions(+), 214 deletions(-) rename src/app/[locale]/(payment)/payment/success/{Metrics.module.scss => Button.module.scss} (100%) create mode 100644 src/app/[locale]/(payment)/payment/success/Button.tsx delete mode 100644 src/app/[locale]/(payment)/payment/success/Metrics.tsx diff --git a/src/app/[locale]/(payment)/payment/success/Metrics.module.scss b/src/app/[locale]/(payment)/payment/success/Button.module.scss similarity index 100% rename from src/app/[locale]/(payment)/payment/success/Metrics.module.scss rename to src/app/[locale]/(payment)/payment/success/Button.module.scss diff --git a/src/app/[locale]/(payment)/payment/success/Button.tsx b/src/app/[locale]/(payment)/payment/success/Button.tsx new file mode 100644 index 0000000..65b0541 --- /dev/null +++ b/src/app/[locale]/(payment)/payment/success/Button.tsx @@ -0,0 +1,24 @@ +"use client"; + +import { useRouter } from "next/navigation"; +import { useTranslations } from "next-intl"; + +import { Button, Typography } from "@/components/ui"; +import { ROUTES } from "@/shared/constants/client-routes"; + +import styles from "./Button.module.scss"; + +export default function PaymentSuccessButton() { + const t = useTranslations("Payment.Success"); + const router = useRouter(); + + const handleNext = () => { + router.push(ROUTES.additionalPurchases()); + }; + + return ( + + ); +} diff --git a/src/app/[locale]/(payment)/payment/success/Metrics.tsx b/src/app/[locale]/(payment)/payment/success/Metrics.tsx deleted file mode 100644 index 75ad095..0000000 --- a/src/app/[locale]/(payment)/payment/success/Metrics.tsx +++ /dev/null @@ -1,195 +0,0 @@ -"use client"; - -import { useEffect, useState } from "react"; -import Script from "next/script"; -import { useTranslations } from "next-intl"; - -import { Button, Typography } from "@/components/ui"; -import { ROUTES } from "@/shared/constants/client-routes"; - -import styles from "./Metrics.module.scss"; - -interface MetricsProps { - fbPixels: string[]; - productPrice: string; - currency: string; -} - -export default function Metrics({ - fbPixels, - productPrice, - currency, -}: MetricsProps) { - const t = useTranslations("Payment.Success"); - - const [isButtonVisible, setIsButtonVisible] = useState(false); - - const handleNext = () => { - window.location.href = ROUTES.additionalPurchases(); - }; - - // Yandex Metrica - useEffect(() => { - const timeout = setTimeout(() => { - if ( - typeof window.ym === "function" && - typeof window.klaviyo === "object" && - typeof window.gtag === "function" - ) { - try { - window.gtag("event", "PaymentSuccess"); - window.klaviyo.push(["track", "PaymentSuccess"]); - - window.ym(95799066, "init", { - clickmap: true, - trackLinks: true, - accurateTrackBounce: true, - webvisor: true, - }); - - window.ym(95799066, "reachGoal", "PaymentSuccess", {}, () => { - // deleteYm() - }); - } catch (e) { - // eslint-disable-next-line no-console - console.error("YM error:", e); - } finally { - clearTimeout(timeout); - setIsButtonVisible(true); - } - } - }, 200); - - return () => clearTimeout(timeout); - }, []); - - return ( - <> - {/* Klaviyo */} - {/* - - - {/* Yandex Metrica */} - - - {/* Google Analytics */} - - - {/* Facebook Pixel */} - {fbPixels.map(pixel => ( - - ))} - - {isButtonVisible && ( - - )} - - ); -} diff --git a/src/app/[locale]/(payment)/payment/success/page.tsx b/src/app/[locale]/(payment)/payment/success/page.tsx index 138c657..6614735 100644 --- a/src/app/[locale]/(payment)/payment/success/page.tsx +++ b/src/app/[locale]/(payment)/payment/success/page.tsx @@ -3,21 +3,9 @@ import { getTranslations } from "next-intl/server"; import { AnimatedInfoScreen, LottieAnimation } from "@/components/widgets"; import { ELottieKeys } from "@/shared/constants/lottie"; -import Metrics from "./Metrics"; - -export default async function PaymentSuccess({ - searchParams, -}: { - searchParams: Promise<{ - [key: string]: string | undefined; - }>; -}) { - const params = await searchParams; - - const fbPixels = params?.fb_pixels?.split(",") || []; - const productPrice = params?.price || "0"; - const currency = params?.currency || "USD"; +import PaymentSuccessButton from "./Button"; +export default async function PaymentSuccess() { const t = await getTranslations("Payment.Success"); return ( @@ -28,11 +16,7 @@ export default async function PaymentSuccess({ } title={t("title")} /> - + ); }