[Axios] Error logger

This commit is contained in:
Matej Glasnák committed 2023-07-24 14:20:36 +02:00
1 parent 886a44229f
commit da63ed5ed2
1 file changed
+22 -9
+22 -9
View File
@@ -1,8 +1,8 @@
import { Language, Options } from "../types"
import { Ref, ref } from 'vue'
import axios from 'axios'
import { Language, Options } from "../types"
import { Ref, ref } from 'vue'
import axios from 'axios'
import { createI18n, I18n as I18nType } from 'vue-i18n'
import { Preferences } from '@capacitor/preferences'
import { Preferences } from '@capacitor/preferences'
export class I18n {
@@ -15,10 +15,10 @@ export class I18n {
constructor(properties: Options) {
this.availableLanguages = properties.languages || []
this.defaultLanguage = properties.languages.find(language => language.value == properties.defaultLanguage)
this.languageKey = properties.languageKey || process.env.VUE_APP_PLATFORM + '_language' || 'w18n_language'
this.defaultLanguage = properties.languages.find(language => language.value == properties.defaultLanguage)
this.languageKey = properties.languageKey || process.env.VUE_APP_PLATFORM + '_language' || 'w18n_language'
this.vendorI18n = createI18n({
this.vendorI18n = createI18n({
legacy: true,
fallbackLocale: this.defaultLanguage.value,
messages: this._loadLocaleMessages(),
@@ -26,7 +26,7 @@ export class I18n {
postTranslation: this._postTranslation,
})
this.changeLanguage({title: "Slovenský", flag: "sk", value: "sk"})
this.changeLanguage({ title: "Slovenský", flag: "sk", value: "sk" })
this.initCurrentLanguage()
}
@@ -76,6 +76,19 @@ export class I18n {
return config
})
// axios.interceptors.response.use(
// (response) => {
// return response
// },
// (error) => {
// axios.post('https://logger.wezeo.dev/api/v1/log', {
// data: JSON.stringify(error)
// })
// return Promise.reject(error)
// }
// );
}
public _loadLocaleMessages(path = '@/locales') {
@@ -91,7 +104,7 @@ export class I18n {
return {}
}
const messages: {[key: string]: {[key: string]: string}} = {}
const messages: { [key: string]: { [key: string]: string } } = {}
locales.keys().forEach((key) => {
const matched = key.match(/([A-Za-z0-9-_]+)\./i)