hotfix-yandex-metric-loading

This commit is contained in:
Денис Катаев 2024-05-28 04:39:03 +00:00 committed by Daniil Chemerkin
parent 2d4a44459c
commit fb26f56598
9 changed files with 67 additions and 14 deletions

View File

@ -2,7 +2,10 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"
/>
<link rel="preload" as="image" href="/leo.png" fetchpriority="high" />
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png" />
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png" />
@ -65,6 +68,50 @@
></script> -->
</head>
<body>
<!-- Yandex.Metrika counter -->
<script type="text/javascript" async="async">
(function (m, e, t, r, i, k, a) {
m[i] =
m[i] ||
function () {
(m[i].a = m[i].a || []).push(arguments);
};
m[i].l = 1 * new Date();
for (var j = 0; j < document.scripts.length; j++) {
if (document.scripts[j].src === r) {
return;
}
}
(k = e.createElement(t)),
(a = e.getElementsByTagName(t)[0]),
(k.async = 1),
(k.src = r),
a.parentNode.insertBefore(k, a);
})(
window,
document,
"script",
"https://mc.yandex.ru/metrika/tag.js",
"ym"
);
ym(95799066, "init", {
clickmap: true,
trackLinks: true,
accurateTrackBounce: true,
webvisor: true,
});
</script>
<noscript>
<div>
<img
src="https://mc.yandex.ru/watch/95799066"
style="position: absolute; left: -9999px"
alt=""
/>
</div>
</noscript>
<!-- /Yandex.Metrika counter -->
<noscript>You need to enable JavaScript to run this app.</noscript>
<noscript
><div>

View File

@ -109,7 +109,8 @@ function EmailEnterPage({
const handleClick = () => {
authorize();
window.ym(95799066, "reachGoal", "EnteredEmail");
if (typeof window.ym === "function")
window.ym(95799066, "reachGoal", "EnteredEmail");
};
const authorize = async () => {

View File

@ -18,7 +18,8 @@ function PaymentSuccessPage(): JSX.Element {
};
useEffect(() => {
window.ym(95799066, "reachGoal", "PaymentSuccess");
if (typeof window.ym === "function")
window.ym(95799066, "reachGoal", "PaymentSuccess");
}, []);
return (

View File

@ -114,7 +114,8 @@ function EmailEnterPage({
const handleClick = () => {
authorize();
window.ym(95799066, "reachGoal", "EnteredEmail");
if (typeof window.ym === "function")
window.ym(95799066, "reachGoal", "EnteredEmail");
};
const authorize = async () => {

View File

@ -15,7 +15,8 @@ function SuccessPaymentPage(): JSX.Element {
: "The information has been sent to your email";
useEffect(() => {
window.ym(95799066, "reachGoal", "PaymentSuccess");
if (typeof window.ym === "function")
window.ym(95799066, "reachGoal", "PaymentSuccess");
}, []);
return (

View File

@ -134,7 +134,8 @@ function PaymentWithEmailPage() {
return;
}
const { user, token } = authData;
window.ym(95799066, "reachGoal", "EnteredEmail");
if (typeof window.ym === "function")
window.ym(95799066, "reachGoal", "EnteredEmail");
await createSinglePayment({
user,

View File

@ -43,7 +43,8 @@ export default function StepEmail() {
const authorize = async () => {
await authorization(email, ESourceAuthorization["aura.palmistry"]);
window.ym(95799066, "reachGoal", "EnteredEmail");
if (typeof window.ym === "function")
window.ym(95799066, "reachGoal", "EnteredEmail");
setIsAuth(true);
};

View File

@ -116,7 +116,7 @@ export const useAuthentication = () => {
const payload = getAuthorizationPayload(email, source);
const { token, userId } = await api.authorization(payload);
const { user } = await api.getUser({ token });
if (userId?.length && !!window.ym) {
if (userId?.length && !!window.ym && typeof window.ym === 'function') {
window.ym(95799066, 'userParams', {
email: user.email,
UserID: userId

View File

@ -38,11 +38,11 @@ const init = async () => {
const isProduction = import.meta.env.MODE === "production";
// SCRIPTS TO HEAD
const yandexMetric = () => {
const script = document.createElement("script");
script.setAttribute("src", "/metrics/yandex.js");
document.head.appendChild(script);
};
// const yandexMetric = () => {
// const script = document.createElement("script");
// script.setAttribute("src", "/metrics/yandex.js");
// document.head.appendChild(script);
// };
const smartLook = () => {
if (!config.smartlook_manage) return;
@ -51,7 +51,7 @@ const init = async () => {
document.head.appendChild(script);
};
if (isProduction) {
yandexMetric();
// yandexMetric();
smartLook();
}