#include "chrome/browser/web_applications/daily_metrics_helper.h"
#include <stdint.h>
#include <algorithm>
#include <string>
#include <utility>
#include "base/check.h"
#include "base/functional/bind.h"
#include "base/numerics/clamped_math.h"
#include "base/value_iterators.h"
#include "base/values.h"
#include "chrome/browser/metrics/ukm_background_recorder_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "components/metrics/date_changed_helper.h"
#include "components/prefs/pref_registry_simple.h"
#include "components/prefs/pref_service.h"
#include "components/prefs/scoped_user_pref_update.h"
#include "components/ukm/app_source_url_recorder.h"
#include "content/public/browser/browser_thread.h"
#include "services/metrics/public/cpp/metrics_utils.h"
#include "services/metrics/public/cpp/ukm_builders.h"
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "url/origin.h"
namespace web_app {
namespace {
int BucketedDailySeconds(base::TimeDelta delta) { … }
}
class DesktopWebAppUkmRecorder { … };
namespace {
optional;
bool skip_origin_check_for_testing_ = …;
const char kInstalled[] = …;
const char kInstallSource[] = …;
const char kEffectiveDisplayMode[] = …;
const char kCapturesLinks[] = …;
const char kPromotable[] = …;
const char kForegroundDurationSec[] = …;
const char kBackgroundDurationSec[] = …;
const char kNumSessions[] = …;
optional<DailyInteraction> DictToRecord(const std::string& url,
const base::Value::Dict& record_dict) { … }
base::Value::Dict RecordToDict(DailyInteraction& record) { … }
void EmitIfSourceIdExists(DailyInteraction record,
optional<ukm::SourceId> origin_source_id) { … }
void EmitRecord(DailyInteraction record, Profile* profile) { … }
void EmitRecords(Profile* profile) { … }
void RemoveRecords(PrefService* prefs) { … }
void UpdateRecord(DailyInteraction& record, PrefService* prefs) { … }
}
DailyInteraction::DailyInteraction() = default;
DailyInteraction::DailyInteraction(GURL start_url)
: … { … }
DailyInteraction::DailyInteraction(const DailyInteraction&) = default;
DailyInteraction::~DailyInteraction() = default;
void FlushOldRecordsAndUpdate(DailyInteraction& record, Profile* profile) { … }
void FlushAllRecordsForTesting(Profile* profile) { … }
void SkipOriginCheckForTesting() { … }
void RegisterDailyWebAppMetricsProfilePrefs(PrefRegistrySimple* registry) { … }
}