Skip to content

Commit 94aea92

Browse files
NTP omnibar: send the attachment kind with the learn more notification
Native splits the learn_more_tapped pixel by what was attached, the same way iOS does, and it never sees the attach — so the page has to say which kind the disclaimer was about.
1 parent f0c159f commit 94aea92

6 files changed

Lines changed: 34 additions & 11 deletions

File tree

‎special-pages/pages/new-tab/app/omnibar/components/OmnibarProvider.js‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export const OmnibarContext = createContext({
9999
attachmentPrivacyDisclaimerShown: () => {
100100
throw new Error('must implement');
101101
},
102-
/** @type {() => void} */
102+
/** @type {(kind: 'image' | 'file') => void} */
103103
openAttachmentPrivacyLearnMore: () => {
104104
throw new Error('must implement');
105105
},
@@ -306,10 +306,13 @@ export function OmnibarProvider(props) {
306306
[service],
307307
);
308308

309-
/** @type {() => void} */
310-
const openAttachmentPrivacyLearnMore = useCallback(() => {
311-
service.current?.openAttachmentPrivacyLearnMore();
312-
}, [service]);
309+
/** @type {(kind: 'image' | 'file') => void} */
310+
const openAttachmentPrivacyLearnMore = useCallback(
311+
(kind) => {
312+
service.current?.openAttachmentPrivacyLearnMore(kind);
313+
},
314+
[service],
315+
);
313316

314317
/** @type {(modelId?: string) => void} */
315318
const selectUsageLimitsCta = useCallback(

‎special-pages/pages/new-tab/app/omnibar/components/useAttachmentPrivacyNotice.js‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,14 @@ export function useAttachmentPrivacyNotice() {
4141
attachmentPrivacyDisclaimerShown(attachmentKind);
4242
}, [attachmentKind, granted, allowed, setGranted, attachmentPrivacyDisclaimerShown]);
4343

44-
const messageValues = { button: { click: openAttachmentPrivacyLearnMore } };
44+
const messageValues = {
45+
button: {
46+
click: () => {
47+
// Non-null whenever the notice is on screen; the presentation below needs it too.
48+
if (attachmentKind) openAttachmentPrivacyLearnMore(attachmentKind);
49+
},
50+
},
51+
};
4552

4653
// `granted` outlasts `allowed`: the display that spends the last one stays on screen.
4754
const presentation =

‎special-pages/pages/new-tab/app/omnibar/integration-tests/omnibar-attachment-privacy.spec.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ test.describe('omnibar attachment privacy disclaimer', () => {
237237
await attachFile(omnibar);
238238
await omnibar.attachmentPrivacyLearnMore().click();
239239

240-
await omnibar.expectMethodCalledWith('omnibar_openAttachmentPrivacyLearnMore', {});
240+
await omnibar.expectMethodCalledWith('omnibar_openAttachmentPrivacyLearnMore', { kind: 'file' });
241241
await expect(omnibar.fileChip()).toHaveCount(1);
242242
await expect(omnibar.noticeDrawer()).toBeVisible();
243243
});

‎special-pages/pages/new-tab/app/omnibar/omnibar.service.js‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,10 @@ export class OmnibarService {
250250

251251
/**
252252
* Notify native to open the attachment privacy help page in a new tab.
253+
* @param {'image' | 'file'} kind
253254
*/
254-
openAttachmentPrivacyLearnMore() {
255-
this.ntp.messaging.notify('omnibar_openAttachmentPrivacyLearnMore', {});
255+
openAttachmentPrivacyLearnMore(kind) {
256+
this.ntp.messaging.notify('omnibar_openAttachmentPrivacyLearnMore', { kind });
256257
}
257258

258259
/**

‎special-pages/pages/new-tab/messages/omnibar_openAttachmentPrivacyLearnMore.notify.json‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,12 @@
44
"description": "Sent when the user selects 'Learn more' in the file-upload privacy disclaimer. Native opens the help page in a new tab and fires the learn_more_tapped pixel; the staged attachment is left untouched.",
55
"type": "object",
66
"additionalProperties": false,
7-
"properties": {}
7+
"required": ["kind"],
8+
"properties": {
9+
"kind": {
10+
"description": "Which attachment the disclaimer was about. Native never sees the attach, so it cannot infer this for the pixel.",
11+
"type": "string",
12+
"enum": ["image", "file"]
13+
}
14+
}
815
}

‎special-pages/pages/new-tab/types/new-tab.ts‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,12 @@ export interface OmnibarOpenAttachmentPrivacyLearnMoreNotification {
755755
/**
756756
* Sent when the user selects 'Learn more' in the file-upload privacy disclaimer. Native opens the help page in a new tab and fires the learn_more_tapped pixel; the staged attachment is left untouched.
757757
*/
758-
export interface OpenAttachmentPrivacyLearnMore {}
758+
export interface OpenAttachmentPrivacyLearnMore {
759+
/**
760+
* Which attachment the disclaimer was about. Native never sees the attach, so it cannot infer this for the pixel.
761+
*/
762+
kind: "image" | "file";
763+
}
759764
/**
760765
* Generated from @see "../messages/omnibar_openCustomizeResponses.notify.json"
761766
*/

0 commit comments

Comments
 (0)