From 863604de22e22a2fcae4a3f29d32411b58cd0a8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20Fern=C3=A1ndez=20Haro?= Date: Mon, 19 Jun 2023 10:21:50 +0200 Subject: [PATCH] [Telemetry] Update `lastVersionChecked` on banner dismissal --- src/plugins/telemetry/server/routes/index.ts | 2 +- .../server/routes/telemetry_user_has_seen_notice.ts | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/plugins/telemetry/server/routes/index.ts b/src/plugins/telemetry/server/routes/index.ts index 8b73c8d76c4e..5a47b4a00ac1 100644 --- a/src/plugins/telemetry/server/routes/index.ts +++ b/src/plugins/telemetry/server/routes/index.ts @@ -35,6 +35,6 @@ export function registerRoutes(options: RegisterRoutesParams) { registerTelemetryConfigRoutes(options); registerTelemetryUsageStatsRoutes(router, telemetryCollectionManager, isDev, getSecurity); registerTelemetryOptInStatsRoutes(router, telemetryCollectionManager); - registerTelemetryUserHasSeenNotice(router); + registerTelemetryUserHasSeenNotice(router, options.currentKibanaVersion); registerTelemetryLastReported(router, savedObjectsInternalClient$); } diff --git a/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts b/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts index eeac24c0f5a0..d9cb0b981b0a 100644 --- a/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts +++ b/src/plugins/telemetry/server/routes/telemetry_user_has_seen_notice.ts @@ -15,7 +15,7 @@ import { updateTelemetrySavedObject, } from '../saved_objects'; -export function registerTelemetryUserHasSeenNotice(router: IRouter) { +export function registerTelemetryUserHasSeenNotice(router: IRouter, currentKibanaVersion: string) { router.put( { path: '/api/telemetry/v2/userHasSeenNotice', @@ -31,6 +31,9 @@ export function registerTelemetryUserHasSeenNotice(router: IRouter) { const updatedAttributes: TelemetrySavedObjectAttributes = { ...telemetrySavedObject, userHasSeenNotice: true, + // We need to store that the user was notified in this version. + // Otherwise, it'll continuously show the banner if previously opted-out. + lastVersionChecked: currentKibanaVersion, }; await updateTelemetrySavedObject(soClient, updatedAttributes);