diff --git a/src/auth/authentication-provider/auth-process.ts b/src/auth/authentication-provider/auth-process.ts index a683b4c7..fac1c7b8 100644 --- a/src/auth/authentication-provider/auth-process.ts +++ b/src/auth/authentication-provider/auth-process.ts @@ -2,6 +2,8 @@ import { ProgressLocation, window } from 'vscode' import { authMessage } from '../messages' import { userManagementClient } from '../../features/user-management/userManagementClient' import { validateEmail, validateOTP } from './validators' +import { credentialsVault } from '../../config/credentialsVault' +import { telemetryHelpers } from '../../features/telemetry/telemetryHelpers' type AuthProcessOutput = { id: string @@ -73,7 +75,9 @@ export const executeAuthProcess = async ({ }) }, ) - + credentialsVault.setTimeStamp() + if (isSignUp) telemetryHelpers.trackCommand('affinidi.signUp.completed') + else telemetryHelpers.trackCommand('affinidi.login.completed') const { userId } = parseJwt(consoleAuthToken) return { email, id: userId, accessToken: consoleAuthToken } diff --git a/src/auth/init-authentication.ts b/src/auth/init-authentication.ts index 46d928b8..c29e9d9a 100644 --- a/src/auth/init-authentication.ts +++ b/src/auth/init-authentication.ts @@ -38,7 +38,6 @@ async function signUpHandler(): Promise { window.showInformationMessage(authMessage.signedUp) ext.outputChannel.appendLine(authMessage.signedUp) - await iamHelpers.createDefaultProject() cliHelper.suggestInstallingCLI() @@ -60,7 +59,6 @@ async function loginHandler(): Promise { await authentication.getSession(AUTH_PROVIDER_ID, ['login'], { forceNewSession: true, }) - window.showInformationMessage(authMessage.loggedIn) ext.outputChannel.appendLine(authMessage.loggedIn) cliHelper.suggestInstallingCLI() diff --git a/src/config/credentialsVault.ts b/src/config/credentialsVault.ts index 8b97998e..229d4281 100644 --- a/src/config/credentialsVault.ts +++ b/src/config/credentialsVault.ts @@ -11,6 +11,7 @@ export type ConfigType = { env?: Environment activeProjectSummary?: ProjectSummary session?: Session + timeStamp?: number } export type Session = { @@ -68,6 +69,14 @@ class CredentialsVault { onSessionChange(callback: OnDidChangeCallback) { return this.store.onDidChange('session', callback) } + + getTimeStamp(): number | undefined { + return this.store.get('timeStamp') + } + + setTimeStamp() { + this.store.set('timeStamp', Date.now()) + } } const credentialConf = new Conf({ diff --git a/src/config/validateVaultFiles.ts b/src/config/validateVaultFiles.ts index e02bafdb..cc383f70 100644 --- a/src/config/validateVaultFiles.ts +++ b/src/config/validateVaultFiles.ts @@ -41,6 +41,12 @@ const configInlogin = z.object({ configs: z.record(z.optional(z.object({ activeProjectId: z.string() }))).optional(), }) +function clearVault() { + credentialsVault.clear() + configVault.clear() + + window.showErrorMessage(configMessage.invalidConfigFiles) +} export function validateConfig() { const isConfigValid = isValidObject(configInlogin, configVault.getObject()) @@ -57,10 +63,3 @@ export function validateConfigAndCredentials() { clearVault() } } - -function clearVault() { - credentialsVault.clear() - configVault.clear() - - window.showErrorMessage(configMessage.invalidConfigFiles) -} diff --git a/src/generators/initGenerators.ts b/src/generators/initGenerators.ts index 50b2c538..2a78ef4d 100644 --- a/src/generators/initGenerators.ts +++ b/src/generators/initGenerators.ts @@ -1,20 +1,28 @@ import { commands } from 'vscode' + import { ext } from '../extensionVariables' import { telemetryHelpers } from '../features/telemetry/telemetryHelpers' import { generateAffinidiAppWithCLI } from './create-app/generator' import { labels } from '../tree/messages' import { DevToolsTreeItem } from '../tree/devToolsTreeItem' +import { credentialsVault } from '../config/credentialsVault' export const initGenerators = () => { ext.context.subscriptions.push( commands.registerCommand('affinidi.codegen.app', async (element: DevToolsTreeItem) => { telemetryHelpers.trackCommand('affinidi.codegen.app') - - await generateAffinidiAppWithCLI( + const reffAppName = element?.label?.toString() === labels.portableReputation ? 'portable-reputation' - : 'certification-and-verification', - ) + : 'certification-and-verification' + + const timeStamp = credentialsVault.getTimeStamp() + await generateAffinidiAppWithCLI(reffAppName) + + telemetryHelpers.trackCommand('affinidi.codegen.app.completed', { + timeTaken: timeStamp ? Math.floor((Date.now() - timeStamp) / 1000) : 0, + referenceApp: reffAppName, + }) }), ) }