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

ash / ambient / metrics / ambient_consumer_session_metrics_delegate.cc [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.

#include "ash/ambient/metrics/ambient_consumer_session_metrics_delegate.h"

#include <utility>

#include "ash/ambient/metrics/ambient_metrics.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/public/cpp/ambient/ambient_ui_model.h"
#include "ash/shell.h"
#include "base/check.h"
#include "base/logging.h"
#include "base/metrics/histogram_functions.h"
#include "base/strings/strcat.h"

namespace ash {

AmbientConsumerSessionMetricsDelegate::AmbientConsumerSessionMetricsDelegate(
    AmbientUiSettings ui_settings)
    : ui_settings_(std::move(ui_settings)) {}

AmbientConsumerSessionMetricsDelegate::
    ~AmbientConsumerSessionMetricsDelegate() = default;

void AmbientConsumerSessionMetricsDelegate::RecordActivation() {
  ambient::RecordAmbientModeActivation(
      /*ui_mode=*/LockScreen::HasInstance() ? AmbientUiMode::kLockScreenUi
                                            : AmbientUiMode::kInSessionUi,
      /*tablet_mode=*/Shell::Get()->IsInTabletMode());
}

void AmbientConsumerSessionMetricsDelegate::RecordInitStatus(bool success) {
  base::UmaHistogramBoolean(
      base::StrCat({"Ash.AmbientMode.Init.", ui_settings_.ToString()}),
      success);
}

void AmbientConsumerSessionMetricsDelegate::RecordStartupTime(
    base::TimeDelta startup_time) {
  ambient::RecordAmbientModeStartupTime(startup_time, ui_settings_);
}

void AmbientConsumerSessionMetricsDelegate::RecordEngagementTime(
    base::TimeDelta engagement_time) {
  ambient::RecordAmbientModeTimeElapsed(
      engagement_time, Shell::Get()->IsInTabletMode(), ui_settings_);
}

void AmbientConsumerSessionMetricsDelegate::RecordScreenCount(int num_screens) {
  base::UmaHistogramCounts100(
      base::StrCat({"Ash.AmbientMode.ScreenCount.", ui_settings_.ToString()}),
      num_screens);
}

}  // namespace ash