Files
progcode/docs/metrika/programmer-review.md
T
2026-10-27 03:59:37 +03:00

37 lines
6.2 KiB
Markdown

# Programmer review — analytics-only integration
Reviewer `/root/programmer_expert`, 2026-10-27. Scope: current `web/lib/metrika.mjs`, `web/app/Metrika.jsx`, Catalog/layout diff and counter/event contract at `/Users/gavrilovdev/tmp/pupline/site-restoration-status/metrika/counters-and-contract.json`. No product edits, browser launch or statistics submission performed by this reviewer.
**Source verdict: ACCEPTED with the identified article-scope defect corrected in source. Final fixed-build and release acceptance remain pending.** Earlier intercepted results are useful, but do not by themselves prove behavior of the final rebuilt candidate. No full restoration PASS.
## Actual finding and correction
Initial blocking finding M-1: `.article-content` was also present on `/about/` and its legacy `/контакты/` equivalent (`web/app/about/page.jsx`), so the original observer could award engaged_read there after60 visible/focused seconds and75% depth. This violated the contract's actual-article-only condition.
Re-read corrected source: `metrika.mjs:41-43` now scopes both reading body and content-image failure detection to `main.article-shell .article-content`. Canonical and legacy articles use that actual template; about/resources/tools do not. This is the appropriate small compromise: retain the generic content styling class, bind analytics to the real article template. Source defect resolved. Required final behavioral evidence: intercepted61-second/depth negative cases on `/about/`, `/контакты/`, `/resources/`, `/tools/`, alongside positive article timing/depth and hidden/unfocused exclusions.
## Code and contract inspection
- `metrika.mjs:2-12`: existing counter109268613; HTTPS plus exact apex or dot-bounded subdomain guard. Localhost, HTTP and suffix-spoof domains fail. Custom event names are allowlisted; content_problem adds only one fixed reason enum. No raw query, URL, fragment, personal metadata or error text is placed in custom goal parameters.
- `:19-34`: one SDK/init setup per module lifecycle, `defer:true` plus one explicit initial hit and subsequent pathname-change hits. `Metrika.jsx` effect depends on `usePathname`, so ordinary hash changes do not create synthetic hits. No explicit notBounce, forced bounce manipulation or scroll/timer-generated hit exists. `accurateTrackBounce:true`, trackHash:false and webvisor:false match the contract. Route effects clean up listeners/timers.
- `:36-56`: confirmed branded404 template marker; actual content-image error/cache-failure checks; nonempty ordinary fragment decoded and checked against id/name. Reasons are deduplicated per observed route lifecycle. Absence of an image on an inapplicable page is not itself an event. Missing404 URL is normalized in the explicit hit to `/404/` rather than custom diagnostic payload carrying the bad path.
- `:57-64`: trusted primary-button clicks, current aria-disabled exclusion; related_content_click only within `.related`, not every internal link. download_click requires an actual `download` anchor and is a click event, not claimed completion. Current site has no invented download flow. Capture-phase listening lets actual Next Link clicks be observed before Next's client routing interception; the event measures the click, not successful navigation.
- `:65-91`: elapsed time accrues only while the previous visibility/focus state is active; focus/blur/visibility events update accounting. Threshold requires actual article body, active current state, elapsed>=60000ms and viewport reaching75% of article height; once-per-observed-page boolean. Timers and all registered listeners are cleaned up on route change. About-scope fix above is essential to this logic.
- Catalog: search_zero_results is debounced only for actual nonempty query with displayed zero results; initial blank state does not fire. search_used fires on explicit trusted result selection when the query is nonempty. This site does not have a submit-search UX, so the selected contractual branch is explicit selection. Typing alone is not mislabeled as submit; query text is never passed to trackGoal.
- Layout only mounts the client observer; content, body data, route map, CSS and visual assets are outside this analytics change. The precise preservation result must be tied to the final new build before release.
## Evidence inspected and limits
Read `docs/metrika/browser-contract.js`, `browser-real-sdk.js`, existing JSON results, CSP record and preservation verifier. Contract harness routes all requests before navigation, serves local site under guarded production host and stubs the SDK; the separate real-SDK harness serves actual downloaded SDK bytes while locally fulfilling all statistics requests. Neither harness is a live-statistics delivery test. Recorded real SDK result shows both search/zero goals serialized, no raw test query in captured request payload, no runtime/CSP errors, locally fulfilled requests and statisticsDelivered0. No existing CSP relaxation is claimed or needed by the current record.
Read current preservation record:81 HTML body regions equal baseline excluding scripts, route set identical,12 CSS/media bytes unchanged. This is appropriate bounded analytics evidence, but the record was being regenerated during review. **No final fixed-build PASS is claimed here until updated exact candidate identity, negative nonarticle cases and relevant intercepted results are pinned together.** This reviewer did not run the browser or actual SDK and sent no statistics.
Source file SHA256 at this review:
- metrika.mjs: fd2a25b321bb530887076dd574e95cf9946e8aac72cf659a08da3b74172b1d54
- Metrika.jsx: ae4d7a4e17919f1c7c1ce0b89c40f2e19c73d851ba17c56a772def1090fe771f
- Catalog.jsx: 6510a71e0b49a92fdc464260408b26d5f7fe187cb04c570875bdccee57fd759f
- layout.jsx: 6f26f3645ca50604f86e09d8f0a08d51d67e0bb8ce8e2b58176c2cb8ee4d6986
Final analytics release gate: exact-source rebuild/preservation; intercepted negative/positive event and SPA-hit checks after final selector fix; actual SDK serialization with no external statistics delivery; successful authorized site-specific CI/deploy; healthy exact OCI/source identity and public HTTPS for apex/www. Existing restoration/content gates remain independent and are not waived by analytics acceptance.