fleet/website/api/controllers/webhooks/receive-usage-analytics.js
Mike McNeil 00f30c1e84
Fleetbot (#1572)
* Move usage analytics action for the sake of convention

* followup to ed4a500e15 to fix policy mapping

* Add stub of webhook handler for GitHub bot (at this point, a mostly-verbatim copy paste of sailsbot -- will work backwards from this to what we actually need in Fleet)

* Everyone can follow the same rules.  Except bots.  And Noah.

* same as 5c97f47eff

* replace a separate, explicit check for "sailsbot"

* Comment out stuff Fleet is not using for the foreseeable future

* use Fleet's green label color (could switch to "+" prefix as well, just would require tweaking)
2021-08-06 02:52:02 -05:00

33 lines
747 B
JavaScript
Vendored

module.exports = {
friendlyName: 'Receive usage analytics',
description: '',
inputs: {
anonymousIdentifier: { required: true, type: 'string', example: '1', description: 'An anonymous identifier telling us which Fleet deployment this is.', },
fleetVersion: { required: true, type: 'string', example: 'x.x.x' },
numHostsEnrolled: { required: true, type: 'number', min: 0, custom: (num) => Math.floor(num) === num },
},
exits: {
success: { description: 'Analytics data was stored successfully.' },
},
fn: async function ({anonymousIdentifier, fleetVersion, numHostsEnrolled}) {
await HistoricalUsageSnapshot.create({
anonymousIdentifier,
fleetVersion,
numHostsEnrolled
});
}
};