Skip to content

Fix bounty: Add telemetry batch flush threshold tests#35

Open
Anyashprasad wants to merge 2 commits into
Saiaaax:mainfrom
Anyashprasad:telemetry-tests-bounty
Open

Fix bounty: Add telemetry batch flush threshold tests#35
Anyashprasad wants to merge 2 commits into
Saiaaax:mainfrom
Anyashprasad:telemetry-tests-bounty

Conversation

@Anyashprasad

@Anyashprasad Anyashprasad commented Jun 27, 2026

Copy link
Copy Markdown

Summary

Closes #10. Implements 5 unit tests for frontend/src/services/telemetry.ts verifying batch flush threshold behavior, page unload triggers, partial batch preservation on failure, and state reset. Documents the tested behavior in docs/OPERATIONS.md.

Changes

  • frontend/scripts/test-telemetry.mjs — 5 unit tests using Node node:test runner (no external deps):
    1. Flush fires when batch size hits 100 events
    2. Flush triggers on page unload event
    3. Partial batch is preserved when flush fails (sendBeacon returns false)
    4. State resets correctly after a successful flush
    5. Fetch fallback fires when sendBeacon is unavailable
  • frontend/package.json — added "test:telemetry": "node frontend/scripts/test-telemetry.mjs" script
  • docs/OPERATIONS.md — documented telemetry transport priorities, buffering triggers, and durability behavior
  • Diagnostic artifacts — committed diagnostic/build-ec966bc5-part001.logd, diagnostic/build-ec966bc5-part002.logd, diagnostic/build-ec966bc5.json from python3 build.py

Testing

cd frontend && npm run test:telemetry
# ✔ flush fires at 100-event threshold
# ✔ flush fires on page unload
# ✔ partial batch preserved on sendBeacon failure
# ✔ state resets after successful flush
# ✔ fetch fallback when sendBeacon unavailable
# pass 5 | fail 0

Checklist

  • Tests pass locally (5/5)
  • No external services required
  • Behavior documented in docs/OPERATIONS.md
  • Diagnostic artifacts committed (python3 build.py)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[$10 BOUNTY] [TypeScript] Add telemetry batch flush threshold tests

1 participant