mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-03 23:15:31 +00:00
parent
f06e3a6493
commit
3a4f73be19
@ -13,6 +13,8 @@
|
||||
"include_globs": [
|
||||
"https://www.google.*/search*",
|
||||
"https://www.bing.com/search*",
|
||||
"https://www.baidu.com/*",
|
||||
"https://m.baidu.com/*",
|
||||
"https://duckduckgo.com/*"
|
||||
],
|
||||
"js": ["ads.js"],
|
||||
|
@ -12,8 +12,8 @@
|
||||
"matches": ["https://*/*"],
|
||||
"include_globs": [
|
||||
"https://www.google.*/search*",
|
||||
"https://www.baidu.com/from=844b/s*",
|
||||
"https://www.baidu.com/from=844b/baidu*",
|
||||
"https://www.baidu.com/*",
|
||||
"https://m.baidu.com/*",
|
||||
"https://*search.yahoo.com/search*",
|
||||
"https://www.bing.com/search*",
|
||||
"https://duckduckgo.com/*"
|
||||
|
@ -52,10 +52,10 @@ abstract class BaseSearchTelemetry {
|
||||
),
|
||||
SearchProviderModel(
|
||||
name = "baidu",
|
||||
regexp = "^https:\\/\\/www\\.baidu\\.com\\/from=844b\\/(?:s|baidu)",
|
||||
queryParam = "wd",
|
||||
codeParam = "tn",
|
||||
codePrefixes = listOf("34046034_", "monline_"),
|
||||
regexp = "^https:\\/\\/m\\.baidu\\.com(?:.*)\\/s",
|
||||
queryParam = "word",
|
||||
codeParam = "from",
|
||||
codePrefixes = listOf("1000969a"),
|
||||
followOnParams = listOf("oq")
|
||||
),
|
||||
SearchProviderModel(
|
||||
|
@ -22,6 +22,20 @@ internal fun getTrackKey(
|
||||
|
||||
if (provider.codeParam.isNotEmpty()) {
|
||||
code = uri.getQueryParameter(provider.codeParam)
|
||||
if (code.isNullOrEmpty() &&
|
||||
provider.name == "baidu" &&
|
||||
uri.toString().contains("from=")) {
|
||||
code = uri.toString().substringAfter("from=", "")
|
||||
.substringBefore("/", "")
|
||||
}
|
||||
|
||||
// Glean doesn't allow code starting with a figure
|
||||
if (code != null && code.isNotEmpty()) {
|
||||
val codeStart = code.first()
|
||||
if (codeStart.isDigit()) {
|
||||
code = "_$code"
|
||||
}
|
||||
}
|
||||
|
||||
// Try cookies first because Bing has followOnCookies and valid code, but no
|
||||
// followOnParams => would tracks organic instead of sap-follow-on
|
||||
@ -33,7 +47,7 @@ internal fun getTrackKey(
|
||||
}
|
||||
|
||||
// For Bing if it didn't have a valid cookie and for all the other search engines
|
||||
if (hasValidCode(code, provider)) {
|
||||
if (hasValidCode(uri.getQueryParameter(provider.codeParam), provider)) {
|
||||
val channel = uri.getQueryParameter(CHANNEL_KEY)
|
||||
val type = getSapType(provider.followOnParams, paramSet)
|
||||
return TrackKeyInfo(provider.name, type, code, channel).createTrackKey()
|
||||
|
@ -84,11 +84,11 @@ class InContentTelemetryTest {
|
||||
|
||||
@Test
|
||||
fun `track baidu sap metric`() {
|
||||
val url = "https://www.baidu.com/from=844b/s?wd=aaa&tn=34046034_firefox"
|
||||
val url = "https://m.baidu.com/s?from=1000969a&word=aaa"
|
||||
|
||||
telemetry.trackPartnerUrlTypeMetric(url, listOf())
|
||||
|
||||
verify { metrics.track(Event.SearchInContent("baidu.in-content.sap.34046034_firefox")) }
|
||||
verify { metrics.track(Event.SearchInContent("baidu.in-content.sap._1000969a")) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -120,11 +120,11 @@ class InContentTelemetryTest {
|
||||
|
||||
@Test
|
||||
fun `track baidu sap-follow-on metric`() {
|
||||
val url = "https://www.baidu.com/from=844b/s?wd=aaa&tn=34046034_firefox&oq=random"
|
||||
val url = "https://m.baidu.com/s?from=1000969a&word=aaa&oq=random"
|
||||
|
||||
telemetry.trackPartnerUrlTypeMetric(url, listOf())
|
||||
|
||||
verify { metrics.track(Event.SearchInContent("baidu.in-content.sap-follow-on.34046034_firefox")) }
|
||||
verify { metrics.track(Event.SearchInContent("baidu.in-content.sap-follow-on._1000969a")) }
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -165,7 +165,7 @@ class InContentTelemetryTest {
|
||||
|
||||
@Test
|
||||
fun `track baidu organic metric`() {
|
||||
val url = "https://www.baidu.com/from=844b/s?wd=aaa"
|
||||
val url = "https://m.baidu.com/s?word=aaa"
|
||||
|
||||
telemetry.trackPartnerUrlTypeMetric(url, listOf())
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user