File: stats.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (122 lines) | stat: -rw-r--r-- 3,893 bytes parent folder | download | duplicates (6)
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
// 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.
// LINT.IfChange(TriggerHelpUIResult)
enum class TriggerHelpUIResult {
  // The help UI is triggered.
  SUCCESS = 0,

  // The help UI is not triggered.
  FAILURE = 1,

  // Event model is not ready.
  FAILURE_EVENT_MODEL_NOT_READY = 2,

  // Some other help UI is currently showing.
  FAILURE_CURRENTLY_SHOWING = 3,

  // The feature is disabled.
  FAILURE_FEATURE_DISABLED = 4,

  // Configuration can not be parsed.
  FAILURE_CONFIG_INVALID = 5,

  // Used event precondition is not satisfied.
  FAILURE_USED_PRECONDITION_UNMET = 6,

  // Trigger event precondition is not satisfied.
  FAILURE_TRIGGER_PRECONDITION_UNMET = 7,

  // Other event precondition is not satisfied.
  FAILURE_OTHER_PRECONDITION_UNMET = 8,

  // Session rate does not meet the requirement.
  FAILURE_SESSION_RATE = 9,

  // Availability model is not ready.
  FAILURE_AVAILABILITY_MODEL_NOT_READY = 10,

  // Availability precondition is not satisfied.
  FAILURE_AVAILABILITY_PRECONDITION_UNMET = 11,

  // Same as |SUCCESS|, but feature configuration was set to tracking only.
  SUCCESS_TRACKING_ONLY = 12,

  // Display of help UI is locked.
  FAILURE_DISPLAY_LOCK = 13,

  // Groups conditions are not satisfied.
  FAILURE_GROUPS_PRECONDITION_UNMET = 14,

  // Last entry for the enum.
  COUNT = 15,
};
// LINT.ThenChange(//tools/metrics/histograms/enums.xml: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 {
  // Events store.
  EVENTS_STORE = 0,

  // Availability store.
  AVAILABILITY_STORE = 1,
};

// 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_