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
|
// 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_COMMERCE_CORE_METRICS_METRICS_UTILS_H_
#define COMPONENTS_COMMERCE_CORE_METRICS_METRICS_UTILS_H_
#include "components/optimization_guide/core/optimization_guide_util.h"
#include "components/optimization_guide/core/optimization_metadata.h"
#include "components/optimization_guide/proto/hints.pb.h"
#include "components/prefs/pref_service.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
class GURL;
namespace commerce {
class AccountChecker;
} // namespace commerce
namespace commerce::metrics {
extern const char kPDPNavShoppingListEligibleHistogramName[];
extern const char kPDPStateHistogramName[];
extern const char kPDPStateWithLocalMetaName[];
extern const char kShoppingListIneligibleHistogramName[];
// Possible options for the state of a product details page (PDP). These must be
// kept in sync with the values in enums.xml.
enum class ShoppingPDPState {
kNotPDP = 0,
// The cluster ID is used to identify a product that is not specific to a
// particular merchant (i.e. many merchants sell this). This is the
// counterpart to offer ID which identifies a product for a specific merchant.
kIsPDPWithoutClusterId = 1,
kIsPDPWithClusterId = 2,
// This enum must be last and is only used for histograms.
kMaxValue = kIsPDPWithClusterId
};
// The possible ways a product details page (PDP) can be detected. These must be
// kept in sync with the values in enums.xml.
enum class ShoppingPDPDetectionMethod {
kNotPDP = 0,
kPDPServerOnly = 1,
kPDPLocalMetaOnly = 2,
kPDPServerAndLocalMeta = 3,
// This enum must be last and is only used for histograms.
kMaxValue = kPDPServerAndLocalMeta
};
// Reasons why a user may be ineligible for a particular feature. These must be
// kept in sync with the values in enums.xml.
enum class ShoppingFeatureIneligibilityReason {
kOther = 0,
kUnsupportedCountryOrLocale = 1,
kEnterprisePolicy = 2,
kSignin = 3,
kSync = 4,
// Make search and browsing better.
kMSBB = 5,
// Web and app activity.
kWAA = 6,
kParentalControls = 7,
// This enum must be last and is only used for histograms.
kMaxValue = kParentalControls
};
// The possible actions that user can take on a shopping page. These must be
// kept in sync with Shopping.ShoppingActions in ukm.xml.
enum class ShoppingAction {
kDiscountCopied = 0,
kDiscountOpened = 1,
kPriceInsightsOpened = 2,
kPriceTracked = 3,
};
// Shopping features that are contextual. These must be kept in sync with the
// values in enums.xml.
enum class ShoppingContextualFeature {
kPriceTracking = 0,
kPriceInsights = 1,
kDiscounts = 2,
};
// Record the state of a PDP for a navigation.
void RecordPDPMetrics(optimization_guide::OptimizationGuideDecision decision,
const optimization_guide::OptimizationMetadata& metadata,
PrefService* pref_service,
bool is_off_the_record,
bool is_shopping_list_eligible,
const GURL& url);
// Record how a PDP was detected.
void RecordPDPStateWithLocalMeta(bool detected_by_server,
bool detected_by_client,
ukm::SourceId source_id);
// Record reasons why a user was ineligible for the shopping list feature.
void RecordShoppingListIneligibilityReasons(PrefService* pref_service,
AccountChecker* account_checker,
bool is_off_the_record,
bool supported_country);
// Record UKM for shopping actions that users take.
void RecordShoppingActionUKM(ukm::SourceId ukm_source_id,
ShoppingAction action);
} // namespace commerce::metrics
#endif // COMPONENTS_COMMERCE_CORE_METRICS_METRICS_UTILS_H_
|