From 389d977b3c5e17c2925239b776a5c3c25a36e61d Mon Sep 17 00:00:00 2001 From: Nastya Date: Sun, 12 May 2024 21:41:13 +0300 Subject: [PATCH] =?UTF-8?q?=D0=BC=D0=B5=D1=82=D1=80=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BF=D0=BE=D0=BB=D0=B5=D0=B9=20=D0=A4=D0=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ContactForm/ContactForm.tsx | 59 ++++++++++++------- .../ViewPublicationPage/ResultForm.tsx | 2 - lib/utils/hooks/metrics/useVkMetricsGoals.ts | 5 +- .../hooks/metrics/useYandexMetricsGoals.ts | 5 +- 4 files changed, 43 insertions(+), 28 deletions(-) diff --git a/lib/components/ViewPublicationPage/ContactForm/ContactForm.tsx b/lib/components/ViewPublicationPage/ContactForm/ContactForm.tsx index 03cd30a..f091016 100644 --- a/lib/components/ViewPublicationPage/ContactForm/ContactForm.tsx +++ b/lib/components/ViewPublicationPage/ContactForm/ContactForm.tsx @@ -69,18 +69,18 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { currentQuestion.type === "result" ? currentQuestion : questions.find((question): question is QuizQuestionResult => { - if (settings?.cfg.haveRoot) { - return ( - question.type === "result" && - question.content.rule.parentId === currentQuestion.content.id - ); - } else { - return ( - question.type === "result" && - question.content.rule.parentId === "line" - ); - } - }); + if (settings?.cfg.haveRoot) { + return ( + question.type === "result" && + question.content.rule.parentId === currentQuestion.content.id + ); + } else { + return ( + question.type === "result" && + question.content.rule.parentId === "line" + ); + } + }); if (!resultQuestion) throw new Error("Result question not found"); @@ -153,6 +153,27 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { vkMetrics.contactsFormFilled(); yandexMetrics.contactsFormFilled(); + //Оповещаем какие поля были заполнены + if (name.length !== 0) { + vkMetrics.contactsFormField("name"); + yandexMetrics.contactsFormField("name"); + } + if (email.length !== 0) { + vkMetrics.contactsFormField("email"); + yandexMetrics.contactsFormField("email"); + } + if (phone.length !== 0) { + vkMetrics.contactsFormField("phone"); + yandexMetrics.contactsFormField("phone"); + } + if (text.length !== 0) { + vkMetrics.contactsFormField("text"); + yandexMetrics.contactsFormField("text"); + } + if (adress.length !== 0) { + vkMetrics.contactsFormField("address"); + yandexMetrics.contactsFormField("address"); + } } catch (e) { enqueueSnackbar("повторите попытку позже"); } @@ -190,9 +211,8 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { settings.cfg.design && !isMobile ? quizThemes[settings.cfg.theme].isLight ? `url(${DESIGN_LIST[settings.cfg.theme]})` - : `linear-gradient(90deg, #272626, transparent), url(${ - DESIGN_LIST[settings.cfg.theme] - })` + : `linear-gradient(90deg, #272626, transparent), url(${DESIGN_LIST[settings.cfg.theme] + })` : null, }} > @@ -230,8 +250,8 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => { p: isMobile ? "0 20px" : isTablet - ? "0px 40px 30px 60px" - : "125px 60px 30px 60px", + ? "0px 40px 30px 60px" + : "125px 60px 30px 60px", }} > { { useEffect(() => { vkMetrics.resultIdShown(resultQuestion.id); yandexMetrics.resultIdShown(resultQuestion.id); - vkMetrics.resultShown(); - yandexMetrics.resultShown(); }, []); return ( diff --git a/lib/utils/hooks/metrics/useVkMetricsGoals.ts b/lib/utils/hooks/metrics/useVkMetricsGoals.ts index c14aa25..e215bb8 100644 --- a/lib/utils/hooks/metrics/useVkMetricsGoals.ts +++ b/lib/utils/hooks/metrics/useVkMetricsGoals.ts @@ -31,9 +31,6 @@ export const useVkMetricsGoals = (vkId: number | undefined) => { // Посетитель увидел определенный результат (id - айдишник вопроса с типом result) resultIdShown: (resultId: string) => sendMetrics(vkId, `penaquiz-result-${resultId}`), - // Посетитель увидел результат - resultShown: () => - sendMetrics(vkId, `penaquiz-finish`), // Посетитель нажал на ссылку в результате resultLink: () => sendMetrics(vkId, `penaquiz-resultlink`), @@ -41,6 +38,8 @@ export const useVkMetricsGoals = (vkId: number | undefined) => { contactsFormOpened: () => sendMetrics(vkId, "penaquiz-form"), // Посетитель заполнил форму контактов contactsFormFilled: () => sendMetrics(vkId, "penaquiz-contacts"), + // Посетитель заполнил поле формы контактов + contactsFormField: (field: string) => sendMetrics(vkId, `penaquiz-formfield-${field}`), // Посетитель отправил заявку с мессенджером messengerRequestSended: (messenger: MetricsMessengers) => sendMetrics(vkId, `penaquiz-messengers-${messenger}`), diff --git a/lib/utils/hooks/metrics/useYandexMetricsGoals.ts b/lib/utils/hooks/metrics/useYandexMetricsGoals.ts index d450854..c822903 100644 --- a/lib/utils/hooks/metrics/useYandexMetricsGoals.ts +++ b/lib/utils/hooks/metrics/useYandexMetricsGoals.ts @@ -23,9 +23,6 @@ export const useYandexMetricsGoals = (id: number | undefined) => { // Посетитель увидел определенный результат (id - айдишник вопроса с типом result) resultIdShown: (resultId: string) => sendMetrics(id, `penaquiz-result-${resultId}`), - // Посетитель увидел результат - resultShown: () => - sendMetrics(id, `penaquiz-finish`), // Посетитель нажал на ссылку в результате resultLink: () => sendMetrics(id, `penaquiz-resultlink`), @@ -33,6 +30,8 @@ export const useYandexMetricsGoals = (id: number | undefined) => { contactsFormOpened: () => sendMetrics(id, "penaquiz-form"), // Посетитель заполнил форму контактов contactsFormFilled: () => sendMetrics(id, "penaquiz-contacts"), + // Посетитель заполнил поле формы контактов + contactsFormField: (field: string) => sendMetrics(id, `penaquiz-formfield-${field}`), // Посетитель отправил заявку с мессенджером messengerRequestSended: (messenger: MetricsMessengers) => sendMetrics(id, `penaquiz-messengers-${messenger}`),