зеркало из https://github.com/mozilla/fxa-shared.git
Merge pull request #40 from mozilla/issue-6757-client-id-as-entrypoint r=@philbooth
feat(metrics): Use the service name or client_id as the entrypoint if none given.
This commit is contained in:
Коммит
98ffc5a933
|
@ -180,7 +180,7 @@ module.exports = {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return pruneUnsetValues({
|
const properties = pruneUnsetValues({
|
||||||
op: 'amplitudeEvent',
|
op: 'amplitudeEvent',
|
||||||
event_type: `${eventGroup} - ${eventType}`,
|
event_type: `${eventGroup} - ${eventType}`,
|
||||||
time: event.time,
|
time: event.time,
|
||||||
|
@ -197,6 +197,21 @@ module.exports = {
|
||||||
event_properties: mapEventProperties(eventType, eventGroup, eventCategory, eventTarget, data),
|
event_properties: mapEventProperties(eventType, eventGroup, eventCategory, eventTarget, data),
|
||||||
user_properties: mapUserProperties(eventGroup, eventCategory, data)
|
user_properties: mapUserProperties(eventGroup, eventCategory, data)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (! properties.user_properties.entrypoint) {
|
||||||
|
// If no entrypoint is specified, use the service name or client_id
|
||||||
|
// as the entrypoint to minimize occurrences of "entrypoint=none"
|
||||||
|
// results in Amplitude. service name is preferred because
|
||||||
|
// it's human readable.
|
||||||
|
// See https://github.com/mozilla/fxa-content-server/issues/6757
|
||||||
|
if (properties.event_properties.service && properties.event_properties.service !== 'undefined_oauth') {
|
||||||
|
properties.user_properties.entrypoint = properties.event_properties.service;
|
||||||
|
} else if (properties.event_properties.oauth_client_id) {
|
||||||
|
properties.user_properties.entrypoint = properties.event_properties.oauth_client_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return properties;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -294,7 +294,7 @@ describe('metrics/amplitude:', () => {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('transform an event with undefined service:', () => {
|
describe('transform an event with service=unknown client_id:', () => {
|
||||||
let result;
|
let result;
|
||||||
|
|
||||||
before(() => {
|
before(() => {
|
||||||
|
@ -306,7 +306,29 @@ describe('metrics/amplitude:', () => {
|
||||||
oauth_client_id: 'gribble',
|
oauth_client_id: 'gribble',
|
||||||
service: 'undefined_oauth'
|
service: 'undefined_oauth'
|
||||||
});
|
});
|
||||||
assert.deepEqual(result.user_properties, { '$append': { fxa_services_used: 'undefined_oauth' } });
|
assert.deepEqual(result.user_properties, {
|
||||||
|
'$append': { fxa_services_used: 'undefined_oauth' },
|
||||||
|
entrypoint: 'gribble'
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('transform an event with service=known client_id:', () => {
|
||||||
|
let result;
|
||||||
|
|
||||||
|
before(() => {
|
||||||
|
result = transform({ type: 'wibble.blee' }, { service: 'foo' });
|
||||||
|
});
|
||||||
|
|
||||||
|
it('returned the correct event data', () => {
|
||||||
|
assert.deepEqual(result.event_properties, {
|
||||||
|
oauth_client_id: 'foo',
|
||||||
|
service: 'bar'
|
||||||
|
});
|
||||||
|
assert.deepEqual(result.user_properties, {
|
||||||
|
'$append': { fxa_services_used: 'bar' },
|
||||||
|
entrypoint: 'bar'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -319,7 +341,10 @@ describe('metrics/amplitude:', () => {
|
||||||
|
|
||||||
it('returned the correct event data', () => {
|
it('returned the correct event data', () => {
|
||||||
assert.deepEqual(result.event_properties, { service: 'sync' });
|
assert.deepEqual(result.event_properties, { service: 'sync' });
|
||||||
assert.deepEqual(result.user_properties, { '$append': { fxa_services_used: 'sync' } });
|
assert.deepEqual(result.user_properties, {
|
||||||
|
'$append': { fxa_services_used: 'sync' },
|
||||||
|
entrypoint: 'sync'
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче