Skip to content

feat: event log package with a v2 storage format (@miodec) - #8644

Open
Miodec wants to merge 2 commits into
masterfrom
feat/event-log-v2
Open

Miodec wants to merge 2 commits into
masterfrom
feat/event-log-v2

Conversation

@Miodec

@Miodec Miodec commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Summary

Event log types move into a package; adds v2, a storage format for event logs. Nothing writes or reads v2 yet: saving stacks on this (#8643).

 packages/
+└── event-log/          # @monkeytype/event-log
+    ├── events.ts       # event zod schemas, types inferred (moved from frontend engine/events/types.ts)
+    ├── keycode.ts      # moved from frontend constants/keys.ts
+    ├── input-type.ts   # moved from frontend engine/input-type.ts
+    ├── v1/             # runtime format (testMs), schema
+    ├── v2/             # stored format (deltaCentiMs), same event schemas, fromV1/toV1
+    └── convert.ts      # any version → any version, through v1
v2 event: { type, data, deltaCentiMs }
  deltaCentiMs = round(testMs * 100) − previous event's  (first: from test start, can be negative)
toV1: running sum / 100

Also: vite alias for exact package subpaths (./v1), turbo concurrency for the extra dev task.

Evidence

  • event-log tests: 8 pass (v1 and v2 schemas, v1 → v2 → v1 round trip, integer deltas under float noise, schema).
  • frontend engine + input tests: 338 pass; lint and typecheck clean (pre-existing vitest.config.ts warning on master).

Merge Danger

Door: two-way

No runtime behaviour change: frontend imports move to the package.

Blast Radius: imports

Frontend build resolves the new workspace package; a missing alias would break the build, not runtime.

🤖 Generated with Claude Code

Moves the event log types into @monkeytype/event-log and adds v2: events
keep deltaCentiMs (hundredths of a ms since the previous event) instead of
testMs, with convert() between versions and a zod schema.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Copilot AI balanced review requested due to automatic review settings December 1, 2026 19:53
@monkeytypegeorge monkeytypegeorge added frontend User interface or web stuff local dev Related to the build process or dependencies docs Related to Markdown files and documentation 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

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

Approval is blocked because there are still moderate-impact issues to address, including a too-narrow return type in parseEventLogV2 and an invalid concurrency value type in turbo.json, alongside a minor documentation typo.

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

Introduces a new workspace package @monkeytype/event-log to centralize event-log types and add a v2 stored-log format (delta centi-ms) with schema + converters, then updates frontend code/tests to consume the package.

Changes:

  • Add packages/event-log with v1 runtime types, v2 stored format + zod schema, and v1↔v2 conversion utilities plus tests.
  • Rewire frontend and tests to import event-log/keycode/input-type definitions from @monkeytype/event-log/*.
  • Update Vite workspace aliasing for exact package subpaths and adjust repo tooling/config docs.
File Description
turbo.json Updates Turbo configuration to set a concurrency limit for tasks.
pnpm-lock.yaml Updates the lockfile to include the new workspace package and its dependencies.
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 bundling the new package.
packages/​event-log/​tsconfig.json Defines TypeScript compiler settings for building the event-log package.
packages/​event-log/​src/​v2/​types.ts Introduces TypeScript types/constants for the v2 stored event-log format.
packages/​event-log/​src/​v2/​schema.ts Adds a Zod schema and parsing utilities for validating v2 stored logs.
packages/​event-log/​src/​v2/​index.ts Exports the v2 public API surface (types/schema/conversion).
packages/​event-log/​src/​v2/​convert.ts Implements conversion logic between v1 runtime logs and v2 stored logs using delta centi-ms timing.
packages/​event-log/​src/​v1/​index.ts Exports the v1 runtime event-log format and related types.
packages/​event-log/​src/​keycode.ts Moves/defines the shared Keycode type in the new package.
packages/​event-log/​src/​input-type.ts Moves/defines shared input-type unions in the new package.
packages/​event-log/​src/​events.ts Moves/defines the shared event type definitions in the new package.
packages/​event-log/​src/​convert.ts Adds version-agnostic conversion helpers to convert between event-log versions via v1.
packages/​event-log/​package.json Defines the new workspace package metadata, exports map, scripts, and dependencies.
packages/​event-log/​.oxlintrc.json Adds lint configuration for the new event-log package.
packages/​event-log/​__test__/​v2.spec.ts Adds tests covering v2 schema validation behavior.
packages/​event-log/​__test__/​tsconfig.json Adds a TypeScript config tailored for running package tests.
packages/​event-log/​__test__/​fixture.ts Provides shared fixture data for event-log conversion and schema tests.
packages/​event-log/​__test__/​convert.spec.ts Adds tests verifying v1↔v2 conversion round-trips and delta semantics.
GLOSSARY.md Adds or updates glossary documentation related to event logs.
frontend/​vite-plugins/​workspace-packages.ts Updates Vite workspace package aliasing to support exact export subpaths (e.g., ./v1, ./v2).
frontend/​src/​ts/​utils/​layout-key-codes.ts Updates key-code layout utilities to use the package-provided Keycode typing.
frontend/​src/​ts/​utils/​key-converter.ts Switches key conversion utilities to import Keycode from the new package.
frontend/​src/​ts/​test/​words-history.ts Updates words-history test utilities to use event-log types from the package.
frontend/​src/​ts/​test/​shift-tracker.ts Updates shift-tracking logic to use the package Keycode type.
frontend/​src/​ts/​test/​engine/​result-data.ts Updates engine result-data typing to use packaged event-log v1 types.
frontend/​src/​ts/​test/​engine/​input-type.ts Replaces local input-type definitions with imports from @monkeytype/event-log.
frontend/​src/​ts/​test/​engine/​events/​stats.ts Updates stats event processing typings/imports to consume packaged event-log types.
frontend/​src/​ts/​test/​engine/​events/​live-cache.ts Updates live-cache event typings to use packaged event types.
frontend/​src/​ts/​test/​engine/​events/​helpers.ts Updates helper typings/imports to use packaged event definitions.
frontend/​src/​ts/​test/​engine/​events/​data.ts Updates event test data and typings to use @monkeytype/event-log exports.
frontend/​src/​ts/​states/​monkey.ts Updates application state typing to use packaged Keycode where relevant.
frontend/​src/​ts/​states/​event-log-viewer.ts Updates event-log viewer state typing to use the new package event-log definitions.
frontend/​src/​ts/​input/​helpers/​word-navigation.ts Updates word-navigation helper typing to use packaged delete/input-type unions.
frontend/​src/​ts/​input/​helpers/​test-event-code.ts Updates test-event code helpers to use packaged Keycode typing.
frontend/​src/​ts/​input/​handlers/​keydown.ts Updates keydown handler typings/imports to use @monkeytype/event-log key/event types.
frontend/​src/​ts/​input/​handlers/​insert-text.ts Updates insert-text handler typings/imports to use packaged input-type definitions.
frontend/​src/​ts/​input/​handlers/​delete.ts Updates delete handler typings/imports to use packaged input-type definitions.
frontend/​src/​ts/​constants/​keys.ts Refactors key constants/types to rely on the shared package Keycode typing.
frontend/​src/​ts/​components/​pages/​test/​result/​ResultWordsHistory.tsx Updates result words-history component prop/data typing to use packaged event-log types.
frontend/​src/​ts/​components/​pages/​test/​result/​ResultMainStats.tsx Updates result main-stats component typing to use packaged event-log types.
frontend/​src/​ts/​components/​pages/​test/​result/​ResultChart.tsx Updates result chart component typing to use packaged event-log types.
frontend/​src/​ts/​components/​pages/​test/​result/​replay.ts Updates replay logic typing to use packaged event-log types.
frontend/​src/​ts/​components/​pages/​event-log-viewer/​EventLogViewerPage.tsx Updates the event-log viewer page to use packaged event-log types and constants.
frontend/​package.json Adds @monkeytype/event-log as a frontend dependency.
frontend/​__tests__/​test/​engine/​events/​stats.spec.ts Updates stats-related engine tests to import event-log types from the new package.
frontend/​__tests__/​test/​engine/​events/​helpers.spec.ts Updates engine helper tests to import event/input types from the new package.
frontend/​__tests__/​test/​engine/​events/​data.spec.ts Updates engine event data tests to import event/keycode types from the new package.
frontend/​__tests__/​input/​handlers/​insert-text.spec.ts Updates insert-text handler tests to import input/event types from the new package.

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

Comment thread packages/event-log/src/v2/schema.ts Resolved
Comment thread turbo.json Resolved
Comment thread packages/event-log/src/v2/types.ts Resolved
v1 events and context are zod schemas now, types are inferred from them.
v2 reuses the same event definitions with deltaCentiMs instead of testMs,
so the two versions can't drift apart.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Related to Markdown files and documentation frontend User interface or web stuff local dev Related to the build process or dependencies packages Changes in local packages waiting for review Pull requests that require a review before continuing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants