1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138

ash / glanceables / glanceables_metrics.h [blame]

// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef ASH_GLANCEABLES_GLANCEABLES_METRICS_H_
#define ASH_GLANCEABLES_GLANCEABLES_METRICS_H_

#include <string>

#include "ash/ash_export.h"
#include "base/time/time.h"

namespace base {
class TimeDelta;
}  // namespace base

namespace ash {

enum class StudentAssignmentsListType;

// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused.
// Note this should be kept in sync with `ContextualGoogleIntegrationStatus`
// enum in tools/metrics/histograms/metadata/ash/enums.xml.
enum class ContextualGoogleIntegrationStatus {
  kEnabled = 0,
  kDisabledByPolicy = 1,
  kDisabledByAppBlock = 2,
  kDisabledByUrlBlock = 3,
  kMaxValue = kDisabledByUrlBlock,
};

enum class TasksLaunchSource {
  kHeaderButton = 0,
  kAddNewTaskButton = 1,
  kFooterButton = 2,
  kEditInGoogleTasksButton = 3,
  kMaxValue = kEditInGoogleTasksButton,
};

enum class TaskModificationResult {
  kCommitted = 0,
  kCancelled = 1,
  kMaxValue = kCancelled
};

ASH_EXPORT void RecordContextualGoogleIntegrationStatus(
    const std::string& integration_name,
    ContextualGoogleIntegrationStatus status);

void RecordActiveTaskListChanged();

void RecordTaskMarkedAsCompleted(bool complete);

void RecordTasksLaunchSource(TasksLaunchSource source);

// Records a user action that indicates that a user with no tasks preformed an
// action that redirected them to tasks web UI.
void RecordUserWithNoTasksRedictedToTasksUI();

// Records an user action indicating the user triggered tasks glanceables UI to
// add a new task.
void RecordUserStartedAddingTask();

// Records a histogram that tracks whether the UI to add a task resulted in an
// tasks API request to create a new task, or whether the task creation was
// cancelled.
void RecordTaskAdditionResult(TaskModificationResult result);

// Records the number of tasks the user added from the tasks UI. The count is
// scoped to the time a task list is being shown - it will be reset when the
// bubble is reopened, or the user changes the selected task list.
// `added_tasks` - number of tasks added.
// `in_empty_task_list` - whether the task list was empty when selected.
// `first_usage` - whether the user had any tasks at the time the task list was
// selected - this will be true for users that had a single empty task list.
void RecordNumberOfAddedTasks(int added_tasks,
                              bool in_empty_task_list,
                              bool first_usage);

// Records an user action indicating the user clicked on a task title, which
// triggers UI to modify the task.
void RecordUserModifyingTask();

// Records a histogram that tracks whether the UI to modify a task resulted in
// an tasks API request to update the task, or whether the task modification
// was no-op.
void RecordTaskModificationResult(TaskModificationResult result);

void RecordAddTaskButtonShownForTT();

// Records "Add new task" button impression vs. interaction for new Tasks users
// (users with only one tasks list and zero tasks in it) and only for Trusted
// Testers UI.
void RecordAddTaskButtonUsageForNewTasksUsersTT(bool pressed);

void RecordLoginToShowTime(base::TimeDelta login_to_show_time);

void RecordTotalShowTime(base::TimeDelta total_show_time);

void RecordTotalShowTimeForClassroom(base::TimeDelta total_show_time);

void RecordTotalShowTimeForTasks(base::TimeDelta total_show_time);

void RecordClassromInitialLoadTime(bool first_occurrence,
                                   base::TimeDelta load_time);

void RecordClassroomChangeLoadTime(bool success, base::TimeDelta load_time);

void RecordTasksInitialLoadTime(bool first_occurrence,
                                base::TimeDelta load_time);

void RecordTasksChangeLoadTime(base::TimeDelta load_time);

void RecordTasksListChangeCount(int change_count);

// Record the length of time that the `list_type` was shown.
void RecordStudentAssignmentListShowTime(StudentAssignmentsListType list_type,
                                         base::TimeDelta time_shown,
                                         bool default_list);

// Records user actions for user press on an assignment.
// `default_list` - whether the assignment was pressed for the assignment list
// that was shown initially.
void RecordStudentAssignmentPressed(bool default_list);

// Records that the user pressed a header icon in the classroom bubble.
void RecordClassroomHeaderIconPressed();

// Record the number of times that the student assignment list changed.
void RecordStudentSelectedListChangeCount(int change_count);

// Record that the `list_type` was selected.
void RecordStudentAssignmentListSelected(StudentAssignmentsListType list_type);

}  // namespace ash

#endif  // ASH_GLANCEABLES_GLANCEABLES_METRICS_H_