Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Commit

Permalink
No issue: Add valid channel set (#11622)
Browse files Browse the repository at this point in the history
  • Loading branch information
rocketsroger authored Jan 26, 2022
1 parent a4a7867 commit d6efa19
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ private val validCodeSet = setOf(
"ffab", "ffcm", "ffhp", "ffip", "ffit", "ffnt", "ffocus", "ffos", "ffsb", "fpas", "fpsa",
"ftas", "ftsa", "newext", "1000969a", null
)
private val validChannelSet = setOf("ts")

/**
* Get a String in a specific format allowing to identify how an ads/search provider was used.
Expand Down Expand Up @@ -70,7 +71,13 @@ internal fun getTrackKey(

// For Bing if it didn't have a valid cookie and for all the other search engines
if (hasValidCode(uri.getQueryParameter(provider.codeParam), provider)) {
val channel = uri.getQueryParameter(CHANNEL_KEY)
var channel = uri.getQueryParameter(CHANNEL_KEY)

// For Bug 1751955
if (!validChannelSet.contains(channel)) {
channel = null
}

val type = getSapType(provider.followOnParams, paramSet)
return TrackKeyInfo(provider.name, type, code, channel).createTrackKey()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,25 @@ class InContentTelemetryTest {
assertEquals("google.in-content.sap-follow-on.firefox-b-m.ts", facts[0].value)
}

@Test
fun `GIVEN an invalid Google channel from topSite WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() {
val url = "https://www.google.com/search?q=aaa&client=firefox-b-m&channel=tsTest&oq=random"
val facts = mutableListOf<Fact>()
Facts.registerProcessor(object : FactProcessor {
override fun process(fact: Fact) {
facts.add(fact)
}
})

telemetry.trackPartnerUrlTypeMetric(url, listOf())

assertEquals(1, facts.size)
assertEquals(Component.FEATURE_SEARCH, facts[0].component)
assertEquals(Action.INTERACTION, facts[0].action)
assertEquals(InContentTelemetry.IN_CONTENT_SEARCH, facts[0].item)
assertEquals("google.in-content.sap-follow-on.firefox-b-m", facts[0].value)
}

@Test
fun `GIVEN a Baidu sap-follow-on WHEN trackPartnerUrlTypeMetric is called THEN emit an appropriate IN_CONTENT_SEARCH fact`() {
val url = "https://m.baidu.com/s?from=1000969a&word=aaa&oq=random"
Expand Down

0 comments on commit d6efa19

Please sign in to comment.