feat: Improve error logging and validation across various flows and utilities

This commit is contained in:
2025-11-09 18:05:43 +01:00
parent 9fb5911fa2
commit 2c55fff61d
8 changed files with 128 additions and 34 deletions

View File

@@ -29,8 +29,23 @@ export class DesktopFlow {
/**
* Execute the full desktop automation flow for an account
* @param account Account to process
* @returns Points collected during the flow
*
* Performs the following tasks in sequence:
* 1. Browser initialization with fingerprinting
* 2. Microsoft account login with 2FA support
* 3. Daily set completion
* 4. More promotions (quizzes, polls, etc.)
* 5. Punch cards
* 6. Desktop searches
*
* @param account Account to process (email, password, totp, proxy)
* @returns Promise resolving to points collected during the flow
* @throws {Error} If critical operation fails (login, browser init)
*
* @example
* const flow = new DesktopFlow(bot)
* const result = await flow.run(account)
* console.log(`Collected ${result.collectedPoints} points`)
*/
async run(account: Account): Promise<DesktopFlowResult> {
this.bot.log(false, 'DESKTOP-FLOW', 'Starting desktop automation flow')
@@ -63,7 +78,10 @@ export class DesktopFlow {
undefined,
0xFFAA00
)
} catch {/* ignore */}
} catch (error) {
const errorMsg = error instanceof Error ? error.message : String(error)
this.bot.log(false, 'DESKTOP-FLOW', `Failed to send security webhook: ${errorMsg}`, 'warn')
}
// Save session for convenience, but do not close the browser
try {

View File

@@ -31,9 +31,24 @@ export class MobileFlow {
/**
* Execute the full mobile automation flow for an account
* @param account Account to process
* @param retryTracker Retry tracker for mobile search failures
* @returns Points collected during the flow
*
* Performs the following tasks in sequence:
* 1. Mobile browser initialization with mobile user agent
* 2. Microsoft account login
* 3. OAuth token acquisition for mobile API access
* 4. Daily check-in via mobile API
* 5. Read to earn articles
* 6. Mobile searches with retry logic
*
* @param account Account to process (email, password, totp, proxy)
* @param retryTracker Retry tracker for mobile search failures (auto-created if not provided)
* @returns Promise resolving to points collected during mobile flow
* @throws {Error} If critical operation fails (login, OAuth)
*
* @example
* const flow = new MobileFlow(bot)
* const result = await flow.run(account)
* console.log(`Mobile: ${result.collectedPoints} points`)
*/
async run(
account: Account,
@@ -69,7 +84,10 @@ export class MobileFlow {
undefined,
0xFFAA00
)
} catch {/* ignore */}
} catch (error) {
const errorMsg = error instanceof Error ? error.message : String(error)
this.bot.log(true, 'MOBILE-FLOW', `Failed to send security webhook: ${errorMsg}`, 'warn')
}
try {
await saveSessionData(this.bot.config.sessionPath, this.bot.homePage.context(), account.email, true)