diff --git a/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt b/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt index 0dbd9ef0a..23017c9c7 100644 --- a/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt +++ b/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt @@ -4,15 +4,12 @@ import com.intellij.openapi.components.Service import com.intellij.openapi.project.Project import io.snyk.plugin.events.SnykScanListener import io.snyk.plugin.getSnykTaskQueueService -import io.snyk.plugin.pluginSettings import io.snyk.plugin.snykcode.SnykCodeResults -import org.apache.commons.lang.SystemUtils import snyk.common.SnykError import snyk.common.lsp.commands.ScanDoneEvent import snyk.container.ContainerResult import snyk.iac.IacResult import snyk.oss.OssResult -import snyk.pluginInfo @Service(Service.Level.PROJECT) class AnalyticsScanListener(val project: Project) { @@ -21,19 +18,7 @@ class AnalyticsScanListener(val project: Project) { ): ScanDoneEvent { return ScanDoneEvent( ScanDoneEvent.Data( - type = "analytics", attributes = ScanDoneEvent.Attributes( - deviceId = pluginSettings().userAnonymousId, - application = pluginInfo.integrationName, - applicationVersion = pluginInfo.integrationVersion, - os = SystemUtils.OS_NAME, - arch = SystemUtils.OS_ARCH, - integrationName = pluginInfo.integrationName, - integrationVersion = pluginInfo.integrationVersion, - integrationEnvironment = pluginInfo.integrationEnvironment, - integrationEnvironmentVersion = pluginInfo.integrationEnvironmentVersion, - eventType = "Scan done", - status = "Succeeded", scanType = product, uniqueIssueCount = ScanDoneEvent.UniqueIssueCount( critical = critical, @@ -92,18 +77,6 @@ class AnalyticsScanListener(val project: Project) { getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) } - override fun scanningOssError(snykError: SnykError) { - // do nothing - } - - override fun scanningIacError(snykError: SnykError) { - // do nothing - } - - override fun scanningSnykCodeError(snykError: SnykError) { - // do nothing - } - override fun scanningContainerFinished(containerResult: ContainerResult) { val scanDoneEvent = getScanDoneEvent( System.currentTimeMillis() - start, @@ -116,6 +89,18 @@ class AnalyticsScanListener(val project: Project) { getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) } + override fun scanningOssError(snykError: SnykError) { + // do nothing + } + + override fun scanningIacError(snykError: SnykError) { + // do nothing + } + + override fun scanningSnykCodeError(snykError: SnykError) { + // do nothing + } + override fun scanningContainerError(snykError: SnykError) { // do nothing } diff --git a/src/main/kotlin/snyk/common/lsp/commands/ScanDoneEvent.kt b/src/main/kotlin/snyk/common/lsp/commands/ScanDoneEvent.kt index 956a1ebf2..822d20971 100644 --- a/src/main/kotlin/snyk/common/lsp/commands/ScanDoneEvent.kt +++ b/src/main/kotlin/snyk/common/lsp/commands/ScanDoneEvent.kt @@ -1,6 +1,8 @@ package snyk.common.lsp.commands import com.google.gson.annotations.SerializedName +import io.snyk.plugin.pluginSettings +import org.apache.commons.lang.SystemUtils import snyk.pluginInfo import java.time.ZonedDateTime @@ -8,24 +10,25 @@ data class ScanDoneEvent( @SerializedName("data") val data: Data ) { data class Data( - @SerializedName("type") val type: String, @SerializedName("attributes") val attributes: Attributes + @SerializedName("type") val type: String = "analytics", + @SerializedName("attributes") val attributes: Attributes ) data class Attributes( - @SerializedName("deviceId") val deviceId: String, + @SerializedName("deviceId") val deviceId: String = pluginSettings().userAnonymousId, @SerializedName("application") val application: String = pluginInfo.integrationEnvironment, @SerializedName("application_version") val applicationVersion: String = pluginInfo.integrationEnvironmentVersion, - @SerializedName("os") val os: String, - @SerializedName("arch") val arch: String, + @SerializedName("os") val os: String = SystemUtils.OS_NAME, + @SerializedName("arch") val arch: String = SystemUtils.OS_ARCH, @SerializedName("integration_name") val integrationName: String = pluginInfo.integrationName, @SerializedName("integration_version") val integrationVersion: String = pluginInfo.integrationVersion, @SerializedName("integration_environment") val integrationEnvironment: String = pluginInfo.integrationEnvironment, @SerializedName("integration_environment_version") val integrationEnvironmentVersion: String = pluginInfo.integrationEnvironmentVersion, - @SerializedName("event_type") val eventType: String, - @SerializedName("status") val status: String, + @SerializedName("event_type") val eventType: String = "Scan done", + @SerializedName("status") val status: String = "Succeeded", @SerializedName("scan_type") val scanType: String, @SerializedName("unique_issue_count") val uniqueIssueCount: UniqueIssueCount, @SerializedName("duration_ms") val durationMs: String,