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

Add primary language metric #21355

Merged
merged 3 commits into from
Jan 22, 2024
Merged

Add primary language metric #21355

merged 3 commits into from
Jan 22, 2024

Conversation

DJAndries
Copy link
Collaborator

@DJAndries DJAndries commented Dec 13, 2023

Resolves brave/brave-browser#34853

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run lint, npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

Ensure metric only appears in the logs_constellation_prep_express object in local state (and maybe constellation_logs_slow if the metric was encrypted/prepared at the time of viewing the local state page).

Ensure the metric value matches the primary language set in the browser. The answer should match the relevant index in this list of languages:

"aa", // Afar
"ab", // Abkhazian
"ae", // Avestan
"af", // Afrikaans
"ak", // Akan
"am", // Amharic
"an", // Aragonese
"ar", // Arabic
"as", // Assamese
"av", // Avaric
"ay", // Aymara
"az", // Azerbaijani
"ba", // Bashkir
"be", // Belarusian
"bg", // Bulgarian
"bh", // Bihari languages
"bi", // Bislama
"bm", // Bambara
"bn", // Bengali
"bo", // Tibetan
"br", // Breton
"bs", // Bosnian
"ca", // Catalan; Valencian
"ce", // Chechen
"ch", // Chamorro
"co", // Corsican
"cr", // Cree
"cs", // Czech
"cu", // Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian;
// Old Church Slavonic
"cv", // Chuvash
"cy", // Welsh
"da", // Danish
"de", // German
"dv", // Divehi; Dhivehi; Maldivian
"dz", // Dzongkha
"ee", // Ewe
"el", // "Greek, Modern (1453-)"
"en", // English
"eo", // Esperanto
"es", // Spanish; Castilian
"et", // Estonian
"eu", // Basque
"fa", // Persian
"ff", // Fulah
"fi", // Finnish
"fj", // Fijian
"fo", // Faroese
"fr", // French
"fy", // Western Frisian
"ga", // Irish
"gd", // Gaelic; Scottish Gaelic
"gl", // Galician
"gn", // Guarani
"gu", // Gujarati
"gv", // Manx
"ha", // Hausa
"he", // Hebrew
"hi", // Hindi
"ho", // Hiri Motu
"hr", // Croatian
"ht", // Haitian; Haitian Creole
"hu", // Hungarian
"hy", // Armenian
"hz", // Herero
"ia", // Interlingua (International Auxiliary Language Association)
"id", // Indonesian
"ie", // Interlingue; Occidental
"ig", // Igbo
"ii", // Sichuan Yi; Nuosu
"ik", // Inupiaq
"io", // Ido
"is", // Icelandic
"it", // Italian
"iu", // Inuktitut
"ja", // Japanese
"jv", // Javanese
"ka", // Georgian
"kg", // Kongo
"ki", // Kikuyu; Gikuyu
"kj", // Kuanyama; Kwanyama
"kk", // Kazakh
"kl", // Kalaallisut; Greenlandic
"km", // Central Khmer
"kn", // Kannada
"ko", // Korean
"kr", // Kanuri
"ks", // Kashmiri
"ku", // Kurdish
"kv", // Komi
"kw", // Cornish
"ky", // Kirghiz; Kyrgyz
"la", // Latin
"lb", // Luxembourgish; Letzeburgesch
"lg", // Ganda
"li", // Limburgan; Limburger; Limburgish
"ln", // Lingala
"lo", // Lao
"lt", // Lithuanian
"lu", // Luba-Katanga
"lv", // Latvian
"mg", // Malagasy
"mh", // Marshallese
"mi", // Maori
"mk", // Macedonian
"ml", // Malayalam
"mn", // Mongolian
"mr", // Marathi
"ms", // Malay
"mt", // Maltese
"my", // Burmese
"na", // Nauru
"nb", // "Bokmål, Norwegian; Norwegian Bokmål"
"nd", // "Ndebele, North; North Ndebele"
"ne", // Nepali
"ng", // Ndonga
"nl", // Dutch; Flemish
"nn", // "Norwegian Nynorsk; Nynorsk, Norwegian"
"no", // Norwegian
"nr", // "Ndebele, South; South Ndebele"
"nv", // Navajo; Navaho
"ny", // Chichewa; Chewa; Nyanja
"oc", // Occitan (post 1500)
"oj", // Ojibwa
"om", // Oromo
"or", // Oriya
"os", // Ossetian; Ossetic
"pa", // Panjabi; Punjabi
"pi", // Pali
"pl", // Polish
"ps", // Pushto; Pashto
"pt", // Portuguese
"qu", // Quechua
"rm", // Romansh
"rn", // Rundi
"ro", // Romanian; Moldavian; Moldovan
"ru", // Russian
"rw", // Kinyarwanda
"sa", // Sanskrit
"sc", // Sardinian
"sd", // Sindhi
"se", // Northern Sami
"sg", // Sango
"si", // Sinhala; Sinhalese
"sk", // Slovak
"sl", // Slovenian
"sm", // Samoan
"sn", // Shona
"so", // Somali
"sq", // Albanian
"sr", // Serbian
"ss", // Swati
"st", // "Sotho, Southern"
"su", // Sundanese
"sv", // Swedish
"sw", // Swahili
"ta", // Tamil
"te", // Telugu
"tg", // Tajik
"th", // Thai
"ti", // Tigrinya
"tk", // Turkmen
"tl", // Tagalog
"tn", // Tswana
"to", // Tonga (Tonga Islands)
"tr", // Turkish
"ts", // Tsonga
"tt", // Tatar
"tw", // Twi
"ty", // Tahitian
"ug", // Uighur; Uyghur
"uk", // Ukrainian
"ur", // Urdu
"uz", // Uzbek
"ve", // Venda
"vi", // Vietnamese
"vo", // Volapük
"wa", // Walloon
"wo", // Wolof
"xh", // Xhosa
"yi", // Yiddish
"yo", // Yoruba
"za", // Zhuang; Chuang
"zh", // Chinese
"zu", // Zulu

