diff --git a/modules/common/src/main/scala/com.snowplowanalytics.snowplow.enrich/common/enrichments/registry/YauaaEnrichment.scala b/modules/common/src/main/scala/com.snowplowanalytics.snowplow.enrich/common/enrichments/registry/YauaaEnrichment.scala index c1edf7955..2ac17ba63 100644 --- a/modules/common/src/main/scala/com.snowplowanalytics.snowplow.enrich/common/enrichments/registry/YauaaEnrichment.scala +++ b/modules/common/src/main/scala/com.snowplowanalytics.snowplow.enrich/common/enrichments/registry/YauaaEnrichment.scala @@ -92,14 +92,14 @@ final case class YauaaEnrichment(cacheSize: Option[Int]) extends Enrichment { * @return Attributes retrieved thanks to the user agent (if any), as self-describing JSON. */ def getYauaaContext(userAgent: String, headers: List[String]): SelfDescribingData[Json] = - SelfDescribingData(YauaaEnrichment.outputSchema, parseUserAgent(userAgent, headers).asJson) + SelfDescribingData(YauaaEnrichment.outputSchema, analyzeUserAgent(userAgent, headers).asJson) /** * Gets the map of attributes retrieved by YAUAA from the user agent. * @return Map with all the fields extracted by YAUAA by parsing the user agent. * If the input is null or empty, a map with just the DeviceClass set to Unknown is returned. */ - def parseUserAgent(userAgent: String, headers: List[String]): Map[String, String] = + def analyzeUserAgent(userAgent: String, headers: List[String]): Map[String, String] = userAgent match { case null | "" => YauaaEnrichment.DefaultResult diff --git a/modules/common/src/test/scala/com.snowplowanalytics.snowplow.enrich.common/enrichments/registry/YauaaEnrichmentSpec.scala b/modules/common/src/test/scala/com.snowplowanalytics.snowplow.enrich.common/enrichments/registry/YauaaEnrichmentSpec.scala index fe52e8d19..03bacebb0 100644 --- a/modules/common/src/test/scala/com.snowplowanalytics.snowplow.enrich.common/enrichments/registry/YauaaEnrichmentSpec.scala +++ b/modules/common/src/test/scala/com.snowplowanalytics.snowplow.enrich.common/enrichments/registry/YauaaEnrichmentSpec.scala @@ -67,11 +67,11 @@ class YauaaEnrichmentSpec extends Specification with ValidatedMatchers { "YAUAA enrichment should" >> { "return default value for null" >> { - yauaaEnrichment.parseUserAgent(null, Nil) shouldEqual YauaaEnrichment.DefaultResult + yauaaEnrichment.analyzeUserAgent(null, Nil) shouldEqual YauaaEnrichment.DefaultResult } "return default value for empty user agent" >> { - yauaaEnrichment.parseUserAgent("", Nil) shouldEqual YauaaEnrichment.DefaultResult + yauaaEnrichment.analyzeUserAgent("", Nil) shouldEqual YauaaEnrichment.DefaultResult } "detect correctly DeviceClass" >> { @@ -187,14 +187,14 @@ class YauaaEnrichmentSpec extends Specification with ValidatedMatchers { "use client hint headers to aid parsing" >> { val clientHintHeader = """Sec-CH-UA-Full-Version-List: "Chromium";v="106.0.5249.119", "Google Chrome";v="106.0.5249.119", "Not;A=Brand";v="99.0.0.0"""" - yauaaEnrichment.parseUserAgent(uaChrome106, Nil)("agentNameVersion") shouldEqual "Chrome 106" - yauaaEnrichment.parseUserAgent(uaChrome106, List(clientHintHeader))("agentNameVersion") shouldEqual "Chrome 106.0.5249.119" + yauaaEnrichment.analyzeUserAgent(uaChrome106, Nil)("agentNameVersion") shouldEqual "Chrome 106" + yauaaEnrichment.analyzeUserAgent(uaChrome106, List(clientHintHeader))("agentNameVersion") shouldEqual "Chrome 106.0.5249.119" } /** Resembles the case when `ua` was sent as a field in the tp2 payload */ "Prioritize explicitly passed user agent over an http header" >> { val headers = List("User-Agent: curl/7.54") - yauaaEnrichment.parseUserAgent(uaFirefox, headers)("agentName") shouldEqual "Firefox" + yauaaEnrichment.analyzeUserAgent(uaFirefox, headers)("agentName") shouldEqual "Firefox" } "create a JSON with the schema 1-0-4 and the data" >> { @@ -246,7 +246,7 @@ class YauaaEnrichmentSpec extends Specification with ValidatedMatchers { "never add __SyntaxError__ to the context" >> { val ua = "useragent=Mozilla/5.0 (Linux armv7l) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 OPR/25.0.1620.0 OMI/4.3.18.7.Dominik.0 VSTVB MB100 HbbTV/1.2.1 (; PANASONIC; MB100; 0.1.34.28; ;) SmartTvA/3.0.0 UID (00:09:DF:A7:74:6B/MB100/PANASONIC/0.1.34.28)" - yauaaEnrichment.parseUserAgent(ua, Nil).contains("__SyntaxError__") shouldEqual false + yauaaEnrichment.analyzeUserAgent(ua, Nil).contains("__SyntaxError__") shouldEqual false } } @@ -254,7 +254,7 @@ class YauaaEnrichmentSpec extends Specification with ValidatedMatchers { def checkYauaaParsingForField(expectedResults: Map[String, String], fieldName: String) = expectedResults.map { case (userAgent, expectedField) => - yauaaEnrichment.parseUserAgent(userAgent, Nil)(decapitalize(fieldName)) shouldEqual expectedField + yauaaEnrichment.analyzeUserAgent(userAgent, Nil)(decapitalize(fieldName)) shouldEqual expectedField }.toList "decapitalize should" >> {