-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
190 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 2 additions & 82 deletions
84
android-kit-base/src/main/java/com/mparticle/kits/MPSideloadedFilters.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,10 @@ | ||
package com.mparticle.kits | ||
|
||
import android.util.SparseBooleanArray | ||
import com.mparticle.MParticle | ||
import org.json.JSONObject | ||
|
||
class MPSideloadedFilters { | ||
|
||
var filters: MutableMap<String, String> = mutableMapOf() | ||
var filters: MutableMap<String, JSONObject> = mutableMapOf() | ||
private set | ||
|
||
// Each of these methods hashes these values using the correct algorithm as described | ||
// in the previous section and adds them to a private dictionary | ||
fun addEventTypeFilter(eventType: MParticle.EventType): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addEventNameFilter(eventType: MParticle.EventType, eventName: String): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addScreenNameFilter(screenName: String): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addEventAttributeFilter( | ||
eventType: MParticle.EventType, | ||
eventName: String, | ||
customAttributeKey: String | ||
): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addScreenAttributeFilter( | ||
screenName: String, | ||
customAttributeKey: String | ||
): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addUserIdentityFilter(userIdentity: SparseBooleanArray): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addUserAttributeFilter(userAttributeKey: String): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addCommerceEventAttributeFilter( | ||
eventType: MParticle.EventType, | ||
eventAttributeKey: String | ||
): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addCommerceEventEntityTypeFilter(commerceEventKind: SparseBooleanArray): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
fun addCommerceEventAppFamilyAttributeFilter(attributeKey: String): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
// Special filter case that can only have 1 at a time unlike the others | ||
// If `forward` is true, ONLY matching events are forwarded, if false, any matching events are blocked | ||
// NOTE: This is iOS/Android only, web has a different signature | ||
fun setEventAttributeConditionalForwarding( | ||
attributeName: String, | ||
attributeValue: String, | ||
onlyForward: Boolean | ||
): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
// NOTE: This is Web only | ||
// If isEvent is true, this is an event attribute conditional filter, if false, it's a user attribute conditional filter, | ||
// there can only be one or the other and that latter is not supported at all on iOS/Android. | ||
fun setAttributeConditionalForwarding( | ||
isEvent: Boolean, | ||
attributeName: String, | ||
attributeValue: String, | ||
onlyForward: Boolean | ||
): MPSideloadedFilters { | ||
return this | ||
} | ||
|
||
// iOS only, this accepts a string because the constants are strings, but in the inline docs comments and main docs, we will refer people to the constants | ||
fun addMessageTypeFilter(messageTypeConstant: String): MPSideloadedFilters { | ||
return this | ||
} | ||
} |
11 changes: 7 additions & 4 deletions
11
android-kit-base/src/main/java/com/mparticle/kits/MPSideloadedKit.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,22 @@ | ||
package com.mparticle.kits | ||
|
||
import com.mparticle.internal.SideloadedKit | ||
import org.json.JSONObject | ||
|
||
abstract class MPSideloadedKit : KitIntegration() { | ||
abstract class MPSideloadedKit : KitIntegration(), SideloadedKit { | ||
|
||
init { | ||
configuration = KitConfiguration.createKitConfiguration(JSONObject()) | ||
} | ||
|
||
fun addFilters(filters: MPSideloadedFilters): MPSideloadedKit { | ||
configuration = configuration.applyFilters(filters) | ||
fun addFilters(filter: MPSideloadedFilters): MPSideloadedKit { | ||
configuration = configuration.applyFilters(filter) | ||
return this | ||
} | ||
|
||
override fun getJsonConfig(): JSONObject = super.getJsonConfig() | ||
|
||
private fun KitConfiguration.applyFilters(filters: MPSideloadedFilters): KitConfiguration { | ||
return this | ||
return configuration.applySideloadedKits(filters) | ||
} | ||
} |