Wizard: add FUS statistic collection
This commit is contained in:
@@ -22,7 +22,8 @@ enum class FUSEventGroups(groupIdSuffix: String, val events: Set<String> = setOf
|
||||
J2K("ide.j2k"),
|
||||
Editor("ide.editor"),
|
||||
Settings("ide.settings"),
|
||||
GradlePerformance("gradle.performance");
|
||||
GradlePerformance("gradle.performance"),
|
||||
NewWizard("ide.new.wizard");
|
||||
|
||||
val GROUP_ID: String = "kotlin.$groupIdSuffix"
|
||||
}
|
||||
|
||||
+4
@@ -8,6 +8,8 @@ import org.jetbrains.kotlin.tools.projectWizard.core.service.WizardService
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.service.ServicesManager
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.StructurePlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.buildSystem.BuildSystemPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.projectTemplates.ProjectTemplatesPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.service.IdeaWizardService
|
||||
import kotlin.properties.ReadWriteProperty
|
||||
import kotlin.reflect.KProperty
|
||||
@@ -37,6 +39,8 @@ class IdeWizard(
|
||||
var artifactId by setting(StructurePlugin::artifactId.reference)
|
||||
var buildSystemType by setting(BuildSystemPlugin::type.reference)
|
||||
|
||||
val projectTemplate by setting(ProjectTemplatesPlugin::template.reference)
|
||||
|
||||
private fun <V : Any, T : SettingType<V>> setting(reference: SettingReference<V, T>) =
|
||||
object : ReadWriteProperty<Any?, V?> {
|
||||
override fun setValue(thisRef: Any?, property: KProperty<*>, value: V?) {
|
||||
|
||||
+20
-3
@@ -15,6 +15,9 @@ import com.intellij.util.SystemProperties
|
||||
import org.jetbrains.kotlin.idea.framework.KotlinModuleSettingStep
|
||||
import org.jetbrains.kotlin.idea.framework.KotlinTemplatesFactory
|
||||
import org.jetbrains.kotlin.idea.projectWizard.NewProjectWizardService
|
||||
import org.jetbrains.kotlin.idea.projectWizard.ProjectCreationStats
|
||||
import org.jetbrains.kotlin.idea.projectWizard.UiEditorUsageStats
|
||||
import org.jetbrains.kotlin.idea.projectWizard.WizardStatsService
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Failure
|
||||
@@ -42,6 +45,7 @@ As EmptyModuleBuilder has not expert panel option which are redundant
|
||||
*/
|
||||
class NewProjectWizardModuleBuilder : EmptyModuleBuilder() {
|
||||
private val wizard = IdeWizard(Plugins.allPlugins, IdeaServices.PROJECT_INDEPENDENT, isUnitTestMode = false)
|
||||
private val uiEditorUsagesStats = UiEditorUsageStats()
|
||||
|
||||
override fun isOpenProjectSettingsAfter(): Boolean = false
|
||||
override fun canCreateModule(): Boolean = false
|
||||
@@ -69,7 +73,7 @@ class NewProjectWizardModuleBuilder : EmptyModuleBuilder() {
|
||||
modulesProvider: ModulesProvider
|
||||
): Array<ModuleWizardStep> {
|
||||
this.wizardContext = wizardContext
|
||||
return arrayOf(ModuleNewWizardSecondStep(wizard))
|
||||
return arrayOf(ModuleNewWizardSecondStep(wizard, uiEditorUsagesStats))
|
||||
}
|
||||
|
||||
override fun commit(
|
||||
@@ -86,6 +90,16 @@ class NewProjectWizardModuleBuilder : EmptyModuleBuilder() {
|
||||
val errorMessages = errors.joinToString(separator = "\n") { it.message }
|
||||
Messages.showErrorDialog(project, errorMessages, "The following errors arose during project generation")
|
||||
}.isSuccess
|
||||
if (success) {
|
||||
val projectCreationStats = ProjectCreationStats(
|
||||
wizard.projectTemplate!!.title,
|
||||
wizard.buildSystemType!!.text
|
||||
)
|
||||
WizardStatsService.logDataOnProjectGenerated(
|
||||
projectCreationStats,
|
||||
uiEditorUsagesStats
|
||||
)
|
||||
}
|
||||
return when {
|
||||
!success -> null
|
||||
wizard.buildSystemType == BuildSystemType.Jps -> runWriteAction {
|
||||
@@ -207,8 +221,11 @@ class ModuleNewWizardFirstStep(wizard: IdeWizard) : WizardStep(wizard, Generatio
|
||||
)
|
||||
}
|
||||
|
||||
class ModuleNewWizardSecondStep(wizard: IdeWizard) : WizardStep(wizard, GenerationPhase.SECOND_STEP) {
|
||||
private val component = SecondStepWizardComponent(wizard)
|
||||
class ModuleNewWizardSecondStep(
|
||||
wizard: IdeWizard,
|
||||
uiEditorUsagesStats: UiEditorUsageStats
|
||||
) : WizardStep(wizard, GenerationPhase.SECOND_STEP) {
|
||||
private val component = SecondStepWizardComponent(wizard, uiEditorUsagesStats)
|
||||
override fun getComponent(): JComponent = component.component
|
||||
|
||||
override fun _init() {
|
||||
|
||||
+6
-2
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.secondStep
|
||||
|
||||
import com.intellij.ui.components.JBTabbedPane
|
||||
import org.jetbrains.kotlin.idea.projectWizard.UiEditorUsageStats
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ValuesReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.StringValidators
|
||||
import org.jetbrains.kotlin.tools.projectWizard.moduleConfigurators.configuratorSettings
|
||||
@@ -15,13 +16,16 @@ import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.setting.SettingsList
|
||||
import java.awt.BorderLayout
|
||||
import javax.swing.JComponent
|
||||
|
||||
class ModuleSettingsComponent(valuesReadingContext: ValuesReadingContext) : DynamicComponent(valuesReadingContext) {
|
||||
class ModuleSettingsComponent(
|
||||
valuesReadingContext: ValuesReadingContext,
|
||||
uiEditorUsagesStats: UiEditorUsageStats
|
||||
) : DynamicComponent(valuesReadingContext) {
|
||||
private val validateModuleName =
|
||||
StringValidators.shouldNotBeBlank("Module name") and
|
||||
StringValidators.shouldBeValidIdentifier("Module Name", ALLOWED_SPECIAL_CHARS_IN_MODULE_NAMES)
|
||||
|
||||
private val moduleConfiguratorSettingsList = SettingsList(emptyList(), valuesReadingContext).asSubComponent()
|
||||
private val templateComponent = TemplatesComponent(valuesReadingContext).asSubComponent()
|
||||
private val templateComponent = TemplatesComponent(valuesReadingContext, uiEditorUsagesStats).asSubComponent()
|
||||
|
||||
private val tabPanel = JBTabbedPane().apply {
|
||||
add("Template", templateComponent.component)
|
||||
|
||||
+14
-5
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.secondStep
|
||||
|
||||
import org.jetbrains.kotlin.idea.projectWizard.UiEditorUsageStats
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ValuesReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.DisplayableSettingItem
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||
@@ -11,10 +12,13 @@ import java.awt.BorderLayout
|
||||
import javax.swing.BorderFactory
|
||||
import javax.swing.JComponent
|
||||
|
||||
class SecondStepWizardComponent(wizard: IdeWizard) : WizardStepComponent(wizard.valuesReadingContext) {
|
||||
class SecondStepWizardComponent(
|
||||
wizard: IdeWizard,
|
||||
uiEditorUsagesStats: UiEditorUsageStats
|
||||
) : WizardStepComponent(wizard.valuesReadingContext) {
|
||||
private val moduleEditorSubStep =
|
||||
ModulesEditorSubStep(wizard.valuesReadingContext, ::onNodeSelected).asSubComponent()
|
||||
private val templatesSubStep = ModuleSettingsSubStep(wizard).asSubComponent()
|
||||
ModulesEditorSubStep(wizard.valuesReadingContext, uiEditorUsagesStats, ::onNodeSelected).asSubComponent()
|
||||
private val templatesSubStep = ModuleSettingsSubStep(wizard, uiEditorUsagesStats).asSubComponent()
|
||||
|
||||
override val component = splitterFor(
|
||||
moduleEditorSubStep.component,
|
||||
@@ -29,10 +33,12 @@ class SecondStepWizardComponent(wizard: IdeWizard) : WizardStepComponent(wizard.
|
||||
|
||||
class ModulesEditorSubStep(
|
||||
valuesReadingContext: ValuesReadingContext,
|
||||
uiEditorUsagesStats: UiEditorUsageStats,
|
||||
onNodeSelected: (data: DisplayableSettingItem?) -> Unit
|
||||
) : SubStep(valuesReadingContext) {
|
||||
private val moduleSettingComponent = ModulesEditorComponent(
|
||||
valuesReadingContext,
|
||||
uiEditorUsagesStats,
|
||||
onNodeSelected
|
||||
).asSubComponent()
|
||||
|
||||
@@ -47,9 +53,12 @@ class ModulesEditorSubStep(
|
||||
}
|
||||
|
||||
|
||||
class ModuleSettingsSubStep(wizard: IdeWizard) : SubStep(wizard.valuesReadingContext) {
|
||||
class ModuleSettingsSubStep(
|
||||
wizard: IdeWizard,
|
||||
uiEditorUsagesStats: UiEditorUsageStats
|
||||
) : SubStep(wizard.valuesReadingContext) {
|
||||
private val sourcesetSettingsComponent = SourcesetSettingsComponent(wizard.valuesReadingContext).asSubComponent()
|
||||
private val moduleSettingsComponent = ModuleSettingsComponent(valuesReadingContext).asSubComponent()
|
||||
private val moduleSettingsComponent = ModuleSettingsComponent(valuesReadingContext, uiEditorUsagesStats).asSubComponent()
|
||||
private val nothingSelectedComponent = NothingSelectedComponent().asSubComponent()
|
||||
|
||||
private val panel = panel {
|
||||
|
||||
+7
-2
@@ -8,10 +8,10 @@ import com.intellij.ui.SimpleTextAttributes
|
||||
import com.intellij.util.ui.StatusText
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import org.jetbrains.kotlin.idea.KotlinIcons
|
||||
import org.jetbrains.kotlin.idea.projectWizard.UiEditorUsageStats
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ValuesReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.plugins.templates.TemplatesPlugin
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Sourceset
|
||||
import org.jetbrains.kotlin.tools.projectWizard.templates.Template
|
||||
import org.jetbrains.kotlin.tools.projectWizard.templates.settings
|
||||
import org.jetbrains.kotlin.tools.projectWizard.wizard.ui.*
|
||||
@@ -21,9 +21,13 @@ import java.awt.*
|
||||
import javax.swing.JComponent
|
||||
import javax.swing.JPanel
|
||||
|
||||
class TemplatesComponent(valuesReadingContext: ValuesReadingContext) : DynamicComponent(valuesReadingContext) {
|
||||
class TemplatesComponent(
|
||||
valuesReadingContext: ValuesReadingContext,
|
||||
uiEditorUsagesStats: UiEditorUsageStats
|
||||
) : DynamicComponent(valuesReadingContext) {
|
||||
private val chooseTemplateComponent: ChooseTemplateComponent =
|
||||
ChooseTemplateComponent(valuesReadingContext) { template ->
|
||||
uiEditorUsagesStats.moduleTemplatesSet++
|
||||
module?.template = template
|
||||
switchState(template)
|
||||
}
|
||||
@@ -38,6 +42,7 @@ class TemplatesComponent(valuesReadingContext: ValuesReadingContext) : DynamicCo
|
||||
null
|
||||
) == Messages.OK
|
||||
) {
|
||||
uiEditorUsagesStats.moduleTemplatesRemoved++
|
||||
module?.template = null
|
||||
switchState(null)
|
||||
}
|
||||
|
||||
+3
-1
@@ -1,6 +1,7 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.secondStep.modulesEditor
|
||||
|
||||
import com.intellij.ui.JBColor
|
||||
import org.jetbrains.kotlin.idea.projectWizard.UiEditorUsageStats
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.ListSettingType
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.ValuesReadingContext
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.entity.reference
|
||||
@@ -18,6 +19,7 @@ import javax.swing.JComponent
|
||||
|
||||
class ModulesEditorComponent(
|
||||
valuesReadingContext: ValuesReadingContext,
|
||||
uiEditorUsagesStats: UiEditorUsageStats,
|
||||
oneEntrySelected: (data: DisplayableSettingItem?) -> Unit
|
||||
) : SettingComponent<List<Module>, ListSettingType<Module>>(KotlinPlugin::modules.reference, valuesReadingContext) {
|
||||
private val tree: ModulesEditorTree =
|
||||
@@ -37,7 +39,7 @@ class ModulesEditorComponent(
|
||||
}
|
||||
)
|
||||
|
||||
private val model = TargetsModel(tree, ::value, valuesReadingContext.context)
|
||||
private val model = TargetsModel(tree, ::value, valuesReadingContext.context, uiEditorUsagesStats)
|
||||
|
||||
override fun onInit() {
|
||||
super.onInit()
|
||||
|
||||
+5
-1
@@ -1,5 +1,6 @@
|
||||
package org.jetbrains.kotlin.tools.projectWizard.wizard.ui.secondStep.modulesEditor
|
||||
|
||||
import org.jetbrains.kotlin.idea.projectWizard.UiEditorUsageStats
|
||||
import org.jetbrains.kotlin.tools.projectWizard.core.Context
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.Module
|
||||
import org.jetbrains.kotlin.tools.projectWizard.settings.buildsystem.ModuleKind
|
||||
@@ -11,7 +12,8 @@ import kotlin.reflect.KMutableProperty0
|
||||
class TargetsModel(
|
||||
private val tree: ModulesEditorTree,
|
||||
private val value: KMutableProperty0<List<Module>?>,
|
||||
private val context: Context
|
||||
private val context: Context,
|
||||
private val uiEditorUsagesStats: UiEditorUsageStats
|
||||
) {
|
||||
private val root get() = tree.model.root as DefaultMutableTreeNode
|
||||
|
||||
@@ -61,6 +63,7 @@ class TargetsModel(
|
||||
}
|
||||
|
||||
fun add(module: Module) {
|
||||
uiEditorUsagesStats.modulesCreated++
|
||||
module.initDefaultValuesForSettings(context)
|
||||
addToTheTree(module, modifyValue = true, parent = tree.selectedNode ?: root)
|
||||
}
|
||||
@@ -75,6 +78,7 @@ class TargetsModel(
|
||||
|
||||
fun removeSelected() {
|
||||
val selectedNode = tree.selectedNode?.takeIf { it.userObject is Module } ?: return
|
||||
uiEditorUsagesStats.modulesRemoved++
|
||||
when (val parent = selectedNode.parent.safeAs<DefaultMutableTreeNode>()?.userObject) {
|
||||
ModulesEditorTree.PROJECT_USER_OBJECT -> {
|
||||
val index = selectedNode.parent.getIndex(selectedNode)
|
||||
|
||||
@@ -79,6 +79,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.debugger" version="2"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.j2k" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.editor" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.new.wizard" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.gradle.performance" version="1"/>
|
||||
<statistics.projectUsagesCollector implementation="org.jetbrains.kotlin.idea.statistics.IDESettingsFUSCollector"/>
|
||||
<statistics.projectUsagesCollector implementation="org.jetbrains.kotlin.idea.formatter.KotlinFormatterUsageCollector"/>
|
||||
|
||||
@@ -79,6 +79,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.debugger" version="2"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.j2k" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.editor" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.new.wizard" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.gradle.performance" version="1"/>
|
||||
<statistics.projectUsagesCollector implementation="org.jetbrains.kotlin.idea.statistics.IDESettingsFUSCollector"/>
|
||||
<statistics.projectUsagesCollector implementation="org.jetbrains.kotlin.idea.formatter.KotlinFormatterUsageCollector"/>
|
||||
|
||||
@@ -79,6 +79,7 @@ The Kotlin plugin provides language support in IntelliJ IDEA and Android Studio.
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.debugger" version="2"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.j2k" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.editor" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.ide.new.wizard" version="1"/>
|
||||
<statistics.counterUsagesCollector groupId="kotlin.gradle.performance" version="1"/>
|
||||
<statistics.projectUsagesCollector implementation="org.jetbrains.kotlin.idea.statistics.IDESettingsFUSCollector"/>
|
||||
<statistics.projectUsagesCollector implementation="org.jetbrains.kotlin.idea.formatter.KotlinFormatterUsageCollector"/>
|
||||
|
||||
@@ -14,6 +14,9 @@ object NewProjectWizardService {
|
||||
var isEnabled
|
||||
get() = PropertiesComponent.getInstance().getBoolean(optionName, enabledByDefault)
|
||||
set(value) {
|
||||
if (value != isEnabled) {
|
||||
WizardStatsService.logWizardStatusChanged(isEnabled = value)
|
||||
}
|
||||
PropertiesComponent.getInstance().setValue(optionName, value, enabledByDefault)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.projectWizard
|
||||
|
||||
import org.jetbrains.kotlin.idea.statistics.FUSEventGroups
|
||||
import org.jetbrains.kotlin.idea.statistics.KotlinFUSLogger
|
||||
|
||||
interface WizardStats {
|
||||
fun toMap(): Map<String, String>
|
||||
}
|
||||
|
||||
data class ProjectCreationStats(
|
||||
val projectTemplateName: String,
|
||||
val buildSystemType: String
|
||||
) : WizardStats {
|
||||
override fun toMap(): Map<String, String> = mapOf(
|
||||
::projectTemplateName.name to projectTemplateName,
|
||||
::buildSystemType.name to buildSystemType
|
||||
)
|
||||
}
|
||||
|
||||
data class UiEditorUsageStats(
|
||||
var modulesCreated: Int = 0,
|
||||
var modulesRemoved: Int = 0,
|
||||
var moduleTemplatesRemoved: Int = 0,
|
||||
var moduleTemplatesSet: Int = 0
|
||||
) : WizardStats {
|
||||
override fun toMap(): Map<String, String> = mapOf(
|
||||
::modulesCreated.name to modulesCreated.toString(),
|
||||
::modulesRemoved.name to modulesRemoved.toString(),
|
||||
::moduleTemplatesRemoved.name to moduleTemplatesRemoved.toString(),
|
||||
::moduleTemplatesSet.name to moduleTemplatesSet.toString()
|
||||
)
|
||||
}
|
||||
|
||||
private enum class WizardStatsEvent(val text: String) {
|
||||
PROJECT_CREATED("Project Created"),
|
||||
WIZARD_STATE_CHANGE("New Wizard enabled or disable")
|
||||
}
|
||||
|
||||
object WizardStatsService {
|
||||
fun logDataOnProjectGenerated(projectCreationStats: ProjectCreationStats, uiEditorUsageStats: UiEditorUsageStats) {
|
||||
val data = projectCreationStats.toMap() + uiEditorUsageStats.toMap()
|
||||
KotlinFUSLogger.log(FUSEventGroups.NewWizard, WizardStatsEvent.PROJECT_CREATED.text, data)
|
||||
}
|
||||
|
||||
fun logWizardStatusChanged(isEnabled: Boolean) {
|
||||
val data = mapOf("enabled" to isEnabled.toString())
|
||||
KotlinFUSLogger.log(FUSEventGroups.NewWizard, WizardStatsEvent.WIZARD_STATE_CHANGE.text, data)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user