mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FUS-726 Add unique id in settings group events
GitOrigin-RevId: 4efe3c7713d0a754e9d7139794c2103c31f06980
This commit is contained in:
committed by
intellij-monorepo-bot
parent
990b752da1
commit
a209cdf062
+9
-7
@@ -20,8 +20,9 @@ import org.jdom.Element
|
||||
import java.util.concurrent.atomic.AtomicInteger
|
||||
|
||||
private val LOG = Logger.getInstance("com.intellij.configurationStore.statistic.eventLog.FeatureUsageSettingsEventPrinter")
|
||||
private val GROUP = EventLogGroup("settings", 7)
|
||||
private val GROUP = EventLogGroup("settings", 8)
|
||||
private const val CHANGES_GROUP = "settings.changes"
|
||||
private const val ID_FIELD = "id"
|
||||
|
||||
private val recordedComponents: MutableSet<String> = ContainerUtil.newConcurrentSet()
|
||||
private val recordedOptionNames: MutableSet<String> = ContainerUtil.newConcurrentSet()
|
||||
@@ -75,7 +76,7 @@ open class FeatureUsageSettingsEventPrinter(private val recordDefault: Boolean)
|
||||
val pluginInfo = getPluginInfo(clazz)
|
||||
if (pluginInfo.isDevelopedByJetBrains()) {
|
||||
recordedComponents.add(componentName)
|
||||
logConfig(GROUP, "invoked", createComponentData(project, componentName, pluginInfo))
|
||||
logConfig(GROUP, "invoked", createComponentData(project, componentName, pluginInfo), counter.incrementAndGet())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -99,21 +100,22 @@ open class FeatureUsageSettingsEventPrinter(private val recordDefault: Boolean)
|
||||
fun logConfigurationState(componentName: String, state: Any?, project: Project?) {
|
||||
val (optionsValues, pluginInfo) = valuesExtractor.extract(project, componentName, state) ?: return
|
||||
val eventId = if (recordDefault) "option" else "not.default"
|
||||
val id = counter.incrementAndGet()
|
||||
for (data in optionsValues) {
|
||||
logConfig(GROUP, eventId, data)
|
||||
logConfig(GROUP, eventId, data, id)
|
||||
}
|
||||
|
||||
if (!recordDefault) {
|
||||
logConfig(GROUP, "invoked", createComponentData(project, componentName, pluginInfo))
|
||||
logConfig(GROUP, "invoked", createComponentData(project, componentName, pluginInfo), id)
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun logConfig(group: EventLogGroup, eventId: String, data: FeatureUsageData) {
|
||||
FeatureUsageLogger.logState(group, eventId, data.build())
|
||||
protected open fun logConfig(group: EventLogGroup, eventId: String, data: FeatureUsageData, id: Int) {
|
||||
FeatureUsageLogger.logState(group, eventId, data.addData(ID_FIELD, id).build())
|
||||
}
|
||||
|
||||
protected open fun logSettingsChanged(eventId: String, data: FeatureUsageData, id: Int) {
|
||||
FUCounterUsageLogger.getInstance().logEvent(CHANGES_GROUP, eventId, data.addData("id", id))
|
||||
FUCounterUsageLogger.getInstance().logEvent(CHANGES_GROUP, eventId, data.addData(ID_FIELD, id))
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
||||
+22
-7
@@ -501,6 +501,18 @@ class FeatureUsageSettingsEventsTest {
|
||||
Assert.assertEquals(1, printer.result.size)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `report invoked and options events with the same id`() {
|
||||
val component = TestComponent()
|
||||
component.loadState(ComponentState(bool = true))
|
||||
val printer = TestFeatureUsageSettingsEventsPrinter(recordDefault = false)
|
||||
printer.logConfigurationState(getStateSpec(component).name, component.state, null)
|
||||
|
||||
val invokedEvent = printer.getInvokedEvent()
|
||||
val optionEvent = printer.getOptionByName("boolOption")
|
||||
Assert.assertEquals(invokedEvent.id, optionEvent.id)
|
||||
}
|
||||
|
||||
private fun assertDefaultWithoutDefaultRecording(printer: TestFeatureUsageSettingsEventsPrinter,
|
||||
withProject: Boolean,
|
||||
defaultProject: Boolean) {
|
||||
@@ -526,7 +538,8 @@ class FeatureUsageSettingsEventsTest {
|
||||
defaultProject: Boolean) {
|
||||
assertThat(event.group.id).isEqualTo("settings")
|
||||
assertThat(event.group.version > 0).isTrue()
|
||||
assertThat(event.id).isEqualTo(if (withDefaultRecorded) "option" else "not.default")
|
||||
assertThat(event.eventId).isEqualTo(if (withDefaultRecorded) "option" else "not.default")
|
||||
assertThat(event.id).isNotNull()
|
||||
|
||||
var size = 3
|
||||
if (value != null) size++
|
||||
@@ -569,7 +582,8 @@ class FeatureUsageSettingsEventsTest {
|
||||
defaultProject: Boolean) {
|
||||
assertThat(event.group.id).isEqualTo("settings")
|
||||
assertThat(event.group.version).isGreaterThan(0)
|
||||
assertThat(event.id).isEqualTo("option")
|
||||
assertThat(event.eventId).isEqualTo("option")
|
||||
assertThat(event.id).isNotNull()
|
||||
|
||||
var size = 5
|
||||
if (withProject) size++
|
||||
@@ -596,7 +610,8 @@ class FeatureUsageSettingsEventsTest {
|
||||
private fun assertInvokedRecorded(event: LoggedComponentStateEvents, withProject: Boolean, defaultProject: Boolean) {
|
||||
assertThat(event.group.id).isEqualTo("settings")
|
||||
assertThat(event.group.version).isGreaterThan(0)
|
||||
assertThat(event.id).isEqualTo("invoked")
|
||||
assertThat(event.eventId).isEqualTo("invoked")
|
||||
assertThat(event.id).isNotNull()
|
||||
|
||||
var size = 1
|
||||
if (withProject) size++
|
||||
@@ -619,8 +634,8 @@ class FeatureUsageSettingsEventsTest {
|
||||
private class TestFeatureUsageSettingsEventsPrinter(recordDefault: Boolean) : FeatureUsageSettingsEventPrinter(recordDefault) {
|
||||
val result: MutableList<LoggedComponentStateEvents> = ArrayList()
|
||||
|
||||
override fun logConfig(group: EventLogGroup, eventId: String, data: FeatureUsageData) {
|
||||
result.add(LoggedComponentStateEvents(group, eventId, data.build()))
|
||||
override fun logConfig(group: EventLogGroup, eventId: String, data: FeatureUsageData, id: Int) {
|
||||
result.add(LoggedComponentStateEvents(group, eventId, data.build(), id))
|
||||
}
|
||||
|
||||
fun getOptionByName(name: String): LoggedComponentStateEvents {
|
||||
@@ -634,7 +649,7 @@ class FeatureUsageSettingsEventsTest {
|
||||
|
||||
fun getInvokedEvent(): LoggedComponentStateEvents {
|
||||
for (event in result) {
|
||||
if (event.id == "invoked") {
|
||||
if (event.eventId == "invoked") {
|
||||
return event
|
||||
}
|
||||
}
|
||||
@@ -650,7 +665,7 @@ class FeatureUsageSettingsEventsTest {
|
||||
}
|
||||
}
|
||||
|
||||
private class LoggedComponentStateEvents(val group: EventLogGroup, val id: String, val data: Map<String, Any>)
|
||||
private class LoggedComponentStateEvents(val group: EventLogGroup, val eventId: String, val data: Map<String, Any>, val id: Int)
|
||||
|
||||
@State(name = "MyTestComponent", reportStatistic = true)
|
||||
private class TestComponent : PersistentStateComponent<ComponentState> {
|
||||
|
||||
Reference in New Issue
Block a user