Queries the org's log. Very useful for creating daily activity reports, searching for access anomalies, etc.
Arguments
options (Object)
where
map
group
sort
limit
skip
stats(options)
Queries the org's stats.
Arguments
options (Object)
where
map
group
sort
limit
skip
Examples
The following example finds statistics on all the scripts that ran yesterday (does not factor in script errors or local time).Logs Example
import api from 'api'
import moment from 'moment'
let startId = new ObjectID(moment(new Date()).utc().subtract(1,'day').startOf('day').toDate())
let endId = new ObjectID(moment(new Date()).utc().subtract(1,'day').endOf('day').toDate())
return api.logs({
where: {
_id: {$gte: startId, $lte: endId},
src: consts.logs.sources.script
}
})
The following example returns the login statistics for the previous two days.Stats Example
import api from 'api'
import moment from 'moment'
let starting = moment(new Date()).utc().subtract(2,'day').startOf('day').toDate()
return api.stats({
where: {
starting: {$gte: starting},
code: consts.stats.sources.logins
}
})