зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1857324 - Add new "pocket-button" ping r=thecount
Depends on D190857 Differential Revision: https://phabricator.services.mozilla.com/D190858
This commit is contained in:
Родитель
ed5d9ebafc
Коммит
e070f910cb
|
@ -108,4 +108,38 @@ export var pktTelemetry = {
|
|||
STRUCTURED_INGESTION_NAMESPACE_AS
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Records the provided data and common pocket-button data to Glean,
|
||||
* then submits it all in a pocket-button ping.
|
||||
*
|
||||
* @param eventAction - A string like "click"
|
||||
* @param eventSource - A string like "save_button"
|
||||
* @param eventPosition - (optional) A 0-based index.
|
||||
* If falsey and not 0, is coalesced to undefined.
|
||||
* @param model - (optional) An identifier for the machine learning model
|
||||
* used to generate the recommendations like "vec-bestarticle"
|
||||
*/
|
||||
submitPocketButtonPing(
|
||||
eventAction,
|
||||
eventSource,
|
||||
eventPosition = undefined,
|
||||
model = undefined
|
||||
) {
|
||||
eventPosition = eventPosition || eventPosition === 0 ? 0 : undefined;
|
||||
Glean.pocketButton.impressionId.set(this.impressionId);
|
||||
Glean.pocketButton.pocketLoggedInStatus.set(lazy.pktApi.isUserLoggedIn());
|
||||
Glean.pocketButton.profileCreationDate.set(this._profileCreationDate());
|
||||
|
||||
Glean.pocketButton.eventAction.set(eventAction);
|
||||
Glean.pocketButton.eventSource.set(eventSource);
|
||||
if (eventPosition !== undefined) {
|
||||
Glean.pocketButton.eventPosition.set(eventPosition);
|
||||
}
|
||||
if (model !== undefined) {
|
||||
Glean.pocketButton.model.set(model);
|
||||
}
|
||||
|
||||
GleanPings.pocketButton.submit();
|
||||
},
|
||||
};
|
||||
|
|
|
@ -226,6 +226,7 @@ var pktUI = (function () {
|
|||
function onShowSignup() {
|
||||
// Ensure opening the signup panel clears the icon state from any previous sessions.
|
||||
SaveToPocket.itemDeleted();
|
||||
pktTelemetry.submitPocketButtonPing("click", "save_button");
|
||||
// A successful button click, for logged out users.
|
||||
pktTelemetry.sendStructuredIngestionEvent(
|
||||
pktTelemetry.createPingPayload({
|
||||
|
@ -240,6 +241,7 @@ var pktUI = (function () {
|
|||
}
|
||||
|
||||
async function onShowHome() {
|
||||
pktTelemetry.submitPocketButtonPing("click", "home_button");
|
||||
// A successful home button click.
|
||||
pktTelemetry.sendStructuredIngestionEvent(
|
||||
pktTelemetry.createPingPayload({
|
||||
|
@ -300,6 +302,7 @@ var pktUI = (function () {
|
|||
return;
|
||||
}
|
||||
|
||||
pktTelemetry.submitPocketButtonPing("click", "save_button");
|
||||
// A successful button click, for logged in users.
|
||||
pktTelemetry.sendStructuredIngestionEvent(
|
||||
pktTelemetry.createPingPayload({
|
||||
|
@ -451,6 +454,7 @@ var pktUI = (function () {
|
|||
// We don't track every click, only clicks with a known source.
|
||||
if (data.source) {
|
||||
const { position, source, model } = data;
|
||||
pktTelemetry.submitPocketButtonPing("click", source, position, model);
|
||||
const payload = pktTelemetry.createPingPayload({
|
||||
...(model ? { model } : {}),
|
||||
events: [
|
||||
|
@ -485,6 +489,12 @@ var pktUI = (function () {
|
|||
const { url, position, model } = data;
|
||||
// Check to see if we need to and can fire valid telemetry.
|
||||
if (model && (position || position === 0)) {
|
||||
pktTelemetry.submitPocketButtonPing(
|
||||
"click",
|
||||
"on_save_recs",
|
||||
position,
|
||||
model
|
||||
);
|
||||
const payload = pktTelemetry.createPingPayload({
|
||||
model,
|
||||
events: [
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# Adding a new metric? We have docs for that!
|
||||
# https://firefox-source-docs.mozilla.org/toolkit/components/glean/user/new_definitions_file.html
|
||||
|
||||
---
|
||||
$schema: moz://mozilla.org/schemas/glean/metrics/2-0-0
|
||||
$tags:
|
||||
- 'Firefox :: Pocket'
|
||||
|
||||
pocket.button:
|
||||
impression_id:
|
||||
type: uuid
|
||||
description: >
|
||||
A UUID representing this profile.
|
||||
This isn't client_id, nor can it be used to link to a client_id.
|
||||
This also means it should never be sent in a ping with a client_id.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_sensitivity:
|
||||
- technical
|
||||
notification_emails:
|
||||
- chutten@mozilla.com
|
||||
- kdemtchouk@mozilla.com
|
||||
- sdowne@mozilla.com
|
||||
expires: never
|
||||
send_in_pings: [ pocket-button ]
|
||||
|
||||
pocket_logged_in_status:
|
||||
type: boolean
|
||||
description: >
|
||||
Whether there was a logged-in Pocket account in the Pocket-Firefox
|
||||
integration at the point in time this action occurred.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_sensitivity:
|
||||
- technical
|
||||
notification_emails:
|
||||
- chutten@mozilla.com
|
||||
- kdemtchouk@mozilla.com
|
||||
- sdowne@mozilla.com
|
||||
expires: never
|
||||
send_in_pings: [ pocket-button ]
|
||||
|
||||
profile_creation_date:
|
||||
type: quantity
|
||||
unit: days_since_jan_1_1970
|
||||
description: >
|
||||
The days since Jan 1, 1970 that the oldest file in the profile dir was
|
||||
modified. Or created. Or just the day and time of the first thing to ask
|
||||
for the profile age called in. Or something earlier or later than that.
|
||||
|
||||
You may not want to use this.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_sensitivity:
|
||||
- technical
|
||||
notification_emails:
|
||||
- chutten@mozilla.com
|
||||
- kdemtchouk@mozilla.com
|
||||
- sdowne@mozilla.com
|
||||
expires: never
|
||||
send_in_pings: [ pocket-button ]
|
||||
|
||||
event_action:
|
||||
type: string
|
||||
description: >
|
||||
The action that was taken, like "click" or... actually, it might only
|
||||
ever be "click".
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
notification_emails:
|
||||
- chutten@mozilla.com
|
||||
- kdemtchouk@mozilla.com
|
||||
- sdowne@mozilla.com
|
||||
expires: never
|
||||
send_in_pings: [ pocket-button ]
|
||||
|
||||
event_source:
|
||||
type: string
|
||||
description: >
|
||||
The source of the taken action, like "save_button", "home_button",
|
||||
"on_save_recs", or the like.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
notification_emails:
|
||||
- chutten@mozilla.com
|
||||
- kdemtchouk@mozilla.com
|
||||
- sdowne@mozilla.com
|
||||
expires: never
|
||||
send_in_pings: [ pocket-button ]
|
||||
|
||||
event_position:
|
||||
type: quantity
|
||||
unit: index
|
||||
description: >
|
||||
0-based index of the item on which the action was performed.
|
||||
Not always provided.
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
notification_emails:
|
||||
- chutten@mozilla.com
|
||||
- kdemtchouk@mozilla.com
|
||||
- sdowne@mozilla.com
|
||||
expires: never
|
||||
send_in_pings: [ pocket-button ]
|
||||
|
||||
model:
|
||||
type: string
|
||||
description: >
|
||||
A string that identifies the ML model (if any) used to generate on-save
|
||||
recommendations. Like "doc2vec-incremental-best-article-pubspread".
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_sensitivity:
|
||||
- interaction
|
||||
notification_emails:
|
||||
- chutten@mozilla.com
|
||||
- kdemtchouk@mozilla.com
|
||||
- sdowne@mozilla.com
|
||||
expires: never
|
||||
send_in_pings: [ pocket-button ]
|
|
@ -0,0 +1,22 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
---
|
||||
$schema: moz://mozilla.org/schemas/glean/pings/2-0-0
|
||||
|
||||
pocket-button:
|
||||
description: |
|
||||
Reinstrumentation of the Activity Stream "pocket-button" ping.
|
||||
Submitted when actions are taken around the pocket button.
|
||||
Does not contain any `client_id`.
|
||||
Instead uses an `impression_id`.
|
||||
include_client_id: false
|
||||
bugs:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
data_reviews:
|
||||
- https://bugzilla.mozilla.org/show_bug.cgi?id=1857324
|
||||
notification_emails:
|
||||
- chutten@mozilla.com
|
||||
- kdemtchouk@mozilla.com
|
||||
- sdowne@mozilla.com
|
|
@ -52,3 +52,70 @@ test_runner(async function test_generateStructuredIngestionEndpoint({
|
|||
"https://incoming.telemetry.mozilla.org/submit/activity-stream/pocket-button/1/7fd5a1ac-6089-4212-91a7-fcdec1d2f533"
|
||||
);
|
||||
});
|
||||
|
||||
test_runner(async function test_submitPocketButtonPing({ sandbox }) {
|
||||
const creationDate = "19640";
|
||||
const impressionId = "{422e3da9-c694-4fd2-b676-8ae070156128}";
|
||||
sandbox.stub(pktTelemetry, "impressionId").value(impressionId);
|
||||
sandbox.stub(pktTelemetry, "_profileCreationDate").returns(creationDate);
|
||||
|
||||
const eventAction = "some action like 'click'";
|
||||
const eventSource = "some source like 'save_button'";
|
||||
|
||||
const assertConstantStuff = () => {
|
||||
Assert.equal(
|
||||
"{" + Glean.pocketButton.impressionId.testGetValue() + "}",
|
||||
impressionId
|
||||
);
|
||||
Assert.equal(Glean.pocketButton.pocketLoggedInStatus.testGetValue(), false);
|
||||
Assert.equal(
|
||||
Glean.pocketButton.profileCreationDate.testGetValue(),
|
||||
creationDate
|
||||
);
|
||||
|
||||
Assert.equal(Glean.pocketButton.eventAction.testGetValue(), eventAction);
|
||||
Assert.equal(Glean.pocketButton.eventSource.testGetValue(), eventSource);
|
||||
};
|
||||
|
||||
let submitted = false;
|
||||
GleanPings.pocketButton.testBeforeNextSubmit(() => {
|
||||
submitted = true;
|
||||
assertConstantStuff();
|
||||
Assert.equal(Glean.pocketButton.eventPosition.testGetValue(), null);
|
||||
Assert.equal(Glean.pocketButton.model.testGetValue(), null);
|
||||
});
|
||||
|
||||
pktTelemetry.submitPocketButtonPing(eventAction, eventSource);
|
||||
Assert.ok(submitted, "Ping submitted successfully");
|
||||
|
||||
submitted = false;
|
||||
GleanPings.pocketButton.testBeforeNextSubmit(() => {
|
||||
submitted = true;
|
||||
assertConstantStuff();
|
||||
Assert.equal(Glean.pocketButton.eventPosition.testGetValue(), 0);
|
||||
Assert.equal(Glean.pocketButton.model.testGetValue(), null);
|
||||
});
|
||||
|
||||
pktTelemetry.submitPocketButtonPing(eventAction, eventSource, 0, null);
|
||||
Assert.ok(submitted, "Ping submitted successfully");
|
||||
|
||||
submitted = false;
|
||||
GleanPings.pocketButton.testBeforeNextSubmit(() => {
|
||||
submitted = true;
|
||||
assertConstantStuff();
|
||||
// falsey but not undefined positions will be omitted.
|
||||
Assert.equal(Glean.pocketButton.eventPosition.testGetValue(), null);
|
||||
Assert.equal(
|
||||
Glean.pocketButton.model.testGetValue(),
|
||||
"some-really-groovy-model"
|
||||
);
|
||||
});
|
||||
|
||||
pktTelemetry.submitPocketButtonPing(
|
||||
eventAction,
|
||||
eventSource,
|
||||
false,
|
||||
"some-really-groovy-model"
|
||||
);
|
||||
Assert.ok(submitted, "Ping submitted successfully");
|
||||
});
|
||||
|
|
|
@ -43,6 +43,7 @@ firefox_desktop_metrics = [
|
|||
"browser/components/metrics.yaml",
|
||||
"browser/components/migration/metrics.yaml",
|
||||
"browser/components/newtab/metrics.yaml",
|
||||
"browser/components/pocket/metrics.yaml",
|
||||
"browser/components/preferences/metrics.yaml",
|
||||
"browser/components/privatebrowsing/metrics.yaml",
|
||||
"browser/components/search/metrics.yaml",
|
||||
|
@ -106,6 +107,7 @@ gecko_pings = [
|
|||
# Order is lexicographical, enforced by t/c/glean/tests/pytest/test_yaml_indices.py
|
||||
firefox_desktop_pings = [
|
||||
"browser/components/newtab/pings.yaml",
|
||||
"browser/components/pocket/pings.yaml",
|
||||
"browser/components/urlbar/pings.yaml",
|
||||
"toolkit/components/crashes/pings.yaml",
|
||||
"toolkit/components/telemetry/pings.yaml",
|
||||
|
|
Загрузка…
Ссылка в новой задаче