[ML-2618] ML API: Use the ML recorder for logging events

Update the group version

Add ML event recorder


Merge-request: IJ-MR-127859
Merged-by: Gleb Marin <Gleb.Marin@jetbrains.com>

GitOrigin-RevId: 6ea502c751a7b47bbe3860caa6209be1f6ef45b4
This commit is contained in:
Gleb.Marin
2024-03-05 13:51:51 +00:00
committed by intellij-monorepo-bot
parent b9c46aff5f
commit c5434fd3df
3 changed files with 43 additions and 1 deletions

View File

@@ -6,6 +6,8 @@
<projectService serviceInterface="com.intellij.internal.statistic.local.LanguageUsageStatisticsProvider"
serviceImplementation="com.intellij.internal.statistic.local.LanguageUsageStatisticsProviderImpl"/>
<statistic.eventLog.eventLoggerProvider implementation="com.intellij.platform.ml.impl.logs.MLEventLoggerProvider"/>
</extensions>
<projectListeners>

View File

@@ -0,0 +1,40 @@
// Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.platform.ml.impl.logs
import com.intellij.internal.statistic.eventLog.StatisticsEventLoggerProvider
import com.intellij.internal.statistic.utils.StatisticsUploadAssistant
import com.intellij.openapi.application.ApplicationInfo
import com.intellij.openapi.application.ApplicationManager
import com.intellij.util.PlatformUtils
import org.jetbrains.annotations.ApiStatus
import java.util.concurrent.TimeUnit
/**
* Creates collector of ML logs
*
* Is also handled here: [com.intellij.internal.statistic.eventLog.StatisticsEventLogProvidersHolder.isProviderApplicable]
*/
@ApiStatus.Internal
class MLEventLoggerProvider : StatisticsEventLoggerProvider(
ML_RECORDER_ID,
1,
sendFrequencyMs = TimeUnit.MINUTES.toMillis(10),
maxFileSizeInBytes = 100 * 1024,
sendLogsOnIdeClose = true,
isCharsEscapingRequired = true
) {
override fun isRecordEnabled(): Boolean {
val app = ApplicationManager.getApplication()
return !app.isUnitTestMode && app.isEAP &&
StatisticsUploadAssistant.isCollectAllowed() &&
(ApplicationInfo.getInstance() == null || PlatformUtils.isJetBrainsProduct())
}
override fun isSendEnabled(): Boolean {
return isRecordEnabled() && StatisticsUploadAssistant.isSendAllowed()
}
companion object {
const val ML_RECORDER_ID = "ML"
}
}

View File

@@ -57,7 +57,7 @@ internal class StatisticsEventLogProvidersHolder {
}
val pluginInfo = getPluginInfo(extension::class.java)
return if (recorderId == "MLSE") {
return if (recorderId == "MLSE" || recorderId == "ML") {
pluginInfo.isDevelopedByJetBrains()
}
else {