Transforms complex documents like PDFs and Office docs into LLM-ready markdown/JSON for your Agentic workflows.
Python ai4sciencedocument-analysisdocxextract-datalayout-analysisocrparserpdfpdf-converterpdf-extractor-llmpdf-extractor-pretrainpdf-extractor-ragpdf-parserpptxpythonxlsx
feat: enable telemetry flush during alpha
jinzhenj373add7b941c
diff --git a/README.md b/README.mdindex 4f2e0546..f55f7856 100644--- a/README.md+++ b/README.md@@ -271,6 +271,8 @@ Telemetry does not collect document contents, extracted text or images, file namTelemetry starts in an unset consent state. In this state MinerU may keep local aggregate data but will not upload it. Users can enable or disable telemetry explicitly; disabling telemetry stops new telemetry aggregation and removes unsent local telemetry data.+During the current alpha prerelease, the unset state may also upload locally aggregated metrics. The existing interactive prompt and explicit enable/disable commands remain unchanged. This temporary behavior will be reverted for the stable release.+Do not prompt for telemetry consent in agent or non-interactive contexts. If the user asks about telemetry, use:```bashdiff --git a/mineru/cli/commands/telemetry.py b/mineru/cli/commands/telemetry.pyindex 975869a6..2c42e32a 100644--- a/mineru/cli/commands/telemetry.py+++ b/mineru/cli/commands/telemetry.py@@ -43,7 +43,7 @@ def telemetry_disable(json_mode: bool = typer.Option(False, "--json", help="JSON@app.command("flush")def telemetry_flush(json_mode: bool = typer.Option(False, "--json", help="JSON output")) -> None:- """Flush pending telemetry now when telemetry is enabled."""+ """Flush pending telemetry now when telemetry is enabled (or unset during prerelease)."""_run_action("flush", json_mode=json_mode)diff --git a/mineru/doclib/telemetry/service.py b/mineru/doclib/telemetry/service.pyindex 184fe39b..b1bca176 100644--- a/mineru/doclib/telemetry/service.py+++ b/mineru/doclib/telemetry/service.py@@ -8,7 +8,7 @@ from dataclasses import dataclassfrom typing import Anyfrom .buckets import duration_bucket-from .constants import CONSENT_DISABLED, CONSENT_ENABLED, DIMENSION_VALUES, METRIC_SPECS, TELEMETRY_MAX_FLUSH_PERIODS, TelemetryConsentState+from .constants import CONSENT_DISABLED, DIMENSION_VALUES, METRIC_SPECS, TELEMETRY_MAX_FLUSH_PERIODS, TelemetryConsentStatefrom .context import get_telemetry_contextfrom .payload import build_period_payload, collect_environment_contextfrom .store import TelemetryStore, period_bounds@@ -97,7 +97,8 @@ class TelemetryService:)async def flush_once(self) -> TelemetryFlushResult:- if await self.store.consent_state() != CONSENT_ENABLED:+ # if await self.store.consent_state() != CONSENT_ENABLED: (recover after prerelease)+ if await self.store.consent_state() == CONSENT_DISABLED:return TelemetryFlushResult(status="disabled")if not await self.store.try_acquire_flush_lock():return TelemetryFlushResult(status="locked")@@ -234,9 +235,9 @@ def _int_or_none(value: str | None) -> int | None:async def send_payload(payload: dict[str, Any]) -> str:import httpx- from .transport import signed_headers- from .payload import compact_json_bytesfrom .constants import TELEMETRY_ENDPOINT, TELEMETRY_HTTP_TIMEOUT_SEC+ from .payload import compact_json_bytes+ from .transport import signed_headersbody = compact_json_bytes(payload)headers = signed_headers(body)diff --git a/skills/mineru/SKILL.md b/skills/mineru/SKILL.mdindex 996125cb..4d604851 100644--- a/skills/mineru/SKILL.md+++ b/skills/mineru/SKILL.md@@ -261,6 +261,8 @@ Telemetry does not collect document contents, extracted text or images, file namTelemetry starts in an unset consent state. In this state MinerU may keep local aggregate data but will not upload it. Users can enable or disable telemetry explicitly; disabling telemetry stops new telemetry aggregation and removes unsent local telemetry data.+During the current alpha prerelease, the unset state may also upload locally aggregated metrics. The existing interactive prompt and explicit enable/disable commands remain unchanged. This temporary behavior will be reverted for the stable release.+Do not prompt for telemetry consent in agent or non-interactive contexts. If the user asks about telemetry, use:```bashdiff --git a/tests/unittest/test_doclib_telemetry_core.py b/tests/unittest/test_doclib_telemetry_core.pyindex fc8e30f2..b1a5b833 100644--- a/tests/unittest/test_doclib_telemetry_core.py+++ b/tests/unittest/test_doclib_telemetry_core.py@@ -216,6 +216,32 @@ def test_flush_once_sends_enabled_period_and_deletes_on_success(monkeypatch, tmpasyncio.run(_run())+def test_flush_once_sends_unset_period_during_alpha(monkeypatch, tmp_path) -> None:+ async def _run() -> None:+ captured: list[dict] = []++ async def _send(payload: dict) -> str:+ captured.append(payload)+ return "success"++ monkeypatch.setattr(telemetry_service_module, "send_payload", _send)+ db = DatabaseManager(str(tmp_path / "doclib.db"))+ await db.initialize()+ store = TelemetryStore(db)+ service = TelemetryService(store)+ await service.initialize()+ await service.record_count("search.request.count", timestamp_ms=1_700_000_000_000)++ result = await service.flush_once()++ assert result.status == "success"+ assert result.succeeded == 1+ assert len(captured) == 1+ assert await store.list_periods_for_flush() == []++ asyncio.run(_run())++def test_flush_once_keeps_period_on_retry(monkeypatch, tmp_path) -> None:async def _run() -> None:async def _send(_payload: dict) -> str: