This repository runs a lightweight Python proxy that mirrors the CodeTime client endpoints, logs every request/response pair with ANSI colors, and forwards the traffic to https://api.codetime.dev.
- Create a virtual environment (optional but recommended):
python -m venv .venv
- Activate the virtual environment and install dependencies:
pip install -r requirements.txt
- Copy
.env.exampleto.envand set yourPG_URLplus any overrides (CODETIME_UPSTREAM,CODETIME_LOG_DIR):cp .env.example .env
Start the proxy with Uvicorn. By default it listens on port 9492:
uvicorn proxy:app --host 0.0.0.0 --port 9492Or run the module directly; it will launch Uvicorn for you using the same defaults:
python proxy.pyPoint your CodeTime client (or a curl command) at http://localhost:9492 followed by the usual /v3/... path. The proxy forwards every request to https://api.codetime.dev (or the upstream override) and streams the response back to the client.
- All requests/responses are printed to the terminal with ANSI colors (cyan for requests, green for responses).
- Every interaction is persisted to
logs/traffic.jsonl(one JSON object per line) and is tagged with arow_hash. - When
PG_URLis defined in your.env, the proxy also inserts each entry (including theAuthorizationheader) into thecodetime_entriestable (saved asauth_header).
- Set
CODETIME_UPSTREAMto override the target host (defaults tohttps://api.codetime.dev). - Set
CODETIME_LOG_DIRto change where the JSON log file is written (logs/by default). - Set
PG_URLvia.envto enable Postgres inserts. - Set
CODETIME_PORT(orPORT) if you want a different port when runningpython proxy.py.
- Run
psql -f create_table.sqlto create thecodetime_entriestable before starting the proxy (it now stores headers/body asJSONplus extracted metadata includinglanguage). - Each row stores the JSON payload plus HTTP metadata and enforces uniqueness via
row_hash. The table now capturesclient_ip,user_agent,windows_username,file_extension,operation_type,git_branch,project,editor,platform,event_time,absolute_filepath, andevent_type. - Known event types logged in
event_type:activateFileChangededitorChangedfileSavedfileAddedLinefileCreatedfileEditedchangeEditorSelectionchangeEditorVisibleRanges
- Proxy (Python):
pip install -r requirements-dev.txtthenpython -m pytest tests/ -v - Zed extension (Rust):
cd extensions/zed && cargo test - VS Code extension:
cd extensions/vscode && npm install && npm test - Neovim stub (Lua): from repo root,
lua extensions/nvim/spec/test_init_spec.lua(requires Lua 5.1+)
- The proxy implements the GET
/v3/users/self/minutesand POST/v3/users/event-logpaths (among others) because it captures everything and forwards it transparently. - This setup can be extended with extra filters or saved analytics as needed.
- The proxy only forwards requests whose
User-AgentincludesCodeTime Client; other requests return403immediately.