• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2021 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef COMPONENTS_METRICS_STRUCTURED_NEUTRINO_LOGGING_H_
6 #define COMPONENTS_METRICS_STRUCTURED_NEUTRINO_LOGGING_H_
7 
8 #include <string>
9 
10 // Some functions in this file are called by code in //components/metrics, so
11 // nothing here can depend upon //components/metrics. Functions that need to
12 // depend upon //components/metrics should be placed in neutrino_logging_util.h.
13 
14 namespace metrics {
15 namespace structured {
16 
17 // Specifies the location in the code that NeurinoDevices logging occurs.
18 // 1: Other
19 // 2-9: Code paths within ForceClientIdCreation.
20 // 10-99: Code paths leading to ForceClientIDCreation.
21 // 100-199: Code paths leading to UpdateMetricsPrefsOnPermissionChange.
22 // 200+: Other locations.
23 // These values are persisted to logs. Entries should not be renumbered and
24 // numerical values should never be reused.
25 enum class NeutrinoDevicesLocation {
26   kOther = 1,
27   kClientIdFromLocalState = 2,
28   kClientIdBackupRecovered = 3,
29   kClientIdNew = 4,
30   kClientIdFromProvisionalId = 5,
31   kEnableRecording = 10,
32   kMetricsStateManager = 11,
33   kCreateVariationsService = 12,
34   kCreateMetricsServiceClient = 13,
35   kCreateEntropyProvider = 14,
36   kSetMetricsReporting = 101,
37   kChangeMetricsReportingStateWithReply = 102,
38   kOnEulaAccepted = 103,
39   kFirstRunDiolag = 104,
40   kMaybeEnableUma = 105,
41   kNotifyObservers = 106,
42   kIsEnabled = 107,
43   kLoginDisplayHostWebUI = 201,
44   kLoginDisplayHostWebUIDestructor = 202,
45   kProvidePreviousSessionData = 203,
46   kIsMetricsAndCrashReportingEnabled = 204,
47   kIsMetricsReportingPolicyManaged = 205,
48 };
49 
50 // Log the location in the code to the NeutrinoDevices structured metrics log.
51 void NeutrinoDevicesLog(const NeutrinoDevicesLocation location);
52 
53 // Log the location in the code and the client id to the NeutrinoDevices
54 // structured metrics log.
55 void NeutrinoDevicesLogWithClientId(const std::string& client_id,
56                                     NeutrinoDevicesLocation location);
57 
58 // Log the policy status (managed or unmanaged) and location in the code
59 // to the NeutrinoDevices structured metrics log.
60 void NeutrinoDevicesLogPolicy(const std::string& client_id,
61                               bool is_managed,
62                               NeutrinoDevicesLocation location);
63 
64 // Log that the client id has been cleared to the NeutrinoDevices structured
65 // metrics log.
66 void NeutrinoDevicesLogClientIdCleared(
67     const std::string& client_id,
68     int64_t install_date_timestamp,
69     int64_t metrics_reporting_enabled_timestamp);
70 
71 // Log that the client id has been changed to the NeutrinoDevices structured
72 // metrics log.
73 void NeutrinoDevicesLogClientIdChanged(
74     const std::string& client_id,
75     const std::string& initial_client_id,
76     int64_t install_date_timestamp,
77     int64_t metrics_reporting_enabled_timestamp,
78     NeutrinoDevicesLocation location);
79 
80 }  // namespace structured
81 }  // namespace metrics
82 
83 #endif  // COMPONENTS_METRICS_STRUCTURED_NEUTRINO_LOGGING_H_
84