mirror of
https://github.com/Lissy93/dashy.git
synced 2024-12-28 19:32:49 +03:00
✨ Implements optional, off by default crash reporting
This commit is contained in:
parent
424cef1f81
commit
309dcee3c3
34
src/main.js
34
src/main.js
@ -1,22 +1,25 @@
|
||||
/* eslint-disable no-multi-spaces */
|
||||
// Import core framework and essential utils
|
||||
import Vue from 'vue';
|
||||
import VueI18n from 'vue-i18n'; // i18n for localization
|
||||
|
||||
// Import component Vue plugins, used throughout the app
|
||||
import VTooltip from 'v-tooltip'; // A Vue directive for Popper.js, tooltip component
|
||||
import VModal from 'vue-js-modal'; // Modal component
|
||||
import VSelect from 'vue-select'; // Select dropdown component
|
||||
import VTabs from 'vue-material-tabs'; // Tab view component, used on the config page
|
||||
import Toasted from 'vue-toasted'; // Toast component, used to show confirmation notifications
|
||||
import VTooltip from 'v-tooltip'; // A Vue directive for Popper.js, tooltip component
|
||||
import VModal from 'vue-js-modal'; // Modal component
|
||||
import VSelect from 'vue-select'; // Select dropdown component
|
||||
import VTabs from 'vue-material-tabs'; // Tab view component, used on the config page
|
||||
import Toasted from 'vue-toasted'; // Toast component, used to show confirmation notifications
|
||||
|
||||
// Import base Dashy components and utils
|
||||
import Dashy from '@/App.vue';
|
||||
import router from '@/router';
|
||||
import registerServiceWorker from '@/registerServiceWorker';
|
||||
import clickOutside from '@/utils/ClickOutside';
|
||||
import { toastedOptions, language as defaultLanguage } from '@/utils/defaults';
|
||||
import { messages } from '@/utils/languages';
|
||||
import Dashy from '@/App.vue'; // Main Dashy Vue app
|
||||
import router from '@/router'; // Router, for navigation
|
||||
import serviceWorker from '@/utils/InitServiceWorker'; // Service worker initialization
|
||||
import clickOutside from '@/utils/ClickOutside'; // Directive for closing popups, modals, etc
|
||||
import { messages } from '@/utils/languages'; // Language texts
|
||||
import ErrorReporting from '@/utils/ErrorReporting'; // Error reporting initializer (off)
|
||||
import { toastedOptions, language as defaultLanguage } from '@/utils/defaults'; // Defaults
|
||||
|
||||
// Initialize global Vue components
|
||||
Vue.use(VueI18n);
|
||||
Vue.use(VTooltip);
|
||||
Vue.use(VModal);
|
||||
@ -25,7 +28,7 @@ Vue.use(Toasted, toastedOptions);
|
||||
Vue.component('v-select', VSelect);
|
||||
Vue.directive('clickOutside', clickOutside);
|
||||
|
||||
Vue.config.productionTip = false;
|
||||
Vue.config.productionTip = false; // Disable annoying console message
|
||||
|
||||
// Setup i18n translations
|
||||
const i18n = new VueI18n({
|
||||
@ -34,8 +37,11 @@ const i18n = new VueI18n({
|
||||
messages,
|
||||
});
|
||||
|
||||
// Register Service Worker
|
||||
registerServiceWorker();
|
||||
// Checks if service worker not disable, and if so will registers it
|
||||
serviceWorker();
|
||||
|
||||
// Checks if user enabled error reporting, and if so will initialize it
|
||||
ErrorReporting(Vue, router);
|
||||
|
||||
// Render function
|
||||
const render = (awesome) => awesome(Dashy);
|
||||
|
39
src/utils/ErrorReporting.js
Normal file
39
src/utils/ErrorReporting.js
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* NOTE: No data is EVER sent to any external service without your explicit consent.
|
||||
* In the case of error reporting, Sentry will not even be initialized unless
|
||||
* you have purposely set appConfig.enableErrorReporting: true.
|
||||
* It is false by default.
|
||||
* You may want to enable error reporting if you have encountered a bug,
|
||||
* as access to the console errors enable it to be triaged an fixed effectively
|
||||
*/
|
||||
|
||||
/* eslint-disable global-require */
|
||||
|
||||
import ConfigAccumulator from '@/utils/ConfigAccumalator';
|
||||
|
||||
const ErrorTracking = (Vue, router) => {
|
||||
// Fetch users config
|
||||
const appConfig = new ConfigAccumulator().appConfig() || {};
|
||||
// Check if error reporting is enabled. Only proceed if user has turned it on.
|
||||
if (appConfig.enableErrorReporting) {
|
||||
// Import Sentry
|
||||
const Sentry = require('@sentry/vue');
|
||||
const { Integrations } = require('@sentry/tracing');
|
||||
const dsn = 'https://3138ea85f15a4fa883a5b27a4dc8ee28@o937511.ingest.sentry.io/5887934';
|
||||
// Initialize Sentry
|
||||
Sentry.init({
|
||||
Vue,
|
||||
dsn,
|
||||
integrations: [
|
||||
new Integrations.BrowserTracing({
|
||||
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
|
||||
}),
|
||||
],
|
||||
tracesSampleRate: 1.0,
|
||||
});
|
||||
} else {
|
||||
// Error reporting not enabled. Do Nothing.
|
||||
}
|
||||
};
|
||||
|
||||
export default ErrorTracking;
|
Loading…
Reference in New Issue
Block a user