@ -16,6 +16,9 @@ import org.mozilla.fenix.shopping.store.ReviewQualityCheckMiddleware
import org.mozilla.fenix.shopping.store.ReviewQualityCheckState
import org.mozilla.fenix.shopping.store.ReviewQualityCheckState
import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductReviewState.AnalysisPresent.AnalysisStatus
import org.mozilla.fenix.shopping.store.ReviewQualityCheckState.OptedIn.ProductReviewState.AnalysisPresent.AnalysisStatus
private const val ACTION _ENABLED = " enabled "
private const val ACTION _DISABLED = " disabled "
/ * *
/ * *
* Middleware that captures telemetry events for the review quality check feature .
* Middleware that captures telemetry events for the review quality check feature .
* /
* /
@ -39,6 +42,7 @@ class ReviewQualityCheckTelemetryMiddleware(
}
}
}
}
@Suppress ( " LongMethod " )
private fun processAction (
private fun processAction (
store : Store < ReviewQualityCheckState , ReviewQualityCheckAction > ,
store : Store < ReviewQualityCheckState , ReviewQualityCheckAction > ,
action : ReviewQualityCheckAction . TelemetryAction ,
action : ReviewQualityCheckAction . TelemetryAction ,
@ -130,6 +134,32 @@ class ReviewQualityCheckTelemetryMiddleware(
is ReviewQualityCheckAction . OpenPoweredByLink -> {
is ReviewQualityCheckAction . OpenPoweredByLink -> {
Shopping . surfacePoweredByFakespotLinkClicked . record ( )
Shopping . surfacePoweredByFakespotLinkClicked . record ( )
}
}
is ReviewQualityCheckAction . RecommendedProductImpression -> {
Shopping . surfaceAdsImpression . record ( )
}
is ReviewQualityCheckAction . RecommendedProductClick -> {
Shopping . surfaceAdsClicked . record ( )
}
ReviewQualityCheckAction . ToggleProductRecommendation -> {
val state = store . state
if ( state is ReviewQualityCheckState . OptedIn &&
state . productRecommendationsPreference != null
) {
val toggleAction = if ( state . productRecommendationsPreference ) {
ACTION _ENABLED
} else {
ACTION _DISABLED
}
Shopping . surfaceAdsSettingToggled . record (
Shopping . SurfaceAdsSettingToggledExtra (
action = toggleAction ,
) ,
)
}
}
}
}
}
}