Skip to content

Commit a493ba2

Browse files
stats: fix missing docId url param (#1401)
1 parent 16ca6c0 commit a493ba2

5 files changed

Lines changed: 13 additions & 2 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* Fix: Pass missing `docId` query params from `_stats/` page
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 1.84.1
2+
3+
:include-markdowns: 1.84.1

znai-docs/znai/toc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ example-references
101101
znai-development
102102
local-build
103103
release-notes
104+
2026
104105
2025
105106
2024
106107
2023

znai-enterprise-sample-server/znai-enterprise-sample-server.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,12 @@ def apply_stats_multiplier(page_stats, multiplier):
316316
@app.route('/doc-stats', methods=['GET'])
317317
def get_doc_stats():
318318
try:
319+
doc_id = request.args.get('docId')
319320
events = load_tracking_events()
320321

322+
if doc_id:
323+
events = [e for e in events if e.get('docId') == doc_id]
324+
321325
now = datetime.utcnow()
322326
week_ago = now - timedelta(days=7)
323327

znai-reactjs/src/screens/doc-stats/DocStatsScreen.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import React, { useEffect, useState } from "react";
1818
import { TocItem } from "../../structure/TocItem";
19-
import { DocMeta, getDocMeta, mergeDocMeta } from "../../structure/docMeta";
19+
import { DocMeta, getDocId, getDocMeta, mergeDocMeta } from "../../structure/docMeta";
2020
import { fetchWithCredentials } from "../../utils/fetchWithCredentials";
2121
import { DocStatsView, PageStats, TimePeriod } from "./DocStatsView";
2222

@@ -30,7 +30,9 @@ export interface DocStatsScreenProps {
3030
}
3131

3232
async function fetchDocStats(url: string): Promise<DocStatsResponse> {
33-
const response = await fetchWithCredentials(url, {});
33+
const fullUrl = new URL(url);
34+
fullUrl.searchParams.set("docId", getDocId());
35+
const response = await fetchWithCredentials(fullUrl.toString(), {});
3436

3537
if (!response.ok) {
3638
const body = await response.json().catch(() => ({}));

0 commit comments

Comments
 (0)