Merge pull request #3634 from mozilla/tag-metrics-with-correct-service-in-sync-optional-flow;=shane-tomlinson

Set `service` tag for metrics events based on fxa_status response.
This commit is contained in:
Ryan Kelly 2019-12-14 07:57:55 +11:00 коммит произвёл GitHub
Родитель a25f476d26 16e58737d9
Коммит bfdf0cb3a9
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 68 добавлений и 21 удалений

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

@ -584,6 +584,17 @@ _.extend(Metrics.prototype, Backbone.Events, {
return id;
},
/**
* Set the `service` parameter to use for all future metrics.
* This is useful in cases where don't learn the appropriate
* service value until after the app has been initialized.
*
* @param {String} [service] The service identifier
*/
setService(service) {
this._service = service || NOT_REPORTED_VALUE;
},
/**
* Set the view name prefix for metrics that contain a viewName.
* This is used to differentiate between flows when the same

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

@ -67,6 +67,7 @@ export default BaseAuthenticationBroker.extend({
// the service in the query parameter currently overrides the status message
// this is due to backwards compatibility
this.relier.set('service', response.clientId);
this._metrics.setService(response.clientId);
}
}
const additionalEngineIds =

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

@ -704,6 +704,15 @@ describe('lib/metrics', () => {
});
});
describe('setService', function() {
it('sets the service identifier', function() {
metrics.setService('00112233445566');
const { service } = metrics.getFilteredData();
assert.equal(service, '00112233445566');
});
});
describe('isCollectionEnabled', () => {
it('reports that collection is enabled if `isSampledUser===true`', () => {
assert.isTrue(metrics.isCollectionEnabled());

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

@ -84,6 +84,7 @@ describe('models/auth_brokers/fx-sync', () => {
});
});
describe('fxa_status response handling', () => {
describe('syncOptional capability', () => {
it('sets `syncOptional` to false if no multiService capability', () => {
relier.set('service', 'foo');
@ -114,6 +115,31 @@ describe('models/auth_brokers/fx-sync', () => {
});
});
describe('clientId', () => {
it('sets `service` based on `clientId` when not otherwise known', () => {
broker.onFxaStatus({
capabilities: { multiService: true },
clientId: 'fx-desktop',
});
assert.equal(relier.get('service'), 'fx-desktop');
assert.equal(metrics.getFilteredData().service, 'fx-desktop');
});
it('does not override an explicit `service` value obtained from query parameters', () => {
relier.set('service', 'sync');
metrics.setService('sync');
broker.onFxaStatus({
capabilities: { multiService: true },
clientId: 'fx-desktop',
});
assert.equal(relier.get('service'), 'sync');
assert.equal(metrics.getFilteredData().service, 'sync');
});
});
});
describe('afterSignUpConfirmationPoll', () => {
describe('broker does not have `browserTransitionsAfterEmailVerification` capability', () => {
it('sets the metrics viewName prefix, resolves to a `ConnectAnotherDeviceBehavior`', () => {