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
|
// Copyright 2022 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_DEVICE_SIGNALS_CORE_BROWSER_METRICS_UTILS_H_
#define COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_METRICS_UTILS_H_
#include <optional>
#include "base/time/time.h"
namespace device_signals {
enum class SignalCollectionError;
enum class SignalName;
enum class UserPermission;
// Set of possible errors encountered when parsing some signal values from a
// file or other data source. Do not reorder the values. Also change
// DeviceSignalsParsingError in enums.xml if adding new values here.
enum class SignalsParsingError {
kHitMaxDataSize = 0,
kDataMalformed = 1,
kBase64DecodingFailed = 2,
kJsonParsingFailed = 3,
kMissingRequiredProperty = 4,
kMaxValue = kMissingRequiredProperty
};
// Records that `permission` was the outcome of a permission check.
void LogUserPermissionChecked(UserPermission permission);
// Records that a request to collect `signal_name` was received.
void LogSignalCollectionRequested(SignalName signal_name);
// Records that a request to collect `number_of_signals` was received.
void LogSignalsCountRequested(size_t number_of_signals);
// Records that a request to collect the parameterized signal named
// `signal_name` was received with `number_of_items` parameters.
void LogSignalCollectionRequestedWithItems(SignalName signal_name,
size_t number_of_items);
// Records that the collection of the signal `signal_name` failed with `error`,
// which, based on `is_top_level_error`, is either a top-level aggregation
// error, or a collection-level error. `start_time` is the time at which the
// signal collection request was received.
void LogSignalCollectionFailed(SignalName signal_name,
base::TimeTicks start_time,
SignalCollectionError error,
bool is_top_level_error);
// Records that the collection of the signal `signal_name` was successful.
// If applicable, will also record the number of items collected as given by
// `signal_collection_size`. `start_time` is the time at which the
// signal collection request was received. `signal_request_size` is the number
// of items that were part of the signal collection request.
void LogSignalCollectionSucceeded(
SignalName signal_name,
base::TimeTicks start_time,
std::optional<size_t> signal_collection_size,
std::optional<size_t> signal_request_size = std::nullopt);
// Records that an error occurred when trying to parse signals from the
// CrowdStrike data.zta file.
void LogCrowdStrikeParsingError(SignalsParsingError error);
} // namespace device_signals
#endif // COMPONENTS_DEVICE_SIGNALS_CORE_BROWSER_METRICS_UTILS_H_
|