From 3346108594c857edd0f15d3c5b986ded1adc62d4 Mon Sep 17 00:00:00 2001 From: sveisvei Date: Fri, 9 Dec 2016 20:21:24 +0100 Subject: [PATCH] Revert "Remove /api/client/seen-toggles as we don't need it anyway" This reverts commit 63e69312651a7ddb23d2ff0345015b1683174360. --- lib/routes/metrics.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/lib/routes/metrics.js b/lib/routes/metrics.js index 2992b02b2c..d618aca4c4 100644 --- a/lib/routes/metrics.js +++ b/lib/routes/metrics.js @@ -20,6 +20,23 @@ module.exports = function (app, config) { res.json(seenAppToggles); }); + app.get('/client/seen-apps', (req, res) => { + const seenApps = metrics.getSeenAppsPerToggle(); + clientApplicationsStore.getApplications() + .then(toLookup) + .then(metaData => { + Object.keys(seenApps).forEach(key => { + seenApps[key] = seenApps[key].map(entry => { + if (metaData[entry.appName]) { + entry.data = metaData[entry.appName]; + } + return entry; + }); + }); + res.json(seenApps); + }); + }); + app.get('/client/metrics/feature-toggles', (req, res) => { res.json(metrics.getTogglesMetrics()); }); @@ -91,6 +108,13 @@ module.exports = function (app, config) { }); }); + function toLookup (metaData) { + return metaData.reduce((result, entry) => { + result[entry.appName] = entry; + return result; + }, {}); + } + app.get('/client/applications/', (req, res) => { clientApplicationsStore .getApplications(req.query)