This repository has been archived by the owner on Feb 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For #6556: Adds Telemetry counts for Search Access Points
Added two new sources to be counted ('widget' and 'shortcut') besides 'action' and 'suggestion'. Also modified/fixed some tests.
- Loading branch information
1 parent
9c25d27
commit 981d19d
Showing
16 changed files
with
247 additions
and
57 deletions.
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
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
54 changes: 54 additions & 0 deletions
54
app/src/main/java/org/mozilla/fenix/components/metrics/MetricsUtils.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,54 @@ | ||
/* 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.fenix.components.metrics | ||
|
||
import android.content.Context | ||
import mozilla.components.browser.search.SearchEngine | ||
import org.mozilla.fenix.components.metrics.Event.PerformedSearch.SearchAccessPoint | ||
import org.mozilla.fenix.components.searchengine.CustomSearchEngineStore | ||
import org.mozilla.fenix.ext.searchEngineManager | ||
|
||
object MetricsUtils { | ||
fun createSearchEvent( | ||
engine: SearchEngine, | ||
context: Context, | ||
searchAccessPoint: SearchAccessPoint | ||
): Event.PerformedSearch? { | ||
val isShortcut = engine != context.searchEngineManager.defaultSearchEngine | ||
val isCustom = CustomSearchEngineStore.isCustomSearchEngine(context, engine.identifier) | ||
|
||
val engineSource = | ||
if (isShortcut) Event.PerformedSearch.EngineSource.Shortcut(engine, isCustom) | ||
else Event.PerformedSearch.EngineSource.Default(engine, isCustom) | ||
|
||
return when (searchAccessPoint) { | ||
SearchAccessPoint.SUGGESTION -> Event.PerformedSearch( | ||
Event.PerformedSearch.EventSource.Suggestion( | ||
engineSource | ||
) | ||
) | ||
SearchAccessPoint.ACTION -> Event.PerformedSearch( | ||
Event.PerformedSearch.EventSource.Action( | ||
engineSource | ||
) | ||
) | ||
SearchAccessPoint.WIDGET -> Event.PerformedSearch( | ||
Event.PerformedSearch.EventSource.Widget( | ||
engineSource | ||
) | ||
) | ||
SearchAccessPoint.SHORTCUT -> Event.PerformedSearch( | ||
Event.PerformedSearch.EventSource.Shortcut( | ||
engineSource | ||
) | ||
) | ||
SearchAccessPoint.NONE -> Event.PerformedSearch( | ||
Event.PerformedSearch.EventSource.Other( | ||
engineSource | ||
) | ||
) | ||
} | ||
} | ||
} |
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
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
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
Oops, something went wrong.