await callWithTelemetryAndErrorHandling()

in src/login/AzureLoginHelper.ts [96:144]


		await callWithTelemetryAndErrorHandling('azure-account.login', async (context: IActionContext) => {
			let codePath: CodePath = 'newLogin';
			let environmentName: string = 'uninitialized';
			const cancelSource: CancellationTokenSource = new CancellationTokenSource();
			try {
				const environment: Environment = await getSelectedEnvironment();
				environmentName = environment.name;
				const onlineTask: Promise<void> = waitUntilOnline(environment, 2000, cancelSource.token);
				const timerTask: Promise<boolean | PromiseLike<boolean> | undefined> = delay(2000, true);

				if (await Promise.race([onlineTask, timerTask])) {
					const cancel: MessageItem = { title: localize('azure-account.cancel', "Cancel") };
					await Promise.race([
						onlineTask,
						window.showInformationMessage(localize('azure-account.checkNetwork', "You appear to be offline. Please check your network connection."), cancel)
							.then(result => {
								if (result === cancel) {
									throw new AzureLoginError(localize('azure-account.offline', "Offline"));
								}
							})
					]);
					await onlineTask;
				}

				this.beginLoggingIn();

				const tenantId: string = getSettingValue(tenantSetting) || commonTenantId;
				const isAdfs: boolean = isADFS(environment);
				const useCodeFlow: boolean = trigger !== 'loginWithDeviceCode' && await checkRedirectServer(isAdfs);
				codePath = useCodeFlow ? 'newLoginCodeFlow' : 'newLoginDeviceCode';
				const loginResult = useCodeFlow ?
					await this.authProvider.login(clientId, environment, isAdfs, tenantId, openUri, redirectTimeout) :
					await this.authProvider.loginWithDeviceCode(environment, tenantId);
				await this.updateSessions(this.authProvider, environment, loginResult);
				void this.sendLoginTelemetry(context, { trigger, codePath, environmentName, outcome: 'success' }, true);
			} catch (err) {
				if (err instanceof AzureLoginError && err.reason) {
					ext.outputChannel.appendLog(err.reason);
					void this.sendLoginTelemetry(context, { trigger, codePath, environmentName, outcome: 'error', message: getErrorMessage(err.reason) || getErrorMessage(err) });
				} else {
					void this.sendLoginTelemetry(context, { trigger, codePath, environmentName, outcome: 'failure', message: getErrorMessage(err) });
				}
				throw err;
			} finally {
				cancelSource.cancel();
				cancelSource.dispose();
				this.updateLoginStatus();
			}
		});