Skip to content

feat: save the event log of the fastest time 60 result (@miodec) - #8643

Open
Miodec wants to merge 3 commits into
feat/event-log-v2from
feat/saved-event-log
Open

Miodec wants to merge 3 commits into
feat/event-log-v2from
feat/saved-event-log

Conversation

@Miodec

@Miodec Miodec commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Stacked on #8644 (event log package + v2). Spec: docs/specs/saved-event-log/spec.md. Keeps the saved event log of each user's fastest qualifying time 60 result (wpm ≥ minWpm, PB-eligible, lazy allowed).

 packages/event-log/
+└── util.ts             # qualifiesForSavedEventLog, slot
frontend onResult
  if qualifies: convert(log, 2) → gzip → base64 → body.eventLog
backend addResult
  qualifies && no log && required → 467
  qualifies && log && !anticheat.validateEventLog → 468
  addResult
  EventLogsDal.saveIfFaster  (conditional upsert on {uid, slot}, retry on dup key)
GET /admin/eventLogs/:uid → gunzip (10 MB cap) → v2 schema → v1

Config results.savedEventLog {enabled, required, minWpm}, default {false, false, 130}. Rollout: anticheat readability checks → enabled → required once clients have updated.
Logs are deleted on account delete, reset, and clear PB.

Evidence

  • Tests: event-log 15, backend 565, frontend 2025 pass; lint and typecheck clean.
  • Browser (dev, minWpm: 10, required: true): time 60 at 123 wpm → 200; admin endpoint → 1906 events, first testMs −4.5; event log viewer loads it.
  • Not run here: backend/__tests__/__integration__/dal/event-logs.spec.ts (needs Docker).

Merge Danger

Door: two-way

Everything is behind savedEventLog.enabled (off). New eventLogs collection and index only.

Blast Radius: results

Result saving touches the add-result controller; with config off the only change is the extra optional eventLog body field.

🤖 Generated with Claude Code

Copilot AI balanced review requested due to automatic review settings December 1, 2026 18:26
@monkeytypegeorge monkeytypegeorge added backend Server stuff frontend User interface or web stuff local dev Related to the build process or dependencies docs Related to Markdown files and documentation api A change to the Application Programming Interface (API) packages Changes in local packages labels Dec 1, 2026
@github-actions github-actions Bot added the waiting for review Pull requests that require a review before continuing label Dec 1, 2026
@github-actions

github-actions Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Continuous integration check(s) failed. Please review the failing check's logs and make the necessary changes.

@github-actions github-actions Bot added waiting for update Pull requests or issues that require changes/comments before continuing and removed waiting for review Pull requests that require a review before continuing labels Dec 1, 2026
@Miodec Miodec added the force-ci Force CI to run on draft PRs label Dec 1, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The change introduces critical configuration breakages by adding // comments that make .oxlintrc.json and turbo.json invalid JSON (and sets concurrency to a string), which would cause tooling/config loading to fail.

3 open issues
1 file not reviewed
  • pnpm-lock.yaml: Generated file
What changed in this PR

Adds support for saving a compressed event log for each user’s fastest qualifying Time 60 result, including shared event-log types/converters, client upload, server validation/storage, and an admin fetch endpoint.

Changes:

  • Introduce new workspace package @monkeytype/event-log with v1/v2 formats, zod validation, and version conversion utilities.
  • Frontend encodes (gzip+base64) and uploads qualifying event logs and migrates engine/viewer typings to the shared package.
  • Backend validates/optionally requires event logs, conditionally stores only the fastest per user, and exposes an admin read endpoint with lifecycle cleanup.
