eventproducer
This module is only intended for internal use at TIDAL, but feel free to look at the code.
Event Producer is an events transportation layer of the TIDAL Event Platform (TEP). Its responsibility is to make sure that events get transported to the backend as fast, secure, and reliable as possible.
Features
Sending events in batches.
Filtering events based on the provided blocked consent categories list.
Collecting and sending monitoring data about dropped events.
Notifying about the Outage.
Documentation
Read the documentation for a detailed overview of the EventProducer functionality.
Check the API documentation for the module classes and methods.
Visit our TIDAL Developer Platform for more information and getting started.
Usage
Installation
Add the dependency to your build.gradle.kts
file.
dependencies {
implementation("com.tidal.sdk:eventproducer:<VERSION>")
}
Initialization
The EventSender role exposes functionality for sending events and monitoring the status of the transportation layer. It is exposed through the EventProducer which is initialized by providing appropriate configuration and CredentialsProvider. The tlConsumerUri
parameter is optional, with its default value set to the Tidal production environment. If user chooses to provide their own ingest endpoint, it's important to ensure that the entire backend infrastructure is in place.
val eventsConfig = EventsConfig(
maxDiskUsageBytes = 1000000,
blockedConsentCategories = setOf(ConsentCategory.PERFORMANCE),
appVersion = "1.0",
)
val eventProducer = EventProducer.getInstance(
credentialsProvider = getCredentialsProvider(),
config = eventsConfig,
context = context,
coroutineScope = CoroutineScope(Dispatchers.IO),
tlConsumerUri = URI("https://event-collector-url")
)
val eventSender = eventProducer.eventSender
Sending events
eventSender.sendEvent(
eventName = "click_button",
consentCategory = ConsentCategory.PERFORMANCE,
payload = "{'buttonId':'123'}",
headers = mapOf("client-id" to "45678")
)
Updating blockedConsentCategories
on the fly
eventSender.setBlockedConsentCategories(setOf(ConsentCategory.TARGETING))
Receiving outage notifications
coroutineScope.launch {
eventSender.outageState.collect {
if (it is OutageState.Outage) {
// Outage start
} else if (it is OutageState.NoOutage) {
// Outage end
}
}
}