Skip to content

Commit

Permalink
ntp: temporary events for show more/less (#1281)
Browse files Browse the repository at this point in the history
* ntp: temporary events for show more/less

* commit translations for now.

* fixed build on windows

---------

Co-authored-by: Shane Osbourne <[email protected]>
  • Loading branch information
shakyShane and Shane Osbourne authored Nov 27, 2024
1 parent 06c9e7f commit 9d311d3
Show file tree
Hide file tree
Showing 9 changed files with 258 additions and 25 deletions.
3 changes: 3 additions & 0 deletions special-pages/messages/new-tab/stats_showLess.notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "http://json-schema.org/draft-07/schema#"
}
3 changes: 3 additions & 0 deletions special-pages/messages/new-tab/stats_showMore.notify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"$schema": "http://json-schema.org/draft-07/schema#"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
13 changes: 13 additions & 0 deletions special-pages/pages/new-tab/src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion special-pages/pages/new-tab/src/locales/en/.gitignore

This file was deleted.

200 changes: 200 additions & 0 deletions special-pages/pages/new-tab/src/locales/en/new-tab.json
Original file line number Diff line number Diff line change
@@ -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 <a>what's new</a> in this release.",
"note": "The `<a>` 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"
}
}
4 changes: 2 additions & 2 deletions special-pages/translations.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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')
Expand Down
14 changes: 14 additions & 0 deletions special-pages/types/new-tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export interface NewTabMessages {
| RmfPrimaryActionNotification
| RmfSecondaryActionNotification
| StatsSetConfigNotification
| StatsShowLessNotification
| StatsShowMoreNotification
| TelemetryEventNotification
| UpdateNotificationDismissNotification
| WidgetsSetConfigNotification;
Expand Down Expand Up @@ -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"
*/
Expand Down

0 comments on commit 9d311d3

Please sign in to comment.