Add JavaScript sentry

This commit is contained in:
Sebastian Serth
2020-03-05 10:30:57 +01:00
parent f2c45b2488
commit 74d99df070
10 changed files with 93 additions and 105 deletions

View File

@@ -12,5 +12,6 @@ CodeOceanEditorAJAX = {
$.flash.danger({
text: message.length > 0 ? message : $('#flash').data('message-failure')
});
Sentry.captureException(response);
}
};

View File

@@ -565,6 +565,7 @@ configureEditors: function () {
icon: ['fa', 'fa-bug'],
text: $('#run').data('message-failure')
});
Sentry.captureException(output);
}
},
@@ -606,7 +607,7 @@ configureEditors: function () {
});
},
showWebsocketError: function() {
showWebsocketError: function(error) {
if (window.navigator.userAgent.indexOf('Edge') > -1 || window.navigator.userAgent.indexOf('Trident') > -1) {
// Mute errors in Microsoft Edge and Internet Explorer
return;
@@ -614,6 +615,7 @@ configureEditors: function () {
$.flash.danger({
text: $('#flash').data('message-failure')
});
Sentry.captureException(error);
},
showFileDialog: function(event) {

View File

@@ -108,10 +108,11 @@ $(document).on('turbolinks:load', function() {
}
}
var ajaxError = function() {
var ajaxError = function(error) {
$.flash.danger({
text: $('#flash').data('message-failure')
});
Sentry.captureException(error);
};
var buildCheckboxes = function() {

View File

@@ -121,6 +121,7 @@ class ExecutionEnvironmentsController < ApplicationController
rescue DockerClient::Error => error
@docker_images = []
flash[:warning] = error.message
Raven.capture_exception(error)
end
private :set_docker_images

View File

@@ -190,9 +190,11 @@ class SubmissionsController < ApplicationController
socket.send data
Rails.logger.debug('Sent the received client data to docker:' + data)
end
rescue JSON::ParserError
rescue JSON::ParserError => error
socket.send data
Rails.logger.debug('Rescued parsing error, sent the received client data to docker:' + data)
Raven.extra_context(data: data)
Raven.capture_exception(error)
end
end
@@ -395,7 +397,8 @@ class SubmissionsController < ApplicationController
Rails.logger.debug('stopping submission ' + @submission.id.to_s)
container = Docker::Container.get(params[:container_id])
DockerClient.destroy_container(container)
rescue Docker::Error::NotFoundError
rescue Docker::Error::NotFoundError => error
Raven.capture_exception(error)
ensure
head :ok
end
@@ -425,6 +428,7 @@ class SubmissionsController < ApplicationController
yield(server_sent_event) if block_given?
server_sent_event.write({code: 200}, event: 'close')
rescue => exception
Raven.capture_exception(exception)
logger.error(exception.message)
logger.error(exception.backtrace.join("\n"))
server_sent_event.write({code: 500}, event: 'close')

View File

@@ -8,14 +8,16 @@
// layout file, like app/views/layouts/application.html.slim
// JS
import 'jquery'
import 'jquery';
import 'bootstrap/dist/js/bootstrap.bundle.min';
import 'chosen-js/chosen.jquery';
import 'jstree';
import 'underscore';
import 'd3'
import 'd3';
import '@sentry/browser';
window._ = _; // Publish underscore's `_` in global namespace
window.d3 = d3; // Publish d3 in global namespace
window.Sentry = Sentry; // Publish sentry in global namespace
// CSS
import 'chosen-js/chosen.css';

View File

@@ -17,6 +17,21 @@ html lang='en'
script type="text/javascript"
| I18n.defaultLocale = "#{I18n.default_locale}";
| I18n.locale = "#{I18n.locale}";
| Sentry.init({
| dsn: 'https://637ca99538224b4bb28cd9e670e1b372@sentry.xikolo.de/33',
| attachStacktrace: true,
| release: "#{Raven.configuration.release}",
| environment: "#{Raven.configuration.current_environment}",
| });
- if @current_user
| Sentry.configureScope(function(scope) {
| scope.setUser({
| "id": "#{@current_user.id}",
| "type": "#{@current_user.class.name}",
| "username": "#{@current_user.displayname}",
| "consumer": "#{@current_user.consumer.name}"
| });
| });
body
- unless @embed_options[:hide_navbar]
nav.navbar.navbar-dark.bg-dark.navbar-expand-md.mb-4.py-1 role='navigation'