diff --git a/README.md b/README.md index 417903d..d7ac91e 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,17 @@ Currently VS Code extensions don't support getting file/project names for non-ed This extension requires ActivityWatch to be running on your machine. +## VS Code-compatible editors + +When this extension runs in VS Code-compatible editors, it uses a distinct +ActivityWatch client and bucket name for each known editor so their activity +streams do not overlap: + +- VS Code: `aw-watcher-vscode` +- VSCodium: `aw-watcher-vscodium` +- Cursor: `aw-watcher-cursor` +- Antigravity: `aw-watcher-antigravity` + ## Install Instructions To install this extension, search for aw-watcher-vscode in the Extensions sidebar in VS Code, and install the one with ActivityWatch as the publisher name. And that's it, if Activity Watch was running, it should detect this vs-code watcher automatically. Give it some time to have some data to display and it should show in the ActivityWatch Timeline and Activity sections soon. diff --git a/src/extension.ts b/src/extension.ts index b54452b..550462c 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -1,6 +1,6 @@ // The module 'vscode' contains the VS Code extensibility API // Import the necessary extensibility types to use in your code below -import { Disposable, ExtensionContext, commands, window, workspace, Uri, Extension, extensions } from 'vscode'; +import { Disposable, ExtensionContext, commands, window, workspace, Uri, Extension, extensions, env } from 'vscode'; import { AWClient, IAppEditorEvent } from '../aw-client-js/src/aw-client'; import { hostname } from 'os'; import { API, GitExtension } from './git'; @@ -20,6 +20,22 @@ export function activate(context: ExtensionContext) { context.subscriptions.push(reloadCommand); } +function activityWatchClientName(): string { + const appName = env.appName.toLowerCase(); + + if (appName.includes('cursor')) { + return 'aw-watcher-cursor'; + } + if (appName.includes('antigravity')) { + return 'aw-watcher-antigravity'; + } + if (appName.includes('codium')) { + return 'aw-watcher-vscodium'; + } + + return 'aw-watcher-vscode'; +} + class ActivityWatch { private _disposable: Disposable; private _client: AWClient; @@ -45,7 +61,7 @@ class ActivityWatch { this._bucket = { id: '', hostName: hostname(), - clientName: 'aw-watcher-vscode', + clientName: activityWatchClientName(), eventType: 'app.editor.activity' }; this._bucket.id = `${this._bucket.clientName}_${this._bucket.hostName}`;