Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* global Sentry */
- /* In eigenem Scope um den Rest nicht zu "beladen". */
- var VERSION = "5.1.0";
- /* Füge Script via JS hinzu und wenn erfolgreich führte Funktion aus */
- var loadJS = (url, wennFertigFunction, ort) => {
- const scriptTag = document.createElement("script");
- scriptTag.src = url;
- scriptTag.onload = wennFertigFunction;
- scriptTag.onreadystatechange = wennFertigFunction;
- ort.appendChild(scriptTag);
- };
- /* Läd Sentry nur für nicht-dev-server */
- var getSentryOptions = () => {
- const getCookie = (key = null) => {
- const cookies = document.cookie.split(/[;] */).reduce((prev, curr) => {
- const [name, value] = curr.split('=');
- prev[name] = value;
- return prev;
- }, {});
- if (key) return cookies[key] || null;
- return cookies;
- };
- if (getCookie('sentryLaden') !== '1') {
- return {dsn: ''};
- }
- return {dsn: 'https://eecc2b20b08440d9a1aa1754e79e9780@s2000-sentry.mpibpc.mpg.de/4'};
- };
- /* Initialisiere Sentry und Konfiguriere standartwerte */
- var initSentry = () => {
- if(typeof Sentry !== 'undefined') return;
- if(window.hasOwnProperty('Sentry')) return;
- Sentry.init(getSentryOptions());
- const userData = {
- id: localStorage.getItem("systemName") || "unbekannt",
- name: localStorage.getItem("fullname") || "unbekannt",
- email: localStorage.getItem("email") || "unbekannt",
- rolle: localStorage.getItem("rolle") || "unbekannt",
- };
- Sentry.configureScope(scope => {
- scope.setUser(userData);
- scope.setTag("hostname", location.hostname);
- scope.setTag("dbname", localStorage.getItem("dbname") || "unbekannt");
- scope.setTag("rolle", localStorage.getItem("rolle") || "unbekannt");
- });
- };
- var catPos = location.href.indexOf("/cat/");
- var urlStringBisCat = location.href.slice(0, catPos + 4);
- var sentryBundle = `${urlStringBisCat}/lib/modules/sentry-bundle-${VERSION}.min.js`;
- loadJS(sentryBundle, initSentry, document.head);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement