From 2d3e16efd1e2b1d77ff29062f1b2be9883bac4b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9?= Date: Wed, 8 Jul 2026 04:38:45 +0300 Subject: [PATCH] =?UTF-8?q?feat(metrika):=20hit=20=D1=82=D0=BE=D0=BB=D1=8C?= =?UTF-8?q?=D0=BA=D0=BE=20=D0=B4=D0=BB=D1=8F=20=D0=BC=D0=B0=D1=80=D1=88?= =?UTF-8?q?=D1=80=D1=83=D1=82=D0=BE=D0=B2=20=D0=BA=D0=B0=D0=B1=D0=B8=D0=BD?= =?UTF-8?q?=D0=B5=D1=82=D0=B0=20(layout=3Dapp)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit router.afterEach: при входе на layout=app лениво грузит Метрику и шлёт hit(fullPath). Вход/публичные/админка/портал продаж — без Метрики. + убраны лишние @ts-expect-error в тесте (type-check чист). Co-Authored-By: Claude Opus 4.8 (1M context) --- app/resources/js/router/index.ts | 11 +++++++++++ app/tests/Frontend/metrika.spec.ts | 2 -- docs/observer/STATUS.md | 8 ++++---- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/app/resources/js/router/index.ts b/app/resources/js/router/index.ts index 15a2404f..f0b813ff 100644 --- a/app/resources/js/router/index.ts +++ b/app/resources/js/router/index.ts @@ -1,6 +1,7 @@ import { createRouter, createWebHistory, type RouteRecordRaw } from 'vue-router'; import { useAuthStore } from '../stores/auth'; import { useSalesAuthStore } from '../stores/salesAuth'; +import { ensureLoaded, hit } from '../plugins/metrika'; /** * Vue Router (фаза 2). История — `createWebHistory` (HTML5 history API); @@ -513,3 +514,13 @@ router.beforeEach(async (to) => { return true; }); + +// Метрика/Вебвизор — только в кабинете клиента (layout==='app'). +// Загружаем лениво при первом входе, затем шлём hit на каждом переходе внутри кабинета. +// Вход (auth), публичные (public), админка (admin), портал продаж (salesAuth) — БЕЗ Метрики. +router.afterEach((to) => { + if (to.meta.layout === 'app') { + ensureLoaded(); + hit(to.fullPath); + } +}); diff --git a/app/tests/Frontend/metrika.spec.ts b/app/tests/Frontend/metrika.spec.ts index b1f47042..95c28c62 100644 --- a/app/tests/Frontend/metrika.spec.ts +++ b/app/tests/Frontend/metrika.spec.ts @@ -8,7 +8,6 @@ describe('metrika loader', () => { beforeEach(() => { document.head.innerHTML = ''; document.body.innerHTML = ''; - // @ts-expect-error чистим глобал между тестами delete window.ym; vi.resetModules(); }); @@ -39,7 +38,6 @@ describe('metrika loader', () => { document.head.appendChild(meta); const ym = vi.fn(); - // @ts-expect-error стаб глобала window.ym = ym; const { hit } = await import('../../resources/js/plugins/metrika'); diff --git a/docs/observer/STATUS.md b/docs/observer/STATUS.md index 6bca48a6..1b1bcfd2 100644 --- a/docs/observer/STATUS.md +++ b/docs/observer/STATUS.md @@ -1,6 +1,6 @@ # Brain Status (auto-generated) -Last updated: 2026-07-08T01:33:18.450Z +Last updated: 2026-07-08T01:35:59.804Z | Контролёр | Состояние | Детали | |---|---|---| @@ -112,9 +112,9 @@ Episodes since last run: 542 / threshold: 10 | PID | Имя | CPU-время | Возраст | |---|---|---|---| -| 2132 | Code | 9.47ч | NaNч | -| 3276 | MsMpEng | 9.15ч | NaNч | -| 4 | System | 3.77ч | NaNч | +| 2132 | Code | 9.48ч | 0.0ч | +| 3276 | MsMpEng | 9.16ч | 0.0ч | +| 4 | System | 3.78ч | 0.0ч | ⚠️ Проверь, не «осиротевшие» ли это процессы от завершённых Claude-сессий.