From dcfd907f81dceb7c54695d6f288a501620a4baa8 Mon Sep 17 00:00:00 2001 From: Altamash Shaikh Date: Wed, 29 Jan 2025 09:39:27 +0530 Subject: [PATCH] Handles site deletion edge case, #PG-4108 --- CHANGELOG.md | 3 +++ Commands/ImportGA4Reports.php | 9 ++++++--- plugin.json | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9564b6bc..3e704176 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ ## Changelog +# 5.1.1 - 2025-02-03 +- Handled an edge case to delete the import if website is deleted + # 5.1.0 - 2025-01-20 - Added code to make GA4 imports work with a proxy - Added missing license file diff --git a/Commands/ImportGA4Reports.php b/Commands/ImportGA4Reports.php index 1d14efec..e5bb25f7 100644 --- a/Commands/ImportGA4Reports.php +++ b/Commands/ImportGA4Reports.php @@ -109,9 +109,12 @@ protected function executeImpl(): int $gaClient = $googleAuth->getClient(); $gaAdminClient = $googleAuth->getAdminClient(); } catch (\Exception $ex) { - $output->writeln(LogToSingleFileProcessor::$cliOutputPrefix . "Cannot continue with import, client is misconfigured: " . $ex->getMessage()); - if (!empty($idSite)) { - $importStatus->erroredImport($idSite, $ex->getMessage()); + $errorMessage = $ex->getMessage(); + $output->writeln(LogToSingleFileProcessor::$cliOutputPrefix . "Cannot continue with import, client is misconfigured: " . $errorMessage); + if ($idSite && stripos($errorMessage, 'an unexpected website was found in the request') !== false) { + $importStatus->deleteStatus($idSite); + } elseif (!empty($idSite)) { + $importStatus->erroredImport($idSite, $errorMessage); } return self::FAILURE; } diff --git a/plugin.json b/plugin.json index 48b7a1b2..b374fcc7 100644 --- a/plugin.json +++ b/plugin.json @@ -1,7 +1,7 @@ { "name": "GoogleAnalyticsImporter", "description": "Import reports from a Google Analytics account into Matomo.", - "version": "5.1.0", + "version": "5.1.1", "theme": false, "require": { "matomo": ">=5.0.0-rc5,<6.0.0-b1"