From 38f6197732b4365d81207480c845c3194595d625 Mon Sep 17 00:00:00 2001 From: morgan Date: Thu, 16 Jan 2025 09:41:41 +0100 Subject: [PATCH] Add new sentry tags --- _dev/global.d.ts | 2 ++ _dev/jest.setup.ts | 4 +++- _dev/src/ts/api/sentryApi.ts | 8 ++++++-- classes/Analytics.php | 5 +++++ controllers/admin/AdminSelfUpgradeController.php | 3 +++ 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/_dev/global.d.ts b/_dev/global.d.ts index 132e92195..c67ce24c2 100644 --- a/_dev/global.d.ts +++ b/_dev/global.d.ts @@ -6,6 +6,8 @@ interface AutoUpgradeVariables { admin_dir: string; stepper_parent_id: string; module_version: string; + php_version: string; + anonymous_id: string; } declare global { diff --git a/_dev/jest.setup.ts b/_dev/jest.setup.ts index c65b6d285..e9a7b2b5b 100644 --- a/_dev/jest.setup.ts +++ b/_dev/jest.setup.ts @@ -4,7 +4,9 @@ window.AutoUpgradeVariables = { admin_url: 'http://localhost', admin_dir: '/admin_directory', stepper_parent_id: 'stepper_content', - module_version: '7.1.0' + module_version: '7.1.0', + anonymous_id: 'b168a116d1a14fda8c21a22c7560fa27ade7dae22641ce9d773be680640dac0f', + php_version: '7.4.33' }; beforeAll(() => {}); diff --git a/_dev/src/ts/api/sentryApi.ts b/_dev/src/ts/api/sentryApi.ts index 879c7c70a..9182b7b99 100644 --- a/_dev/src/ts/api/sentryApi.ts +++ b/_dev/src/ts/api/sentryApi.ts @@ -70,7 +70,9 @@ export function sendUserFeedback( level, tags: { url: maskedUrl, - source: feedbackModalTag + source: feedbackModalTag, + phpVersion: window.AutoUpgradeVariables.php_version, + anonymousId: window.AutoUpgradeVariables.anonymous_id } }); @@ -85,7 +87,9 @@ export function sendUserFeedback( captureContext: { tags: { url: maskedUrl, - source: feedbackModalTag + source: feedbackModalTag, + phpVersion: window.AutoUpgradeVariables.php_version, + anonymousId: window.AutoUpgradeVariables.anonymous_id } } } diff --git a/classes/Analytics.php b/classes/Analytics.php index 97502332c..3a5bce11a 100644 --- a/classes/Analytics.php +++ b/classes/Analytics.php @@ -164,4 +164,9 @@ private function hasOptedOut(): bool return isset($_SERVER[self::URL_TRACKING_ENV_NAME]) && ((bool) $_SERVER[self::URL_TRACKING_ENV_NAME] === false || $_SERVER[self::URL_TRACKING_ENV_NAME] === 'false'); } + + public function getAnonymousId(): string + { + return $this->anonymousId; + } } diff --git a/controllers/admin/AdminSelfUpgradeController.php b/controllers/admin/AdminSelfUpgradeController.php index 808c74d4e..b8e763b4d 100644 --- a/controllers/admin/AdminSelfUpgradeController.php +++ b/controllers/admin/AdminSelfUpgradeController.php @@ -31,6 +31,7 @@ use PrestaShop\Module\AutoUpgrade\Tools14; use PrestaShop\Module\AutoUpgrade\UpgradeContainer; use PrestaShop\Module\AutoUpgrade\UpgradePage; +use PrestaShop\Module\AutoUpgrade\VersionUtils; use Symfony\Component\HttpFoundation\Request; class AdminSelfUpgradeController extends ModuleAdminController @@ -531,6 +532,8 @@ private function getScriptsVariables() 'admin_dir' => $adminDir, 'stepper_parent_id' => \PrestaShop\Module\AutoUpgrade\Twig\PageSelectors::STEPPER_PARENT_ID, 'module_version' => $this->module->version, + 'php_version' => VersionUtils::getHumanReadableVersionOf(PHP_VERSION_ID), + 'anonymous_id' => $this->upgradeContainer->getAnalytics()->getAnonymousId(), ]; }