From 8bf4361c95b91a2b456512804c4544f4eb8a95cd Mon Sep 17 00:00:00 2001 From: Bastian Doetsch Date: Fri, 10 Nov 2023 17:06:19 +0100 Subject: [PATCH] fix: add edge case --- .../snyk/plugin/analytics/AnalyticsScanListener.kt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt b/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt index 23017c9c7..fcc18defd 100644 --- a/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt +++ b/src/main/kotlin/io/snyk/plugin/analytics/AnalyticsScanListener.kt @@ -52,17 +52,21 @@ class AnalyticsScanListener(val project: Project) { } override fun scanningSnykCodeFinished(snykCodeResults: SnykCodeResults?) { - snykCodeResults?.let { - val scanDoneEvent = getScanDoneEvent( - System.currentTimeMillis() - start, - "Snyk Code", + val duration = System.currentTimeMillis() - start + val product = "Snyk Code" + val scanDoneEvent = if (snykCodeResults != null) { + getScanDoneEvent( + duration, + product, snykCodeResults.totalCriticalCount, snykCodeResults.totalErrorsCount, snykCodeResults.totalWarnsCount, snykCodeResults.totalInfosCount, ) - getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) + } else { + getScanDoneEvent(duration, product, 0, 0, 0, 0) } + getSnykTaskQueueService(project)?.ls?.sendReportAnalyticsCommand(scanDoneEvent) } override fun scanningIacFinished(iacResult: IacResult) {