src/middlewares/metrics.js
function assignExtraMetrics(ctx, name, payload) {
	let def = ctx.action.metrics[name];
	// if metrics definitions is boolean do default, metrics=true
	if (def === true) {
		payload[name] = ctx[name];
	} else if (_.isArray(def)) {
		payload[name] = _.pick(ctx[name], def);
	} else if (_.isFunction(def)) {
		payload[name] = def(ctx[name]);
	}
}
function assignExtraMetrics(ctx, name, payload) {
	let def = ctx.action.metrics[name];
	// if metrics definitions is boolean do default, metrics=true
	if (def === true) {
		payload[name] = ctx[name];
	} else if (_.isArray(def)) {
		payload[name] = _.pick(ctx[name], def);
	} else if (_.isFunction(def)) {
		payload[name] = def(ctx[name]);
	}
}
function assignExtraMetrics ( ctx , name , payload ) { let def = ctx . action . metrics [ name ] ; // if metrics definitions is boolean do default, metrics=true if ( def === true ) { payload [ name ] = ctx [ name ] ; } else if ( _ . isArray ( def ) ) { payload [ name ] = _ . pick ( ctx [ name ] , def ) ; } else if ( _ . isFunction ( def ) ) { payload [ name ] = def ( ctx [ name ] ) ; } }
Assign extra metrics taking into account action definitions

@param {Context} ctx
@param {string} name Field of the context to be assigned.
@param {any} payload Object for assignment.

@private
Assign extra metrics taking into account action definitions