Bug 1968074 - Fix truncated inferred interests ping r=thecount,home-newtab-reviewers
Differential Revision: https://phabricator.services.mozilla.com/D250825
This commit is contained in:
committed by
rrando@mozilla.com
parent
b6bab59343
commit
e13051d979
@@ -1918,7 +1918,7 @@ newtab_content:
|
||||
- newtab-content
|
||||
|
||||
inferred_interests:
|
||||
type: string
|
||||
type: object
|
||||
description: >
|
||||
Differentially private high-level inferred interests (e.g. Entertainment or News), encoded in a JSON string.
|
||||
Key is the feature, and the value is a unary encoded string that must be decoded based on known differential
|
||||
@@ -1935,6 +1935,16 @@ newtab_content:
|
||||
lifetime: application
|
||||
send_in_pings:
|
||||
- newtab-content
|
||||
structure:
|
||||
type: object
|
||||
properties:
|
||||
values:
|
||||
type: array
|
||||
items:
|
||||
type: string
|
||||
model_id:
|
||||
type: string
|
||||
|
||||
|
||||
coarse_os:
|
||||
type: string
|
||||
|
||||
@@ -395,6 +395,7 @@ export class FeatureModel {
|
||||
dataForIntervals,
|
||||
indexSchema,
|
||||
model_id = "unknown",
|
||||
condensePrivateValues = true,
|
||||
}) {
|
||||
const result = {};
|
||||
let inferredInterests;
|
||||
@@ -429,10 +430,17 @@ export class FeatureModel {
|
||||
applyDifferentialPrivacy: true,
|
||||
});
|
||||
if (coarsePrivateInferredInterests) {
|
||||
result.coarsePrivateInferredInterests = {
|
||||
...coarsePrivateInferredInterests,
|
||||
model_id,
|
||||
};
|
||||
if (condensePrivateValues) {
|
||||
result.coarsePrivateInferredInterests = {
|
||||
values: Object.values(coarsePrivateInferredInterests), // Key order presrved in Gecko
|
||||
model_id,
|
||||
};
|
||||
} else {
|
||||
result.coarsePrivateInferredInterests = {
|
||||
...coarsePrivateInferredInterests,
|
||||
model_id,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1037,9 +1037,7 @@ export class TelemetryFeed {
|
||||
const inferredInterests =
|
||||
this.privatePingInferredInterestsEnabled && this.inferredInterests;
|
||||
if (inferredInterests) {
|
||||
Glean.newtabContent.inferredInterests.set(
|
||||
JSON.stringify(inferredInterests)
|
||||
);
|
||||
Glean.newtabContent.inferredInterests.set(inferredInterests);
|
||||
}
|
||||
|
||||
// When we have a coarse interest vector we want to make sure there isn't
|
||||
|
||||
@@ -369,6 +369,7 @@ add_task(function test_computeMultipleVectors() {
|
||||
dataForIntervals: SQL_RESULT_DATA,
|
||||
indexSchema: SCHEMA,
|
||||
model_id: "test",
|
||||
condensePrivateValues: false,
|
||||
});
|
||||
Assert.equal(
|
||||
result.coarsePrivateInferredInterests.parenting,
|
||||
@@ -385,12 +386,48 @@ add_task(function test_computeMultipleVectors() {
|
||||
);
|
||||
});
|
||||
|
||||
add_task(function test_computeMultipleVectorsCondensed() {
|
||||
const modelData = { ...jsonModelData, rescale: true };
|
||||
const model = FeatureModel.fromJSON(modelData);
|
||||
const result = model.computeInterestVectors({
|
||||
dataForIntervals: SQL_RESULT_DATA,
|
||||
indexSchema: SCHEMA,
|
||||
model_id: "test",
|
||||
});
|
||||
Assert.equal(
|
||||
result.coarsePrivateInferredInterests.values.length,
|
||||
3,
|
||||
"Items in an array"
|
||||
);
|
||||
Assert.equal(
|
||||
result.coarsePrivateInferredInterests.values[0].length,
|
||||
3,
|
||||
"One value in string per possible result"
|
||||
);
|
||||
Assert.ok(
|
||||
result.coarsePrivateInferredInterests.values[0]
|
||||
.split("")
|
||||
.every(a => a === "1" || a === "0"),
|
||||
"Combined coarse values are 1 and 0"
|
||||
);
|
||||
Assert.equal(
|
||||
result.coarsePrivateInferredInterests.model_id,
|
||||
"test",
|
||||
"Model id returned"
|
||||
);
|
||||
Assert.ok(
|
||||
result.inferredInterests.parenting > 0,
|
||||
"Original inferred interest is returned"
|
||||
);
|
||||
});
|
||||
|
||||
add_task(function test_computeMultipleVectorsNoPrivate() {
|
||||
const model = FeatureModel.fromJSON(jsonModelDataNoCoarseSupport);
|
||||
const result = model.computeInterestVectors({
|
||||
dataForIntervals: SQL_RESULT_DATA,
|
||||
indexSchema: SCHEMA,
|
||||
model_id: "test",
|
||||
condensePrivateValues: false,
|
||||
});
|
||||
Assert.ok(
|
||||
!result.coarsePrivateInferredInterests,
|
||||
|
||||
Reference in New Issue
Block a user