Copy link
Contributor

[puLL-Merge] - brave/brave-core@21355

Description

The pull request appears to focus on refactoring and renaming of various components within the brave-core codebase, changing the terminology from *_service to a more appropriate naming that reflects the components' functionalities without the service suffix, which might have been misleading or unnecessarily verbose.

Changes

Changes

browser/brave_local_state_prefs.cc

  • Renamed include from page_metrics_service.h to page_metrics.h
  • Renamed PageMetricsService::RegisterPrefs() to PageMetrics::RegisterPrefs()

browser/browser_context_keyed_service_factories.cc

  • Removed includes for removed *_service_factory files
  • Renamed the PageMetricsServiceFactory to ProfileMiscMetricsServiceFactory
  • Removed instances of the Android-specific MiscAndroidMetricsFactory
  • Other factories are also being cleaned up to reflect these changes

browser/misc_metrics/BUILD.gn

  • Updated unit test sources to reflect the renamed test file from page_metrics_service_unittest.cc to page_metrics_unittest.cc
  • Update source set to reflect the changed filenames

browser/misc_metrics/extension_metrics_service.cc => browser/misc_metrics/extension_metrics.cc

  • Renamed the file and references from extension_metrics_service to just extension_metrics
  • Updated pathway inclusions to reflect new filenames

browser/misc_metrics/extension_metrics_service.h => browser/misc_metrics/extension_metrics.h

  • Similar to the .cc file, renamed and updated code to reflect the new naming scheme.

browser/misc_metrics/extension_metrics_service_factory.cc

  • The entire file is removed, signaling the removal of the corresponding factory code.

browser/misc_metrics/misc_android_metrics_factory.cc, browser/misc_metrics/misc_android_metrics_factory.h

  • Removed these files, similar to extension_metrics_service_factory.cc because potentially the factory pattern is no longer desired or has been consolidated.

browser/misc_metrics/misc_android_metrics_factory_android.cc

  • Updated code to use ProfileMiscMetricsServiceFactory instead of MiscAndroidMetricsFactory

browser/misc_metrics/page_metrics_service_factory.cc, browser/misc_metrics/page_metrics_service_factory.h

  • Entire files are removed, consolidating factories into the new ProfileMiscMetricsServiceFactory.

browser/misc_metrics/page_metrics_tab_helper.cc, browser/misc_metrics/page_metrics_tab_helper.h

  • Updated to use ProfileMiscMetricsServiceFactory and the non-service PageMetrics naming.

browser/misc_metrics/page_metrics_service_unittest.cc => browser/misc_metrics/page_metrics_unittest.cc

  • Renamed to reflect change in the corresponding class naming.

a/browser/misc_metrics/profile_misc_metrics_service.cc, a/browser/misc_metrics/profile_misc_metrics_service.h

  • New files that establish the ProfileMiscMetricsService, which seem to consolidate the functionalities of separate metrics-related services into a more streamlined service for the profile scope.

browser/misc_metrics/sources.gni

  • Updated the source set to reflect the changed filenames and removed the lines for deleted or renamed service factories.

browser/profiles/brave_profile_manager.cc

  • Updated to access ProfileMiscMetricsServiceFactory instead of the individual removed factories.

components/misc_metrics/BUILD.gn

  • Added new files for language_metrics and removed references to page_metrics_service in favor of page_metrics.

a/components/misc_metrics/language_metrics.cc, a/components/misc_metrics/language_metrics.h, a/components/misc_metrics/language_metrics_unittest.cc

  • New files introduced for language metrics logging, with appropriate testing implemented.

components/misc_metrics/page_metrics_service.cc => components/misc_metrics/page_metrics.cc, components/misc_metrics/page_metrics_service.h => components/misc_metrics/page_metrics.h

  • Renamed these files to remove the _service nomenclature.

components/p3a/metric_names.h

  • Added new metrics to be collected for Brave.Core.PrimaryLang.

Security Hotspots

  • None of the changes appear to introduce explicit security hotspots; however, attention should be given to the refactoring of the metrics system to ensure that only intended data is collected, avoiding accidental logging of sensitive or identifying information.

@DJAndries DJAndries merged commit ea0ea20 into master Jan 22, 2024
19 checks passed
@DJAndries DJAndries deleted the language-p3a branch January 22, 2024 23:58
@github-actions github-actions bot added this to the 1.64.x - Nightly milestone Jan 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add primary language P3A metric
4 participants