From e68e9fa74e73300e70582c8a490db406c861c95f Mon Sep 17 00:00:00 2001 From: "Svetlana.Zemlyanskaya" Date: Mon, 11 Feb 2019 10:32:19 -0500 Subject: [PATCH] FUS: add plugin info to ui dialogs (FUS-244) --- .../eventLog/FeatureUsageUiEventsImpl.kt | 40 +++++++++++-------- 1 file changed, 23 insertions(+), 17 deletions(-) diff --git a/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/FeatureUsageUiEventsImpl.kt b/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/FeatureUsageUiEventsImpl.kt index 2d09519849ca..e4dbda68adce 100644 --- a/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/FeatureUsageUiEventsImpl.kt +++ b/platform/platform-impl/src/com/intellij/internal/statistic/eventLog/FeatureUsageUiEventsImpl.kt @@ -1,9 +1,8 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.internal.statistic.eventLog -import com.intellij.ide.plugins.PluginManagerCore import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger -import com.intellij.internal.statistic.utils.isDevelopedByJetBrains +import com.intellij.internal.statistic.utils.getPluginInfo import com.intellij.openapi.ui.DialogWrapper private const val DIALOGS = "ui.dialogs" @@ -30,28 +29,35 @@ class FeatureUsageUiEventsImpl : FeatureUsageUiEvents { override fun logShowDialog(name: String, context: Class<*>) { if (FeatureUsageLogger.isEnabled()) { - val report = toReport(context, name, DIALOGS_DEFAULT) - FUCounterUsageLogger.getInstance().logEvent(DIALOGS, report, SHOW_DIALOG_DATA) + val data = SHOW_DIALOG_DATA.copy() + val report = toReport(context, name, DIALOGS_DEFAULT, data) + FUCounterUsageLogger.getInstance().logEvent(DIALOGS, report, data) } } override fun logCloseDialog(name: String, exitCode: Int, context: Class<*>) { if (FeatureUsageLogger.isEnabled()) { - val report = toReport(context, name, DIALOGS_DEFAULT) - if (exitCode == DialogWrapper.OK_EXIT_CODE) { - FUCounterUsageLogger.getInstance().logEvent(DIALOGS, report, CLOSE_OK_DIALOG_DATA) - } - else if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) { - FUCounterUsageLogger.getInstance().logEvent(DIALOGS, report, CLOSE_CANCEL_DIALOG_DATA) - } - else { - FUCounterUsageLogger.getInstance().logEvent(DIALOGS, report, CLOSE_CUSTOM_DIALOG_DATA) - } + val data = getDataForCloseDialog(exitCode).copy() + val report = toReport(context, name, DIALOGS_DEFAULT, data) + FUCounterUsageLogger.getInstance().logEvent(DIALOGS, report, data) } } - private fun toReport(context: Class<*>, name: String, defaultValue: String): String { - val pluginId = PluginManagerCore.getPluginByClassName(context.name) - return if (isDevelopedByJetBrains(pluginId)) name else defaultValue + private fun getDataForCloseDialog(exitCode: Int): FeatureUsageData { + if (exitCode == DialogWrapper.OK_EXIT_CODE) { + return CLOSE_OK_DIALOG_DATA + } + else if (exitCode == DialogWrapper.CANCEL_EXIT_CODE) { + return CLOSE_CANCEL_DIALOG_DATA + } + else { + return CLOSE_CUSTOM_DIALOG_DATA + } + } + + private fun toReport(context: Class<*>, name: String, defaultValue: String, data: FeatureUsageData): String { + val info = getPluginInfo(context) + data.addPluginInfo(info) + return if (info.isDevelopedByJetBrains()) name else defaultValue } } \ No newline at end of file