mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
add metrics
This commit is contained in:
parent
797353de15
commit
50d66e9f31
2 changed files with 6 additions and 0 deletions
|
@ -1,15 +1,18 @@
|
|||
Notifications = require("./Notifications")
|
||||
logger = require("logger-sharelatex")
|
||||
metrics = require('metrics-sharelatex')
|
||||
|
||||
module.exports =
|
||||
|
||||
getUserNotifications: (req, res)->
|
||||
logger.log user_id: req.params.user_id, "getting user unread notifications"
|
||||
metrics.inc "getUserNotifications"
|
||||
Notifications.getUserNotifications req.params.user_id, (err, notifications)->
|
||||
res.json(notifications)
|
||||
|
||||
addNotification: (req, res)->
|
||||
logger.log user_id: req.params.user_id, notification:req.body, "adding notification"
|
||||
metrics.inc "addNotification"
|
||||
Notifications.addNotification req.params.user_id, req.body, (err, notifications)->
|
||||
if err?
|
||||
res.send 500
|
||||
|
@ -18,5 +21,6 @@ module.exports =
|
|||
|
||||
removeNotification: (req, res)->
|
||||
logger.log user_id: req.params.user_id, notification_id: req.params.notification_id, "mark notification as read"
|
||||
metrics.inc "removeNotification"
|
||||
Notifications.removeNotification req.params.user_id, req.params.notification_id, (err, notifications)->
|
||||
res.send()
|
||||
|
|
|
@ -15,6 +15,8 @@ describe 'Notifications controller', ->
|
|||
@controller = SandboxedModule.require modulePath, requires:
|
||||
'logger-sharelatex': log:->
|
||||
'./Notifications':@notifications
|
||||
'metrics-sharelatex':
|
||||
inc: sinon.stub()
|
||||
|
||||
@stubbedNotification = [{key:"notification-key", messageOpts:"some info", templateKey:"template-key"}]
|
||||
|
||||
|
|
Loading…
Reference in a new issue