Add firebase event for task completions

pull/3074/head
Alex Baker 4 weeks ago
parent 257bf826b6
commit 689cd20a88

@ -50,6 +50,9 @@ class Firebase @Inject constructor(
fun addTask(source: String) =
logEvent(R.string.event_add_task, R.string.param_type to source)
fun completeTask(source: String) =
logEvent(R.string.event_complete_task, R.string.param_type to source)
fun logEvent(@StringRes event: Int, vararg p: Pair<Int, Any>) {
analytics?.logEvent(context.getString(event), Bundle().apply {
p.forEach {

@ -12,6 +12,7 @@ import org.tasks.GrpcProto.Tasks
import org.tasks.GrpcProto.ToggleGroupRequest
import org.tasks.GrpcProto.ToggleGroupResponse
import org.tasks.WearServiceGrpcKt
import org.tasks.analytics.Firebase
import org.tasks.copy
import org.tasks.data.isHidden
import org.tasks.filters.AstridOrderingFilter
@ -27,6 +28,7 @@ class WearService(
private val taskCompleter: TaskCompleter,
private val headerFormatter: HeaderFormatter,
private val settings: DataStore<GrpcProto.Settings>,
private val firebase: Firebase,
) : WearServiceGrpcKt.WearServiceCoroutineImplBase() {
override suspend fun getTasks(request: GetTasksRequest): Tasks {
val position = request.position
@ -85,6 +87,7 @@ class WearService(
override suspend fun completeTask(request: CompleteTaskRequest): CompleteTaskResponse {
taskCompleter.setComplete(request.id, request.completed)
firebase.completeTask("wearable")
return CompleteTaskResponse.newBuilder().setSuccess(true).build()
}

@ -958,6 +958,7 @@ class TaskListFragment : Fragment(), OnRefreshListener, Toolbar.OnMenuItemClickL
}
lifecycleScope.launch {
taskCompleter.setComplete(task.task, newState)
firebase.completeTask("task_list")
taskAdapter.onCompletedTask(task.uuid, newState)
loadTaskListContent()
}

@ -7,6 +7,7 @@ import com.todoroo.astrid.service.TaskCompleter
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.launch
import org.tasks.analytics.Firebase
import org.tasks.data.dao.NotificationDao
import org.tasks.injection.ApplicationScope
import org.tasks.notifications.NotificationManager
@ -19,6 +20,7 @@ class CompleteTaskReceiver : BroadcastReceiver() {
@Inject lateinit var notificationDao: NotificationDao
@Inject lateinit var taskCompleter: TaskCompleter
@Inject @ApplicationScope lateinit var scope: CoroutineScope
@Inject lateinit var firebase: Firebase
override fun onReceive(context: Context, intent: Intent) {
val taskId = intent.getLongExtra(TASK_ID, 0)
@ -30,6 +32,7 @@ class CompleteTaskReceiver : BroadcastReceiver() {
}
notificationManager.cancel(taskId)
taskCompleter.setComplete(taskId)
firebase.completeTask("notification")
}
}

@ -16,6 +16,7 @@ import com.todoroo.astrid.service.TaskCreator
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
import org.tasks.R
import org.tasks.analytics.Firebase
import org.tasks.compose.edit.SubtaskRow
import org.tasks.data.dao.GoogleTaskDao
import org.tasks.data.entity.Task
@ -39,6 +40,7 @@ class SubtaskControlSet : TaskEditControlFragment() {
@Inject lateinit var chipProvider: ChipProvider
@Inject lateinit var colorProvider: ColorProvider
@Inject lateinit var preferences: Preferences
@Inject lateinit var firebase: Firebase
private lateinit var listViewModel: TaskListViewModel
private val mainViewModel: MainActivityViewModel by activityViewModels()
@ -106,6 +108,7 @@ class SubtaskControlSet : TaskEditControlFragment() {
private fun complete(task: Task, completed: Boolean) = lifecycleScope.launch {
taskCompleter.setComplete(task, completed)
firebase.completeTask("edit_screen_subtask")
}
companion object {

@ -401,6 +401,9 @@ class TaskEditViewModel @Inject constructor(
if (task.isCompleted != completed) {
taskCompleter.setComplete(task, completed)
if (task.isCompleted) {
firebase?.completeTask("edit_screen")
}
}
if (isNew) {

@ -4,13 +4,14 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.todoroo.astrid.dao.TaskDao
import org.tasks.data.entity.Task
import com.todoroo.astrid.service.TaskCompleter
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.NonCancellable
import kotlinx.coroutines.launch
import org.tasks.LocalBroadcastManager
import org.tasks.R
import org.tasks.analytics.Firebase
import org.tasks.data.entity.Task
import org.tasks.dialogs.BaseDateTimePicker.OnDismissHandler
import org.tasks.dialogs.DateTimePicker.Companion.newDateTimePicker
import org.tasks.intents.TaskIntents
@ -23,6 +24,7 @@ class WidgetClickActivity : AppCompatActivity(), OnDismissHandler {
@Inject lateinit var taskDao: TaskDao
@Inject lateinit var localBroadcastManager: LocalBroadcastManager
@Inject lateinit var preferences: Preferences
@Inject lateinit var firebase: Firebase
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -35,6 +37,7 @@ class WidgetClickActivity : AppCompatActivity(), OnDismissHandler {
COMPLETE_TASK -> {
lifecycleScope.launch(NonCancellable) {
taskCompleter.setComplete(task, !task.isCompleted)
firebase.completeTask("widget")
}
finish()
}

@ -422,6 +422,7 @@
<string name="event_banner_beast">banner_beast</string>
<string name="event_banner_sub">banner_subscribe</string>
<string name="event_add_task">add_task</string>
<string name="event_complete_task">complete_task</string>
<string name="event_request_review">request_review</string>
<string name="param_type">type</string>
<string name="p_map_theme">map_theme</string>

Loading…
Cancel
Save