Updated on 2026-08-14
This commit is contained in:
parent
de93d0f350
commit
fec0f14952
2 changed files with 15 additions and 2 deletions
|
|
@ -87,11 +87,11 @@ object Analytics : GlobalAnalyticsEventHandler {
|
|||
|
||||
val eventFilter = analyticsFilters.firstOrNull { it.canBeAppliedTo(event) }
|
||||
when {
|
||||
eventFilter == null -> analyticsHandlers.forEach { it.send(eventString, eventParams) }
|
||||
eventFilter == null -> analyticsHandlers.forEach { handler -> handler.send(eventString, eventParams) }
|
||||
eventFilter.canBeSent(event) -> {
|
||||
analyticsHandlers
|
||||
.filter { handler -> eventFilter.canBeConsumedByHandler(handler, event) }
|
||||
.forEach { it.send(eventString, eventParams) }
|
||||
.forEach { handler -> handler.send(eventString, eventParams) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,10 +4,23 @@ import com.tangem.tap.common.analytics.events.AnalyticsEvent
|
|||
|
||||
/**
|
||||
[REDACTED_AUTHOR]
|
||||
* The filter is used to separate events to send and determine which handler it can be processed with.
|
||||
*/
|
||||
interface AnalyticsEventFilter {
|
||||
/**
|
||||
* Recognizes the event and checks if the given filter can be applied to the event.
|
||||
*/
|
||||
fun canBeAppliedTo(event: AnalyticsEvent): Boolean
|
||||
|
||||
/**
|
||||
* An internal filter check that, on external or internal conditions, recognizes the possibility of
|
||||
* sending an event.
|
||||
*/
|
||||
fun canBeSent(event: AnalyticsEvent): Boolean
|
||||
|
||||
/**
|
||||
* Performs a check to see if the event can be dispatched by a specific handler
|
||||
*/
|
||||
fun canBeConsumedByHandler(handler: AnalyticsEventHandler, event: AnalyticsEvent): Boolean
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue