Bug 1764070 - Differentiate between auto advance and user click when sending Spotlight/AboutWelcome event telemetry r=Mardak

Differential Revision: https://phabricator.services.mozilla.com/D143767
This commit is contained in:
Meg Viar 2022-04-19 22:43:15 +00:00
Родитель 84f5976ec1
Коммит 245a7b42c1
5 изменённых файлов: 24 добавлений и 11 удалений

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

@ -292,7 +292,7 @@ class WelcomeScreen extends (react__WEBPACK_IMPORTED_MODULE_0___default().PureCo
} // Send telemetry before waiting on actions } // Send telemetry before waiting on actions
_lib_aboutwelcome_utils__WEBPACK_IMPORTED_MODULE_2__.AboutWelcomeUtils.sendActionTelemetry(props.messageId, event.currentTarget.value); _lib_aboutwelcome_utils__WEBPACK_IMPORTED_MODULE_2__.AboutWelcomeUtils.sendActionTelemetry(props.messageId, event.currentTarget.value, event.name);
let { let {
action action
} = targetContent; } = targetContent;
@ -460,9 +460,9 @@ const AboutWelcomeUtils = {
}); });
}, },
sendActionTelemetry(messageId, elementId) { sendActionTelemetry(messageId, elementId, eventName = "CLICK_BUTTON") {
const ping = { const ping = {
event: "CLICK_BUTTON", event: eventName,
event_context: { event_context: {
source: elementId, source: elementId,
page: "about:welcome" page: "about:welcome"
@ -605,7 +605,8 @@ const MultiStageProtonScreen = props => {
handleAction({ handleAction({
currentTarget: { currentTarget: {
value: autoAdvance value: autoAdvance
} },
name: "AUTO_ADVANCE"
}); });
}, 20000); }, 20000);
return () => clearTimeout(timer); return () => clearTimeout(timer);

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

@ -283,7 +283,8 @@ export class WelcomeScreen extends React.PureComponent {
// Send telemetry before waiting on actions // Send telemetry before waiting on actions
AboutWelcomeUtils.sendActionTelemetry( AboutWelcomeUtils.sendActionTelemetry(
props.messageId, props.messageId,
event.currentTarget.value event.currentTarget.value,
event.name
); );
let { action } = targetContent; let { action } = targetContent;

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

@ -19,6 +19,7 @@ export const MultiStageProtonScreen = props => {
currentTarget: { currentTarget: {
value: autoAdvance, value: autoAdvance,
}, },
name: "AUTO_ADVANCE",
}); });
}, 20000); }, 20000);
return () => clearTimeout(timer); return () => clearTimeout(timer);

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

@ -13,9 +13,9 @@ export const AboutWelcomeUtils = {
message_id: messageId, message_id: messageId,
}); });
}, },
sendActionTelemetry(messageId, elementId) { sendActionTelemetry(messageId, elementId, eventName = "CLICK_BUTTON") {
const ping = { const ping = {
event: "CLICK_BUTTON", event: eventName,
event_context: { event_context: {
source: elementId, source: elementId,
page: "about:welcome", page: "about:welcome",

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

@ -108,9 +108,10 @@ describe("MultiStageAboutWelcome module", () => {
welcomeScreenWrapper.props().messageId welcomeScreenWrapper.props().messageId
); );
assert.equal(stub.firstCall.args[1], "primary_button"); assert.equal(stub.firstCall.args[1], "primary_button");
stub.restore();
}); });
it("should autoAdvance on last screen", () => { it("should autoAdvance on last screen and send appropriate telemetry", () => {
let clock = sinon.useFakeTimers(); let clock = sinon.useFakeTimers();
const screens = [ const screens = [
{ {
@ -135,11 +136,20 @@ describe("MultiStageAboutWelcome module", () => {
}; };
const wrapper = mount(<MultiStageAboutWelcome {...AUTO_ADVANCE_PROPS} />); const wrapper = mount(<MultiStageAboutWelcome {...AUTO_ADVANCE_PROPS} />);
wrapper.update(); wrapper.update();
const stub = sandbox.stub(global, "AWFinish"); const finishStub = sandbox.stub(global, "AWFinish");
assert.notCalled(stub); const telemetryStub = sinon.stub(
AboutWelcomeUtils,
"sendActionTelemetry"
);
assert.notCalled(finishStub);
clock.tick(20001); clock.tick(20001);
assert.calledOnce(stub); assert.calledOnce(finishStub);
assert.calledOnce(telemetryStub);
assert.equal(telemetryStub.lastCall.args[2], "AUTO_ADVANCE");
clock.restore(); clock.restore();
finishStub.restore();
telemetryStub.restore();
}); });
}); });