Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ads diagnostics ads internals #7004

Closed
wants to merge 2 commits into from

Conversation

yachtcaptain23
Copy link
Contributor

Resolves brave/brave-browser#10964

Submitter Checklist:

Test Plan:

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@yachtcaptain23 yachtcaptain23 force-pushed the feature/ads_diagnostics_ads-internals branch from 6d30f95 to 2fa40d7 Compare December 8, 2020 01:52
@yachtcaptain23 yachtcaptain23 marked this pull request as ready for review December 8, 2020 02:20
@yachtcaptain23 yachtcaptain23 requested review from tmancey and a team as code owners December 8, 2020 02:20
return;
}

base::DictionaryValue info_dict;
Copy link
Collaborator

@tmancey tmancey Dec 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be serialized from the ads lib using base::JSONReader and passed via std::string as then we do not need to update Rewards internals for future changes

@@ -51,6 +51,12 @@ void AdsService::RegisterProfilePrefs(
registry->RegisterBooleanPref(
ads::prefs::kShouldAllowConversionTracking, true);

// Diagnostics
registry->RegisterIntegerPref(ads::prefs::kEligibleAdsCount, -1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we persisting some values in prefs as all of these values can be returned in the serialized JSON from the ads library?

onClick={this.props.onGet}
/>
</ButtonWrapper>
<div>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be dynamically building the following based upon the JSON

@@ -459,6 +459,7 @@
<message name="IDS_BRAVE_REWARDS_INTERNALS_EVENT_LOG_TIME" desc="when event was logged">Logged at</message>
<message name="IDS_BRAVE_REWARDS_INTERNALS_MAIN_DISCLAIMER" desc="">WARNING: Data on this page may be sensitive. Treat them as you would your wallet private keys. Be careful who you share them with.</message>
<message name="IDS_BRAVE_REWARDS_INTERNALS_CONTRIBUTION_TYPE" desc="Contribution type">Type:</message>
<message name="IDS_BRAVE_REWARDS_INTERNALS_TAB_GENERAL_ADS_INFO" desc="">General Ads Info</message>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please change General Ads Info to Ad Diagnostics

Comment on lines +31 to +32
using InternalsInfoCallback =
std::function<void(InternalsInfoPtr)>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fits on same line

Comment on lines +9 to +10
#include "brave/vendor/bat-native-ads/include/bat/ads/public/interfaces/ads.mojom.h"
#include "brave/vendor/bat-native-ads/include/bat/ads/public/interfaces/ads_database.mojom.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we add brave/vendor/bat-native-ads-include/ as this should not be needed?

Comment on lines +16 to +18
using InternalsInfo = mojom::BraveAdsInternalsInfo;
using InternalsInfoPtr = mojom::BraveAdsInternalsInfoPtr;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please move to after BuildChannel/BuildChannelPtr

@@ -10,6 +10,16 @@ enum BraveAdsEnvironment {
DEVELOPMENT
};

struct BraveAdsInternalsInfo {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, as discussed we should be serializing as JSON in the library and rendering the JSON in the UI as this will reduce changes within the rewards code for future additions

@@ -174,7 +174,7 @@ void AdServing::MaybeServeAdForParentChildCategories(
const CreativeAdNotificationList eligible_ads =
eligible_ad_notifications.Get(ads,
last_delivered_creative_ad_, ad_events);

ads_client_->SetIntegerPref(prefs::kEligibleAdsCount, eligible_ads.size());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be storing diagnostics under a pref, we should have a diagnostics object, which has a data structure and this data structure is serialized, i.e. AdDiagnostics()->Get()->SetEligibleAdCount(...). Then AdsImpl::GetInternalsInfo can get the serialized JSON from this object

Comment on lines +289 to +296
InternalsInfo info_ = *info;
info->catalog_id = AdsClientHelper::Get()->GetStringPref(prefs::kCatalogId);
info->catalog_last_updated = AdsClientHelper::Get()->GetInt64Pref(prefs::kCatalogLastUpdated);
info->enabled = IsInitialized();
info->eligible_ads_count = 0;
info->flagged_ads = "";
info->last_filtered_ads = "";
callback(std::move(info));
Copy link
Collaborator

@tmancey tmancey Dec 8, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AdsImpl should not have any business logic other than calling out to fetch the required information, please move to an AdDiagnostics class, see UserActivity for an example

@@ -472,7 +490,7 @@ void AdsImpl::InitializeStep6(
is_initialized_ = true;

BLOG(1, "Successfully initialized ads");

AdsClientHelper::Get()->SetIntegerPref(prefs::kEligibleAdsCount, -1);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above concerning state

@@ -10,6 +10,7 @@
#include <string>
#include <vector>

#include "base/strings/stringprintf.h"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this needed?

Copy link
Collaborator

@tmancey tmancey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments, thanks

@tmancey tmancey closed this Jun 11, 2021
@tmancey tmancey deleted the feature/ads_diagnostics_ads-internals branch June 11, 2021 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Ads tab on brave://rewards-internals with diagnostic information
2 participants