0
0
mirror of https://github.com/Maks1mS/free-ozon-dpr.git synced 2024-12-23 18:42:59 +03:00

more analytics

This commit is contained in:
Maxim Slipenko 2024-06-13 20:57:21 +03:00
parent 41a33e6516
commit c11e80178d
4 changed files with 55 additions and 12 deletions

32
src/analytics.js Normal file
View File

@ -0,0 +1,32 @@
import { el } from "./utils.js";
class Analytics {
static event(name, data = undefined) {
if (typeof ym !== 'undefined') {
// eslint-disable-next-line no-undef
ym(window.YANDEX_METRICA_ID, 'reachGoal', name, data);
}
}
}
document.addEventListener("DOMContentLoaded", function () {
const popupPVZId = el("popup-pvz-id");
const pvzData = { pvz: popupPVZId.innerText };
const popupLink = el("popup-link");
const sourceLink = el("popup-source");
const infoPopupButton = el("info-popup-button");
popupLink.addEventListener("click", function () {
Analytics.event("pvz-link-clicked", pvzData);
});
sourceLink.addEventListener("click", function () {
Analytics.event("pvz-link-clicked", pvzData);
});
infoPopupButton.addEventListener("click", function () {
Analytics.event("info-popup-closed");
});
});

View File

@ -93,7 +93,7 @@
<input type="checkbox" name="no-show">
Больше не показывать
</label>
<button>Я прочитал и понял прочитанное</button>
<button id="info-popup-button">Я прочитал и понял прочитанное</button>
</footer>
</div>
</div>

View File

@ -4,6 +4,7 @@ import map from "./map";
import "./info-popup";
import "./popup";
import "./analytics";
import mergedData from "../merged-data.json";
import { createFeatures } from "./features";

View File

@ -1,26 +1,35 @@
import webfontDownload from "vite-plugin-webfont-dl";
import { VitePluginRadar } from "vite-plugin-radar";
import htmlPlugin from 'vite-plugin-html-config'
import htmlPlugin from "vite-plugin-html-config";
const metas = []
const metas = [];
const headScripts = [];
console.log(process.env.YANDEX_METRICA_ID)
if (process.env.YANDEX_VERIFICATION) {
metas.push({
name: 'yandex-verification',
content: process.env.YANDEX_VERIFICATION
})
name: "yandex-verification",
content: process.env.YANDEX_VERIFICATION,
});
}
const PUBLIC_URL = process.env.PUBLIC_URL || process.env.VERCEL_PROJECT_PRODUCTION_URL
if (process.env.YANDEX_METRICA_ID) {
headScripts.push(
`window.YANDEX_METRICA_ID=${process.env.YANDEX_METRICA_ID}`,
);
}
const PUBLIC_URL =
process.env.PUBLIC_URL || process.env.VERCEL_PROJECT_PRODUCTION_URL;
if (PUBLIC_URL) {
metas.push({
name: 'og:url',
content: 'https://' + PUBLIC_URL
})
name: "og:url",
content: "https://" + PUBLIC_URL,
});
}
export default {
root: "src",
build: {
@ -35,6 +44,7 @@ export default {
}),
htmlPlugin({
metas,
},)
headScripts,
}),
],
};