@@ -12,10 +12,10 @@ import { cryptoRandomObjectId } from '@apify/utilities';
1212import { ApifyCommand } from '../lib/command-framework/apify-command.js' ;
1313import { Flags } from '../lib/command-framework/flags.js' ;
1414import { AUTH_FILE_PATH } from '../lib/consts.js' ;
15+ import { updateUserId } from '../lib/hooks/telemetry/useTelemetryState.js' ;
1516import { useMaskedInput } from '../lib/hooks/user-confirmations/useMaskedInput.js' ;
1617import { useSelectFromList } from '../lib/hooks/user-confirmations/useSelectFromList.js' ;
1718import { error , info , success } from '../lib/outputs.js' ;
18- import { useApifyIdentity } from '../lib/telemetry.js' ;
1919import { getLocalUserInfo , getLoggedClient } from '../lib/utils.js' ;
2020
2121const CONSOLE_BASE_URL = 'https://console.apify.com/settings/integrations' ;
@@ -30,8 +30,10 @@ const API_VERSION = 'v1';
3030const tryToLogin = async ( token : string ) => {
3131 const isUserLogged = await getLoggedClient ( token , API_BASE_URL ) ;
3232 const userInfo = await getLocalUserInfo ( ) ;
33+
3334 if ( isUserLogged ) {
34- await useApifyIdentity ( userInfo . id ! ) ;
35+ await updateUserId ( userInfo . id ! ) ;
36+
3537 success ( {
3638 message : `You are logged in to Apify as ${ userInfo . username || userInfo . id } . ${ chalk . gray ( `Your token is stored at ${ AUTH_FILE_PATH ( ) } .` ) } ` ,
3739 } ) ;
@@ -67,6 +69,7 @@ export class LoginCommand extends ApifyCommand<typeof LoginCommand> {
6769
6870 async run ( ) {
6971 const { token, method } = this . flags ;
72+
7073 if ( token ) {
7174 await tryToLogin ( token ) ;
7275 return ;
0 commit comments