Remove vue3-logger

This commit is contained in:
Ramon Wenger 2023-02-02 14:13:27 +01:00
parent 3afeea928f
commit 6ad1df8310
2 changed files with 148 additions and 142 deletions

View File

@ -1,9 +1,9 @@
import 'core-js/stable';
import {createApp, configureCompat } from 'vue';
import { createApp, configureCompat } from 'vue';
import VueVimeoPlayer from 'vue-vimeo-player';
import apolloClientFactory from './graphql/client';
import App from './App.vue';
import {postLoginRedirectUrlKey, router} from './router';
import { postLoginRedirectUrlKey, router } from './router';
import { store } from '@/store';
import VueScrollTo from 'vue-scrollto';
import autoGrow from '@/directives/auto-grow';
@ -12,7 +12,6 @@ import ME_QUERY from '@/graphql/gql/queries/meQuery.gql';
import VueModal from '@/plugins/modal';
import VueRemoveEdges from '@/plugins/edges';
import VueMatomo from 'vue-matomo';
import VueLogger from 'vuejs3-logger';
import { createApolloProvider } from '@vue/apollo-option';
import { joiningClass, loginRequired, unauthorizedAccess } from '@/router/guards';
import flavorPlugin from '@/plugins/flavor';
@ -28,24 +27,16 @@ const apolloProvider = createApolloProvider({
});
configureCompat({
MODE: 2
MODE: 2,
});
const app = createApp(App);
app.use(store);
const isProduction = process.env.NODE_ENV === 'production';
app.use(VueModal);
app.use(VueRemoveEdges);
app.use(VueVimeoPlayer);
app.use(VueLogger, {
isEnabled: true,
logLevel: isProduction ? 'error' : 'debug',
stringifyArguments: false,
showConsoleColors: true,
});
app.use(apolloProvider);
app.use(router);
@ -57,7 +48,6 @@ app.use(router);
app.directive('scroll-to', VueScrollTo);
app.use(flavorPlugin);
if (process.env.MATOMO_HOST) {
@ -73,33 +63,36 @@ app.directive('auto-grow', autoGrow);
/* guards */
function redirectUsersWithoutValidLicense() {
return privateApolloClient.query({
query: ME_QUERY,
}).then(({data}) => data.me.expiryDate == null);
return privateApolloClient
.query({
query: ME_QUERY,
})
.then(({ data }) => data.me.expiryDate == null);
}
function redirectStudentsWithoutClass() {
return privateApolloClient.query({
query: ME_QUERY,
}).then(({data}) => data.me.schoolClasses.length === 0 && !data.me.isTeacher);
return privateApolloClient
.query({
query: ME_QUERY,
})
.then(({ data }) => data.me.schoolClasses.length === 0 && !data.me.isTeacher);
}
function redirectUsersToOnboarding() {
return privateApolloClient.query({
query: ME_QUERY,
}).then(({data}) => !data.me.onboardingVisited);
return privateApolloClient
.query({
query: ME_QUERY,
})
.then(({ data }) => !data.me.onboardingVisited);
}
function networkErrorCallback(statusCode) {
if (statusCode === 402) {
router.push({name: 'licenseActivation'});
router.push({ name: 'licenseActivation' });
}
}
router.beforeEach(async (to, from, next) => {
// todo: make logger work outside vue app
// const logger = inject('vuejs3-logger');
@ -111,7 +104,7 @@ router.beforeEach(async (to, from, next) => {
next(false);
return;
} else {
next({name: 'hello'});
next({ name: 'hello' });
return;
}
}
@ -130,23 +123,29 @@ router.beforeEach(async (to, from, next) => {
return;
}
if (to.name && to.name !== 'licenseActivation' && loginRequired(to) && await redirectUsersWithoutValidLicense()) {
if (to.name && to.name !== 'licenseActivation' && loginRequired(to) && (await redirectUsersWithoutValidLicense())) {
// logger.$log.debug('redirecting to licenseActivation', to, null);
console.log('redirecting to licenseActivation', to, null);
next({name: 'licenseActivation'});
next({ name: 'licenseActivation' });
return;
}
if (!joiningClass(to) && loginRequired(to) && await redirectStudentsWithoutClass()) {
if (!joiningClass(to) && loginRequired(to) && (await redirectStudentsWithoutClass())) {
//logger.$log.debug('redirecting to join-class', to);
//logger.$log.debug('await redirectStudentsWithoutClass()', await redirectStudentsWithoutClass());
next({name: 'join-class'});
next({ name: 'join-class' });
return;
}
if ((to.name && to.name.indexOf('onboarding') === -1) && !joiningClass(to) && loginRequired(to) && await redirectUsersToOnboarding()) {
if (
to.name &&
to.name.indexOf('onboarding') === -1 &&
!joiningClass(to) &&
loginRequired(to) &&
(await redirectUsersToOnboarding())
) {
//logger.$log.debug('redirecting to onboarding-start', to);
next({name: 'onboarding-start'});
next({ name: 'onboarding-start' });
return;
}

File diff suppressed because one or more lines are too long