chromium/components/feature_engagement/internal/stats.h

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

#ifndef COMPONENTS_FEATURE_ENGAGEMENT_INTERNAL_STATS_H_
#define COMPONENTS_FEATURE_ENGAGEMENT_INTERNAL_STATS_H_

#include <string>
#include <vector>

#include "components/feature_engagement/internal/condition_validator.h"
#include "components/feature_engagement/internal/proto/feature_event.pb.h"
#include "components/feature_engagement/public/configuration.h"
#include "components/feature_engagement/public/tracker.h"

namespace feature_engagement {
namespace stats {

// Enum used in the metrics to record the result when in-product help UI is
// going to be triggered.
// Most of the fields maps to |ConditionValidator::Result|.
// The failure reasons are not mutually exclusive.
// Out-dated entries shouldn't be deleted but marked as obselete.
// Keep this synced with the enum in //tools/metrics/histograms/enums.xml.
enum class TriggerHelpUIResult {};

// Used in metrics to track database states. Each type will match to a suffix
// in the histograms to identify the database.
enum class StoreType {};

// Helper function that converts a store type to histogram suffix string.
std::string ToDbHistogramSuffix(StoreType type);

// Records the feature engagement events. Used event will be tracked
// separately.
void RecordNotifyEvent(const std::string& event,
                       const Configuration* config,
                       bool is_model_ready);

// Records user action and the result histogram when in-product help will be
// shown to the user.
void RecordShouldTriggerHelpUI(const base::Feature& feature,
                               const FeatureConfig& feature_config,
                               const ConditionValidator::Result& result);

// Records when the user dismisses the in-product help UI.
void RecordUserDismiss();

// Records when the user dismisses or snoozes the snoozable in-product help UI.
void RecordUserSnoozeAction(Tracker::SnoozeAction snooze_action);

// Records the result of database updates.
void RecordDbUpdate(bool success, StoreType type);

// Record database init.
void RecordDbInitEvent(bool success, StoreType type);

// Records events database load event.
void RecordEventDbLoadEvent(bool success, const std::vector<Event>& events);

// Records availability database load event.
void RecordAvailabilityDbLoadEvent(bool success);

}  // namespace stats
}  // namespace feature_engagement

#endif  // COMPONENTS_FEATURE_ENGAGEMENT_INTERNAL_STATS_H_