Skip to content

Commit

Permalink
Cleanup (better name for Windows Defender stats collector class)
Browse files Browse the repository at this point in the history
GitOrigin-RevId: 96acace1fec2eb593ca85e806e63783302cd93e9
  • Loading branch information
trespasserw authored and intellij-monorepo-bot committed Feb 24, 2023
1 parent afe2247 commit d524850
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity {
val checker = WindowsDefenderChecker.getInstance()
if (checker.isStatusCheckIgnored(project)) {
LOG.info("status check is disabled")
DefenderCheckerUsagesCollector.rtProtectionCheckSkipped(project)
WindowsDefenderStatisticsCollector.protectionCheckSkipped(project)
return
}

val protection = checker.isRealTimeProtectionEnabled
if (protection != true) {
LOG.info("real-time protection: ${protection}")
DefenderCheckerUsagesCollector.rtProtectionCheckStatus(project, protection)
WindowsDefenderStatisticsCollector.protectionCheckStatus(project, protection)
return
}

Expand Down Expand Up @@ -65,7 +65,7 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity {
}

private fun updateDefenderConfig(checker: WindowsDefenderChecker, project: Project, paths: List<Path>) {
DefenderCheckerUsagesCollector.auto(project)
WindowsDefenderStatisticsCollector.auto(project)
@Suppress("DialogTitleCapitalization")
runBackgroundableTask(DiagnosticBundle.message("defender.config.progress"), project, false) {
val success = checker.excludeProjectPaths(paths)
Expand All @@ -79,21 +79,21 @@ internal class WindowsDefenderCheckerActivity : ProjectActivity {
.addAction(ShowLogAction.notificationAction())
.notify(project)
}
DefenderCheckerUsagesCollector.configured(project, success)
WindowsDefenderStatisticsCollector.configured(project, success)
}
}

private fun showInstructions(checker: WindowsDefenderChecker, project: Project) {
BrowserUtil.browse(checker.configurationInstructionsUrl)
DefenderCheckerUsagesCollector.manual(project)
WindowsDefenderStatisticsCollector.manual(project)
}

private fun suppressCheck(checker: WindowsDefenderChecker, project: Project, globally: Boolean) {
checker.ignoreStatusCheck(if (globally) null else project, true)
val action = ActionsBundle.message("action.ResetWindowsDefenderNotification.text")
notification(DiagnosticBundle.message("defender.config.restore", action), NotificationType.INFORMATION)
.notify(project)
DefenderCheckerUsagesCollector.suppressed(project, globally)
WindowsDefenderStatisticsCollector.suppressed(project, globally)
}

private fun notification(@NlsContexts.NotificationContent content: String, type: NotificationType): Notification =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

final class DefenderCheckerUsagesCollector extends CounterUsagesCollector {
final class WindowsDefenderStatisticsCollector extends CounterUsagesCollector {
private static final EventLogGroup GROUP = new EventLogGroup("defender", 1);

private enum Status {Skipped, Enabled, Disabled, Error}
Expand All @@ -19,11 +19,11 @@ private enum Reaction {Auto, Manual, ProjectMute, GlobalMute}
private static final EventId1<Reaction> NOTIFICATION_EVENT = GROUP.registerEvent("notification", EventFields.Enum("reaction", Reaction.class));
private static final EventId1<Boolean> AUTO_CONFIG_EVENT = GROUP.registerEvent("auto_config", EventFields.Boolean("success"));

static void rtProtectionCheckSkipped(@NotNull Project project) {
static void protectionCheckSkipped(@NotNull Project project) {
PROTECTION_CHECK_EVENT.log(project, Status.Skipped);
}

static void rtProtectionCheckStatus(@NotNull Project project, @Nullable Boolean status) {
static void protectionCheckStatus(@NotNull Project project, @Nullable Boolean status) {
PROTECTION_CHECK_EVENT.log(project, status == Boolean.TRUE ? Status.Enabled : status == Boolean.FALSE ? Status.Disabled : Status.Error);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@
<statistics.counterUsagesCollector implementationClass="com.intellij.codeInsight.daemon.impl.analysis.HighlightingSettingsPerFile$InspectionWidgetUsageCollector"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.ide.actions.cache.CacheRecoveryUsageCollector"/>.
<statistics.counterUsagesCollector groupId="new.project.wizard" version="3"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.diagnostic.DefenderCheckerUsagesCollector"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.diagnostic.WindowsDefenderStatisticsCollector"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.openapi.vfs.newvfs.VfsUsageCollector"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.openapi.project.DumbModeStatisticsCollector"/>
<statistics.counterUsagesCollector implementationClass="com.intellij.util.indexing.diagnostic.IndexOperationFUS$IndexOperationFusCollector"/>
Expand Down

0 comments on commit d524850

Please sign in to comment.