Merge branch 'dev' into 'staging'
Dev See merge request frontend/squzanswerer!158
This commit is contained in:
commit
cecfa8bbdd
@ -78,7 +78,7 @@ export async function getData(quizId: string): Promise<{
|
||||
error?: AxiosError;
|
||||
}> {
|
||||
try {
|
||||
const { data, headers } = await axios<GetQuizDataResponse>(domain + `/answer/settings`, {
|
||||
const { data, headers } = await axios<GetQuizDataResponse>(domain + `/answer/settings${window.location.search}`, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"X-Sessionkey": SESSIONS,
|
||||
@ -160,7 +160,7 @@ export function sendAnswer({ questionId, body, qid, preview }: SendAnswerProps)
|
||||
formData.append("qid", qid);
|
||||
|
||||
return publicationMakeRequest({
|
||||
url: domain + `/answer/answer`,
|
||||
url: domain + `/answer/v1.0.0/answer`,
|
||||
body: formData,
|
||||
method: "POST",
|
||||
});
|
||||
@ -199,7 +199,7 @@ export function sendFile({ questionId, body, qid }: SendFileParams) {
|
||||
formData.append("qid", qid);
|
||||
|
||||
return publicationMakeRequest({
|
||||
url: domain + `/answer/answer`,
|
||||
url: domain + `/answer/v1.0.0/answer`,
|
||||
body: formData,
|
||||
method: "POST",
|
||||
});
|
||||
@ -242,7 +242,7 @@ export function sendFC({ questionId, body, qid, preview }: SendFCParams) {
|
||||
formData.append("qid", qid);
|
||||
|
||||
return publicationMakeRequest({
|
||||
url: domain + `/answer/answer`,
|
||||
url: domain + `/answer/v1.0.0/answer`,
|
||||
body: formData,
|
||||
method: "POST",
|
||||
});
|
||||
|
@ -310,7 +310,7 @@ export const ContactForm = ({ currentQuestion, onShowResult }: Props) => {
|
||||
target={"_blank"}
|
||||
href={`https://${
|
||||
window.location.hostname.includes("s") ? "s" : ""
|
||||
}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
|
||||
}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
|
@ -40,7 +40,7 @@ export const Question = ({
|
||||
questionSelect,
|
||||
}: Props) => {
|
||||
const theme = useTheme();
|
||||
const { settings, show_badge } = useQuizSettings();
|
||||
const { settings, show_badge, quizId } = useQuizSettings();
|
||||
|
||||
return (
|
||||
<Box
|
||||
@ -95,7 +95,7 @@ export const Question = ({
|
||||
{show_badge && (
|
||||
<Link
|
||||
target="_blank"
|
||||
href="https://quiz.pena.digital"
|
||||
href={`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
sx={{
|
||||
mt: "20px",
|
||||
alignSelf: "end",
|
||||
|
@ -34,7 +34,7 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
useEffect(() => {
|
||||
vkMetrics.resultIdShown(resultQuestion.id);
|
||||
yandexMetrics.resultIdShown(resultQuestion.id);
|
||||
}, []);
|
||||
}, [resultQuestion.id, vkMetrics, yandexMetrics]);
|
||||
|
||||
return (
|
||||
<Box
|
||||
@ -195,7 +195,7 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
target={"_blank"}
|
||||
href={`https://${
|
||||
window.location.hostname.includes("s") ? "s" : ""
|
||||
}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
|
||||
}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
@ -229,19 +229,21 @@ export const ResultForm = ({ resultQuestion }: ResultFormProps) => {
|
||||
bottom: 0,
|
||||
}}
|
||||
>
|
||||
{settings.cfg.resultInfo.showResultForm === "before" && !settings.cfg.score && (
|
||||
<Button
|
||||
onClick={() => setCurrentQuizStep("contactform")}
|
||||
variant="contained"
|
||||
sx={{
|
||||
p: "10px 20px",
|
||||
width: "auto",
|
||||
height: "50px",
|
||||
}}
|
||||
>
|
||||
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
||||
</Button>
|
||||
)}
|
||||
{settings.cfg.resultInfo.showResultForm === "before" &&
|
||||
settings.cfg.showfc !== false &&
|
||||
!settings.cfg.score && (
|
||||
<Button
|
||||
onClick={() => setCurrentQuizStep("contactform")}
|
||||
variant="contained"
|
||||
sx={{
|
||||
p: "10px 20px",
|
||||
width: "auto",
|
||||
height: "50px",
|
||||
}}
|
||||
>
|
||||
{resultQuestion.content.hint.text || "Узнать подробнее"}
|
||||
</Button>
|
||||
)}
|
||||
{settings.cfg.resultInfo.showResultForm === "after" && resultQuestion.content.redirect && (
|
||||
<Button
|
||||
onClick={() => {
|
||||
|
@ -136,7 +136,7 @@ export const StartPageViewPublication = () => {
|
||||
<Box
|
||||
component={Link}
|
||||
target={"_blank"}
|
||||
href={`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/squiz/quiz/logo?q=${quizId}`}
|
||||
href={`https://${window.location.hostname.includes("s") ? "s" : ""}quiz.pena.digital/answer/v1.0.0/logo?q=${quizId}`}
|
||||
sx={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
|
@ -110,10 +110,10 @@ export interface QuizConfig {
|
||||
law?: string;
|
||||
};
|
||||
meta: string;
|
||||
antifraud: boolean;
|
||||
showfc: boolean;
|
||||
yandexMetricsNumber: number | undefined;
|
||||
vkMetricsNumber: number | undefined;
|
||||
antifraud?: boolean;
|
||||
showfc?: boolean;
|
||||
yandexMetricsNumber?: number;
|
||||
vkMetricsNumber?: number;
|
||||
}
|
||||
|
||||
export type FormContactFieldName = "name" | "email" | "phone" | "text" | "address";
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { MetricsMessengers } from "@model/metrics";
|
||||
import { useMemo } from "react";
|
||||
|
||||
type MetricsGoal = {
|
||||
type: "reachGoal";
|
||||
@ -19,28 +20,31 @@ const sendMetrics = (vkPixelId: number | undefined, goal: string) => {
|
||||
};
|
||||
|
||||
export const useVkMetricsGoals = (vkId: number | undefined) => {
|
||||
return {
|
||||
// Посетитель открыл квиз
|
||||
quizOpened: () => sendMetrics(vkId, "penaquiz-start"),
|
||||
// Посетитель нажал на кнопку стартовой страницы
|
||||
firstPageOpened: () => sendMetrics(vkId, "penaquiz-startquiz"),
|
||||
// Посетитель кликнул по номеру телефона на стартовой странице
|
||||
phoneNumberOpened: () => sendMetrics(vkId, "penaquiz-phone"),
|
||||
// Посетитель кликнул по email на стартовой странице
|
||||
emailOpened: () => sendMetrics(vkId, "penaquiz-email"),
|
||||
// Посетитель увидел определенный результат (id - айдишник вопроса с типом result)
|
||||
resultIdShown: (resultId: string) => sendMetrics(vkId, `penaquiz-result-${resultId}`),
|
||||
// Посетитель нажал на ссылку в результате
|
||||
resultLink: () => sendMetrics(vkId, `penaquiz-resultlink`),
|
||||
// Посетитель дошёл до формы контактов
|
||||
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}`),
|
||||
// Посетитель прошёл вопрос
|
||||
questionPassed: (questionId: string) => sendMetrics(vkId, `penaquiz-step${questionId}`),
|
||||
};
|
||||
return useMemo(
|
||||
() => ({
|
||||
// Посетитель открыл квиз
|
||||
quizOpened: () => sendMetrics(vkId, "penaquiz-start"),
|
||||
// Посетитель нажал на кнопку стартовой страницы
|
||||
firstPageOpened: () => sendMetrics(vkId, "penaquiz-startquiz"),
|
||||
// Посетитель кликнул по номеру телефона на стартовой странице
|
||||
phoneNumberOpened: () => sendMetrics(vkId, "penaquiz-phone"),
|
||||
// Посетитель кликнул по email на стартовой странице
|
||||
emailOpened: () => sendMetrics(vkId, "penaquiz-email"),
|
||||
// Посетитель увидел определенный результат (id - айдишник вопроса с типом result)
|
||||
resultIdShown: (resultId: string) => sendMetrics(vkId, `penaquiz-result-${resultId}`),
|
||||
// Посетитель нажал на ссылку в результате
|
||||
resultLink: () => sendMetrics(vkId, `penaquiz-resultlink`),
|
||||
// Посетитель дошёл до формы контактов
|
||||
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}`),
|
||||
// Посетитель прошёл вопрос
|
||||
questionPassed: (questionId: string) => sendMetrics(vkId, `penaquiz-step${questionId}`),
|
||||
}),
|
||||
[vkId]
|
||||
);
|
||||
};
|
||||
|
@ -1,4 +1,5 @@
|
||||
import type { MetricsMessengers } from "@model/metrics";
|
||||
import { useMemo } from "react";
|
||||
|
||||
type ExtendedWindow = Window & {
|
||||
ym?: (id: number, type: string, goal: string) => void;
|
||||
@ -11,28 +12,31 @@ const sendMetrics = (yandexMetricsId: number | undefined, goal: string) => {
|
||||
};
|
||||
|
||||
export const useYandexMetricsGoals = (id: number | undefined) => {
|
||||
return {
|
||||
// Посетитель открыл квиз
|
||||
quizOpened: () => sendMetrics(id, "penaquiz-start"),
|
||||
// Посетитель нажал на кнопку стартовой страницы
|
||||
firstPageOpened: () => sendMetrics(id, "penaquiz-startquiz"),
|
||||
// Посетитель кликнул по номеру телефона на стартовой странице
|
||||
phoneNumberOpened: () => sendMetrics(id, "penaquiz-phone"),
|
||||
// Посетитель кликнул по email на стартовой странице
|
||||
emailOpened: () => sendMetrics(id, "penaquiz-email"),
|
||||
// Посетитель увидел определенный результат (id - айдишник вопроса с типом result)
|
||||
resultIdShown: (resultId: string) => sendMetrics(id, `penaquiz-result-${resultId}`),
|
||||
// Посетитель нажал на ссылку в результате
|
||||
resultLink: () => sendMetrics(id, `penaquiz-resultlink`),
|
||||
// Посетитель дошёл до формы контактов
|
||||
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}`),
|
||||
// Посетитель прошёл вопрос
|
||||
questionPassed: (questionId: string) => sendMetrics(id, `penaquiz-step${questionId}`),
|
||||
};
|
||||
return useMemo(
|
||||
() => ({
|
||||
// Посетитель открыл квиз
|
||||
quizOpened: () => sendMetrics(id, "penaquiz-start"),
|
||||
// Посетитель нажал на кнопку стартовой страницы
|
||||
firstPageOpened: () => sendMetrics(id, "penaquiz-startquiz"),
|
||||
// Посетитель кликнул по номеру телефона на стартовой странице
|
||||
phoneNumberOpened: () => sendMetrics(id, "penaquiz-phone"),
|
||||
// Посетитель кликнул по email на стартовой странице
|
||||
emailOpened: () => sendMetrics(id, "penaquiz-email"),
|
||||
// Посетитель увидел определенный результат (id - айдишник вопроса с типом result)
|
||||
resultIdShown: (resultId: string) => sendMetrics(id, `penaquiz-result-${resultId}`),
|
||||
// Посетитель нажал на ссылку в результате
|
||||
resultLink: () => sendMetrics(id, `penaquiz-resultlink`),
|
||||
// Посетитель дошёл до формы контактов
|
||||
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}`),
|
||||
// Посетитель прошёл вопрос
|
||||
questionPassed: (questionId: string) => sendMetrics(id, `penaquiz-step${questionId}`),
|
||||
}),
|
||||
[id]
|
||||
);
|
||||
};
|
||||
|
@ -23,7 +23,6 @@ export function useQuestionFlowControl() {
|
||||
const yandexMetrics = useYandexMetricsGoals(settings.cfg.yandexMetricsNumber);
|
||||
|
||||
const currentQuestion = sortedQuestions.find((question) => question.id === currentQuestionId) ?? sortedQuestions[0];
|
||||
console.log("currentQuestion", currentQuestion);
|
||||
|
||||
const linearQuestionIndex =
|
||||
currentQuestion && sortedQuestions.every(({ content }) => content.rule.parentId !== "root") // null when branching enabled
|
||||
@ -131,9 +130,12 @@ export function useQuestionFlowControl() {
|
||||
if (nextQuestion?.type !== "result") throw new Error("Current question is not result");
|
||||
|
||||
setCurrentQuestionId(nextQuestion.id);
|
||||
if (settings.cfg.resultInfo.showResultForm === "after" || isResultQuestionEmpty(nextQuestion))
|
||||
if (
|
||||
settings.cfg.showfc !== false &&
|
||||
(settings.cfg.resultInfo.showResultForm === "after" || isResultQuestionEmpty(nextQuestion))
|
||||
)
|
||||
setCurrentQuizStep("contactform");
|
||||
}, [nextQuestion, setCurrentQuizStep, settings.cfg.resultInfo.showResultForm]);
|
||||
}, [nextQuestion, setCurrentQuizStep, settings.cfg.resultInfo.showResultForm, settings.cfg.showfc]);
|
||||
|
||||
const showResultAfterContactForm = useCallback(() => {
|
||||
if (currentQuestion?.type !== "result") throw new Error("Current question is not result");
|
||||
@ -161,7 +163,7 @@ export function useQuestionFlowControl() {
|
||||
if (nextQuestion.type === "result") return showResult();
|
||||
|
||||
setCurrentQuestionId(nextQuestion.id);
|
||||
}, [currentQuestion, nextQuestion, showResult]);
|
||||
}, [currentQuestion.id, nextQuestion, showResult, vkMetrics, yandexMetrics]);
|
||||
|
||||
const setQuestion = useCallback(
|
||||
(questionId: string) => {
|
||||
|
Loading…
Reference in New Issue
Block a user