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) (#11624)
Browse files Browse the repository at this point in the history
(cherry picked from commit d6efa19)

Co-authored-by: Roger Yang <[email protected]>
  • Loading branch information
mergify[bot] and rocketsroger authored Jan 26, 2022
1 parent 5c6316e commit 27f5b19
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

1 comment on commit 27f5b19

@firefoxci-taskcluster
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh oh! Looks like an error! Details

Failed to fetch task artifact public/github/customCheckRunText.md for GitHub integration.
Make sure the artifact exists on the worker or other location.

Please sign in to comment.