From 68cc0ea601754d0751ebded1abe60b49cf84d7db Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Fri, 7 Jan 2022 17:16:21 +0100 Subject: [PATCH] Collect changed notification settings (IDEA-283343) GitOrigin-RevId: d6ba697a76b17269604e39b5374e8e26481bc435 --- .../impl/NotificationSettingsCollector.kt | 43 +++++++++++++++++++ .../src/META-INF/PlatformExtensions.xml | 1 + 2 files changed, 44 insertions(+) create mode 100644 platform/platform-impl/src/com/intellij/notification/impl/NotificationSettingsCollector.kt diff --git a/platform/platform-impl/src/com/intellij/notification/impl/NotificationSettingsCollector.kt b/platform/platform-impl/src/com/intellij/notification/impl/NotificationSettingsCollector.kt new file mode 100644 index 000000000000..9a34c1d92ffb --- /dev/null +++ b/platform/platform-impl/src/com/intellij/notification/impl/NotificationSettingsCollector.kt @@ -0,0 +1,43 @@ +// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. +package com.intellij.notification.impl + +import com.intellij.internal.statistic.beans.MetricEvent +import com.intellij.internal.statistic.eventLog.EventLogGroup +import com.intellij.internal.statistic.eventLog.events.EventFields +import com.intellij.internal.statistic.service.fus.collectors.ApplicationUsagesCollector +import com.intellij.notification.NotificationGroupManager + +class NotificationSettingsCollector : ApplicationUsagesCollector() { + private val GROUP = EventLogGroup("notification.settings", 1) + private val SHOULD_LOG = EventFields.Boolean("should_log") + private val PLAY_SOUND = EventFields.Boolean("play_sound") + private val READ_ALOUD = EventFields.Boolean("read_aloud") + private val CHANGED = GROUP.registerVarargEvent( + "changed", + NotificationsEventLogGroup.NOTIFICATION_GROUP_ID, + NotificationsEventLogGroup.DISPLAY_TYPE, + SHOULD_LOG, + PLAY_SOUND, + READ_ALOUD + ) + + override fun getGroup(): EventLogGroup = GROUP + + override fun getMetrics(): Set { + val result = mutableSetOf() + for (group in NotificationGroupManager.getInstance().registeredNotificationGroups) { + val changedSettings = NotificationsConfigurationImpl.getSettings(group.displayId) + val defaultSettings = NotificationSettings(group.displayId, group.displayType, group.isLogByDefault, false) + if (changedSettings != defaultSettings) { + result.add(CHANGED.metric( + NotificationsEventLogGroup.NOTIFICATION_GROUP_ID with group.displayId, + NotificationsEventLogGroup.DISPLAY_TYPE with changedSettings.displayType, + SHOULD_LOG with changedSettings.isShouldLog, + PLAY_SOUND with changedSettings.isPlaySound, + READ_ALOUD with changedSettings.isShouldReadAloud + )) + } + } + return result + } +} diff --git a/platform/platform-resources/src/META-INF/PlatformExtensions.xml b/platform/platform-resources/src/META-INF/PlatformExtensions.xml index ae0eb235b42f..40ceba34be7e 100644 --- a/platform/platform-resources/src/META-INF/PlatformExtensions.xml +++ b/platform/platform-resources/src/META-INF/PlatformExtensions.xml @@ -798,6 +798,7 @@ +