Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,26 @@
"type": "object",
"title": "aw-watcher-vscode extension configuration",
"properties": {
"aw-watcher-vscode.host": {
"type": "string",
"default": "",
"description": "ActivityWatch server hostname. Leave empty for localhost."
},
"aw-watcher-vscode.port": {
"type": "number",
"default": 0,
"description": "ActivityWatch server port. Set to 0 for default (5600)."
},
"aw-watcher-vscode.authUser": {
"type": "string",
"default": "",
"description": "Username for HTTP Basic Auth (for nginx-proxied servers)."
},
"aw-watcher-vscode.authPassword": {
"type": "string",
"default": "",
"description": "Password for HTTP Basic Auth (for nginx-proxied servers)."
},
"aw-watcher-vscode.maxHeartbeatsPerSec": {
"type": "number",
"default": 1,
Expand Down
22 changes: 21 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,28 @@ class ActivityWatch {
};
this._bucket.id = `${this._bucket.clientName}_${this._bucket.hostName}`;

// Read server configuration
const extConfig = workspace.getConfiguration('aw-watcher-vscode');
const host = extConfig.get<string>('host') || '';
const port = extConfig.get<number>('port') || 0;
const authUser = extConfig.get<string>('authUser') || '';
const authPassword = extConfig.get<string>('authPassword') || '';

// Build client options
const clientOptions: any = { testing: false };
if (host) {
const effectivePort = port || 5600;
clientOptions.baseURL = `http://${host}:${effectivePort}`;
}

// Create AWClient
this._client = new AWClient(this._bucket.clientName, { testing: false });
this._client = new AWClient(this._bucket.clientName, clientOptions);

// Inject Basic Auth into axios instance if configured
if (authUser && authPassword) {
const token = Buffer.from(`${authUser}:${authPassword}`).toString('base64');
this._client.req.defaults.headers.common['Authorization'] = `Basic ${token}`;
}

// subscribe to VS Code Events
let subscriptions: Disposable[] = [];
Expand Down