/
rewards_p3a.h
97 lines (72 loc) · 2.47 KB
/
rewards_p3a.h
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
/* Copyright 2019 The Brave Authors. All rights reserved.
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_P3A_H_
#define BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_P3A_H_
#include <stddef.h>
#include <ctype.h>
#include <string>
#include "base/containers/flat_map.h"
#include "base/strings/string_piece.h"
class PrefService;
namespace base {
class DictionaryValue;
}
namespace brave_rewards {
namespace p3a {
struct WalletState {
bool wallet_created = false;
bool rewards_enabled = false;
bool grants_claimed = false;
bool funds_added = false;
};
void RecordWalletState(const WalletState& state);
void RecordWalletBalance(bool wallet_created,
bool rewards_enabled,
size_t balance);
enum class AutoContributionsState {
kNoWallet,
kRewardsDisabled,
kWalletCreatedAutoContributeOff,
kAutoContributeOn,
};
void RecordAutoContributionsState(AutoContributionsState state, int count);
void RecordTipsState(bool wallet_created,
bool rewards_enabled,
int one_time_count,
int recurring_count);
enum class AdsState {
kNoWallet,
kRewardsDisabled,
kAdsDisabled,
kAdsEnabled,
kAdsEnabledThenDisabledRewardsOn,
kAdsEnabledThenDisabledRewardsOff,
kMaxValue = kAdsEnabledThenDisabledRewardsOff,
};
void RecordAdsState(AdsState state);
void UpdateAdsStateOnPreferenceChange(PrefService* prefs,
const std::string& pref);
// Records an initial metric state ("disabled" or "enabled") if it was not done
// before. Intended to be called if the user has already created a wallet.
void MaybeRecordInitialAdsState(PrefService* local_state);
void RecordNoWalletCreatedForAllMetrics();
void RecordRewardsDisabledForSomeMetrics();
enum class RewardsEnabledDuration {
kNever,
kStillEnabled,
kHours,
kDays,
kWeeks,
kMonths,
kLonger,
kMaxValue = kLonger,
};
void RecordRewardsEnabledDuration(PrefService* prefs, bool rewards_enabled);
double CalcWalletBalance(base::flat_map<std::string, double> wallets,
double user_funds);
void ExtractAndLogStats(const base::DictionaryValue& dict);
} // namespace p3a
} // namespace brave_rewards
#endif // BRAVE_COMPONENTS_BRAVE_REWARDS_BROWSER_REWARDS_P3A_H_