Connection logs now record how a connection was made (`connection_method`) separately from which app made it (`app_name`). Storage, the HTTP API, search filters, and the UI move to the new fields. Legacy agent reports and the deprecated `type` field keep working. - Add `connection_method` (`ssh`, `reconnecting_pty`, `workspace_app`, `port_forwarding`, `tunnel`) and optional `app_name` and `app_display_name` to `GET /api/v2/connectionlog`. Deprecate `type` and make it a plain string in the API and the Go SDK. - Add `method:` and repeatable `app:` search filters. `type:` keeps its old results but can't be combined with the new filters. - Replace the Type menu with a Method menu, show the app next to the method in each row, and warn when a filter uses `type:`. - Change the Active SSH connections preset to `method:ssh`, so it also includes SSH sessions from VS Code and JetBrains apps. - Generate `codersdk.ConnectionLogMethod` from the database enum with `typegen dbenums`. - Migration 000617 rewrites `connection_logs` under an ACCESS EXCLUSIVE lock, which takes about 50 seconds for 10 million rows. `vscode` and `jetbrains` rows become `ssh` rows with that app. Rolling back folds apps into the old types and loses per-app names. - Document the new filters and how to replace each `type:` value. Closes #27412
38 lines
1.6 KiB
SQL
38 lines
1.6 KiB
SQL
CREATE TYPE connection_type AS ENUM (
|
|
'ssh', 'vscode', 'jetbrains', 'reconnecting_pty',
|
|
'workspace_app', 'port_forwarding', 'tunnel'
|
|
);
|
|
|
|
-- App names collapse to the historical SSH families on rollback.
|
|
ALTER TABLE connection_logs
|
|
ALTER COLUMN app_name_or_port TYPE text USING (
|
|
CASE
|
|
WHEN connection_method IN ('ssh', 'reconnecting_pty', 'tunnel') THEN NULL
|
|
ELSE app_name_or_port
|
|
END
|
|
),
|
|
ALTER COLUMN connection_method TYPE connection_type USING (
|
|
CASE
|
|
WHEN connection_method != 'ssh' THEN connection_method::text
|
|
-- Snapshot of the VS Code and JetBrains families in
|
|
-- codersdk/appname.go. Apps registered later roll back to ssh.
|
|
WHEN app_name_or_port IN (
|
|
'vscode', 'vscode_insiders', 'vscode_web', 'code_server', 'cursor',
|
|
'windsurf', 'positron', 'vscodium', 'codium', 'antigravity', 'trae',
|
|
'kiro', 'devin', 'code_oss', 'vscodium_insiders', 'devin_next', 'trae_cn'
|
|
) THEN 'vscode'
|
|
WHEN app_name_or_port IN (
|
|
'jetbrains', 'intellij', 'pycharm', 'goland', 'webstorm', 'phpstorm',
|
|
'rubymine', 'clion', 'rider', 'rustrover', 'datagrip', 'dataspell',
|
|
'mps', 'android_studio'
|
|
) THEN 'jetbrains'
|
|
ELSE 'ssh'
|
|
END
|
|
)::connection_type;
|
|
|
|
COMMENT ON COLUMN connection_logs.connection_method IS NULL;
|
|
COMMENT ON COLUMN connection_logs.app_name_or_port IS 'Null for SSH events. For web connections, this is the slug of the app or the port number being forwarded.';
|
|
ALTER TABLE connection_logs RENAME COLUMN app_name_or_port TO slug_or_port;
|
|
ALTER TABLE connection_logs RENAME COLUMN connection_method TO type;
|
|
DROP TYPE connection_log_method;
|