3 var clientEnv = require('gitter-client-env');
4 var Raven = require('raven-js');
6 function normalise(s) {
7 return s.replace(/\/_s\/\w+\//, '/_s/l/');
12 captureUnhandledRejections: true
15 function ravenClientFactory(options) {
16 var ravenUrl = clientEnv.ravenUrl;
17 var opts = Object.assign({}, DEFAULTS, options);
20 // No raven in this environment
24 Raven.config(ravenUrl, {
25 release: clientEnv['version'],
26 captureUnhandledRejections: opts.captureUnhandledRejections,
27 // # we highly recommend restricting exceptions to a domain in order to filter out clutter
28 // whitelistUrls: ['example.com/scripts/']
29 dataCallback: function(data) {
31 data.stacktrace.frames.forEach(function(frame) {
33 frame.filename = normalise(frame.filename);
38 data.culprit = normalise(data.culprit);
46 // via https://docs.sentry.io/clients/javascript/tips/#decluttering-sentry
48 // Halley spam, see https://github.com/troupe/gitter-webapp/issues/1056
51 // Elasticsearch, see https://gitlab.com/gitterHQ/webapp/issues/1950
53 // Random plugins/extensions
55 // See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error. html
56 'originalCreateNotification',
57 'canvas.contentDocument',
58 'MyApp_RemoveAllHighlights',
59 'http://tt.epicplay.com',
60 "Can't find variable: ZiteReader",
61 'jigsaw is not defined',
62 'ComboSearch is not defined',
63 'http://loading.retry.widdit.com/',
67 // ISP "optimizing" proxy - `Cache-Control: no-transform` seems to
68 // reduce this. (thanks @acdha)
69 // See http://stackoverflow.com/questions/4113268
71 'EBCallBackMessageReceived',
72 // See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx
77 /graph\.facebook\.com/i,
79 /connect\.facebook\.net\/en_US\/all\.js/i,
81 /eatdifferent\.com\.woopra-ns\.com/i,
82 /static\.woopra\.com\/js\/woopra\.js/i,
87 /127\.0\.0\.1:4001\/isrunning/i, // Cacaoweb
88 /webappstoolbarba\.texthelp\.com\//i,
89 /metrics\.itunes\.apple\.com\.edgesuite\.net\//i
93 Raven.setUserContext({
94 username: opts.username
97 return function(err, extraData) {
98 return Raven.captureException(err, extraData);
102 module.exports = ravenClientFactory;