From 736a9caf405799f90c6869b411fa367d1bbc37fa Mon Sep 17 00:00:00 2001 From: Sarosh Aga Date: Fri, 26 Jan 2024 19:41:36 +0530 Subject: [PATCH] Add event tracking for PMA enable failures (#1667) * Add event tracking for PMA enable failures * Refactor * Bring back empty line * Print progress steps properly on error scenarios --------- Co-authored-by: Ahmed Sayeed Wasif --- src/commands/phpmyadmin.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/commands/phpmyadmin.ts b/src/commands/phpmyadmin.ts index 5bb580a7b8..7dd9ab7b36 100644 --- a/src/commands/phpmyadmin.ts +++ b/src/commands/phpmyadmin.ts @@ -133,7 +133,7 @@ export class PhpMyAdminCommand { this.env = env; this.track = trackerFn; this.progressTracker = new ProgressTracker( [ - { id: this.steps.ENABLE, name: 'Enabling PHPMyAdmin for this site' }, + { id: this.steps.ENABLE, name: 'Enabling PHPMyAdmin for this environment' }, { id: this.steps.GENERATE, name: 'Generating access link' }, ] ); } @@ -198,6 +198,15 @@ export class PhpMyAdminCommand { this.progressTracker.stepSuccess( this.steps.ENABLE ); } catch ( err ) { this.progressTracker.stepFailed( this.steps.ENABLE ); + const error = err as Error & { + graphQLErrors?: GraphQLFormattedError[]; + }; + void this.track( 'error', { + error_type: 'enable_pma', + error_message: error.message, + stack: error.stack, + } ); + this.stopProgressTracker(); exit.withError( 'Failed to enable PhpMyAdmin' ); } @@ -216,6 +225,7 @@ export class PhpMyAdminCommand { error_message: error.message, stack: error.stack, } ); + this.stopProgressTracker(); exit.withError( `Failed to generate PhpMyAdmin URL: ${ error.message }` ); }