Skip to content

Commit

Permalink
RMF Docs (#1170)
Browse files Browse the repository at this point in the history
* docs: Add RMF Service spec docs, examples

* fix: Examples

* docs: Update new-tab app

* fix: RMF service
  • Loading branch information
vkraucunas authored Oct 28, 2024
1 parent 360983f commit 6f94a00
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 4 deletions.
53 changes: 53 additions & 0 deletions special-pages/messages/new-tab/examples/rmf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/**
* @type {import("../../../types/new-tab").RMFData}
*/
const rmfDataSmallMsg = {
"content": {
"messageType": "small",
"id": "id-1",
"titleText": "Tell Us Your Thoughts on Privacy Pro",
"descriptionText": "Lorem Ipsum is simply dummy text of the printing and typesetting industry."
},
}

/**
* @type {import("../../../types/new-tab").RMFData}
*/
const rmfDataMediumMsg = {
"content": {
messageType: 'medium',
id: 'id-2',
icon: 'DDGAnnounce',
titleText: 'New Search Feature!',
descriptionText: 'DuckDuckGo now offers Instant Answers for quicker access to the information you need.'
},
}

/**
* @type {import("../../../types/new-tab").RMFData}
*/
const rmfDataBigSingleActionMsg = {
"content": {
messageType: 'big_single_action',
id: 'id-big-single',
titleText: 'Tell Us Your Thoughts on Privacy Pro',
descriptionText: 'Take our short anonymous survey and share your feedback.',
icon: 'PrivacyPro',
primaryActionText: 'Take Survey'
}
}

/**
* @type {import("../../../types/new-tab").RMFData}
*/
const rmfDataBigTwoActionMsg = {
"content": {
messageType: 'big_two_action',
id: 'id-big-two',
titleText: 'Tell Us Your Thoughts on Privacy Pro',
descriptionText: 'Take our short anonymous survey and share your feedback.',
icon: 'Announce',
primaryActionText: 'Take Survey',
secondaryActionText: 'Remind me'
}
}
2 changes: 2 additions & 0 deletions special-pages/pages/new-tab/app/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
*
* - {@link WidgetConfigService}
* - {@link PrivacyStatsService}
* - {@link RMFService}
*
* @module NewTab Services
*/
export * from './privacy-stats/privacy-stats.service.js'
export * from './widget-list/widget-config.service.js'
export * from './remote-messaging-framework/rmf.service.js'
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/**
* @typedef {import("../../../../types/new-tab.js").RMFData} RMFData
* @typedef {import("../../../../types/new-tab.js").StatsConfig} StatsConfig
*/
import { Service } from '../service.js'

/**
*
* @document ./rmf.service.md
*/

export class RMFService {
/**
* @param {import("../../src/js/index.js").NewTabPage} ntp - The internal data feed, expected to have a `subscribe` method.
Expand Down Expand Up @@ -52,8 +52,6 @@ export class RMFService {
return this.ntp.messaging.notify('rmf_dismiss', { id })
}

toggleExpansion () { }

/**
* @param {string} id
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
title: Remote Messaging Framework
---

## Requests:
- {@link "NewTab Messages".RmfGetDataRequest `rmf_getData`}
- Used to fetch the initial data (during the first render)
- returns {@link "NewTab Messages".RMFData}

## Subscriptions:
- {@link "NewTab Messages".RmfOnDataUpdateSubscription `rmf_onDataUpdate`}.
- The messages available for the platform
- returns {@link "NewTab Messages".RMFData}

## Notifications:
- {@link "NewTab Messages".RmfPrimaryActionNotification `rmf_primaryAction`}
- Sent when the user clicks the primaryAction button
- sends {@link "NewTab Messages".RMFPrimaryAction}
- example payload:
```json
{
"id": "windows_privacy_pro_survey_2"
}
```
- {@link "NewTab Messages".RmfSecondaryActionNotification `rmf_secondaryAction`}
- Sent when the user clicks the secondaryAction button
- sends {@link "NewTab Messages".RMFSecondaryAction}
- example payload:
```json
{
"id": "windows_privacy_pro_survey_2"
}
```
- {@link "NewTab Messages".RmfDismissNotification `rmf_dismiss`}
- Sent when the user clicks the dismiss button
- sends {@link "NewTab Messages".RMFDismissAction}
- example payload:
```json
{
"id": "windows_privacy_pro_survey_2"
}
```

## Examples:

The following examples show the data types in JSON format:
[messages/new-tab/examples/stats.js](../../../../messages/new-tab/examples/rmf.js)

0 comments on commit 6f94a00

Please sign in to comment.