Skip to content

Commit b77fe30

Browse files
mmustafa-tseBrandonStalnakermarkvdouw
authored
fix:screen attributes filters not working (#385)
* fix:screen attributes filters not working * fix:screen attributes filters not working * update submodule * ktlint fix --------- Co-authored-by: Brandon Stalnaker <33703490+BrandonStalnaker@users.noreply.github.com> Co-authored-by: markvdouw <v-mvanderouw@mparticle.com>
1 parent 28d0b28 commit b77fe30

3 files changed

Lines changed: 21 additions & 3 deletions

File tree

android-kit-base/src/main/java/com/mparticle/kits/KitConfiguration.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,10 +435,10 @@ public final Map<String, Object> filterEventAttributes(MPEvent event) {
435435
}
436436

437437
public final Map<String, Object> filterScreenAttributes(MParticle.EventType eventType, String eventName, Map<String, Object> eventAttributes) {
438-
return filterEventAttributes(eventType, eventName, mScreenNameFilters, eventAttributes);
438+
return filterEventAttributes(eventType, eventName, mScreenAttributeFilters, eventAttributes);
439439
}
440440

441-
public final Map<String, Object> filterEventAttributes(MParticle.EventType eventType, String eventName, SparseBooleanArray filter, Map<String, Object> eventAttributes) {
441+
public static final Map<String, Object> filterEventAttributes(MParticle.EventType eventType, String eventName, SparseBooleanArray filter, Map<String, Object> eventAttributes) {
442442
if (eventAttributes != null && eventAttributes.size() > 0 && filter != null && filter.size() > 0) {
443443
String eventTypeStr = "0";
444444
if (eventType != null) {

android-kit-base/src/test/kotlin/com/mparticle/kits/KitConfigurationTest.kt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,24 @@ class KitConfigurationTest {
391391
)
392392
}
393393

394+
@Test
395+
@Throws(Exception::class)
396+
fun testScreenAttributeFiltering() {
397+
val configuration =
398+
MockKitConfiguration.createKitConfiguration(JSONObject(" {\"id\":56, \"as\":{\"secretKey\":\"testappkey\", \"eventList\":\"[\\\"test1\\\",\\\"test2\\\",\\\"test3\\\"]\", \"sendTransactionData\":\"True\", \"eventAttributeList\":null }, \"hs\":{\"svea\":{\"1689004688\":0, \"1198002448\":1 } }, }"))
399+
val testAttributes = mapOf("screen attribute should not forward" to "testVal", "screen attribute should forward" to "testVal", "screen attribute should also forward" to "testVal")
400+
val filterdScreenAttributes = KitConfiguration.filterEventAttributes(null, "testScreenView", configuration.screenAttributeFilters, testAttributes)
401+
Assert.assertFalse(
402+
filterdScreenAttributes.containsKey("screen attribute should not forward")
403+
)
404+
Assert.assertTrue(
405+
filterdScreenAttributes.containsKey("screen attribute should forward")
406+
)
407+
Assert.assertTrue(
408+
filterdScreenAttributes.containsKey("screen attribute should also forward")
409+
)
410+
}
411+
394412
@Test
395413
@Throws(Exception::class)
396414
fun testConsentForwardingRules() {

0 commit comments

Comments
 (0)