diff --git a/app/metrics.yaml b/app/metrics.yaml index 69648f5e91..ab7cdaae70 100644 --- a/app/metrics.yaml +++ b/app/metrics.yaml @@ -10895,7 +10895,7 @@ fx_suggest: block_id: type: quantity description: | - A unique identifier for the suggestion (a.k.a. a keywords block). + A unique identifier for a sponsored suggestion. Not set for non-sponsored suggestions. bugs: - https://bugzilla.mozilla.org/show_bug.cgi?id=1857092 data_reviews: @@ -10951,7 +10951,8 @@ fx_suggest: reporting_url: type: url description: | - The url to report this interaction to. + If this ping is for a sponsored suggestion, the partner URL for reporting this interaction. + Not set for non-sponsored suggestions. bugs: - https://bugzilla.mozilla.org/show_bug.cgi?id=1857092 data_reviews: @@ -10987,7 +10988,8 @@ fx_suggest: iab_category: type: string description: | - The suggestion's category. Either "22 - Shopping" or "5 - Educational". + The suggestion's advertising category. "22 - Shopping" for sponsored suggestions. + Not set for non-sponsored suggestions. bugs: - https://bugzilla.mozilla.org/show_bug.cgi?id=1857092 data_reviews: diff --git a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt index 05fd947692..37bbc92813 100644 --- a/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt +++ b/app/src/main/java/org/mozilla/fenix/components/metrics/MetricController.kt @@ -280,23 +280,33 @@ internal class ReleaseMetricController( } } - Component.FEATURE_FXSUGGEST to FxSuggestFacts.Items.AMP_SUGGESTION_CLICKED -> { + Component.FEATURE_FXSUGGEST to FxSuggestFacts.Items.AMP_SUGGESTION_CLICKED, + Component.FEATURE_FXSUGGEST to FxSuggestFacts.Items.WIKIPEDIA_SUGGESTION_CLICKED, + -> { FxSuggest.pingType.set("fxsuggest-click") FxSuggest.isClicked.set(true) (metadata?.get(FxSuggestFacts.MetadataKeys.POSITION) as? Long)?.let { FxSuggest.position.set(it) } - (metadata?.get(FxSuggestFacts.MetadataKeys.INTERACTION_INFO) as? FxSuggestInteractionInfo.Amp)?.let { - FxSuggest.blockId.set(it.blockId) - FxSuggest.advertiser.set(it.advertiser) - FxSuggest.reportingUrl.set(it.reportingUrl) - FxSuggest.iabCategory.set(it.iabCategory) - FxSuggest.contextId.set(UUID.fromString(it.contextId)) + when (val clickInfo = metadata?.get(FxSuggestFacts.MetadataKeys.INTERACTION_INFO)) { + is FxSuggestInteractionInfo.Amp -> { + FxSuggest.blockId.set(clickInfo.blockId) + FxSuggest.advertiser.set(clickInfo.advertiser) + FxSuggest.reportingUrl.set(clickInfo.reportingUrl) + FxSuggest.iabCategory.set(clickInfo.iabCategory) + FxSuggest.contextId.set(UUID.fromString(clickInfo.contextId)) + } + is FxSuggestInteractionInfo.Wikipedia -> { + FxSuggest.advertiser.set("wikipedia") + FxSuggest.contextId.set(UUID.fromString(clickInfo.contextId)) + } } Pings.fxSuggest.submit() } - Component.FEATURE_FXSUGGEST to FxSuggestFacts.Items.AMP_SUGGESTION_IMPRESSED -> { + Component.FEATURE_FXSUGGEST to FxSuggestFacts.Items.AMP_SUGGESTION_IMPRESSED, + Component.FEATURE_FXSUGGEST to FxSuggestFacts.Items.WIKIPEDIA_SUGGESTION_IMPRESSED, + -> { FxSuggest.pingType.set("fxsuggest-impression") (metadata?.get(FxSuggestFacts.MetadataKeys.IS_CLICKED) as? Boolean)?.let { FxSuggest.isClicked.set(it) @@ -304,12 +314,18 @@ internal class ReleaseMetricController( (metadata?.get(FxSuggestFacts.MetadataKeys.POSITION) as? Long)?.let { FxSuggest.position.set(it) } - (metadata?.get(FxSuggestFacts.MetadataKeys.INTERACTION_INFO) as? FxSuggestInteractionInfo.Amp)?.let { - FxSuggest.blockId.set(it.blockId) - FxSuggest.advertiser.set(it.advertiser) - FxSuggest.reportingUrl.set(it.reportingUrl) - FxSuggest.iabCategory.set(it.iabCategory) - FxSuggest.contextId.set(UUID.fromString(it.contextId)) + when (val impressionInfo = metadata?.get(FxSuggestFacts.MetadataKeys.INTERACTION_INFO)) { + is FxSuggestInteractionInfo.Amp -> { + FxSuggest.blockId.set(impressionInfo.blockId) + FxSuggest.advertiser.set(impressionInfo.advertiser) + FxSuggest.reportingUrl.set(impressionInfo.reportingUrl) + FxSuggest.iabCategory.set(impressionInfo.iabCategory) + FxSuggest.contextId.set(UUID.fromString(impressionInfo.contextId)) + } + is FxSuggestInteractionInfo.Wikipedia -> { + FxSuggest.advertiser.set("wikipedia") + FxSuggest.contextId.set(UUID.fromString(impressionInfo.contextId)) + } } Pings.fxSuggest.submit() }