fix: google analytics only on production

This commit is contained in:
2026-10-04 10:51:53 +05:00
parent 1db83d12ff
commit e1fc11cb54
7 changed files with 26 additions and 20 deletions
+11
View File
@@ -31,6 +31,10 @@
let crumb = $derived(toCrumb(page.url.pathname));
// GA подключается только в production-деплое: флаг выставляется в
// deploy-workflow, локальные и preview-сборки тег не получают.
const gaEnabled = import.meta.env.PUBLIC_GA_ENABLED === "true";
function toCrumb(path: string): string {
if (path === "/") return "/ " + t("header.home");
if (path === "/list-tools") return "/ " + t("header.catalog");
@@ -46,6 +50,13 @@
<svelte:head>
<link rel="icon" href={`${resolve("/")}favicon.svg`} />
{#if gaEnabled}
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-MEQJ7JHRQQ"
></script>
<script src={`${resolve("/")}ga.js`}></script>
{/if}
</svelte:head>
<main class="preview-root" data-theme={theme}>