File Description
turbo.json Adjusts Turborepo configuration, including concurrency settings.
pnpm-lock.yaml Updates the lockfile to include the new workspace package and dependency changes.
packages/​schemas/​src/​configuration.ts Extends the configuration schema with results.savedEventLog settings.
packages/​event-log/​vitest.config.ts Adds Vitest configuration for the new @monkeytype/event-log package.
packages/​event-log/​tsup.config.js Adds tsup build configuration for the new event-log package.
packages/​event-log/​tsconfig.json Adds TypeScript configuration for the new event-log package.
packages/​event-log/​src/​v2/​types.ts Defines v2 stored-format TypeScript types for saved event logs.
packages/​event-log/​src/​v2/​schema.ts Adds a zod schema and parsing/validation for v2 stored event logs.
packages/​event-log/​src/​v2/​index.ts Exports the v2 API surface for the event-log package.
packages/​event-log/​src/​v2/​convert.ts Implements conversion utilities between v1 and v2 event log formats.
packages/​event-log/​src/​v1/​index.ts Defines the v1 runtime event log types used by the frontend/engine.
packages/​event-log/​src/​util.ts Adds shared helpers such as qualification logic and slot selection for saved logs.
packages/​event-log/​src/​keycode.ts Centralizes the Keycode type into the shared event-log package.
packages/​event-log/​src/​input-type.ts Centralizes input-type unions into the shared event-log package.
packages/​event-log/​src/​events.ts Moves shared event type definitions into the event-log package.
packages/​event-log/​src/​convert.ts Adds a version-agnostic conversion entry point for event logs.
packages/​event-log/​package.json Creates the package manifest, exports, and scripts for @monkeytype/event-log.
packages/​event-log/​.oxlintrc.json Adds an oxlint configuration file for the new package.
packages/​event-log/​__test__/​v2.spec.ts Adds tests covering v2 schema acceptance and rejection cases.
packages/​event-log/​__test__/​util.spec.ts Adds tests for saved-event-log qualification and helper utilities.
packages/​event-log/​__test__/​tsconfig.json Adds TypeScript configuration for the event-log package tests.
packages/​event-log/​__test__/​fixture.ts Adds a reusable fixture event log for package-level tests.
packages/​event-log/​__test__/​convert.spec.ts Adds tests for v1↔v2 conversion behavior and roundtrips.
packages/​contracts/​src/​results.ts Extends the results contract to support an optional eventLog on add-result and related statuses.
packages/​contracts/​src/​admin.ts Adds an admin contract for fetching a user’s saved event log.
packages/​contracts/​package.json Updates contracts package dependencies to include @monkeytype/event-log.
GLOSSARY.md Adds glossary definitions related to event logs and saved event logs.
frontend/​vite-plugins/​workspace-packages.ts Improves workspace package resolution/aliasing for explicit subpath exports.
frontend/​src/​ts/​utils/​layout-key-codes.ts Switches keycode typing/imports to use the shared event-log package.
frontend/​src/​ts/​utils/​key-converter.ts Updates key conversion utilities to use the shared Keycode type.
frontend/​src/​ts/​test/​words-history.ts Updates words history logic to use shared v1 event log types.
frontend/​src/​ts/​test/​test-logic.ts Adds logic to attach/upload the saved event log on qualifying result saves and refactors failure handling.
frontend/​src/​ts/​test/​shift-tracker.ts Updates shift tracking to use shared keycode/event-log types.
frontend/​src/​ts/​test/​saved-event-log.ts Implements building a gzipped+base64 v2 event log payload for upload.
frontend/​src/​ts/​test/​result-save-failure.ts Centralizes result-save failure mapping, retry behavior, and user-facing messaging.
frontend/​src/​ts/​test/​engine/​result-data.ts Updates engine result data typing to use the shared v1 event log types.
frontend/​src/​ts/​test/​engine/​input-type.ts Updates engine input-type definitions/imports to the shared package.
frontend/​src/​ts/​test/​engine/​events/​stats.ts Refactors stats event handling to use shared event-log types.
frontend/​src/​ts/​test/​engine/​events/​live-cache.ts Updates live-cache event handling to use shared event types.
frontend/​src/​ts/​test/​engine/​events/​helpers.ts Updates event helpers to import shared event-log types/utilities.
frontend/​src/​ts/​test/​engine/​events/​data.ts Refactors event data construction to use shared v1 event log types and events.
frontend/​src/​ts/​states/​monkey.ts Updates state typings/imports to use shared keycode/event-log types.
frontend/​src/​ts/​states/​event-log-viewer.ts Updates the event log viewer state to use shared event log types.
frontend/​src/​ts/​input/​helpers/​word-navigation.ts Updates word navigation helper types to use shared input-type unions.
frontend/​src/​ts/​input/​helpers/​test-event-code.ts Updates test event code helpers to use the shared Keycode type.
frontend/​src/​ts/​input/​handlers/​keydown.ts Updates keydown handler typing to use shared event-log types.
frontend/​src/​ts/​input/​handlers/​insert-text.ts Updates insert-text handling to use shared input-type unions.
frontend/​src/​ts/​input/​handlers/​delete.ts Updates delete handling to use shared input-type unions.
frontend/​src/​ts/​constants/​keys.ts Adjusts key constants/types to rely on the shared Keycode type.
frontend/​src/​ts/​components/​pages/​test/​result/​ResultWordsHistory.tsx Updates result page words-history component typings to use shared event log types.
frontend/​src/​ts/​components/​pages/​test/​result/​ResultMainStats.tsx Updates result main stats component typings to use shared event log types.
frontend/​src/​ts/​components/​pages/​test/​result/​ResultChart.tsx Updates result chart component typings to use shared event log types.
frontend/​src/​ts/​components/​pages/​test/​result/​replay.ts Updates replay logic to use shared event log types and events.
frontend/​src/​ts/​components/​pages/​event-log-viewer/​EventLogViewerPage.tsx Updates the event log viewer page to consume the shared event-log types/exports.
frontend/​package.json Adds @monkeytype/event-log as a frontend dependency.
frontend/​__tests__/​test/​saved-event-log.spec.ts Adds frontend tests for saved-event-log encoding/upload behavior.
frontend/​__tests__/​test/​result-save-failure.spec.ts Adds tests for centralized save-failure mapping and retry/message rules.
frontend/​__tests__/​test/​engine/​events/​stats.spec.ts Updates stats event tests to align with shared event-log types/imports.
frontend/​__tests__/​test/​engine/​events/​helpers.spec.ts Updates event helper tests for the shared event-log imports.
frontend/​__tests__/​test/​engine/​events/​data.spec.ts Updates event data tests to use the new shared event-log types.
frontend/​__tests__/​input/​handlers/​insert-text.spec.ts Updates insert-text handler tests to use shared input-type unions.
docs/​specs/​saved-event-log/​spec.md Adds the specification for the saved event log feature, formats, and rollout plan.
backend/​src/​services/​user-deletion.ts Ensures saved event logs are deleted during account deletion workflows.
backend/​src/​server.ts Adds server startup initialization for event log storage (including indexes).
backend/​src/​dal/​event-logs.ts Introduces a DAL for saving, retrieving, and deleting saved event logs with conditional upsert behavior.
backend/​src/​constants/​monkey-status-codes.ts Adds new status codes used for saved-event-log validation/requirements.
backend/​src/​constants/​base-configuration.ts Adds default configuration values and admin-facing config fields for saved event logs.
backend/​src/​api/​routes/​admin.ts Wires a new admin route for fetching saved event logs by user id.
backend/​src/​api/​controllers/​user.ts Adds saved event log cleanup to user reset/clear-PB flows.
backend/​src/​api/​controllers/​result.ts Validates/requires event logs per configuration and stores the fastest qualifying saved log on result submission.
backend/​src/​api/​controllers/​admin.ts Implements the admin endpoint to read, decompress, validate, and return saved event logs.
backend/​src/​anticheat/​index.ts Adds a validateEventLog entry point used by the saved-event-log flow.
backend/​package.json Adds @monkeytype/event-log as a backend dependency.
backend/​__tests__/​api/​controllers/​user.spec.ts Updates controller tests to assert saved event logs are deleted in relevant user flows.
backend/​__tests__/​api/​controllers/​result.spec.ts Adds tests covering result submission behavior with optional/required saved event logs.
backend/​__tests__/​api/​controllers/​admin.spec.ts Adds tests for the admin saved-event-log fetch endpoint behavior and edge cases.
backend/​__tests__/​__integration__/​dal/​event-logs.spec.ts Adds integration tests for the event logs DAL behavior (requires Docker).

