This repository has been archived by the owner on Jan 12, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 710
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #4967 - Record search / ads providers appearing in search results
This brings the ads/search telemetry up to par with Fenix.
- Loading branch information
1 parent
1f4173d
commit 3ce7235
Showing
7 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,3 +83,52 @@ legacy_ids: | |
notification_emails: | ||
- [email protected] | ||
expires: never | ||
|
||
browser.search: | ||
with_ads: | ||
type: labeled_counter | ||
description: | | ||
Records counts of SERP pages with adverts displayed. | ||
The key format is `<provider-name>`. | ||
send_in_pings: | ||
- metrics | ||
bugs: | ||
- https://github.com/mozilla-mobile/fenix/issues/4967 | ||
data_reviews: | ||
- https://github.com/mozilla-mobile/focus-android/pull/4968#issuecomment-879256443 | ||
data_sensitivity: | ||
- interaction | ||
notification_emails: | ||
- [email protected] | ||
expires: "2022-07-01" | ||
ad_clicks: | ||
type: labeled_counter | ||
description: | | ||
Records clicks of adverts on SERP pages. | ||
The key format is `<provider-name>`. | ||
send_in_pings: | ||
- metrics | ||
bugs: | ||
- https://github.com/mozilla-mobile/fenix/issues/4967 | ||
data_reviews: | ||
- https://github.com/mozilla-mobile/focus-android/pull/4968#issuecomment-879256443 | ||
data_sensitivity: | ||
- interaction | ||
notification_emails: | ||
- [email protected] | ||
expires: "2022-07-01" | ||
in_content: | ||
type: labeled_counter | ||
description: | | ||
Records the type of interaction a user has on SERP pages. | ||
send_in_pings: | ||
- metrics | ||
bugs: | ||
- https://github.com/mozilla-mobile/fenix/issues/4967 | ||
data_reviews: | ||
- https://github.com/mozilla-mobile/focus-android/pull/4968#issuecomment-879256443 | ||
data_sensitivity: | ||
- interaction | ||
notification_emails: | ||
- [email protected] | ||
expires: "2022-07-01" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/java/org/mozilla/focus/telemetry/FactsProcessor.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.focus.telemetry | ||
|
||
import androidx.annotation.VisibleForTesting | ||
import mozilla.components.feature.search.telemetry.ads.AdsTelemetry | ||
import mozilla.components.feature.search.telemetry.incontent.InContentTelemetry | ||
import mozilla.components.support.base.Component | ||
import mozilla.components.support.base.facts.Fact | ||
import mozilla.components.support.base.facts.FactProcessor | ||
import mozilla.components.support.base.facts.Facts | ||
|
||
/** | ||
* Processes all [Fact]s emitted from Android Components based on which the appropriate telemetry | ||
* will be collected. | ||
*/ | ||
object FactsProcessor { | ||
fun initialize() { | ||
Facts.registerProcessor(object : FactProcessor { | ||
override fun process(fact: Fact) { | ||
fact.process() | ||
} | ||
}) | ||
} | ||
|
||
@VisibleForTesting | ||
internal fun Fact.process() = when (Pair(component, item)) { | ||
Component.FEATURE_SEARCH to AdsTelemetry.SERP_ADD_CLICKED -> { | ||
TelemetryWrapper.clickAddInSearchEvent(value!!) | ||
} | ||
Component.FEATURE_SEARCH to AdsTelemetry.SERP_SHOWN_WITH_ADDS -> { | ||
TelemetryWrapper.searchWithAdsShownEvent(value!!) | ||
} | ||
Component.FEATURE_SEARCH to InContentTelemetry.IN_CONTENT_SEARCH -> { | ||
TelemetryWrapper.inContentSearchEvent(value!!) | ||
} | ||
else -> Unit | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
app/src/test/java/org/mozilla/focus/telemetry/GleanMetricsServiceTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
package org.mozilla.focus.telemetry | ||
|
||
import android.content.Context | ||
import mozilla.components.browser.state.store.BrowserStore | ||
import mozilla.components.concept.engine.Engine | ||
import mozilla.components.feature.search.telemetry.ads.AdsTelemetry | ||
import mozilla.components.feature.search.telemetry.incontent.InContentTelemetry | ||
import org.junit.Test | ||
import org.mockito.Mockito.doReturn | ||
import org.mockito.Mockito.mock | ||
import org.mockito.Mockito.verify | ||
import org.mozilla.focus.Components | ||
|
||
class GleanMetricsServiceTest { | ||
@Test | ||
fun `WHEN installSearchTelemetryExtensions is called THEN install the ads and search telemetry extensions`() { | ||
val components = mock(Components::class.java) | ||
val store = mock(BrowserStore::class.java) | ||
val engine = mock(Engine::class.java) | ||
val adsExtension = mock(AdsTelemetry::class.java) | ||
val searchExtension = mock(InContentTelemetry::class.java) | ||
doReturn(engine).`when`(components).engine | ||
doReturn(store).`when`(components).store | ||
doReturn(adsExtension).`when`(components).adsTelemetry | ||
doReturn(searchExtension).`when`(components).searchTelemetry | ||
val glean = GleanMetricsService(mock(Context::class.java)) | ||
|
||
glean.installSearchTelemetryExtensions(components) | ||
|
||
verify(adsExtension).install(engine, store) | ||
verify(searchExtension).install(engine, store) | ||
} | ||
} |