From 6abca6fffebd9c164ffb802ca473ae57f721ed10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=AE=B8=E6=96=87=E6=B6=9B?= Date: Tue, 15 Sep 2020 11:27:57 +0800 Subject: [PATCH] fix: get user info (#544) * fix: get user info * chore: using en * style: lint --- extensions/iceworks-time-steward/package.json | 2 +- extensions/iceworks-time-steward/src/index.ts | 2 +- extensions/iceworks-time-steward/src/timer.ts | 14 +++++++++++--- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/extensions/iceworks-time-steward/package.json b/extensions/iceworks-time-steward/package.json index 04e738bee..a2bb7262a 100644 --- a/extensions/iceworks-time-steward/package.json +++ b/extensions/iceworks-time-steward/package.json @@ -3,7 +3,7 @@ "displayName": "Iceworks Time Steward(Beta)", "description": "Metrics, insights, and time tracking automatically generated from your programming activity.", "publisher": "iceworks-team", - "version": "0.1.0", + "version": "0.1.1", "engines": { "vscode": "^1.41.0" }, diff --git a/extensions/iceworks-time-steward/src/index.ts b/extensions/iceworks-time-steward/src/index.ts index 212245a0a..437ee9381 100644 --- a/extensions/iceworks-time-steward/src/index.ts +++ b/extensions/iceworks-time-steward/src/index.ts @@ -6,7 +6,7 @@ let timer: Timer; export async function activate() { console.info('start timer'); - let user = { name: vscode.env.machineId }; + let user = { empId: vscode.env.machineId, account: 'anonymous' }; const isAliInternal = await checkIsAliInternal(); if (isAliInternal) { diff --git a/extensions/iceworks-time-steward/src/timer.ts b/extensions/iceworks-time-steward/src/timer.ts index 4edf9d694..0ad14eabe 100755 --- a/extensions/iceworks-time-steward/src/timer.ts +++ b/extensions/iceworks-time-steward/src/timer.ts @@ -14,7 +14,7 @@ export class Timer { private lastHeartbeat: number = 0; - private user; + private user: { empId: string; account: string }; constructor(user) { this.user = user; @@ -79,15 +79,17 @@ export class Timer { if (isWrite || enoughTimePassed || this.lastFile !== file) { const project = this.getProjectName(file); const subTime = time - this.lastHeartbeat; - const { name } = this.user; + const { account, empId } = this.user; if (this.lastHeartbeat !== 0) { recorder.record({ module: 'main', action: 'tracking', data: { - user: name, + userName: account, + userId: empId, timestamp: subTime, project, + version, }, }); } @@ -104,6 +106,12 @@ export class Timer { return this.lastHeartbeat + 120000 < time; } + /** + * Priority: + * - TODO: Git's group/project + * - package.json's name + * - Folder name + */ private getProjectName(file: string): string { const uri = vscode.Uri.file(file); const workspaceFolder = vscode.workspace.getWorkspaceFolder(uri);