From e02ad3c63f6c306e7c63ddc5d26876c0eef16dee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Fri, 21 Jun 2019 13:06:48 +0200 Subject: [PATCH] Use the new library --- contribs/gmf/apps/desktop/Controller.js | 10 ---------- contribs/gmf/apps/desktop_alt/Controller.js | 10 ---------- contribs/gmf/apps/iframe_api/Controller.js | 10 ---------- contribs/gmf/apps/mobile/Controller.js | 10 ---------- contribs/gmf/apps/mobile_alt/Controller.js | 10 ---------- contribs/gmf/apps/oeedit/Controller.js | 10 ---------- contribs/gmf/src/authentication/Service.js | 5 +++++ contribs/gmf/src/controllers/AbstractAppController.js | 11 +++++++++++ package.json | 2 +- 9 files changed, 17 insertions(+), 61 deletions(-) diff --git a/contribs/gmf/apps/desktop/Controller.js b/contribs/gmf/apps/desktop/Controller.js index 4f3cf084512b..27be9d396334 100644 --- a/contribs/gmf/apps/desktop/Controller.js +++ b/contribs/gmf/apps/desktop/Controller.js @@ -15,8 +15,6 @@ import gmfControllersAbstractDesktopController, {AbstractDesktopController} import appBase from '../appmodule.js'; import EPSG2056 from '@geoblocks/proj/src/EPSG_2056.js'; import EPSG21781 from '@geoblocks/proj/src/EPSG_21781.js'; -import Raven from 'raven-js/src/raven.js'; -import RavenPluginsAngular from 'raven-js/plugins/angular.js'; if (!window.requestAnimationFrame) { alert('Your browser is not supported, please update it or use another one. You will be redirected.\n\n' @@ -102,14 +100,6 @@ class Controller extends AbstractDesktopController { gettextCatalog.getString('Add a theme'); gettextCatalog.getString('Add a sub theme'); gettextCatalog.getString('Add a layer'); - - if ($injector.has('sentryUrl')) { - const options = $injector.has('sentryOptions') ? $injector.get('sentryOptions') : undefined; - const raven = new Raven(); - raven.config($injector.get('sentryUrl'), options) - .addPlugin(RavenPluginsAngular) - .install(); - } } } diff --git a/contribs/gmf/apps/desktop_alt/Controller.js b/contribs/gmf/apps/desktop_alt/Controller.js index 342d3070319c..4467b8891190 100644 --- a/contribs/gmf/apps/desktop_alt/Controller.js +++ b/contribs/gmf/apps/desktop_alt/Controller.js @@ -20,8 +20,6 @@ import EPSG2056 from '@geoblocks/proj/src/EPSG_2056.js'; import EPSG21781 from '@geoblocks/proj/src/EPSG_21781.js'; import ngeoStatemanagerWfsPermalink from 'ngeo/statemanager/WfsPermalink.js'; import {Circle, Fill, Stroke, Style} from 'ol/style.js'; -import Raven from 'raven-js/src/raven.js'; -import RavenPluginsAngular from 'raven-js/plugins/angular.js'; if (!window.requestAnimationFrame) { alert('Your browser is not supported, please update it or use another one. You will be redirected.\n\n' @@ -147,14 +145,6 @@ class Controller extends AbstractDesktopController { * @type {string} */ this.bgOpacityOptions = 'orthophoto'; - - if ($injector.has('sentryUrl')) { - const options = $injector.has('sentryOptions') ? $injector.get('sentryOptions') : undefined; - const raven = new Raven(); - raven.config($injector.get('sentryUrl'), options) - .addPlugin(RavenPluginsAngular) - .install(); - } } /** diff --git a/contribs/gmf/apps/iframe_api/Controller.js b/contribs/gmf/apps/iframe_api/Controller.js index b8c270413fcb..51e0eac16692 100644 --- a/contribs/gmf/apps/iframe_api/Controller.js +++ b/contribs/gmf/apps/iframe_api/Controller.js @@ -12,8 +12,6 @@ import gmfControllersAbstractAPIController, {AbstractAPIController} import appBase from '../appmodule.js'; import EPSG2056 from '@geoblocks/proj/src/EPSG_2056.js'; import EPSG21781 from '@geoblocks/proj/src/EPSG_21781.js'; -import Raven from 'raven-js/src/raven.js'; -import RavenPluginsAngular from 'raven-js/plugins/angular.js'; if (!window.requestAnimationFrame) { alert('Your browser is not supported, please update it or use another one. You will be redirected.\n\n' @@ -46,14 +44,6 @@ class Controller extends AbstractAPIController { this.EPSG2056 = EPSG2056; this.EPSG21781 = EPSG21781; - - if ($injector.has('sentryUrl')) { - const options = $injector.has('sentryOptions') ? $injector.get('sentryOptions') : undefined; - const raven = new Raven(); - raven.config($injector.get('sentryUrl'), options) - .addPlugin(RavenPluginsAngular) - .install(); - } } } diff --git a/contribs/gmf/apps/mobile/Controller.js b/contribs/gmf/apps/mobile/Controller.js index f0e45dfe0875..2342f8431ce7 100644 --- a/contribs/gmf/apps/mobile/Controller.js +++ b/contribs/gmf/apps/mobile/Controller.js @@ -15,8 +15,6 @@ import gmfControllersAbstractMobileController, {AbstractMobileController} import appBase from '../appmodule.js'; import EPSG2056 from '@geoblocks/proj/src/EPSG_2056.js'; import EPSG21781 from '@geoblocks/proj/src/EPSG_21781.js'; -import Raven from 'raven-js/src/raven.js'; -import RavenPluginsAngular from 'raven-js/plugins/angular.js'; if (!window.requestAnimationFrame) { alert('Your browser is not supported, please update it or use another one. You will be redirected.\n\n' @@ -60,14 +58,6 @@ class Controller extends AbstractMobileController { * @type {string[]} */ this.searchCoordinatesProjections = [EPSG21781, EPSG2056, 'EPSG:4326']; - - if ($injector.has('sentryUrl')) { - const options = $injector.has('sentryOptions') ? $injector.get('sentryOptions') : undefined; - const raven = new Raven(); - raven.config($injector.get('sentryUrl'), options) - .addPlugin(RavenPluginsAngular) - .install(); - } } } diff --git a/contribs/gmf/apps/mobile_alt/Controller.js b/contribs/gmf/apps/mobile_alt/Controller.js index 314c083cb3a2..4e12629690d2 100644 --- a/contribs/gmf/apps/mobile_alt/Controller.js +++ b/contribs/gmf/apps/mobile_alt/Controller.js @@ -15,8 +15,6 @@ import gmfControllersAbstractMobileController, {AbstractMobileController} import appBase from '../appmodule.js'; import EPSG2056 from '@geoblocks/proj/src/EPSG_2056.js'; import EPSG21781 from '@geoblocks/proj/src/EPSG_21781.js'; -import Raven from 'raven-js/src/raven.js'; -import RavenPluginsAngular from 'raven-js/plugins/angular.js'; if (!window.requestAnimationFrame) { alert('Your browser is not supported, please update it or use another one. You will be redirected.\n\n' @@ -66,14 +64,6 @@ class Controller extends AbstractMobileController { * @type {string[]} */ this.searchCoordinatesProjections = [EPSG21781, EPSG2056, 'EPSG:4326']; - - if ($injector.has('sentryUrl')) { - const options = $injector.has('sentryOptions') ? $injector.get('sentryOptions') : undefined; - const raven = new Raven(); - raven.config($injector.get('sentryUrl'), options) - .addPlugin(RavenPluginsAngular) - .install(); - } } } diff --git a/contribs/gmf/apps/oeedit/Controller.js b/contribs/gmf/apps/oeedit/Controller.js index ee3e54cb1637..f2ef0c180afc 100644 --- a/contribs/gmf/apps/oeedit/Controller.js +++ b/contribs/gmf/apps/oeedit/Controller.js @@ -20,8 +20,6 @@ import EPSG21781 from '@geoblocks/proj/src/EPSG_21781.js'; import olCollection from 'ol/Collection.js'; import olLayerVector from 'ol/layer/Vector.js'; import olSourceVector from 'ol/source/Vector.js'; -import Raven from 'raven-js/src/raven.js'; -import RavenPluginsAngular from 'raven-js/plugins/angular.js'; if (!window.requestAnimationFrame) { alert('Your browser is not supported, please update it or use another one. You will be redirected.\n\n' @@ -201,14 +199,6 @@ class Controller extends AbstractDesktopController { gettextCatalog.getString('Add a theme'); gettextCatalog.getString('Add a sub theme'); gettextCatalog.getString('Add a layer'); - - if ($injector.has('sentryUrl')) { - const options = $injector.has('sentryOptions') ? $injector.get('sentryOptions') : undefined; - const raven = new Raven(); - raven.config($injector.get('sentryUrl'), options) - .addPlugin(RavenPluginsAngular) - .install(); - } } } diff --git a/contribs/gmf/src/authentication/Service.js b/contribs/gmf/src/authentication/Service.js index d91920a45275..ce5ea62babb2 100644 --- a/contribs/gmf/src/authentication/Service.js +++ b/contribs/gmf/src/authentication/Service.js @@ -1,6 +1,7 @@ import angular from 'angular'; import ngeoCustomEvent from 'ngeo/CustomEvent.js'; import olEventsEventTarget from 'ol/events/Target.js'; +import * as Sentry from '@sentry/browser'; /** @@ -249,6 +250,10 @@ export class AuthenticationService extends olEventsEventTarget { * @private */ setUser_(respData, emitEvent) { + Sentry.setUser({ + "username": respData.username + }); + for (const key in this.user_) { // @ts-ignore: unsupported syntax this.user_[key] = null; diff --git a/contribs/gmf/src/controllers/AbstractAppController.js b/contribs/gmf/src/controllers/AbstractAppController.js index 8a58014ad263..83f72502dab6 100644 --- a/contribs/gmf/src/controllers/AbstractAppController.js +++ b/contribs/gmf/src/controllers/AbstractAppController.js @@ -31,6 +31,7 @@ import olStyleStroke from 'ol/style/Stroke.js'; import olStyleStyle from 'ol/style/Style.js'; import {ThemeEventType} from 'gmf/theme/Manager.js'; import {getBrowserLanguage} from 'ngeo/utils.js'; +import * as Sentry from '@sentry/browser'; /** @@ -665,6 +666,16 @@ export function AbstractAppController(config, map, $scope, $injector) { * @type {?string} */ this.displaywindowWidth = '50vw'; + + if ($injector.has('sentryOptions')) { + const options = $injector.get('sentryOptions'); + const tags = options.tags || []; + delete options.tags; + Sentry.init(options); + for (const tag in tags) { + Sentry.setTag(tag, tags[tag]); + } + } } diff --git a/package.json b/package.json index 1bd84fbf9866..d82d0137d658 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,7 @@ "@camptocamp/cesium": "^1.56.1", "@fortawesome/fontawesome-free": "^5.8.2", "@geoblocks/proj": "^0.4.0", + "@sentry/browser": "^5.4.2", "@types/angular": "^1.6.54", "@types/angular-animate": "^1.5.10", "@types/angular-dynamic-locale": "^0.1.34", @@ -115,7 +116,6 @@ "phantomjs-prebuilt": "^2.1.16", "popper.js": "^1.15.0", "proj4": "^2.5.0", - "raven-js": "^3.27.1", "simple-html-tokenizer": "^0.1.1", "sinon": "^7.3.2", "svg-inline-loader": "^0.8.0",