From d1873c63e186a075e053e4295ab8a54a95cfb5c0 Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Tue, 26 Nov 2024 21:32:37 +0000 Subject: [PATCH 1/3] ntp: temporary events for show more/less --- .../new-tab/stats_showLess.notify.json | 3 ++ .../new-tab/stats_showMore.notify.json | 3 ++ .../privacy-stats/components/PrivacyStats.js | 4 +- .../integration-tests/privacy-stats.spec.js | 41 ++++++++++--------- special-pages/pages/new-tab/src/js/index.js | 13 ++++++ special-pages/types/new-tab.ts | 14 +++++++ 6 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 special-pages/messages/new-tab/stats_showLess.notify.json create mode 100644 special-pages/messages/new-tab/stats_showMore.notify.json diff --git a/special-pages/messages/new-tab/stats_showLess.notify.json b/special-pages/messages/new-tab/stats_showLess.notify.json new file mode 100644 index 000000000..0af74a319 --- /dev/null +++ b/special-pages/messages/new-tab/stats_showLess.notify.json @@ -0,0 +1,3 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#" +} diff --git a/special-pages/messages/new-tab/stats_showMore.notify.json b/special-pages/messages/new-tab/stats_showMore.notify.json new file mode 100644 index 000000000..0af74a319 --- /dev/null +++ b/special-pages/messages/new-tab/stats_showMore.notify.json @@ -0,0 +1,3 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#" +} diff --git a/special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.js b/special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.js index cc6598420..23fed5110 100644 --- a/special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.js +++ b/special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.js @@ -143,9 +143,9 @@ export function PrivacyStatsBody({ trackerCompanies, listAttrs = {} }) { const toggleListExpansion = () => { if (hasmore) { - messaging.telemetryEvent({ attributes: { name: 'stats_toggle', value: 'show_more' } }); + messaging.statsShowMore(); } else { - messaging.telemetryEvent({ attributes: { name: 'stats_toggle', value: 'show_less' } }); + messaging.statsShowLess(); } if (visible === defaultRowMax) { setVisible(sorted.length); diff --git a/special-pages/pages/new-tab/app/privacy-stats/integration-tests/privacy-stats.spec.js b/special-pages/pages/new-tab/app/privacy-stats/integration-tests/privacy-stats.spec.js index d4cd0f35f..3311b9ac0 100644 --- a/special-pages/pages/new-tab/app/privacy-stats/integration-tests/privacy-stats.spec.js +++ b/special-pages/pages/new-tab/app/privacy-stats/integration-tests/privacy-stats.spec.js @@ -33,26 +33,27 @@ test.describe('newtab privacy stats', () => { await ntp.openPage({ additional: { stats: 'many' } }); await page.getByLabel('Show More', { exact: true }).click(); await page.getByLabel('Show Less').click(); - const calls1 = await ntp.mocks.waitForCallCount({ method: 'telemetryEvent', count: 2 }); - expect(calls1.length).toBe(2); - expect(calls1).toStrictEqual([ - { - payload: { - context: 'specialPages', - featureName: 'newTabPage', - method: 'telemetryEvent', - params: { attributes: { name: 'stats_toggle', value: 'show_more' } }, - }, - }, - { - payload: { - context: 'specialPages', - featureName: 'newTabPage', - method: 'telemetryEvent', - params: { attributes: { name: 'stats_toggle', value: 'show_less' } }, - }, - }, - ]); + await ntp.mocks.waitForCallCount({ method: 'stats_showMore', count: 1 }); + await ntp.mocks.waitForCallCount({ method: 'stats_showLess', count: 1 }); + // expect(calls1.length).toBe(2); + // expect(calls1).toStrictEqual([ + // { + // payload: { + // context: 'specialPages', + // featureName: 'newTabPage', + // method: 'telemetryEvent', + // params: { attributes: { name: 'stats_toggle', value: 'show_more' } }, + // }, + // }, + // { + // payload: { + // context: 'specialPages', + // featureName: 'newTabPage', + // method: 'telemetryEvent', + // params: { attributes: { name: 'stats_toggle', value: 'show_less' } }, + // }, + // }, + // ]); }); test( 'hiding the expander when empty', diff --git a/special-pages/pages/new-tab/src/js/index.js b/special-pages/pages/new-tab/src/js/index.js index 9dbef171a..e11d2aaa9 100644 --- a/special-pages/pages/new-tab/src/js/index.js +++ b/special-pages/pages/new-tab/src/js/index.js @@ -62,6 +62,19 @@ export class NewTabPage { telemetryEvent(event) { this.messaging.notify('telemetryEvent', event); } + + /** + * NOTE: temporary workaround, to be replaced with 'telemetryEvent' + */ + statsShowMore() { + this.messaging.notify('stats_showMore'); + } + /** + * NOTE: temporary workaround, to be replaced with 'telemetryEvent' + */ + statsShowLess() { + this.messaging.notify('stats_showLess'); + } } const baseEnvironment = new Environment().withInjectName(import.meta.injectName).withEnv(import.meta.env); diff --git a/special-pages/types/new-tab.ts b/special-pages/types/new-tab.ts index 069a46169..463eff2c0 100644 --- a/special-pages/types/new-tab.ts +++ b/special-pages/types/new-tab.ts @@ -59,6 +59,8 @@ export interface NewTabMessages { | RmfPrimaryActionNotification | RmfSecondaryActionNotification | StatsSetConfigNotification + | StatsShowLessNotification + | StatsShowMoreNotification | TelemetryEventNotification | UpdateNotificationDismissNotification | WidgetsSetConfigNotification; @@ -275,6 +277,18 @@ export interface StatsConfig { expansion: Expansion; animation?: Animation; } +/** + * Generated from @see "../messages/new-tab/stats_showLess.notify.json" + */ +export interface StatsShowLessNotification { + method: "stats_showLess"; +} +/** + * Generated from @see "../messages/new-tab/stats_showMore.notify.json" + */ +export interface StatsShowMoreNotification { + method: "stats_showMore"; +} /** * Generated from @see "../messages/new-tab/telemetryEvent.notify.json" */ From bd52889082a67a7330702b65bc77eb1424b6345a Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Wed, 27 Nov 2024 07:51:26 +0000 Subject: [PATCH 2/3] commit translations for now. --- .../pages/new-tab/src/locales/en/.gitignore | 1 - .../pages/new-tab/src/locales/en/new-tab.json | 200 ++++++++++++++++++ 2 files changed, 200 insertions(+), 1 deletion(-) delete mode 100644 special-pages/pages/new-tab/src/locales/en/.gitignore create mode 100644 special-pages/pages/new-tab/src/locales/en/new-tab.json diff --git a/special-pages/pages/new-tab/src/locales/en/.gitignore b/special-pages/pages/new-tab/src/locales/en/.gitignore deleted file mode 100644 index 72e8ffc0d..000000000 --- a/special-pages/pages/new-tab/src/locales/en/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* diff --git a/special-pages/pages/new-tab/src/locales/en/new-tab.json b/special-pages/pages/new-tab/src/locales/en/new-tab.json new file mode 100644 index 000000000..3d3faea4b --- /dev/null +++ b/special-pages/pages/new-tab/src/locales/en/new-tab.json @@ -0,0 +1,200 @@ +{ + "smartling": { + "string_format": "icu", + "translate_paths": [ + { + "path": "*/title", + "key": "{*}/title", + "instruction": "*/note" + } + ] + }, + "ntp_show_less": { + "title": "Show Less", + "note": "Button that reduces the number of items or content displayed." + }, + "ntp_show_more": { + "title": "Show More", + "note": "Button that increases the number of items or content displayed." + }, + "ntp_dismiss": { + "title": "Dismiss", + "note": "Button that closes or hides the current popup or notification." + }, + "ntp_customizer_button": { + "title": "Customize", + "note": "Button opens a menu. The menu allows the user to customize the page, such as showing/hiding sections." + }, + "widgets_visibility_menu_title": { + "title": "Customize New Tab Page", + "note": "Heading text describing that there's a list of toggles for customizing the page layout." + }, + "updateNotification_updated_version": { + "title": "Browser Updated to version {version}.", + "note": "Text to indicate which new version was updated. `{version}` will be formatted like `1.22.0`" + }, + "updateNotification_whats_new": { + "title": "See what's new in this release.", + "note": "The `` tag represents a clickable link, please preserve it." + }, + "updateNotification_dismiss_btn": { + "title": "Dismiss", + "note": "Button label text for an action that removes the widget from the screen." + }, + "stats_menuTitle": { + "title": "Blocked Tracking Attempts", + "note": "Used as a label in a customization menu" + }, + "stats_noActivity": { + "title": "Blocked tracking attempts will appear here. Keep browsing to see how many we block.", + "note": "Placeholder for when we cannot report any blocked trackers yet" + }, + "stats_noRecent": { + "title": "No recent tracking activity", + "note": "Placeholder to indicate that no tracking activity was blocked in the last 7 days" + }, + "stats_countBlockedSingular": { + "title": "1 tracking attempt blocked", + "note": "The main headline indicating that a single tracker was blocked" + }, + "stats_countBlockedPlural": { + "title": "{count} tracking attempts blocked", + "note": "The main headline indicating that more than 1 attempt has been blocked. Eg: '2 tracking attempts blocked'" + }, + "stats_feedCountBlockedSingular": { + "title": "1 attempt blocked by DuckDuckGo in the last 7 days", + "note": "A summary description of how many tracking attempts where blocked, when only one exists." + }, + "stats_feedCountBlockedPeriod": { + "title": "Past 7 days", + "note": "A summary description indicating the time period of the blocked tracking attempts, which is the past 7 days." + }, + "stats_feedCountBlockedPlural": { + "title": "{count} tracking attempts blocked", + "note": "A summary description of how many tracking attempts were blocked by DuckDuckGo in the last 7 days when there is more than one. E.g., '1,028 tracking attempts blocked." + }, + "stats_toggleLabel": { + "title": "Show recent activity", + "note": "The aria-label text for a toggle button that shows the detailed activity feed" + }, + "stats_hideLabel": { + "title": "Hide recent activity", + "note": "The aria-label text for a toggle button that hides the detailed activity feed" + }, + "stats_otherCompanyName": { + "title": "Other", + "note": "A placeholder to represent an aggregated count of entries, not present in the rest of the list. For example, 'Other: 200', which would mean 200 entries excluding the ones already shown" + }, + "stats_otherCount": { + "title": "{count} attempts from other networks", + "note": "An aggregated count of blocked entries not present in the main list. For example, '200 attempts from other networks'" + }, + "nextSteps_sectionTitle": { + "title": "Next Steps", + "note": "Text that goes in the Next Steps bubble above the first card" + }, + "nextSteps_bringStuff_title": { + "title": "Bring Your Stuff", + "note": "Title of the Next Steps card for importing bookmarks and favorites" + }, + "nextSteps_bringStuff_summary": { + "title": "Import bookmarks, favorites, and passwords for a smooth transition from your old browser.", + "note": "Summary of the Next Steps card for importing bookmarks and favorites" + }, + "nextSteps_bringStuff_actionText": { + "title": "Import Now", + "note": "Button text of the Next Steps card for importing bookmarks and favorites" + }, + "nextSteps_defaultApp_title": { + "title": "Set as Default Browser", + "note": "Title of the Next Steps card for making DDG the user's default browser" + }, + "nextSteps_defaultApp_summary": { + "title": "We automatically block trackers as you browse. It’s privacy, simplified.", + "note": "Summary of the Next Steps card for making DDG the user's default browser" + }, + "nextSteps_defaultApp_actionText": { + "title": "Make Default Browser", + "note": "Button text of the Next Steps card for making DDG the user's default browser" + }, + "nextSteps_blockCookies_title": { + "title": "Block Cookie Pop-ups", + "note": "Title of the Next Steps card for blocking cookie pop-ups" + }, + "nextSteps_blockCookies_summary": { + "title": "We need your permission to say no to cookies on your behalf. Easy choice.", + "note": "Summary of the Next Steps card for blocking cookie pop-ups" + }, + "nextSteps_blockCookies_actionText": { + "title": "Block Cookie Pop-ups", + "note": "Button text of the Next Steps card for blocking cookie pop-ups" + }, + "nextSteps_emailProtection_title": { + "title": "Protect Your Inbox", + "note": "Title of the Next Steps card for email protection" + }, + "nextSteps_emailProtection_summary": { + "title": "Generate @duck.com addresses that remove trackers from email and forwards to your inbox.", + "note": "Summary of the Next Steps card for email protection" + }, + "nextSteps_emailProtection_actionText": { + "title": "Get Email Protection", + "note": "Button text of the Next Steps card for email protection" + }, + "nextSteps_duckPlayer_title": { + "title": "YouTube Without Creepy Ads", + "note": "Title of the Next Steps card for adopting DuckPlayer" + }, + "nextSteps_duckPlayer_summary": { + "title": "Enjoy a clean viewing experience without personalized ads.", + "note": "Summary of the Next Steps card for adopting DuckPlayer" + }, + "nextSteps_duckPlayer_actionText": { + "title": "Try DuckPlayer", + "note": "Button text of the Next Steps card for adopting DuckPlayer" + }, + "nextSteps_addAppDockMac_title": { + "title": "Add App to the Dock", + "note": "Title of the Next Steps card for adding DDG app to OS dock" + }, + "nextSteps_addAppDockMac_summary": { + "title": "Access DuckDuckGo faster by adding it to the Dock.", + "note": "Summary of the Next Steps card for adding DDG app to OS dock" + }, + "nextSteps_addAppDockMac_actionText": { + "title": "Add to Dock", + "note": "Initial button text of the Next Steps card for adding DDG app to OS dock" + }, + "nextSteps_addAppDockMac_confirmationText": { + "title": "Added to Dock!", + "note": "Button text after clicking on the Next Steps card for adding DDG app to OS dock" + }, + "nextSteps_pinAppToTaskbarWindows_title": { + "title": "Pin App to the Taskbar", + "note": "Title of the Next Steps card for adding DDG app to OS dock" + }, + "nextSteps_pinAppToTaskbarWindows_summary": { + "title": "Access DuckDuckGo faster by pinning it to the Taskbar.", + "note": "Summary of the Next Steps card for adding DDG app to OS dock" + }, + "nextSteps_pinAppToTaskbarWindows_actionText": { + "title": "Pin to Taskbar", + "note": "Initial button text of the Next Steps card for adding DDG app to OS dock" + }, + "nextSteps_pinAppToTaskbarWindows_confirmationText": { + "title": "Pinned to Taskbar!", + "note": "Button text after clicking on the Next Steps card for adding DDG app to OS dock" + }, + "favorites_show_less": { + "title": "Show less", + "note": "Button label to display fewer items" + }, + "favorites_show_more": { + "title": "Show more ({count} remaining)", + "note": "Button text to show hidden items. {count} will be replaced with the number of remaining favorite items to show, including the parentheses. Example: 'Show more (18 remaining)'" + }, + "favorites_menu_title": { + "title": "Favorites", + "note": "Used as a label in a customization menu" + } +} \ No newline at end of file From 56d3cb822f089c3e81908e07338ea5d69231f3cc Mon Sep 17 00:00:00 2001 From: Shane Osbourne Date: Wed, 27 Nov 2024 07:54:34 +0000 Subject: [PATCH 3/3] fixed build on windows --- special-pages/translations.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/special-pages/translations.mjs b/special-pages/translations.mjs index a8db8e336..6b5982674 100644 --- a/special-pages/translations.mjs +++ b/special-pages/translations.mjs @@ -3,7 +3,7 @@ import { readdir } from 'fs/promises'; import { join, basename } from 'node:path'; import { readFileSync, writeFileSync } from 'node:fs'; -const paths = ['pages/new-tab']; +const paths = [join('pages', 'new-tab')]; const base = { smartling: { string_format: 'icu', @@ -28,7 +28,7 @@ if (isLaunchFile(import.meta.url)) { */ async function processPage(path) { const targetName = basename(path); - const outputFile = `${path}/src/locales/en/${targetName}.json`; + const outputFile = join(path, '/src/locales/en', `${targetName}.json`); const dirents = await readdir(path, { withFileTypes: true, recursive: true }); const rawEntries = dirents .filter((entry) => entry.isFile() && entry.name === 'strings.json')