Files
progcode/docs/metrika/programmer-review.md

53 lines
9.7 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.
## Final exact analytics candidate and release — scoped acceptance
**SCOPED ANALYTICS INTEGRATION/RELEASE ACCEPTED** for commit `0458a99d3a3880a42c8d809731ce6aea09cb4342`, publication source `527ea7bf774eca2b18d9dcd2f1ab0ac0341fa87e50a160ad75aefb3e30ad31a2`, frozen build `6b075dc0d017a122dbc842726882266da62932f6e30059428d99b1cf2c3c375b`. This closes the earlier pending fixed-build/release wording in this report, for analytics only.
Independently recomputed source identity from169 committed Git blobs and build identity from680 frozen files at `/private/tmp/progcode-metrika-frozen-527ea7bf774e`; both match exact candidate pins. Independently compared all81 HTML body regions, excluding only script elements, with accepted53f217 baseline: identical; route set identical; all12 CSS/visual binary files identical. Thus this analytics successor does not introduce hidden body/style/route/visual edits. It does not newly certify historical completeness or all visual quality.
Personally read final `browser-contract.json` and harness source: all9 cases pass, errors/CSP violations empty, statisticsSent0. Crucially the fixed candidate now includes61-second-at-depth negative cases for about, legacy contacts, resources and tools; positive article time/depth-once and simulated hidden/unfocused exclusions; actual search selection/zero with private input; one init and correct initial/client-navigation hit counts; ordinary navigation/hash exclusions; trusted related click; confirmed image/fragment/404 diagnostics and absent-download silence. Hidden/focus and clock controls are explicitly a browser logic model, not a claim of61 wall-clock seconds of observed human reading. M-1 is verified closed on the final fixed build.
Read real SDK result: SHA256 `c960d3e7f2e954d977f05c0771980813d49697f5b2c4add76da7ea9b7285fe50`, HTTP200, external async script behavior, search_used/search_zero_results serialization present, no raw test query flag, no runtime/CSP errors. Every statistics request was locally acknowledged; statisticsDelivered0. Read intercepted live-production result tied to source527ea7: same goals serialized, actual article present, errors empty, all metric requests intercepted and delivered0. These prove serialization, not receipt/reporting in the counter UI. No browser without interception was launched by this reviewer, and I sent no statistics.
Read CI143/run1376/job1580 actual terminal proof with immutable full0458a99 commit/status; read runtime,10-request HTTPS and intercepted live-browser records. Additionally performed own live read-only SSH: service update completed; actual desired immutable digest `af63f6f3eefa618d7429f92742ab16acec4affb1bfc696985be63c215ce981eb`, OCI0458a99 exact, healthy and failing streak0. Independently fetched only `/build-identity.json` on apex and www with standard CA/hostname verification: both HTTP200 and source527ea7. No JavaScript executed or analytics request was made by those reads.
Own reproducible identity/preservation assertions and selected runtime/public results: `docs/metrika/programmer-final-evidence.json`. Local exact candidate remains recorded at127.0.0.1:51555/PID67671 by implementer; this reviewer did not restart it.
No remaining blocking analytics implementation/release defect identified. Counter-account timezone, UI goal configuration and real report receipt are separate account-level evidence, not independently certified by this source/runtime review. Full historical recovery, unseen Semrush scope, design-system proposals and full visual acceptance remain independent gates; this analytics-only acceptance does not waive them.