Skip to content

Commit

Permalink
Add additional logging to help diagnose issues when downloading catalogs
Browse files Browse the repository at this point in the history
  • Loading branch information
tmancey authored Apr 18, 2019
1 parent 6523053 commit 2180dab
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion vendor/bat-native-ads/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ Use staging Ads Serve as defined by `STAGING_SERVER` in `static_values.h`. Defau
--brave-ads-staging
```

Collect initial activity after 25 seconds instead of 1 hour as defined by `kDebugOneHourInSeconds` in `static_values.h`
Collect initial activity after 25 seconds instead of 1 hour as defined by `kDebugOneHourInSeconds` in `static_values.h` and download the catalog after 15 minutes instead of 2 hours as defined by `kDebugCatalogPing` in `static_values.h`

```
--brave-ads-debug
Expand Down
5 changes: 5 additions & 0 deletions vendor/bat-native-ads/src/bat/ads/internal/ads_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ void AdsImpl::SetConfirmationsIsReady(const bool is_ready) {

void AdsImpl::ChangeLocale(const std::string& locale) {
if (!IsInitialized()) {
BLOG(WARNING) << "Failed to change locale as not initialized";
return;
}

Expand Down Expand Up @@ -466,6 +467,7 @@ void AdsImpl::CachePageScore(

void AdsImpl::TestShoppingData(const std::string& url) {
if (!IsInitialized()) {
BLOG(WARNING) << "Failed to test shopping data as not initialized";
return;
}

Expand All @@ -478,6 +480,7 @@ void AdsImpl::TestShoppingData(const std::string& url) {

bool AdsImpl::TestSearchState(const std::string& url) {
if (!IsInitialized()) {
BLOG(WARNING) << "Failed to test search state as not initialized";
return false;
}

Expand All @@ -493,6 +496,7 @@ bool AdsImpl::TestSearchState(const std::string& url) {

void AdsImpl::ServeSampleAd() {
if (!IsInitialized()) {
BLOG(WARNING) << "Failed to serve sample Ad as not initialized";
return;
}

Expand Down Expand Up @@ -867,6 +871,7 @@ void AdsImpl::StartCollectingActivity(const uint64_t start_timer_in) {

void AdsImpl::CollectActivity() {
if (!IsInitialized()) {
BLOG(WARNING) << "Failed to collect activity as not initialized";
return;
}

Expand Down
7 changes: 6 additions & 1 deletion vendor/bat-native-ads/src/bat/ads/internal/ads_serve.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,12 @@ void AdsServe::Reset() {
void AdsServe::UpdateNextCatalogCheck() {
next_retry_start_timer_in_ = 0;

auto ping = bundle_->GetCatalogPing();
uint64_t ping;
if (_is_debug) {
ping = kDebugCatalogPing;
} else {
ping = bundle_->GetCatalogPing();
}

// Add randomized delay so that the Ad server can't correlate users by timing
auto rand_delay = base::RandInt(0, ping / 10);
Expand Down
1 change: 1 addition & 0 deletions vendor/bat-native-ads/src/bat/ads/internal/static_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ static const uint64_t kDeliverNotificationsAfterSeconds =
5 * base::Time::kSecondsPerMinute;

static const uint64_t kDefaultCatalogPing = 2 * base::Time::kSecondsPerHour;
static const uint64_t kDebugCatalogPing = 15 * base::Time::kSecondsPerMinute;

static char kDefaultLanguageCode[] = "en";
static char kDefaultCountryCode[] = "US";
Expand Down

0 comments on commit 2180dab

Please sign in to comment.