diff --git a/lib/client-metrics/index.js b/lib/client-metrics/index.js index 26189e61fd..3be23879f6 100644 --- a/lib/client-metrics/index.js +++ b/lib/client-metrics/index.js @@ -47,6 +47,19 @@ module.exports = class UnleashClientMetrics { return this.apps[appName] ? Object.keys(this.apps[appName].seenToggles) : []; } + getAppsFromToggleName (toggleName) { + const apps = []; + Object.keys(this.apps).forEach(appName => { + const seenToggles = Object.keys(this.apps[appName].seenToggles); + if (seenToggles.includes(toggleName)) { + apps.push({ + appName, + }); + } + }); + return apps; + } + getTogglesMetrics () { return { lastHour: this.lastHourProjection.getProjection(), diff --git a/lib/routes/metrics.js b/lib/routes/metrics.js index 1e420a9b45..9510032d88 100644 --- a/lib/routes/metrics.js +++ b/lib/routes/metrics.js @@ -20,6 +20,11 @@ module.exports = function (app, config) { res.json(seenAppToggles); }); + app.get('/client/seen-apps/:name', (req, res) => { + const seenApps = metrics.getAppsFromToggleName(req.params.name); + res.json(seenApps); + }); + app.get('/client/metrics/feature-toggles', (req, res) => { res.json(metrics.getTogglesMetrics()); });