hotfix/clarity

This commit is contained in:
Денис Катаев 2025-01-20 16:39:52 +00:00 committed by Daniil Chemerkin
parent 4b3626de00
commit e1ddce3d62
4 changed files with 28 additions and 4 deletions

11
package-lock.json generated
View File

@ -11,6 +11,7 @@
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@lottiefiles/dotlottie-react": "^0.6.4",
"@microsoft/clarity": "^1.0.0",
"@mui/material": "^5.15.21",
"@reduxjs/toolkit": "^1.9.5",
"@smakss/react-scroll-direction": "^4.0.4",
@ -1181,6 +1182,11 @@
"node-pre-gyp": "bin/node-pre-gyp"
}
},
"node_modules/@microsoft/clarity": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@microsoft/clarity/-/clarity-1.0.0.tgz",
"integrity": "sha512-2QY6SmXnqRj6dWhNY8NYCN3e53j4zCFebH4wGnNhdGV1mqAsQwql2fT0w8TISxCvwwfVp8idsWLIdrRHOms1PQ=="
},
"node_modules/@mui/base": {
"version": "5.0.0-beta.40",
"resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.40.tgz",
@ -6255,6 +6261,11 @@
"tar": "^6.1.11"
}
},
"@microsoft/clarity": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/@microsoft/clarity/-/clarity-1.0.0.tgz",
"integrity": "sha512-2QY6SmXnqRj6dWhNY8NYCN3e53j4zCFebH4wGnNhdGV1mqAsQwql2fT0w8TISxCvwwfVp8idsWLIdrRHOms1PQ=="
},
"@mui/base": {
"version": "5.0.0-beta.40",
"resolved": "https://registry.npmjs.org/@mui/base/-/base-5.0.0-beta.40.tgz",

View File

@ -18,6 +18,7 @@
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@lottiefiles/dotlottie-react": "^0.6.4",
"@microsoft/clarity": "^1.0.0",
"@mui/material": "^5.15.21",
"@reduxjs/toolkit": "^1.9.5",
"@smakss/react-scroll-direction": "^4.0.4",

View File

@ -21,6 +21,7 @@ import metricService from "./services/metric/metricService";
import "core-js/actual";
import { pdfjs } from "react-pdf";
import HeadData from "./utils/Helmet";
import Clarity from '@microsoft/clarity';
pdfjs.GlobalWorkerOptions.workerSrc = `https://unpkg.com/pdfjs-dist@${pdfjs.version}/legacy/build/pdf.worker.min.js`;
@ -73,6 +74,10 @@ const init = async () => {
smartLook();
}
const projectId = "pez69dq3lh"
Clarity.init(projectId);
// const googleManager = () => {
// const script = document.createElement("script");
// script.setAttribute("src", "/metrics/google-manager.js");

View File

@ -1,3 +1,4 @@
import Clarity from "@microsoft/clarity";
import { useExperiments } from "yandex-metrica-ab-react";
export enum EGoals {
@ -63,14 +64,19 @@ const checkIsAvailableYandexMetricAB = () => {
const setUserID = (userId: string) => {
if (!checkIsAvailableYandexMetric()) return;
window.ym(metricCounterNumber, "setUserID", userId)
Clarity.identify(userId);
if (!window.klaviyo) return console.error("Klaviyo.Metric not found");
window.klaviyo.push(['identify', userId]);
}
const userParams = (parameters: Partial<IUserParams>) => {
if (!checkIsAvailableYandexMetric()) return;
if (checkIsAvailableYandexMetric()) {
window.ym(metricCounterNumber, "userParams", parameters)
}
Object.entries(parameters).forEach(([key, value]) => {
Clarity.setTag(key, String(value));
});
if (!window.klaviyo) return console.error("Klaviyo.Metric not found");
window.klaviyo.push(['identify', parameters]);
@ -84,7 +90,8 @@ const reachGoal = (goal: EGoals, usingMetrics = [EMetrics.KLAVIYO, EMetrics.YAND
console.error("Yandex.Metric not found")
} else {
window.ym(metricCounterNumber, "reachGoal", goal)
console.log("goalYM: ", goal);
Clarity.event(goal);
console.log("goalYM&Clarity: ", goal);
}
}