From 5d788ca7c57a916b3786a53ac7ae94fa2955afaf Mon Sep 17 00:00:00 2001 From: Brian Gough Date: Tue, 17 Mar 2015 16:59:17 +0000 Subject: [PATCH] add grunt version target to report version to sentry it writes the git commit id and Jenkins build number into the sentry configuration --- services/web/Gruntfile.coffee | 17 +++++++ services/web/app/views/layout.jade | 74 +----------------------------- services/web/app/views/sentry.jade | 74 ++++++++++++++++++++++++++++++ services/web/package.json | 2 + 4 files changed, 94 insertions(+), 73 deletions(-) create mode 100644 services/web/app/views/sentry.jade diff --git a/services/web/Gruntfile.coffee b/services/web/Gruntfile.coffee index 3996aba280..adf9763656 100644 --- a/services/web/Gruntfile.coffee +++ b/services/web/Gruntfile.coffee @@ -9,6 +9,8 @@ module.exports = (grunt) -> grunt.loadNpmTasks 'grunt-contrib-requirejs' grunt.loadNpmTasks 'grunt-execute' grunt.loadNpmTasks 'grunt-bunyan' + grunt.loadNpmTasks 'grunt-sed' + grunt.loadNpmTasks 'grunt-git-rev-parse' config = execute: @@ -123,6 +125,20 @@ module.exports = (grunt) -> reporter: grunt.option('reporter') or 'spec' grep: grunt.option("grep") + "git-rev-parse": + version: + options: + prop: 'commit' + + sed: + version: + path: "app/views/sentry.jade" + pattern: '@@COMMIT@@', + replacement: '<%= commit %>', + release: + path: "app/views/sentry.jade" + pattern: "@@RELEASE@@" + replacement: process.env.BUILD_NUMBER || "(unknown build)" availabletasks: tasks: @@ -273,3 +289,4 @@ module.exports = (grunt) -> grunt.registerTask 'run', "Compile and run the web-sharelatex server", ['compile', 'bunyan', 'execute'] grunt.registerTask 'default', 'run' + grunt.registerTask 'version', "Write the version number into sentry.jade", ['git-rev-parse', 'sed'] diff --git a/services/web/app/views/layout.jade b/services/web/app/views/layout.jade index 5b236f789b..dccc4bac33 100644 --- a/services/web/app/views/layout.jade +++ b/services/web/app/views/layout.jade @@ -51,79 +51,7 @@ 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}", { - // Ignore list based off: https://gist.github.com/1878283 - ignoreErrors: [ - 'DealPly', - // Random plugins/extensions - 'top.GLOBALS', - // See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html - 'originalCreateNotification', - 'canvas.contentDocument', - 'MyApp_RemoveAllHighlights', - 'http://tt.epicplay.com', - 'Can\'t find variable: ZiteReader', - 'jigsaw is not defined', - 'ComboSearch is not defined', - 'http://loading.retry.widdit.com/', - 'atomicFindClose', - // Facebook borked - 'fb_xd_fragment', - // ISP optimizing proxy - `Cache-Control: no-transform` seems to reduce this. (thanks @acdha) - // See http://stackoverflow.com/questions/4113268/how-to-stop-javascript-injection-from-vodafone-proxy - 'bmi_SafeAddOnload', - 'EBCallBackMessageReceived', - // See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx - 'conduitPage' - ], - ignoreUrls: [ - // Facebook flakiness - /graph\.facebook\.com/i, - // Facebook blocked - /connect\.facebook\.net\/en_US\/all\.js/i, - // Woopra flakiness - /eatdifferent\.com\.woopra-ns\.com/i, - /static\.woopra\.com\/js\/woopra\.js/i, - // Chrome extensions - /extensions\//i, - /^chrome:\/\//i, - // Other plugins - /127\.0\.0\.1:4001\/isrunning/i, // Cacaoweb - /webappstoolbarba\.texthelp\.com\//i, - /metrics\.itunes\.apple\.com\.edgesuite\.net\//i, - /a\.disquscdn\.com/i, - /platform\.twitter\.com/i, - /pstatic\.datafastguru\.info/i - ], - shouldSendCallback: function(data) { - // only send a fraction of errors - var sampleRate = 1.00; - return (Math.random() <= sampleRate); - }, - dataCallback: function(data) { - // remove circular references from object - var cache = []; - var s = JSON.stringify(data, function(k, v) { if (typeof v === 'object' && v !== null) { if (cache.indexOf(v) !== -1) return "[circular]"; cache.push(v); }; return v; }); - return JSON.parse(s); - } - // 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}'}); - } - + include sentry script. window.sharelatex = { siteUrl: '#{settings.siteUrl}', diff --git a/services/web/app/views/sentry.jade b/services/web/app/views/sentry.jade new file mode 100644 index 0000000000..7bf7af7ab8 --- /dev/null +++ b/services/web/app/views/sentry.jade @@ -0,0 +1,74 @@ +- 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}", { + release: '@@RELEASE@@', + tags: { 'commit': '@@COMMIT@@' }, + // Ignore list based off: https://gist.github.com/1878283 + ignoreErrors: [ + 'DealPly', + // Random plugins/extensions + 'top.GLOBALS', + // See: http://blog.errorception.com/2012/03/tale-of-unfindable-js-error.html + 'originalCreateNotification', + 'canvas.contentDocument', + 'MyApp_RemoveAllHighlights', + 'http://tt.epicplay.com', + 'Can\'t find variable: ZiteReader', + 'jigsaw is not defined', + 'ComboSearch is not defined', + 'http://loading.retry.widdit.com/', + 'atomicFindClose', + // Facebook borked + 'fb_xd_fragment', + // ISP optimizing proxy - `Cache-Control: no-transform` seems to reduce this. (thanks @acdha) + // See http://stackoverflow.com/questions/4113268/how-to-stop-javascript-injection-from-vodafone-proxy + 'bmi_SafeAddOnload', + 'EBCallBackMessageReceived', + // See http://toolbar.conduit.com/Developer/HtmlAndGadget/Methods/JSInjection.aspx + 'conduitPage' + ], + ignoreUrls: [ + // Facebook flakiness + /graph\.facebook\.com/i, + // Facebook blocked + /connect\.facebook\.net\/en_US\/all\.js/i, + // Woopra flakiness + /eatdifferent\.com\.woopra-ns\.com/i, + /static\.woopra\.com\/js\/woopra\.js/i, + // Chrome extensions + /extensions\//i, + /^chrome:\/\//i, + // Other plugins + /127\.0\.0\.1:4001\/isrunning/i, // Cacaoweb + /webappstoolbarba\.texthelp\.com\//i, + /metrics\.itunes\.apple\.com\.edgesuite\.net\//i, + /a\.disquscdn\.com/i, + /platform\.twitter\.com/i, + /pstatic\.datafastguru\.info/i + ], + shouldSendCallback: function(data) { + // only send a fraction of errors + var sampleRate = 1.00; + return (Math.random() <= sampleRate); + }, + dataCallback: function(data) { + // remove circular references from object + var cache = []; + var s = JSON.stringify(data, function(k, v) { if (typeof v === 'object' && v !== null) { if (cache.indexOf(v) !== -1) return "[circular]"; cache.push(v); }; return v; }); + return JSON.parse(s); + } + // 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}'}); + } diff --git a/services/web/package.json b/services/web/package.json index ef22f8f57e..51b39a4b8e 100644 --- a/services/web/package.json +++ b/services/web/package.json @@ -60,6 +60,8 @@ "grunt-available-tasks": "0.4.1", "grunt-contrib-requirejs": "0.4.1", "grunt-execute": "0.1.5", + "grunt-git-rev-parse": "^0.1.4", + "grunt-sed": "^0.1.1", "bunyan": "0.22.1", "grunt-bunyan": "0.5.0" }