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
class MealDemeterEventDispatcher @Inject constructor( | |
@MealDemeter private val demeter: Demeter, | |
) : EventDispatcher { | |
override fun report(event: Event) { | |
val eventData = event.getData().analyticsMap[MealEvent.DEMETER] ?: return | |
... | |
when (eventGroup) { |
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
demeter.addEventResultReporter(DemeterResultReporter()) | |
... | |
class DemeterResultReporter : EventResultReporter { | |
override fun report(result: Result<String>) { | |
if (result.isFailure) { | |
// Report the result | |
} |
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
internal class BatchEventOperation : Operation { | |
override suspend fun operate(demeter: Demeter) { | |
val events = demeter.eventDataProvider.fetchAwaitingEvents(FETCH_EVENT_SIZE) | |
... | |
demeter.eventDataProvider.updateEventStatus( | |
events = events, | |
eventStatus = EventStatus.PROCESSING, |
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
{ | |
"session_id": "...", | |
"platform": "...", | |
"timestamp": "...", | |
"os_version": "...", | |
"app_version": "...", | |
"domain": "...", | |
"channel": "...", | |
"parameters": { | |
"event_param1": "...", |
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
LifecycleAwareTimer.Builder() | |
.interval(DISPATCHER_TIMER_INTERVAL) | |
.scope(dispatcherScope) | |
.lifecycleOwner(ProcessLifecycleOwner.get()) | |
.onInterval(this::onInterval) | |
.build() |
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
internal class DemeterInitializer : Initializer { | |
override suspend fun initialize(demeter: Demeter) { | |
demeter.eventDataProvider.updateEventStatus(EventStatus.AWAITING) | |
} | |
} |
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
internal class OperationQueue(demeter: Demeter, coroutineScope: CoroutineScope) { | |
private val queue = Channel<Operation>(BUFFER_SIZE) | |
init { | |
queue.receiveAsFlow() | |
.onEach { operation -> | |
runCatching { | |
operation.operate(demeter) | |
}.onFailure { |
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
fun sendEvent(name: String, group: String, screen: String, parameters: Map<String, String>) { | |
singleEventDispatcher.dispatch(name, group, screen, parameters) | |
} | |
fun enqueueEvent(name: String, group: String, screen: String, parameters: Map<String, String>) { | |
batchEventDispatcher.dispatch(name, group, screen, parameters) | |
} |
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
class MealDemeterInterceptor @Inject constructor( | |
private val buildConfigProvider: BuildConfigProvider, | |
private val buildModelProvider: BuildModelProvider, | |
) : Demeter.Interceptor { | |
override suspend fun intercept(parameters: Parameters): Parameters { | |
val mutableParameters = parameters.toMutableMap() | |
mutableParameters["os_version"] = buildModelProvider.getBuildVersion() | |
mutableParameters["app_version"] = buildConfigProvider.getAppVersionName() | |
mutableParameters["domain"] = DOMAIN |
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
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { | |
val bottomSheetDialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog | |
bottomSheetDialog.setOnShowListener { | |
val containerLayout = dialog?.findViewById( | |
com.google.android.material.R.id.container | |
) as? FrameLayout | |
val buttonLayout = LayoutInflater.from(dialog?.context) | |
.inflate(R.layout.layout_delivery_bottom_sheet_buttons, null) | |
.findViewById<LinearLayout>(R.id.layoutButtons) |
NewerOlder