Merge pull request #125 from sharelatex/clientside-error-logging

Clientside error logging
This commit is contained in:
James Allen 2014-12-12 15:54:23 +00:00
commit b260287965
7 changed files with 49 additions and 2 deletions

View file

@ -68,4 +68,4 @@ Gemfile.lock
app/views/external
modules
/modules/

View file

@ -126,6 +126,8 @@ module.exports = (app)->
delete req.session.justLoggedIn
res.locals.gaToken = Settings.analytics?.ga?.token
res.locals.tenderUrl = Settings.tenderUrl
res.locals.sentrySrc = Settings.sentry?.src
res.locals.sentryPublicDSN = Settings.sentry?.publicDSN
next()
app.use (req, res, next) ->

View file

@ -47,6 +47,24 @@ html(itemscope, itemtype='http://schema.org/Product')
block scripts
script(src="#{jsPath}libs/jquery-1.11.1.min.js")
script(src="#{jsPath}libs/angular-1.3.0-beta.14.min.js")
- if (typeof(sentrySrc) != "undefined")
- if (sentrySrc.match(/^([a-z]+:)?\/\//i))
script(src="#{sentrySrc}")
- else
script(src="#{jsPath}libs/#{sentrySrc}")
- if (typeof(sentrySrc) != "undefined")
script(type="text/javascript").
if (typeof(Raven) != "undefined" && Raven.config) {
Raven.config("#{sentryPublicDSN}", {
// we highly recommend restricting exceptions to a domain in order to filter out clutter
// whitelistUrls: ['example.com/scripts/']
}).install();
}
- if (typeof(user) != "undefined" && typeof (user.email) != "undefined")
script(type="text/javascript").
if (typeof(Raven) != "undefined" && Raven.setUserContext) {
Raven.setUserContext({email: '#{user.email}'});
}
script.
window.sharelatex = {

View file

@ -203,7 +203,15 @@ module.exports =
# ShareLaTeX's help desk is provided by tenderapp.com
# tenderUrl: ""
#
# Client-side error logging is provided by getsentry.com
# sentry:
# src: ""
# publicDSN: ""
#
# src should be either a remote url like
# //cdn.ravenjs.com/1.1.16/jquery,native/raven.min.js
# or a local file in the js/libs directory.
# The publicDSN is the token for the client-side getSentry service.
# Production Settings
# -------------------

View file

@ -1,6 +1,7 @@
define [
"libs"
"modules/recursionHelper"
"modules/errorCatcher"
"utils/underscore"
], () ->
App = angular.module("SharelatexApp", [
@ -11,6 +12,7 @@ define [
"underscore"
"ngSanitize"
"ipCookie"
"ErrorCatcher"
])
return App

View file

@ -0,0 +1,14 @@
app = angular.module 'ErrorCatcher', []
app.config ['$provide', ($provide) ->
$provide.decorator '$exceptionHandler', ['$log', '$delegate', ($log, $delegate) ->
return (exception, cause) ->
if (Raven?.captureException?)
Raven.captureException exception;
$delegate(exception, cause)
]
]
# TODO: add support for an errorHttpInterceptor to catch failing ajax
# requests as described at
# http://bahmutov.calepin.co/catch-all-errors-in-angular-app.html

File diff suppressed because one or more lines are too long