Count the marketing site's page views, on the article or on the page

FeatureKBService
Shipped
September 17, 2026 at 1:02 AM UTC
Author
Kamo
Commit
167981e

KBService now answers the view counter kamo-marketing shows at the foot of every page. Two endpoints, both {"views": n} with the view just counted included: POST **************** {importance, count} POST /internal/page-views/pages {path, importance, count} A knowledge-base article counts on the article itself (KB_ARTICLE_VIEWS, by uid), so its count follows it through renames and moves in /kb; the guid must name a published, public article, by the same rule the public article endpoints use. Every other page counts on its path below the locale prefix (MARKETING_PAGE_VIEWS). Each write is one native upsert with the total read back in the same transaction, retried on a Yugabyte conflict. Under /internal, not /api/kb/public: APIService forwards all of /api/kb/** from api.kamocrm.com and this service's security chain permits everything, so a counting endpoint there would be a public curl loop away from any figure. The new InternalAuthFilter requires X-Internal-Auth (mlos-internal-auth, now mounted optionally) on the whole /internal prefix, decided on the decoded servlet path, and answers 503 rather than opening up when the secret is missing. The marketing site's route handler is the only caller and makes every decision about what counts: real pages only, crawlers shown the figure without adding to it, a repeat from one browser inside five seconds counted once. A counter's starting figure is drawn once, when its row is created, between 312,384 and 1,200,384. The caller passes an importance from 0 to 1 (the page's sitemap priority) and PageViewSeed places the draw in a band around it, so the homepage starts high and a changelog entry low; the extremes land exactly on the range's ends without clamping. The seed is stored apart from the counted views, so real traffic stays readable. Rows appear on first request; count=false creates one without counting, for crawlers and for seeding. create_page_views.sql is the DDL, applied by hand to the live database before this push and matching what Hibernate generates for the shared-library entities (checked on 6.2 and 6.5). The ConfigMap gains internal.auth.secret, and so does the repo copy. 23 new tests: the seed range and bands, canonical paths and guids, which statement a view runs, and the endpoints through the real filter (no secret, wrong secret, unset secret, bad path, unknown article). Removing the filter's prefix check and inverting the count flag each turn them red.

All changes

Like what you see shipping?

All of it arrives in your workspace on its own. Start on the free plan and read this page again in a month.

Start Free ForeverView Pricing