Skip to content

Commit 95fe032

Browse files
fix: user attribute filtering logic in KitConfiguration
1 parent d19da0f commit 95fe032

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/main/kotlin/com/mparticle/kits/RoktKit.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ class RoktKit :
248248
val userAttributes = mutableMapOf<String, String>()
249249
for ((key, value) in attributes) {
250250
val hashKey = KitUtils.hashForFiltering(key)
251-
if (!kitConfiguration.mUserAttributeFilters.get(hashKey)) {
251+
if (kitConfiguration.mUserAttributeFilters.get(hashKey,true)) {
252252
userAttributes[key] = value
253253
}
254254
}

src/test/kotlin/com/mparticle/kits/RoktKitTests.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ class RoktKitTests {
359359
val filteredKey: String = KitUtils.hashForFiltering("ShouldFilter").toString()
360360
val filteredKey2: String = KitUtils.hashForFiltering("ShouldFilter_key_2").toString()
361361
jsonObject.put(filteredKey, 0)
362-
jsonObject.put(filteredKey2, 1)
362+
jsonObject.put(filteredKey2, 0)
363363
} catch (e: Exception) {
364364
println("Exception occurred: ${e.message}")
365365
}
@@ -1012,7 +1012,7 @@ class RoktKitTests {
10121012
val filteredKey: String = KitUtils.hashForFiltering("ShouldFilter").toString()
10131013
val filteredKey2: String = KitUtils.hashForFiltering("ShouldFilter_key_2").toString()
10141014
jsonObject.put(filteredKey, 0)
1015-
jsonObject.put(filteredKey2, 1)
1015+
jsonObject.put(filteredKey2, 0)
10161016
} catch (e: Exception) {
10171017
println("Exception occurred: ${e.message}")
10181018
}

src/test/kotlin/com/mparticle/kits/mocks/MockKitConfiguration.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ open class MockKitConfiguration : KitConfiguration() {
4141
override fun get(key: Int, valueIfKeyNotFound: Boolean): Boolean {
4242
print("SparseArray getting: $key")
4343
return if (map.containsKey(key)) {
44-
true
44+
map[key] ?: valueIfKeyNotFound
4545
} else {
4646
valueIfKeyNotFound
4747
}

0 commit comments

Comments
 (0)