diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/fus/FUSGroupIds.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/fus/FUSGroupIds.kt index 5f6bd195..c77eed8d 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/fus/FUSGroupIds.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/fus/FUSGroupIds.kt @@ -30,6 +30,8 @@ object FUSGroupIds { const val PACKAGE_ID = "package_id" const val PACKAGE_VERSION = "package_version" const val PACKAGE_FROM_VERSION = "package_from_version" + const val PACKAGE_FROM_SCOPE = "package_from_scope" + const val PACKAGE_TO_SCOPE = "package_to_scope" const val REPOSITORY_ID = "repository_id" const val REPOSITORY_URL = "repository_url" const val REPOSITORY_USES_CUSTOM_URL = "repository_uses_custom_url" diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/fus/PackageSearchEventsLogger.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/fus/PackageSearchEventsLogger.kt index 38b6316b..0072d60e 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/fus/PackageSearchEventsLogger.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/fus/PackageSearchEventsLogger.kt @@ -21,6 +21,7 @@ package com.jetbrains.packagesearch.plugin.fus import com.intellij.internal.statistic.eventLog.EventLogGroup import com.intellij.internal.statistic.eventLog.events.BaseEventId import com.intellij.internal.statistic.eventLog.events.EventFields +import com.intellij.internal.statistic.eventLog.validator.rules.impl.LocalFileCustomValidationRule import com.intellij.internal.statistic.service.fus.collectors.CounterUsagesCollector import com.intellij.openapi.diagnostic.RuntimeExceptionWithAttachments import com.jetbrains.packagesearch.plugin.PackageSearchBundle @@ -39,6 +40,12 @@ private const val VERSION = 13 private val GROUP = EventLogGroup(FUSGroupIds.GROUP_ID, VERSION) +internal class TopScopesValidationRule : LocalFileCustomValidationRule( + /* ruleId = */ "top_scopes_id", + /* resource = */ TopScopesValidationRule::class.java, + /* path = */ "/fus/scopes.txt" +) + // FIELDS private val buildSystemField = EventFields.Class(FUSGroupIds.MODULE_OPERATION_PROVIDER_CLASS) private val packageIdField = @@ -47,6 +54,10 @@ private val packageVersionField = EventFields.StringValidatedByRegexpReference(FUSGroupIds.PACKAGE_VERSION, regexpRef = "version") private val packageFromVersionField = EventFields.StringValidatedByRegexpReference(FUSGroupIds.PACKAGE_FROM_VERSION, regexpRef = "version") +private val packageScopeFromField = + EventFields.StringValidatedByCustomRule(FUSGroupIds.PACKAGE_FROM_SCOPE) +private val packageScopeToField = + EventFields.StringValidatedByCustomRule(FUSGroupIds.PACKAGE_TO_SCOPE) private val repositoryIdField = EventFields.Enum(FUSGroupIds.REPOSITORY_ID) private val repositoryUrlField = EventFields.String(FUSGroupIds.REPOSITORY_URL, allowedValues = FUSGroupIds.indexedRepositoryUrls) @@ -85,11 +96,12 @@ private val packageVersionChangedEvent = GROUP.registerVarargEvent( eventId = FUSGroupIds.PACKAGE_VERSION_UPDATED, packageIdField, packageFromVersionField, packageVersionField, buildSystemField ) -private val packageScopeChangedEvent = GROUP.registerEvent( + +private val packageScopeChangedEvent = GROUP.registerVarargEvent( eventId = FUSGroupIds.PACKAGE_SCOPE_UPDATED, - eventField1 = packageIdField, - eventField2 = buildSystemField + packageIdField, packageScopeFromField, packageScopeToField, buildSystemField ) + private val packageVariantChangedEvent = GROUP.registerEvent( eventId = FUSGroupIds.PACKAGE_VARIANT_UPDATED, eventField1 = packageIdField, @@ -178,9 +190,16 @@ internal fun logPackageVariantChanged( internal fun logPackageScopeChanged( packageIdentifier: String, + scopeFrom: String?, + scopeTo: String?, targetModule: PackageSearchModule, ) = runSafelyIfEnabled(packageScopeChangedEvent) { - log(packageIdentifier, targetModule::class.java) + log( + packageIdField.with(packageIdentifier), + packageScopeFromField.with(scopeFrom ?: "[default]"), + packageScopeToField.with(scopeTo ?: "[default]"), + buildSystemField.with(targetModule::class.java) + ) } internal fun logRepositoryAdded(model: ApiRepository) = runSafelyIfEnabled(repositoryAddedEvent) { diff --git a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt index 0edeb403..5b6fd371 100644 --- a/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt +++ b/plugin/src/main/kotlin/com/jetbrains/packagesearch/plugin/ui/model/packageslist/PackageListViewModel.kt @@ -552,7 +552,7 @@ class PackageListViewModel( when (event) { is PackageListItemEvent.EditPackageEvent.SetPackageScope -> { viewModelScope.launch { - logPackageScopeChanged(dependency.id, module) + logPackageScopeChanged(dependency.id, dependency.declaredScope, event.scope, module) } manager.updateDependency( declaredPackage = dependency, diff --git a/plugin/src/main/resources/fus/scopes.txt b/plugin/src/main/resources/fus/scopes.txt new file mode 100644 index 00000000..33c67315 --- /dev/null +++ b/plugin/src/main/resources/fus/scopes.txt @@ -0,0 +1,24 @@ +[default] +compile +runtime +provided +test +implementation +api +compileOnly +runtimeOnly +testImplementation +testCompileOnly +testRuntimeOnly +kapt +testKapt +androidTestImplementation +androidTestCompileOnly +androidTestRuntimeOnly +androidTestUtil +androidTestUtilDebug +androidTestUtilRelease +androidTestAnnotationProcessor +detekt +detektPlugins +detektTest