Skip to content

Commit

Permalink
Truncate language in platform context entity to max 8 characters (close
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Jun 29, 2023
1 parent bd0c37d commit 8e82e52
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,14 @@ class MockDeviceInfoMonitor : DeviceInfoMonitor() {
return 70000
}

override val language: String?
private var _language: String? = "sk"
override var language: String?
get() {
increaseMethodAccessCount("language")
return "sk"
return _language
}
set(value) {
_language = value
}

override fun getResolution(context: Context): String? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,19 @@ class PlatformContextTest {
Assert.assertFalse(sdjData.containsKey(Parameters.IS_PORTRAIT))
}

@Test
fun truncatesLanguageToMax8Chars() {
val deviceInfoMonitor = MockDeviceInfoMonitor()
deviceInfoMonitor.language = "1234567890"
val platformContext = PlatformContext(0, 0, deviceInfoMonitor, null, context)

val sdj = platformContext.getMobileContext(false)
Assert.assertNotNull(sdj)
val sdjData = sdj!!.map["data"] as Map<*, *>

Assert.assertEquals("12345678", sdjData[Parameters.MOBILE_LANGUAGE])
}

// --- PRIVATE
private val context: Context
get() = InstrumentationRegistry.getInstrumentation().targetContext
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class PlatformContext(
}
// Language
if (shouldTrack(PlatformContextProperty.LANGUAGE)) {
addToMap(Parameters.MOBILE_LANGUAGE, deviceInfoMonitor.language, pairs)
addToMap(Parameters.MOBILE_LANGUAGE, deviceInfoMonitor.language?.take(8), pairs)
}

setEphemeralPlatformDict()
Expand Down

0 comments on commit 8e82e52

Please sign in to comment.