Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Commit

Permalink
fix(metrics): map service event property from client id (#5583), r=@v…
Browse files Browse the repository at this point in the history
  • Loading branch information
philbooth authored and vbudhram committed Oct 13, 2017
1 parent 61d03d3 commit aa0a297
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 7 deletions.
4 changes: 3 additions & 1 deletion server/lib/amplitude.js
Expand Up @@ -21,6 +21,8 @@

'use strict';

const SERVICES = require('./configuration').get('oauth_client_id_map');

const APP_VERSION = /^[0-9]+\.([0-9]+)\./.exec(require('../../package.json').version)[1];

const GROUPS = {
Expand Down Expand Up @@ -232,7 +234,7 @@ function mapEntrypoint (eventCategory, data) {
function mapService (eventCategory, data) {
const service = marshallOptionalValue(data.service);
if (service) {
return { service };
return { service: SERVICES[service] || service };
}
}

Expand Down
6 changes: 6 additions & 0 deletions server/lib/configuration.js
Expand Up @@ -344,6 +344,12 @@ const conf = module.exports = convict({
env: 'FXA_OAUTH_CLIENT_ID',
format: String
},
oauth_client_id_map: {
default: {},
doc: 'Mappings from client id to service name: { "id1": "name-1", "id2": "name-2" }',
env: 'OAUTH_CLIENT_IDS',
format: Object
},
oauth_url: {
default: 'http://127.0.0.1:9010',
doc: 'The url of the Firefox Account OAuth server',
Expand Down
23 changes: 17 additions & 6 deletions tests/server/amplitude.js
Expand Up @@ -7,10 +7,21 @@
define([
'intern!object',
'intern/chai!assert',
'intern/dojo/node!path',
'intern/dojo/node!proxyquire',
'intern/dojo/node!sinon',
'intern/dojo/node!../../server/lib/amplitude',
'intern/dojo/node!../../package.json',
], (registerSuite, assert, sinon, amplitude, package) => {
], (registerSuite, assert, path, proxyquire, sinon, package) => {
const amplitude = proxyquire(path.resolve('server/lib/amplitude'), {
'./configuration': {
get () {
return {
'0': 'amo',
'1': 'pocket'
};
}
}
});
const APP_VERSION = /^[0-9]+\.([0-9]+)\./.exec(package.version)[1];

registerSuite({
Expand Down Expand Up @@ -56,7 +67,7 @@ define([
flowBeginTime: 'qux',
flowId: 'wibble',
lang: 'blee',
service: 'juff',
service: '0',
uid: 'soop',
utm_campaign: 'melm',
utm_content: 'florg',
Expand All @@ -75,7 +86,7 @@ define([
event_properties: {
device_id: 'bar',
entrypoint: 'baz',
service: 'juff'
service: 'amo'
},
event_type: 'fxa_login - forgot_submit',
language: 'blee',
Expand Down Expand Up @@ -211,7 +222,7 @@ define([
flowBeginTime: 'd',
flowId: 'e',
lang: 'f',
service: 'g',
service: '1',
uid: 'h',
utm_campaign: 'i',
utm_content: 'j',
Expand All @@ -228,7 +239,7 @@ define([
event_properties: {
device_id: 'b',
entrypoint: 'c',
service: 'g'
service: 'pocket'
},
event_type: 'fxa_reg - engage',
language: 'f',
Expand Down

0 comments on commit aa0a297

Please sign in to comment.