Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't send analytics events about snyk code when ff enabled #520

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions src/main/kotlin/io/snyk/plugin/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import com.intellij.openapi.wm.ToolWindowManager
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiManager
import com.intellij.util.Alarm
import com.intellij.util.FileContentUtil
import com.intellij.util.messages.Topic
import io.snyk.plugin.analytics.AnalyticsScanListener
import io.snyk.plugin.net.ClientException
Expand Down Expand Up @@ -160,9 +159,6 @@ fun <L : Any> getSyncPublisher(project: Project, topic: Topic<L>): L? {
return messageBus.syncPublisher(topic)
}

val <T> List<T>.tail: List<T>
get() = drop(1)

val <T> List<T>.head: T
get() = first()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,10 @@ package io.snyk.plugin.analytics

import com.intellij.openapi.components.Service
import com.intellij.openapi.project.Project
import io.snyk.plugin.Severity
import io.snyk.plugin.events.SnykCodeScanListenerLS
import io.snyk.plugin.events.SnykScanListener
import io.snyk.plugin.isSnykCodeLSEnabled
import io.snyk.plugin.snykcode.SnykCodeResults
import io.snyk.plugin.snykcode.core.SnykCodeFile
import snyk.common.SnykError
import snyk.common.lsp.LanguageServerWrapper
import snyk.common.lsp.ScanIssue
import snyk.common.lsp.SnykScanParams
import snyk.common.lsp.commands.ScanDoneEvent
import snyk.container.ContainerResult
import snyk.iac.IacResult
Expand Down Expand Up @@ -43,32 +37,6 @@ class AnalyticsScanListener(val project: Project) {
)
}

private val snykCodeScanListenerLS = object : SnykCodeScanListenerLS {
var start = 0L
override fun scanningStarted(snykScan: SnykScanParams) {
start = System.currentTimeMillis()
}

override fun scanningSnykCodeFinished(snykCodeResults: Map<SnykCodeFile, List<ScanIssue>>) {
val duration = System.currentTimeMillis() - start
val product = "Snyk Code"
val issues = snykCodeResults.values.flatten()
val scanDoneEvent = getScanDoneEvent(
duration,
product,
issues.count { it.getSeverityAsEnum() == Severity.CRITICAL },
issues.count { it.getSeverityAsEnum() == Severity.HIGH },
issues.count { it.getSeverityAsEnum() == Severity.MEDIUM },
issues.count { it.getSeverityAsEnum() == Severity.LOW },
)
LanguageServerWrapper.getInstance().sendReportAnalyticsCommand(scanDoneEvent)
}

override fun scanningSnykCodeError(snykScan: SnykScanParams) {
// do nothing
}
}

val snykScanListener = object : SnykScanListener {
var start: Long = 0

Expand Down Expand Up @@ -148,11 +116,5 @@ class AnalyticsScanListener(val project: Project) {
SnykScanListener.SNYK_SCAN_TOPIC,
snykScanListener,
)

if (isSnykCodeLSEnabled())
project.messageBus.connect().subscribe(
SnykCodeScanListenerLS.SNYK_SCAN_TOPIC,
snykCodeScanListenerLS,
)
}
}
Loading