Skip to content

Commit

Permalink
fix: Barcode usage in ContinuousScanActivity
Browse files Browse the repository at this point in the history
  • Loading branch information
VaiTon committed Nov 6, 2022
1 parent 80770c8 commit 220021c
Showing 1 changed file with 12 additions and 7 deletions.
Expand Up @@ -67,7 +67,6 @@ import openfoodfacts.github.scrachx.openfood.features.product.view.summary.Abstr
import openfoodfacts.github.scrachx.openfood.features.product.view.summary.IngredientAnalysisTagsAdapter
import openfoodfacts.github.scrachx.openfood.features.product.view.summary.SummaryProductPresenter
import openfoodfacts.github.scrachx.openfood.features.shared.BaseActivity
import openfoodfacts.github.scrachx.openfood.features.simplescan.SimpleScanViewModel
import openfoodfacts.github.scrachx.openfood.listeners.CommonBottomListenerInstaller.installBottomNavigation
import openfoodfacts.github.scrachx.openfood.listeners.CommonBottomListenerInstaller.selectNavigationItem
import openfoodfacts.github.scrachx.openfood.models.Barcode
Expand Down Expand Up @@ -575,13 +574,19 @@ class ContinuousScanActivity : BaseActivity(), IProductView {
cameraView.stopCameraPreview()
super.onPause()

trackingEvent?.let {
matomoAnalytics.trackEvent(
AnalyticsEvent.BarcodeDecoder(
success = isBarcodeValid(lastBarcode),
duration = it.computeDurationInSeconds(),
)
trackScannerAccuracy()
}

private fun trackScannerAccuracy() {
val trackingEvent = this.trackingEvent
val lastBarcode = this.lastBarcode

if (trackingEvent != null && lastBarcode != null) {
val event = AnalyticsEvent.BarcodeDecoder(
success = lastBarcode.isValid(),
duration = trackingEvent.computeDurationInSeconds(),
)
matomoAnalytics.trackEvent(event)
}
}

Expand Down

0 comments on commit 220021c

Please sign in to comment.