mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FUS: implement util validator for productivity features (FUS-387)
GitOrigin-RevId: f3781626d7818b15069a56ca47aa776772591ad5
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6a2d78291d
commit
63832f19f8
+27
@@ -1,6 +1,9 @@
|
||||
// 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.featureStatistics;
|
||||
|
||||
import com.intellij.internal.statistic.eventLog.validator.ValidationResultType;
|
||||
import com.intellij.internal.statistic.eventLog.validator.rules.EventContext;
|
||||
import com.intellij.internal.statistic.eventLog.validator.rules.impl.CustomUtilsWhiteListRule;
|
||||
import com.intellij.internal.statistic.persistence.UsageStatisticsPersistenceComponent;
|
||||
import com.intellij.internal.statistic.service.fus.collectors.FUCounterUsageLogger;
|
||||
import com.intellij.openapi.components.PersistentStateComponent;
|
||||
@@ -12,6 +15,7 @@ import com.intellij.util.xmlb.XmlSerializer;
|
||||
import org.jdom.Element;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
@@ -188,4 +192,27 @@ public class FeatureUsageTrackerImpl extends FeatureUsageTracker implements Pers
|
||||
}
|
||||
}
|
||||
|
||||
public static class ProductivityUtilValidator extends CustomUtilsWhiteListRule {
|
||||
|
||||
@Override
|
||||
public boolean acceptRuleId(@Nullable String ruleId) {
|
||||
return "productivity".equals(ruleId);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected ValidationResultType doValidate(@NotNull String data, @NotNull EventContext context) {
|
||||
if ("third.party".equals(data)) return ValidationResultType.ACCEPTED;
|
||||
|
||||
final ProductivityFeaturesRegistry registry = ProductivityFeaturesRegistry.getInstance();
|
||||
final FeatureDescriptor descriptor = registry.getFeatureDescriptor(data);
|
||||
if (descriptor == null) {
|
||||
return ValidationResultType.REJECTED;
|
||||
}
|
||||
|
||||
final Class<? extends ProductivityFeaturesProvider> provider = descriptor.getProvider();
|
||||
return provider == null || getPluginType(provider).isDevelopedByJetBrains() ?
|
||||
ValidationResultType.ACCEPTED : ValidationResultType.REJECTED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -410,6 +410,7 @@
|
||||
<keymapExtension implementation="com.intellij.ide.actions.ToolWindowKeymapExtension"/>
|
||||
|
||||
<statistics.validation.customUtilsWhiteListRule implementation="com.intellij.internal.statistic.collectors.fus.FacetTypeUsageCollector$FacetTypeUtilValidator" />
|
||||
<statistics.validation.customUtilsWhiteListRule implementation="com.intellij.featureStatistics.FeatureUsageTrackerImpl$ProductivityUtilValidator" />
|
||||
|
||||
<statistics.projectUsagesCollector implementation="com.intellij.internal.statistic.collectors.fus.fileTypes.ProjectStructureUsageCollector"/>
|
||||
<statistics.projectUsagesCollector implementation="com.intellij.internal.statistic.collectors.fus.FacetTypeUsageCollector"/>
|
||||
|
||||
+25
@@ -1,6 +1,7 @@
|
||||
// Copyright 2000-2019 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.statistics.validator
|
||||
|
||||
import com.intellij.featureStatistics.FeatureUsageTrackerImpl
|
||||
import com.intellij.internal.statistic.collectors.fus.FacetTypeUsageCollector
|
||||
import com.intellij.internal.statistic.eventLog.FeatureUsageData
|
||||
import com.intellij.internal.statistic.eventLog.validator.ValidationResultType
|
||||
@@ -58,4 +59,28 @@ class FeatureUsageCustomValidatorsTest : LightPlatformTestCase() {
|
||||
Disposer.dispose(disposable)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test validate welcome productivity feature`() {
|
||||
val validator = FeatureUsageTrackerImpl.ProductivityUtilValidator()
|
||||
doValidateEventId(validator, "features.welcome", FeatureUsageData())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test validate third party productivity feature`() {
|
||||
val validator = FeatureUsageTrackerImpl.ProductivityUtilValidator()
|
||||
doValidateEventId(validator, "third.party", FeatureUsageData())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test validate productivity feature by id`() {
|
||||
val validator = FeatureUsageTrackerImpl.ProductivityUtilValidator()
|
||||
doValidateEventId(validator, "navigation.popup.camelprefix", FeatureUsageData())
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `test reject unknown productivity feature`() {
|
||||
val validator = FeatureUsageTrackerImpl.ProductivityUtilValidator()
|
||||
doRejectEventId(validator, "unknown.feature.id", FeatureUsageData())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user