Bug 1858542 - Introduce `FxSuggestFactsMiddleware`.

This commit builds on bug 1857092 to record impressions for sponsored
Firefox Suggest search suggestions, and moves the logic for recording
clicks to the same middleware.

An impression means, "did the user see a suggestion when they finished
engaging with the awesomebar?" A "finished engagement" means the user
navigated to a URL, a search results page, or a shown suggestion.

We don't record impressions for:

* Suggestions that the user sees as they're typing.
* Abandoned engagements, when the user dismisses the awesomebar without
  navigating to a destination.

If the user taps on a Firefox Suggest suggestion, we record an
impression _and_ a click for that suggestion. If they tap on any other
suggestion, or navigate to a URL or search results page, we record an
impression only.

The new `FxSuggestFactsMiddleware` in this commit observes the
`EngagementFinished` action added in the last commit, and emits facts
for impressions and clicks.

(cherry picked from commit 196e46c25beba770227dde1594034b1275a450e5)
fenix/120.0
Lina Butler 7 months ago committed by mergify[bot]
parent ae0d46ae91
commit cf91e990c3

@ -16,7 +16,7 @@ import mozilla.components.feature.awesomebar.provider.HistoryStorageSuggestionPr
import mozilla.components.feature.awesomebar.provider.SearchSuggestionProvider
import mozilla.components.feature.awesomebar.provider.SessionSuggestionProvider
import mozilla.components.feature.contextmenu.facts.ContextMenuFacts
import mozilla.components.feature.fxsuggest.FxSuggestClickInfo
import mozilla.components.feature.fxsuggest.FxSuggestInteractionInfo
import mozilla.components.feature.fxsuggest.facts.FxSuggestFacts
import mozilla.components.feature.media.facts.MediaFacts
import mozilla.components.feature.prompts.dialog.LoginDialogFacts
@ -281,11 +281,11 @@ internal class ReleaseMetricController(
}
Component.FEATURE_FXSUGGEST to FxSuggestFacts.Items.AMP_SUGGESTION_CLICKED -> {
(metadata?.get(FxSuggestFacts.MetadataKeys.CLICK_INFO) as? FxSuggestClickInfo.Amp)?.let {
(metadata?.get(FxSuggestFacts.MetadataKeys.INTERACTION_INFO) as? FxSuggestInteractionInfo.Amp)?.let {
FxSuggest.pingType.set("fxsuggest-click")
FxSuggest.blockId.set(it.blockId)
FxSuggest.advertiser.set(it.advertiser)
FxSuggest.reportingUrl.set(it.clickUrl)
FxSuggest.reportingUrl.set(it.reportingUrl)
FxSuggest.iabCategory.set(it.iabCategory)
FxSuggest.contextId.set(UUID.fromString(it.contextId))
Pings.fxSuggest.submit()

Loading…
Cancel
Save