Review effort: Balanced
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.

Comment on lines +1 to +7
{
"ignorePatterns": ["node_modules", "dist", ".turbo"],
"extends": [
"../oxlint-config/index.jsonc"
// "@monkeytype/oxlint-config"
]
}
Comment thread turbo.json
Comment on lines +5 to +6
// one persistent dev task per package, plus frontend and backend
"concurrency": "20",
Comment thread packages/event-log/src/v2/types.ts Outdated
Comment on lines +11 to +16
/**
* Same as V1, but ach event's `testMs` is replaced by `deltaCentiMs`,
* the integer time since the previous event in hundredths of a ms (the first
* one's since test start, so it can be negative). Repeating deltas compress far
* better than absolute timestamps.
*/
@Miodec
Miodec force-pushed the feat/saved-event-log branch from 17c5b90 to 2f8fb6e Compare December 1, 2026 19:38
@github-actions github-actions Bot removed the waiting for update Pull requests or issues that require changes/comments before continuing label Dec 1, 2026
@Miodec
Miodec force-pushed the feat/saved-event-log branch from 2f8fb6e to ac5326f Compare December 1, 2026 19:54
@Miodec
Miodec changed the base branch from master to feat/event-log-v2 December 1, 2026 19:54
@monkeytypegeorge monkeytypegeorge removed the local dev Related to the build process or dependencies label Dec 1, 2026
Miodec and others added 3 commits December 1, 2026 22:55
Adds the eligibility check to @monkeytype/event-log. Qualifying results upload a gzipped v2 log, validated by
anticheat and kept per user when faster. Admin endpoint reads it back.
Config results.savedEventLog {enabled, required, minWpm}.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Miodec)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Miodec
Miodec force-pushed the feat/saved-event-log branch from ac5326f to d11a0b2 Compare December 1, 2026 22:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api A change to the Application Programming Interface (API) backend Server stuff docs Related to Markdown files and documentation force-ci Force CI to run on draft PRs frontend User interface or web stuff packages Changes in local packages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants