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

Issue 8341: Add the default search engine metric. #4771

Merged
merged 2 commits into from
Mar 23, 2020
Merged

Conversation

iefremov
Copy link
Contributor

@iefremov iefremov commented Feb 27, 2020

brave/brave-browser#8341

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.

@iefremov iefremov changed the title Issue 8341: Add the default search engine metric. [WIP] Issue 8341: Add the default search engine metric. Feb 27, 2020
@iefremov iefremov changed the title [WIP] Issue 8341: Add the default search engine metric. Issue 8341: Add the default search engine metric. Mar 3, 2020
@iefremov
Copy link
Contributor Author

iefremov commented Mar 3, 2020

@bridiver @simonhong ready for review

@@ -47,7 +48,7 @@ KeyedService* InitializeSearchEngineProviderServiceIfNeeded(Profile* profile) {
return new PrivateWindowSearchEngineProviderService(profile);
}

return nullptr;
return new DefaultSearchEngineProviderService(profile);
Copy link
Member

@simonhong simonhong Mar 4, 2020

Choose a reason for hiding this comment

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

Hmm, using |profile| could make confusing.
So far, SearchEngineProviderService and its subclasses are instantiated with otr profile because they are only used for otr profile. and all implementation assumes it's otr profile.
How about introducing new service instead of subclassing SearchEngineProviderService?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, that's a good point, I was thinking about it, but decided that observing a single data point doesn't worth creating a whole new service :) If you feel like writing a separate one is more clear, I will do that

Copy link
Member

Choose a reason for hiding this comment

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

actually, passing normal profile doesn't cause any side effect because you're only using original_template_url_service_. Or, how about adding some comments?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, I think this service factory is not a proper place to get default search engine metric because this service was intended only for handling default search engine of non-normal profile.
but you only want normal profile's default search engine changing.
If we don't have yet, I think general-purpose service seems fine for logging metric if there is no good point for. WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Or just using different service with this factory. is it strange?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think I'll just go for separate service&factory to reduce confusion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

