Skip to content

Commit 9d311d3

Browse files
shakyShaneShane Osbourne
andauthored
ntp: temporary events for show more/less (#1281)
* ntp: temporary events for show more/less * commit translations for now. * fixed build on windows --------- Co-authored-by: Shane Osbourne <[email protected]>
1 parent 06c9e7f commit 9d311d3

File tree

9 files changed

+258
-25
lines changed

9 files changed

+258
-25
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#"
3+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#"
3+
}

special-pages/pages/new-tab/app/privacy-stats/components/PrivacyStats.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,9 +143,9 @@ export function PrivacyStatsBody({ trackerCompanies, listAttrs = {} }) {
143143

144144
const toggleListExpansion = () => {
145145
if (hasmore) {
146-
messaging.telemetryEvent({ attributes: { name: 'stats_toggle', value: 'show_more' } });
146+
messaging.statsShowMore();
147147
} else {
148-
messaging.telemetryEvent({ attributes: { name: 'stats_toggle', value: 'show_less' } });
148+
messaging.statsShowLess();
149149
}
150150
if (visible === defaultRowMax) {
151151
setVisible(sorted.length);

special-pages/pages/new-tab/app/privacy-stats/integration-tests/privacy-stats.spec.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -33,26 +33,27 @@ test.describe('newtab privacy stats', () => {
3333
await ntp.openPage({ additional: { stats: 'many' } });
3434
await page.getByLabel('Show More', { exact: true }).click();
3535
await page.getByLabel('Show Less').click();
36-
const calls1 = await ntp.mocks.waitForCallCount({ method: 'telemetryEvent', count: 2 });
37-
expect(calls1.length).toBe(2);
38-
expect(calls1).toStrictEqual([
39-
{
40-
payload: {
41-
context: 'specialPages',
42-
featureName: 'newTabPage',
43-
method: 'telemetryEvent',
44-
params: { attributes: { name: 'stats_toggle', value: 'show_more' } },
45-
},
46-
},
47-
{
48-
payload: {
49-
context: 'specialPages',
50-
featureName: 'newTabPage',
51-
method: 'telemetryEvent',
52-
params: { attributes: { name: 'stats_toggle', value: 'show_less' } },
53-
},
54-
},
55-
]);
36+
await ntp.mocks.waitForCallCount({ method: 'stats_showMore', count: 1 });
37+
await ntp.mocks.waitForCallCount({ method: 'stats_showLess', count: 1 });
38+
// expect(calls1.length).toBe(2);
39+
// expect(calls1).toStrictEqual([
40+
// {
41+
// payload: {
42+
// context: 'specialPages',
43+
// featureName: 'newTabPage',
44+
// method: 'telemetryEvent',
45+
// params: { attributes: { name: 'stats_toggle', value: 'show_more' } },
46+
// },
47+
// },
48+
// {
49+
// payload: {
50+
// context: 'specialPages',
51+
// featureName: 'newTabPage',
52+
// method: 'telemetryEvent',
53+
// params: { attributes: { name: 'stats_toggle', value: 'show_less' } },
54+
// },
55+
// },
56+
// ]);
5657
});
5758
test(
5859
'hiding the expander when empty',

special-pages/pages/new-tab/src/js/index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ export class NewTabPage {
6262
telemetryEvent(event) {
6363
this.messaging.notify('telemetryEvent', event);
6464
}
65+
66+
/**
67+
* NOTE: temporary workaround, to be replaced with 'telemetryEvent'
68+
*/
69+
statsShowMore() {
70+
this.messaging.notify('stats_showMore');
71+
}
72+
/**
73+
* NOTE: temporary workaround, to be replaced with 'telemetryEvent'
74+
*/
75+
statsShowLess() {
76+
this.messaging.notify('stats_showLess');
77+
}
6578
}
6679

6780
const baseEnvironment = new Environment().withInjectName(import.meta.injectName).withEnv(import.meta.env);

special-pages/pages/new-tab/src/locales/en/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
{
2+
"smartling": {
3+
"string_format": "icu",
4+
"translate_paths": [
5+
{
6+
"path": "*/title",
7+
"key": "{*}/title",
8+
"instruction": "*/note"
9+
}
10+
]
11+
},
12+
"ntp_show_less": {
13+
"title": "Show Less",
14+
"note": "Button that reduces the number of items or content displayed."
15+
},
16+
"ntp_show_more": {
17+
"title": "Show More",
18+
"note": "Button that increases the number of items or content displayed."
19+
},
20+
"ntp_dismiss": {
21+
"title": "Dismiss",
22+
"note": "Button that closes or hides the current popup or notification."
23+
},
24+
"ntp_customizer_button": {
25+
"title": "Customize",
26+
"note": "Button opens a menu. The menu allows the user to customize the page, such as showing/hiding sections."
27+
},
28+
"widgets_visibility_menu_title": {
29+
"title": "Customize New Tab Page",
30+
"note": "Heading text describing that there's a list of toggles for customizing the page layout."
31+
},
32+
"updateNotification_updated_version": {
33+
"title": "Browser Updated to version {version}.",
34+
"note": "Text to indicate which new version was updated. `{version}` will be formatted like `1.22.0`"
35+
},
36+
"updateNotification_whats_new": {
37+
"title": "See <a>what's new</a> in this release.",
38+
"note": "The `<a>` tag represents a clickable link, please preserve it."
39+
},
40+
"updateNotification_dismiss_btn": {
41+
"title": "Dismiss",
42+
"note": "Button label text for an action that removes the widget from the screen."
43+
},
44+
"stats_menuTitle": {
45+
"title": "Blocked Tracking Attempts",
46+
"note": "Used as a label in a customization menu"
47+
},
48+
"stats_noActivity": {
49+
"title": "Blocked tracking attempts will appear here. Keep browsing to see how many we block.",
50+
"note": "Placeholder for when we cannot report any blocked trackers yet"
51+
},
52+
"stats_noRecent": {
53+
"title": "No recent tracking activity",
54+
"note": "Placeholder to indicate that no tracking activity was blocked in the last 7 days"
55+
},
56+
"stats_countBlockedSingular": {
57+
"title": "1 tracking attempt blocked",
58+
"note": "The main headline indicating that a single tracker was blocked"
59+
},
60+
"stats_countBlockedPlural": {
61+
"title": "{count} tracking attempts blocked",
62+
"note": "The main headline indicating that more than 1 attempt has been blocked. Eg: '2 tracking attempts blocked'"
63+
},
64+
"stats_feedCountBlockedSingular": {
65+
"title": "1 attempt blocked by DuckDuckGo in the last 7 days",
66+
"note": "A summary description of how many tracking attempts where blocked, when only one exists."
67+
},
68+
"stats_feedCountBlockedPeriod": {
69+
"title": "Past 7 days",
70+
"note": "A summary description indicating the time period of the blocked tracking attempts, which is the past 7 days."
71+
},
72+
"stats_feedCountBlockedPlural": {
73+
"title": "{count} tracking attempts blocked",
74+
"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."
75+
},
76+
"stats_toggleLabel": {
77+
"title": "Show recent activity",
78+
"note": "The aria-label text for a toggle button that shows the detailed activity feed"
79+
},
80+
"stats_hideLabel": {
81+
"title": "Hide recent activity",
82+
"note": "The aria-label text for a toggle button that hides the detailed activity feed"
83+
},
84+
"stats_otherCompanyName": {
85+
"title": "Other",
86+
"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"
87+
},
88+
"stats_otherCount": {
89+
"title": "{count} attempts from other networks",
90+
"note": "An aggregated count of blocked entries not present in the main list. For example, '200 attempts from other networks'"
91+
},
92+
"nextSteps_sectionTitle": {
93+
"title": "Next Steps",
94+
"note": "Text that goes in the Next Steps bubble above the first card"
95+
},
96+
"nextSteps_bringStuff_title": {
97+
"title": "Bring Your Stuff",
98+
"note": "Title of the Next Steps card for importing bookmarks and favorites"
99+
},
100+
"nextSteps_bringStuff_summary": {
101+
"title": "Import bookmarks, favorites, and passwords for a smooth transition from your old browser.",
102+
"note": "Summary of the Next Steps card for importing bookmarks and favorites"
103+
},
104+
"nextSteps_bringStuff_actionText": {
105+
"title": "Import Now",
106+
"note": "Button text of the Next Steps card for importing bookmarks and favorites"
107+
},
108+
"nextSteps_defaultApp_title": {
109+
"title": "Set as Default Browser",
110+
"note": "Title of the Next Steps card for making DDG the user's default browser"
111+
},
112+
"nextSteps_defaultApp_summary": {
113+
"title": "We automatically block trackers as you browse. It’s privacy, simplified.",
114+
"note": "Summary of the Next Steps card for making DDG the user's default browser"
115+
},
116+
"nextSteps_defaultApp_actionText": {
117+
"title": "Make Default Browser",
118+
"note": "Button text of the Next Steps card for making DDG the user's default browser"
119+
},
120+
"nextSteps_blockCookies_title": {
121+
"title": "Block Cookie Pop-ups",
122+
"note": "Title of the Next Steps card for blocking cookie pop-ups"
123+
},
124+
"nextSteps_blockCookies_summary": {
125+
"title": "We need your permission to say no to cookies on your behalf. Easy choice.",
126+
"note": "Summary of the Next Steps card for blocking cookie pop-ups"
127+
},
128+
"nextSteps_blockCookies_actionText": {
129+
"title": "Block Cookie Pop-ups",
130+
"note": "Button text of the Next Steps card for blocking cookie pop-ups"
131+
},
132+
"nextSteps_emailProtection_title": {
133+
"title": "Protect Your Inbox",
134+
"note": "Title of the Next Steps card for email protection"
135+
},
136+
"nextSteps_emailProtection_summary": {
137+
"title": "Generate @duck.com addresses that remove trackers from email and forwards to your inbox.",
138+
"note": "Summary of the Next Steps card for email protection"
139+
},
140+
"nextSteps_emailProtection_actionText": {
141+
"title": "Get Email Protection",
142+
"note": "Button text of the Next Steps card for email protection"
143+
},
144+
"nextSteps_duckPlayer_title": {
145+
"title": "YouTube Without Creepy Ads",
146+
"note": "Title of the Next Steps card for adopting DuckPlayer"
147+
},
148+
"nextSteps_duckPlayer_summary": {
149+
"title": "Enjoy a clean viewing experience without personalized ads.",
150+
"note": "Summary of the Next Steps card for adopting DuckPlayer"
151+
},
152+
"nextSteps_duckPlayer_actionText": {
153+
"title": "Try DuckPlayer",
154+
"note": "Button text of the Next Steps card for adopting DuckPlayer"
155+
},
156+
"nextSteps_addAppDockMac_title": {
157+
"title": "Add App to the Dock",
158+
"note": "Title of the Next Steps card for adding DDG app to OS dock"
159+
},
160+
"nextSteps_addAppDockMac_summary": {
161+
"title": "Access DuckDuckGo faster by adding it to the Dock.",
162+
"note": "Summary of the Next Steps card for adding DDG app to OS dock"
163+
},
164+
"nextSteps_addAppDockMac_actionText": {
165+
"title": "Add to Dock",
166+
"note": "Initial button text of the Next Steps card for adding DDG app to OS dock"
167+
},
168+
"nextSteps_addAppDockMac_confirmationText": {
169+
"title": "Added to Dock!",
170+
"note": "Button text after clicking on the Next Steps card for adding DDG app to OS dock"
171+
},
172+
"nextSteps_pinAppToTaskbarWindows_title": {
173+
"title": "Pin App to the Taskbar",
174+
"note": "Title of the Next Steps card for adding DDG app to OS dock"
175+
},
176+
"nextSteps_pinAppToTaskbarWindows_summary": {
177+
"title": "Access DuckDuckGo faster by pinning it to the Taskbar.",
178+
"note": "Summary of the Next Steps card for adding DDG app to OS dock"
179+
},
180+
"nextSteps_pinAppToTaskbarWindows_actionText": {
181+
"title": "Pin to Taskbar",
182+
"note": "Initial button text of the Next Steps card for adding DDG app to OS dock"
183+
},
184+
"nextSteps_pinAppToTaskbarWindows_confirmationText": {
185+
"title": "Pinned to Taskbar!",
186+
"note": "Button text after clicking on the Next Steps card for adding DDG app to OS dock"
187+
},
188+
"favorites_show_less": {
189+
"title": "Show less",
190+
"note": "Button label to display fewer items"
191+
},
192+
"favorites_show_more": {
193+
"title": "Show more ({count} remaining)",
194+
"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)'"
195+
},
196+
"favorites_menu_title": {
197+
"title": "Favorites",
198+
"note": "Used as a label in a customization menu"
199+
}
200+
}

special-pages/translations.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { readdir } from 'fs/promises';
33
import { join, basename } from 'node:path';
44
import { readFileSync, writeFileSync } from 'node:fs';
55

6-
const paths = ['pages/new-tab'];
6+
const paths = [join('pages', 'new-tab')];
77
const base = {
88
smartling: {
99
string_format: 'icu',
@@ -28,7 +28,7 @@ if (isLaunchFile(import.meta.url)) {
2828
*/
2929
async function processPage(path) {
3030
const targetName = basename(path);
31-
const outputFile = `${path}/src/locales/en/${targetName}.json`;
31+
const outputFile = join(path, '/src/locales/en', `${targetName}.json`);
3232
const dirents = await readdir(path, { withFileTypes: true, recursive: true });
3333
const rawEntries = dirents
3434
.filter((entry) => entry.isFile() && entry.name === 'strings.json')

special-pages/types/new-tab.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ export interface NewTabMessages {
5959
| RmfPrimaryActionNotification
6060
| RmfSecondaryActionNotification
6161
| StatsSetConfigNotification
62+
| StatsShowLessNotification
63+
| StatsShowMoreNotification
6264
| TelemetryEventNotification
6365
| UpdateNotificationDismissNotification
6466
| WidgetsSetConfigNotification;
@@ -275,6 +277,18 @@ export interface StatsConfig {
275277
expansion: Expansion;
276278
animation?: Animation;
277279
}
280+
/**
281+
* Generated from @see "../messages/new-tab/stats_showLess.notify.json"
282+
*/
283+
export interface StatsShowLessNotification {
284+
method: "stats_showLess";
285+
}
286+
/**
287+
* Generated from @see "../messages/new-tab/stats_showMore.notify.json"
288+
*/
289+
export interface StatsShowMoreNotification {
290+
method: "stats_showMore";
291+
}
278292
/**
279293
* Generated from @see "../messages/new-tab/telemetryEvent.notify.json"
280294
*/

0 commit comments

Comments
 (0)