odoo.define('suvit.sentry', function (require) {

  var core = require('web.core');
  var _t = core._t;

  var Client = require('web.AbstractWebClient')
  var WebClient = require('web.WebClient');
  var CrashManager = require('web.CrashManager');
  var Model = require('web.Model');
  var Dialog = require('web.Dialog');

  Dialog.include({
    open: function() {
      var self = this;
      this._super();
      self.$modal.on('click', '.show_details', function() {
        self.$modal.find('.hide_details').show();
        self.$modal.find('.error_details').show();
        $(this).hide();
      });
      self.$modal.on('click', '.hide_details', function() {
        self.$modal.find('.show_details').show();
        self.$modal.find('.error_details').hide();
        $(this).hide();
      });
      return self;
    }
  });

  Client.include({
    init: function(parent) {
      this._super(parent);
      new Model("ir.config_parameter").call("get_param", ['SENTRY_CLIENT_JS_DSN']).then(function(value) {
        if (value) {
          Raven.config(value).install();
        }
      });
    }
  });

  WebClient.include({
    show_common: function() {
      var self = this;
      this._super();
      window.onerror = function (message, file, line) {
          self.crashmanager.show_error({
              type: _t("Client Error"),
              message: message,
              data: {debug: file + ':' + line},
              client: true
          });
      };
    },
  });

  CrashManager.include({
    show_error: function(error) {
      if (error.client) {
        try {
          Raven.setUserContext({
            name: instance.session.username,
            context: instance.session.user_context,
            id: instance.session.uid
          });
          Raven.captureException(error.message, {extra: error});
          error.last_code = Raven.lastEventId();
        } catch (e) {}
      }
      if (error.message.indexOf('XmlHttpRequestError') === 0) {
        error.lost_network = true;
        error.message = 'Связь с сервером потеряна, попробуйте зайти позже';
      }
      return this._super(error);
    },
  });

});

@@ -898,16 +898,39 @@
 arent);%0A
+      var self = this;%0A
       ne
@@ -1068,408 +1068,202 @@
 ven.
-config(value).install();%0A        %7D%0A      %7D);%0A    %7D%0A  %7D);%0A%0A  WebClient.include(%7B%0A    show_common: function() %7B%0A      var self = this;%0A      this._super();%0A      window.onerror = function (message, file, line) %7B%0A          self.crashmanager.show_error(%7B%0A              type: _t(%22Client Error%22),%0A              message: message,%0A              data: %7Bdebug: file + ':' + line%7D,%0A              client: true%0A  
+setUserContext(%7B%0A            name: self.session.username,%0A            context: self.session.user_context,%0A            id: self.session.uid%0A          %7D);%0A          Raven.config(value).install();%0A
     
@@ -1267,26 +1267,24 @@
        %7D
-);
 %0A      %7D
 ;%0A    %7D,
@@ -1275,24 +1275,24 @@
 %0A      %7D
+)
 ;%0A    %7D
-,
 %0A  %7D);%0A%0A
@@ -1293,28 +1293,25 @@
  %7D);%0A%0A  
-CrashManager
+WebClient
 .include
@@ -1321,18 +1321,19 @@
     
-show_error
+bind_events
 : fu
@@ -1339,21 +1339,16 @@
 unction(
-error
 ) %7B%0A    
@@ -1353,223 +1353,176 @@
     
+  
-if (error.client) %7B%0A        try %7B%0A          Raven.setUserContext(%7B%0A            name: instance.session.username,%0A            context: instance.session.user_context,%0A            id: instance.session.uid%0A          %7D);%0A
+this._super();%0A        var onerror_func = window.onerror%0A        window.onerror = function (message, file, line, col, error) %7B%0A          if (!window.onOriginError)%0A  
     
@@ -1559,32 +1559,8 @@
 rror
-.message, %7Bextra: error%7D
 );%0A 
@@ -1572,301 +1572,71 @@
     
+on
 error
-.last_code = Raven.lastEventId();%0A        %7D catch (e) %7B%7D%0A      %7D%0A      if (error.message.indexOf('XmlHttpRequestError') === 0) %7B%0A        error.lost_network = true;%0A        error.message = '%D0%A1%D0%B2%D1%8F%D0%B7%D1%8C %D1%81 %D1%81%D0%B5%D1%80%D0%B2%D0%B5%D1%80%D0%BE%D0%BC %D0%BF%D0%BE%D1%82%D0%B5%D1%80%D1%8F%D0%BD%D0%B0, %D0%BF%D0%BE%D0%BF%D1%80%D0%BE%D0%B1%D1%83%D0%B9%D1%82%D0%B5 %D0%B7%D0%B0%D0%B9%D1%82%D0%B8 %D0%BF%D0%BE%D0%B7%D0%B6%D0%B5';%0A      %7D%0A      return this._super(error)
+_func(message, file, line, col, error);%0A        %7D
 ;%0A    %7D
-,
 %0A  %7D

fix suvit_sentry