From beb55e4a4e57c7dda9e7fa4feb63c77fea17f721 Mon Sep 17 00:00:00 2001 From: Mathieu Pillard Date: Thu, 2 Oct 2025 12:21:45 +0200 Subject: [PATCH 1/4] Remove dead code and strings from statistics --- static/js/stats/chart.js | 95 +------------------------ static/js/stats/csv_keys.js | 134 ------------------------------------ static/js/stats/manager.js | 23 ------- static/js/stats/table.js | 14 ++-- 4 files changed, 6 insertions(+), 260 deletions(-) diff --git a/static/js/stats/chart.js b/static/js/stats/chart.js index ec998407bd7c..4ec5cd30a391 100644 --- a/static/js/stats/chart.js +++ b/static/js/stats/chart.js @@ -91,22 +91,8 @@ const dayMsecs = 24 * 3600 * 1000; locales: 'users', os: 'users', versions: 'users', - statuses: 'users', - users_created: 'users', downloads: 'downloads', sources: 'downloads', - contributions: 'currency', - revenue: 'currency', - reviews_created: 'reviews', - addons_in_use: 'addons', - addons_created: 'addons', - addons_updated: 'addons', - addons_downloaded: 'addons', - collections_created: 'collections', - subscribers: 'collections', - ratings: 'collections', - sales: 'sales', - refunds: 'refunds', installs: 'installs', countries: 'users', contents: 'downloads', @@ -151,7 +137,7 @@ const dayMsecs = 24 * 3600 * 1000; i, field, val, - is_overview = metric == 'overview' || metric == 'app_overview'; + is_overview = metric == 'overview'; if (!(group in acceptedGroups)) { group = 'day'; @@ -282,7 +268,7 @@ const dayMsecs = 24 * 3600 * 1000; // Add offset to line up points and ticks on day grouping. pointStart: start, data: series[field], - visible: !(metric == 'contributions' && id != 'total'), + visible: true, }); } @@ -332,21 +318,6 @@ const dayMsecs = 24 * 3600 * 1000; Highcharts.numberFormat(n, 0), ); } - function currencyFormatter(n) { - return '$' + Highcharts.numberFormat(n, 2); - } - function salesFormatter(n) { - return format( - ngettext('{0} sale', '{0} sales', n), - Highcharts.numberFormat(n, 0), - ); - } - function refundsFormatter(n) { - return format( - ngettext('{0} refund', '{0} refunds', n), - Highcharts.numberFormat(n, 0), - ); - } function installsFormatter(n) { return format( ngettext('{0} install', '{0} installs', n), @@ -381,21 +352,6 @@ const dayMsecs = 24 * 3600 * 1000; } return addEventData(ret, this.x); }; - } else if (metric == 'contributions') { - return function () { - var ret = '' + xFormatter(this.x) + '', - p; - for (var i = 0; i < this.points.length; i++) { - p = this.points[i]; - ret += '
' + p.series.name + ': '; - if (p.series.options.yAxis > 0) { - ret += Highcharts.numberFormat(p.y, 0); - } else { - ret += currencyFormatter(p.y); - } - } - return addEventData(ret, this.x); - }; } else { // Determine y-axis formatter. switch (metricTypes[metric]) { @@ -405,10 +361,6 @@ const dayMsecs = 24 * 3600 * 1000; case 'downloads': yFormatter = downloadFormatter; break; - case 'currency': - case 'revenue': - yFormatter = currencyFormatter; - break; case 'collections': yFormatter = collectionsFormatter; break; @@ -418,12 +370,6 @@ const dayMsecs = 24 * 3600 * 1000; case 'addons': yFormatter = addonsFormatter; break; - case 'sales': - yFormatter = salesFormatter; - break; - case 'refunds': - yFormatter = refundsFormatter; - break; case 'installs': yFormatter = installsFormatter; break; @@ -489,43 +435,6 @@ const dayMsecs = 24 * 3600 * 1000; }).yAxis = 1; } } - if (metric == 'contributions' && newConfig.series.length) { - _.extend(newConfig, { - yAxis: [ - { - // Amount - title: { - text: gettext('Amount, in USD'), - }, - labels: { - formatter: function () { - return Highcharts.numberFormat(this.value, 2); - }, - }, - min: 0, - }, - { - // Number of Contributions - title: { - text: gettext('Number of Contributions'), - }, - min: 0, - labels: { - formatter: function () { - return Highcharts.numberFormat(this.value, 0); - }, - }, - opposite: true, - }, - ], - tooltip: { - shared: true, - crosshairs: true, - }, - }); - // set Daily Users series to use the right yAxis. - newConfig.series[0].yAxis = 1; - } newConfig.tooltip.formatter = tooltipFormatter; function makeSiteEventHandler(e) { diff --git a/static/js/stats/csv_keys.js b/static/js/stats/csv_keys.js index 91771df7e5ba..6b4f14bd0417 100644 --- a/static/js/stats/csv_keys.js +++ b/static/js/stats/csv_keys.js @@ -5,39 +5,6 @@ export default { usage: { count: gettext('Daily Users'), }, - collections_created: { - count: gettext('Collections Created'), - }, - addons_in_use: { - count: gettext('Add-ons in Use'), - }, - addons_created: { - count: gettext('Add-ons Created'), - }, - addons_downloaded: { - count: gettext('Add-ons Downloaded'), - }, - addons_updated: { - count: gettext('Add-ons Updated'), - }, - reviews_created: { - count: gettext('Reviews Written'), - }, - users_created: { - count: gettext('User Signups'), - }, - subscribers: { - count: gettext('Subscribers'), - }, - ratings: { - count: gettext('Ratings'), - }, - sales: { - count: gettext('Sales'), - }, - installs: { - count: gettext('Installs'), - }, sources: { null: gettext('Unknown'), api: gettext('Add-ons Manager'), @@ -71,7 +38,6 @@ export default { developers: gettext('Meet the Developer'), userprofile: gettext('User Profile'), 'version-history': gettext('Version History'), - sharingapi: gettext('Sharing'), category: gettext('Category Pages'), collection: gettext('Collections'), @@ -100,20 +66,10 @@ export default { 'cb-btn-hotness': gettext('Browse Listing Up and Coming Sort'), 'cb-dl-hotness': gettext('Browse Listing Up and Coming Sort'), }, - contributions: { - count: gettext('Number of Contributions'), - total: gettext('Total Amount Contributed'), - average: gettext('Average Contribution'), - }, overview: { downloads: gettext('Downloads'), updates: gettext('Daily Users'), }, - app_overview: { - installs: gettext('Installs'), - sales: gettext('Sales'), - usage: gettext('Usage'), - }, apps: { '{ec8030f7-c20a-464f-9b0e-13a3a9e97384}': gettext('Firefox'), '{86c18b42-e466-45a9-ae7a-9b95ba6f5640}': gettext('Mozilla'), @@ -130,12 +86,6 @@ export default { // L10n: both {0} and {1} are dates in YYYY-MM-DD format. gettext('Downloads and Daily Users from {0} to {1}'), ], - app_overview: [ - // L10n: {0} is an integer. - gettext('Installs and Daily Users, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Installs and Daily Users from {0} to {1}'), - ], downloads: [ // L10n: {0} is an integer. gettext('Downloads, last {0} days'), @@ -178,12 +128,6 @@ export default { // L10n: both {0} and {1} are dates in YYYY-MM-DD format. gettext('Add-on Versions from {0} to {1}'), ], - statuses: [ - // L10n: {0} is an integer. - gettext('Add-on Status, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Add-on Status from {0} to {1}'), - ], sources: [ // L10n: {0} is an integer. gettext('Download Sources, last {0} days'), @@ -208,84 +152,6 @@ export default { // L10n: both {0} and {1} are dates in YYYY-MM-DD format. gettext('Download Campaigns from {0} to {1}'), ], - contributions: [ - // L10n: {0} is an integer. - gettext('Contributions, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Contributions from {0} to {1}'), - ], - site: [ - // L10n: {0} is an integer. - gettext('Site Metrics, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Site Metrics from {0} to {1}'), - ], - addons_in_use: [ - // L10n: {0} is an integer. - gettext('Add-ons in Use, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Add-ons in Use from {0} to {1}'), - ], - addons_downloaded: [ - // L10n: {0} is an integer. - gettext('Add-ons Downloaded, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Add-ons Downloaded from {0} to {1}'), - ], - addons_created: [ - // L10n: {0} is an integer. - gettext('Add-ons Created, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Add-ons Created from {0} to {1}'), - ], - addons_updated: [ - // L10n: {0} is an integer. - gettext('Add-ons Updated, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Add-ons Updated from {0} to {1}'), - ], - reviews_created: [ - // L10n: {0} is an integer. - gettext('Reviews Written, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Reviews Written from {0} to {1}'), - ], - users_created: [ - // L10n: {0} is an integer. - gettext('User Signups, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('User Signups from {0} to {1}'), - ], - collections_created: [ - // L10n: {0} is an integer. - gettext('Collections Created, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Collections Created from {0} to {1}'), - ], - subscribers: [ - // L10n: {0} is an integer. - gettext('Subscribers, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Subscribers from {0} to {1}'), - ], - ratings: [ - // L10n: {0} is an integer. - gettext('Ratings, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Ratings from {0} to {1}'), - ], - sales: [ - // L10n: {0} is an integer. - gettext('Sales, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Sales from {0} to {1}'), - ], - installs: [ - // L10n: {0} is an integer. - gettext('Installs, last {0} days'), - // L10n: both {0} and {1} are dates in YYYY-MM-DD format. - gettext('Installs from {0} to {1}'), - ], }, aggregateLabel: { downloads: [ diff --git a/static/js/stats/manager.js b/static/js/stats/manager.js index 8a18307621e7..c70a2e2ef72b 100644 --- a/static/js/stats/manager.js +++ b/static/js/stats/manager.js @@ -37,9 +37,7 @@ function getStatsManager() { os: true, sources: true, versions: true, - statuses: true, overview: true, - site: true, countries: true, contents: true, mediums: true, @@ -53,10 +51,8 @@ function getStatsManager() { locales: 'mean', os: 'mean', versions: 'mean', - statuses: 'mean', downloads: 'sum', sources: 'sum', - contributions: 'sum', countries: 'mean', contents: 'sum', mediums: 'sum', @@ -161,7 +157,6 @@ function getStatsManager() { fields = {}; // Non-breakdown metrics only have one field. - if (metric == 'contributions') return ['count', 'total', 'average']; if (!(metric in breakdownMetrics)) return ['count']; ds = dataStore[metric]; @@ -303,12 +298,6 @@ function getStatsManager() { data: {}, empty: true, }; - if (metric == 'contributions') { - _.extend(groupVal, { - average: 0, - total: 0, - }); - } } function performAggregation() { @@ -323,8 +312,6 @@ function getStatsManager() { // overview gets special treatment. Only average ADUs. if (metric == 'overview') { groupVal.data.updates /= groupCount; - } else if (metric == 'contributions') { - groupVal.average /= groupCount; } else if (metric in breakdownMetrics) { // average for mean metrics. _.each(groupVal.data, function (val, field) { @@ -359,21 +346,11 @@ function getStatsManager() { data: {}, empty: true, }; - if (metric == 'contributions') { - _.extend(groupVal, { - average: 0, - total: 0, - }); - } } // add the current row to our aggregates. if (row && groupVal) { groupVal.empty = false; groupVal.count += row.count; - if (metric == 'contributions') { - groupVal.total += parseFloat(row.total); - groupVal.average += parseFloat(row.average); - } if (metric in breakdownMetrics) { _.each(row.data, function (val, field) { if (!groupVal.data[field]) { diff --git a/static/js/stats/table.js b/static/js/stats/table.js index b9dd6592081a..bcb3a83201bf 100644 --- a/static/js/stats/table.js +++ b/static/js/stats/table.js @@ -107,16 +107,10 @@ $.fn.csvTable = function (cfg) { ''; _.each(fields, function (f) { newBody += ''; - if (metric == 'contributions' && f != 'count') { - newBody += - '$' + - Highcharts.numberFormat(StatsManager.getField(row, f), 2); - } else { - newBody += Highcharts.numberFormat( - StatsManager.getField(row, f), - 0, - ); - } + newBody += Highcharts.numberFormat( + StatsManager.getField(row, f), + 0, + ); newBody += ''; }); newBody += ''; From 9867a8e84afd264a1001c388781f2b99ce9d1fd7 Mon Sep 17 00:00:00 2001 From: Mathieu Pillard Date: Thu, 2 Oct 2025 17:18:24 +0200 Subject: [PATCH 2/4] More dead code --- static/js/stats/chart.js | 37 ------------------------------------- 1 file changed, 37 deletions(-) diff --git a/static/js/stats/chart.js b/static/js/stats/chart.js index 4ec5cd30a391..e540285a7a15 100644 --- a/static/js/stats/chart.js +++ b/static/js/stats/chart.js @@ -93,7 +93,6 @@ const dayMsecs = 24 * 3600 * 1000; versions: 'users', downloads: 'downloads', sources: 'downloads', - installs: 'installs', countries: 'users', contents: 'downloads', mediums: 'downloads', @@ -300,30 +299,6 @@ const dayMsecs = 24 * 3600 * 1000; Highcharts.numberFormat(n, 0), ); } - function addonsFormatter(n) { - return format( - ngettext('{0} add-on', '{0} add-ons', n), - Highcharts.numberFormat(n, 0), - ); - } - function collectionsFormatter(n) { - return format( - ngettext('{0} collection', '{0} collections', n), - Highcharts.numberFormat(n, 0), - ); - } - function reviewsFormatter(n) { - return format( - ngettext('{0} review', '{0} reviews', n), - Highcharts.numberFormat(n, 0), - ); - } - function installsFormatter(n) { - return format( - ngettext('{0} install', '{0} installs', n), - Highcharts.numberFormat(n, 0), - ); - } function addEventData(s, date) { var e = events[date]; if (e) { @@ -361,18 +336,6 @@ const dayMsecs = 24 * 3600 * 1000; case 'downloads': yFormatter = downloadFormatter; break; - case 'collections': - yFormatter = collectionsFormatter; - break; - case 'reviews': - yFormatter = reviewsFormatter; - break; - case 'addons': - yFormatter = addonsFormatter; - break; - case 'installs': - yFormatter = installsFormatter; - break; } return function () { var ret = From 56d1a00b024a22343a5cd20991282c59fabbb617 Mon Sep 17 00:00:00 2001 From: Mathieu Pillard Date: Fri, 3 Oct 2025 12:15:37 +0200 Subject: [PATCH 3/4] Update docs --- .../topics/runbooks/localdev/test_statistics_dashboard.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/topics/runbooks/localdev/test_statistics_dashboard.md b/docs/topics/runbooks/localdev/test_statistics_dashboard.md index e85889b33546..35a75ed1c69c 100644 --- a/docs/topics/runbooks/localdev/test_statistics_dashboard.md +++ b/docs/topics/runbooks/localdev/test_statistics_dashboard.md @@ -10,8 +10,7 @@ Test the devhub statistics dashboard locally with bigquery credentials. ### Enable a local addon to read from bigquery dev database -Only a [subset of addons][enabled_dev_guids] in dev push data to bigquery. In order to read from bigquery -your local addon will need to use a matching `guid`. +Only a [subset of addons][enabled_dev_guids] in dev push data to bigquery. In order to read from bigquery your local addon will need to use a matching `guid`. Open a django shell `make djshell` and run the following: @@ -19,9 +18,10 @@ Open a django shell `make djshell` and run the following: - guid: the guid from the [list][enabled_dev_guids] you want to use (e.g. `@contain-facebook`) ```python -addon = Addon.objects.get(pk=) +addon = Addon.objects.get(pk=) addon.update(guid=) -addon.save() +addon.addonguid.guid = +addon.addonguid.save() # Need to trigger post-save to update hashed_guid. ``` ### Run the statistics dashboard From d3adebe5869717c236f20971f251d44ee71d15f8 Mon Sep 17 00:00:00 2001 From: Mathieu Pillard Date: Fri, 3 Oct 2025 12:40:05 +0200 Subject: [PATCH 4/4] Also remove outdated download sources - we are no longer using that --- src/olympia/constants/base.py | 66 ----------------------------------- static/js/stats/csv_keys.js | 61 -------------------------------- 2 files changed, 127 deletions(-) diff --git a/src/olympia/constants/base.py b/src/olympia/constants/base.py index 599968f0bcc9..f8a1b295acbd 100644 --- a/src/olympia/constants/base.py +++ b/src/olympia/constants/base.py @@ -403,72 +403,6 @@ # see validate_addon_name() MOZILLA_TRADEMARK_SYMBOLS = ('mozilla', 'firefox') -# If you add/remove any sources, update the docs: /api/download_sources.html -# Note there are some additional sources here for historical/backwards compat. -DOWNLOAD_SOURCES_FULL = ( - 'addondetail', - 'addon-detail-version', - 'api', - 'category', - 'collection', - 'creatured', - 'developers', - 'discovery-dependencies', - 'discovery-upsell', - 'discovery-video', - 'email', - 'find-replacement', - 'fxcustomization', - 'fxfirstrun', - 'fxwhatsnew', - 'homepagebrowse', - 'homepagepromo', - 'installservice', - 'mostshared', - 'oftenusedwith', - 'prerelease-banner', - 'recommended', - 'rockyourfirefox', - 'search', - 'sharingapi', - 'similarcollections', - 'ss', - 'userprofile', - 'version-history', - 'co-hc-sidebar', - 'co-dp-sidebar', - 'cb-hc-featured', - 'cb-dl-featured', - 'cb-hc-toprated', - 'cb-dl-toprated', - 'cb-hc-mostpopular', - 'cb-dl-mostpopular', - 'cb-hc-recentlyadded', - 'cb-dl-recentlyadded', - 'hp-btn-promo', - 'hp-dl-promo', - 'hp-hc-featured', - 'hp-dl-featured', - 'hp-hc-upandcoming', - 'hp-dl-upandcoming', - 'hp-hc-mostpopular', - 'hp-dl-mostpopular', - 'hp-contest-winners', - 'dp-hc-oftenusedwith', - 'dp-dl-oftenusedwith', - 'dp-hc-othersby', - 'dp-dl-othersby', - 'dp-btn-primary', - 'dp-btn-version', - 'dp-btn-devchannel', - 'dp-hc-dependencies', - 'dp-dl-dependencies', - 'dp-hc-upsell', - 'dp-dl-upsell', -) - -DOWNLOAD_SOURCES_PREFIX = ('external-', 'mozcom-', 'discovery-', 'cb-btn-', 'cb-dl-') - # Regexp for Firefox client IDs passed to our APIs, just to avoid sending # garbage to underlying services. VALID_CLIENT_ID = re.compile('^[a-zA-Z0-9]{64}$') diff --git a/static/js/stats/csv_keys.js b/static/js/stats/csv_keys.js index 6b4f14bd0417..561612e153ec 100644 --- a/static/js/stats/csv_keys.js +++ b/static/js/stats/csv_keys.js @@ -5,67 +5,6 @@ export default { usage: { count: gettext('Daily Users'), }, - sources: { - null: gettext('Unknown'), - api: gettext('Add-ons Manager'), - 'discovery-promo': gettext('Add-ons Manager Promo'), - 'discovery-featured': gettext('Add-ons Manager Featured'), - 'discovery-learnmore': gettext('Add-ons Manager Learn More'), - ss: gettext('Search Suggestions'), - search: gettext('Search Results'), - homepagepromo: gettext('Homepage Promo'), - 'hp-btn-promo': gettext('Homepage Promo'), - 'hp-dl-promo': gettext('Homepage Promo'), - 'hp-hc-featured': gettext('Homepage Featured'), - 'hp-dl-featured': gettext('Homepage Featured'), - 'hp-hc-upandcoming': gettext('Homepage Up and Coming'), - 'hp-dl-upandcoming': gettext('Homepage Up and Coming'), - 'hp-dl-mostpopular': gettext('Homepage Most Popular'), - 'dp-btn-primary': gettext('Detail Page'), - 'dp-btn-version': gettext('Detail Page (bottom)'), - addondetail: gettext('Detail Page'), - 'addon-detail-version': gettext('Detail Page (bottom)'), - 'dp-btn-devchannel': gettext('Detail Page (Development Channel)'), - oftenusedwith: gettext('Often Used With'), - 'dp-hc-oftenusedwith': gettext('Often Used With'), - 'dp-dl-oftenusedwith': gettext('Often Used With'), - 'dp-hc-othersby': gettext('Others By Author'), - 'dp-dl-othersby': gettext('Others By Author'), - 'dp-hc-dependencies': gettext('Dependencies'), - 'dp-dl-dependencies': gettext('Dependencies'), - 'dp-hc-upsell': gettext('Upsell'), - 'dp-dl-upsell': gettext('Upsell'), - developers: gettext('Meet the Developer'), - userprofile: gettext('User Profile'), - 'version-history': gettext('Version History'), - sharingapi: gettext('Sharing'), - category: gettext('Category Pages'), - collection: gettext('Collections'), - 'cb-hc-featured': gettext('Category Landing Featured Carousel'), - 'cb-dl-featured': gettext('Category Landing Featured Carousel'), - 'cb-hc-toprated': gettext('Category Landing Top Rated'), - 'cb-dl-toprated': gettext('Category Landing Top Rated'), - 'cb-hc-mostpopular': gettext('Category Landing Most Popular'), - 'cb-dl-mostpopular': gettext('Category Landing Most Popular'), - 'cb-hc-recentlyadded': gettext('Category Landing Recently Added'), - 'cb-dl-recentlyadded': gettext('Category Landing Recently Added'), - 'cb-btn-featured': gettext('Browse Listing Featured Sort'), - 'cb-dl-featured': gettext('Browse Listing Featured Sort'), - 'cb-btn-users': gettext('Browse Listing Users Sort'), - 'cb-dl-users': gettext('Browse Listing Users Sort'), - 'cb-btn-rating': gettext('Browse Listing Rating Sort'), - 'cb-dl-rating': gettext('Browse Listing Rating Sort'), - 'cb-btn-created': gettext('Browse Listing Created Sort'), - 'cb-dl-created': gettext('Browse Listing Created Sort'), - 'cb-btn-name': gettext('Browse Listing Name Sort'), - 'cb-dl-name': gettext('Browse Listing Name Sort'), - 'cb-btn-popular': gettext('Browse Listing Popular Sort'), - 'cb-dl-popular': gettext('Browse Listing Popular Sort'), - 'cb-btn-updated': gettext('Browse Listing Updated Sort'), - 'cb-dl-updated': gettext('Browse Listing Updated Sort'), - 'cb-btn-hotness': gettext('Browse Listing Up and Coming Sort'), - 'cb-dl-hotness': gettext('Browse Listing Up and Coming Sort'), - }, overview: { downloads: gettext('Downloads'), updates: gettext('Daily Users'),