Bug 1663857 - Ensure pioneer pings are properly routed to the study tables. r=rhelmer,amiyaguchi

Differential Revision: https://phabricator.services.mozilla.com/D89798
This commit is contained in:
Alessio Placitelli 2020-09-11 12:18:50 +00:00
Родитель a7cdd69f72
Коммит 60725c5763
3 изменённых файлов: 15 добавлений и 12 удалений

Просмотреть файл

@ -718,7 +718,7 @@ async function sendDeletionPing(studyAddonId) {
// pipeline requires that pings are shaped this way so they are routed to the correct environment.
//
// At the moment, the public key used here isn't important but we do need to use *something*.
encryptionKeyId: "debug",
encryptionKeyId: "discarded",
publicKey: {
crv: "P-256",
kty: "EC",
@ -727,7 +727,9 @@ async function sendDeletionPing(studyAddonId) {
},
schemaName: "deletion-request",
schemaVersion: 1,
schemaNamespace: "pioneer-debug",
// The schema namespace needs to be the study addon id, as we
// want to route the ping to the specific study table.
schemaNamespace: studyAddonId,
};
const payload = {
@ -748,13 +750,14 @@ async function sendDeletionPing(studyAddonId) {
*/
async function sendEnrollmentPing(studyAddonId) {
let options = {
studyName: "pioneer-meta",
addPioneerId: true,
useEncryption: true,
// NOTE - while we're not actually sending useful data in this payload, the current Pioneer v2 Telemetry
// pipeline requires that pings are shaped this way so they are routed to the correct environment.
//
// At the moment, the public key used here isn't important but we do need to use *something*.
encryptionKeyId: "debug",
encryptionKeyId: "discarded",
publicKey: {
crv: "P-256",
kty: "EC",
@ -774,9 +777,9 @@ async function sendEnrollmentPing(studyAddonId) {
// the work on the ingestion pipeline.
if (typeof studyAddonId != "undefined") {
options.studyName = studyAddonId;
// This is the same namespace used for 'deletion-request' pings. This works because
// the pipeline has a specific exception for it.
options.schemaNamespace = "pioneer-debug";
// The schema namespace needs to be the study addon id, as we
// want to route the ping to the specific study table.
options.schemaNamespace = studyAddonId;
}
await TelemetryController.submitExternalPing("pioneer-study", {}, options);

Просмотреть файл

@ -874,7 +874,7 @@ add_task(async function testEnrollmentPings() {
p.schemaName == "pioneer-enrollment" &&
p.schemaNamespace == "pioneer-meta" &&
p.pioneerId == pioneerId &&
!p.studyName
p.studyName == "pioneer-meta"
),
"We expect the Pioneer program consent to be present"
);
@ -883,7 +883,7 @@ add_task(async function testEnrollmentPings() {
pingDetails.find(
p =>
p.schemaName == "pioneer-enrollment" &&
p.schemaNamespace == "pioneer-debug" &&
p.schemaNamespace == CACHED_TEST_ADDON.addon_id &&
p.pioneerId == pioneerId &&
p.studyName == CACHED_TEST_ADDON.addon_id
),

Просмотреть файл

@ -18,8 +18,8 @@ Structure:
"encryptedData": "<encrypted token>",
"schemaVersion": 1,
"schemaName": "debug",
"schemaNamespace": "pioneer-debug",
"encryptionKeyId": "debug",
"schemaNamespace": "<namespace>",
"encryptionKeyId": "<key id>",
"pioneerId": "<UUID>",
"studyName": "pioneer-v2-example"
}
@ -39,7 +39,7 @@ schemaNamespace
The namespace used to segregate data on the pipeline.
encryptionKeyId
The id of the key used to encrypt the data.
The id of the key used to encrypt the data. If `discarded` is used, then the `encryptedData` will be ignored and not decoded (only possible for `deletion-request` and `pioneer-enrollment` schemas).
pioneerId
The id of the pioneer client.
@ -55,4 +55,4 @@ This ping has two special Pioneer payload configurations, indicated by the diffe
The `deletion-request` is sent when a user opts out from a Pioneer study: it contains the `pioneerId` and the `studyName`.
The `pioneer-enrollment` is sent when a user opts into the Pioneer program: in this case it reports `schemaNamespace: "pioneer-meta"` and will have no `studyName`. It is also sent when enrolling into a study, in which case it reports the same namespace as the `deletion-request` (i.e. `"pioneer-debug"`) and the `pioneer-enrollment` schema name.
The `pioneer-enrollment` is sent when a user opts into the Pioneer program: in this case it reports `schemaNamespace: "pioneer-meta"` and will have no `studyName`. It is also sent when enrolling into a study, in which case it reports the same namespace as the `deletion-request` (i.e. the id the study making the request) and the `pioneer-enrollment` schema name.