SearchEngineType type = GetEngineType_ChromiumImpl(url);
if (type == SEARCH_ENGINE_OTHER) {
for (const auto& entry : brave_engines_map) {
const auto& engine = entry.second;
Copy link
Member

Choose a reason for hiding this comment

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

This causes compile failure - maybe you want const auto*?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

compiled successfully on my machine :-/

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@iefremov iefremov force-pushed the ie_search_p3a branch 2 times, most recently from 37af5ca to 8e535ee Compare March 5, 2020 08:26
@iefremov
Copy link
Contributor Author

iefremov commented Mar 5, 2020

@simonhong ptal

@iefremov
Copy link
Contributor Author

iefremov commented Mar 5, 2020

@bridiver pls check the removed patch. We don't need it because:

  1. It is not needed for anything
  2. It spoils the existing chromium histogram values
  3. without it I can reuse the enum for my P3A purposes

SearchEngineTrackerFactory::~SearchEngineTrackerFactory() {}

KeyedService* SearchEngineTrackerFactory::BuildServiceInstanceFor(
content::BrowserContext* context) const {
Copy link
Member

Choose a reason for hiding this comment

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

How about return nullptr if |context| is non normal profile?
I think this only tracks for normal profile?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It already works like this, as per BrowserContextKeyedServiceFactory::GetBrowserContextToUse

Copy link
Member

Choose a reason for hiding this comment

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

Oh, it's default behavior! :)

@simonhong
Copy link
Member

please add issue url in the description.

const SearchTermsData& search_terms =
template_url_service_->search_terms_data();
const GURL& url = template_url->GenerateSearchURL(search_terms);
if (url != default_search_url_) {
Copy link
Member

Choose a reason for hiding this comment

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

Just out of curiosity, this callback is called in url == default_search_url_ case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think yes, because other details (e.g. shortcut or anything else) could be changed, and in this case the callback fires as well

@iefremov
Copy link
Contributor Author

iefremov commented Mar 5, 2020

please add issue url in the description.

added, I hope this will not close it ...

Copy link
Member

@simonhong simonhong left a comment

Choose a reason for hiding this comment

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

LGTM

@iefremov iefremov self-assigned this Mar 17, 2020
@bsclifton
Copy link
Member

@bridiver can you please review 😄 I'll try to check out soon too!

Copy link
Collaborator

@bridiver bridiver left a comment

Choose a reason for hiding this comment

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

patch change looks good

@iefremov iefremov merged commit 3ecf1ba into master Mar 23, 2020
@iefremov iefremov deleted the ie_search_p3a branch March 23, 2020 10:04
bsclifton pushed a commit that referenced this pull request Mar 24, 2020
Issue 8341: Add the default search engine metric.
@GeetaSarvadnya
Copy link

GeetaSarvadnya commented Mar 25, 2020

Edit: Only Question 2 is implemented in this PR. @iefremov logged a follow-up issue for Question1 brave/brave-browser#8854

@GeetaSarvadnya
Copy link

GeetaSarvadnya commented Mar 25, 2020

Verification PASSED with Windows 10 x64 using

Brave 1.8.36 Chromium: 81.0.4044.69 (Official Build) nightly (64-bit)
Revision 6813546031a4bc83f717a2ef7cd4ac6ec1199132-refs/branch-heads/4044@{#776}
OS Windows 10 OS Version 1803 (Build 17134.1006)

Question 2 - metric Brave.Search.DefaultEngine

Clean profile:

  • Verified that default search engine response value is displayed as 1 for Google
  • Verified that search engine response value is displayed as 2 when DDG custom search engine is set in brave://settings/search
  • Verified that search engine response value is displayed as 3 when Startpage custom search engine is set in brave://settings/search
  • Verified that search engine response value is displayed as 4 when Bing custom search engine is set in brave://settings/search
  • Verified that search engine response value is displayed as 5 when Qwant custom search engine is set in brave://settings/search
  • Verified that default search engine response value is displayed as 1 when there is no custom search engine set in the welcome screen
  • Verified that search engine response value is displayed as 2 when DDG custom search engine is set in the welcome screen
  • Verified that search engine response value is displayed as 3 when Startpage custom search engine is set in the welcome screen
  • Verified that search engine response value is displayed as 4 when Bing custom search engine is set in the welcome screen
  • Verified that search engine response value is displayed as 5 when Qwant custom search engine is set in the welcome screen

Upgraded profile:

  • Install 1.6.42 and upgrade to 1.8.36 and ensure that default search engine response value is displayed as 1 for Google
  • Install 1.6.42 and set the default search engine to DDG and upgrade to 1.8.36 and ensured that the search engine response value is displayed as 2
  • Install 1.6.42 and set the default search engine to Startpage and upgrade to 1.8.36 and ensured that the search engine response value is displayed as 3
  • Install 1.6.42 and set the default search engine to Bing and upgrade to 1.8.36 and ensured that the search engine response value is displayed as 4
  • Install 1.6.42 and set the default search engine to Qwant and upgrade to 1.8.36 and ensured that the search engine response value is displayed as 5
  • Install 1.6.42 select default search as DDG in welcome screen and upgrade to 1.8.36 and ensure that default search engine response value is displayed as 2
  • Install 1.6.42 select default search as Startpage in welcome screen and upgrade to 1.8.36 and ensure that default search engine response value is displayed as 3
  • Install 1.6.42 select default search as Bing in welcome screen and upgrade to 1.8.36 and ensure that default search engine response value is displayed as 4
  • Install 1.6.42 select default search as Qwant in welcome screen and upgrade to 1.8.36 and ensure that default search engine response value is displayed as 5

@kjozwiak kjozwiak added this to the 1.8.x - Nightly milestone Mar 25, 2020
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.

6 participants