71 lines
2.3 KiB
TypeScript
71 lines
2.3 KiB
TypeScript
import { createApp } from 'vue';
|
|
import { createPinia } from 'pinia';
|
|
import * as Sentry from '@sentry/vue';
|
|
import { BrowserTracing } from '@sentry/tracing';
|
|
import App from './App.vue';
|
|
import router from './router';
|
|
// import { createI18n } from 'vue-i18n';
|
|
// import messages from '@/i18n'; // Import from absolute path
|
|
|
|
// Global styles
|
|
import './assets/main.scss';
|
|
|
|
// API client (from your axios boot file)
|
|
import { api, globalAxios } from '@/services/api'; // Renamed from boot/axios to services/api
|
|
import { useAuthStore } from '@/stores/auth';
|
|
|
|
// Vue I18n setup (from your i18n boot file)
|
|
// export type MessageLanguages = keyof typeof messages;
|
|
// export type MessageSchema = (typeof messages)['en-US'];
|
|
|
|
// declare module 'vue-i18n' {
|
|
// export interface DefineLocaleMessage extends MessageSchema {}
|
|
// // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
// export interface DefineDateTimeFormat {}
|
|
// // eslint-disable-next-line @typescript-eslint/no-empty-object-type
|
|
// export interface DefineNumberFormat {}
|
|
// }
|
|
// const i18n = createI18n<{ message: MessageSchema }>({
|
|
// locale: 'en-US',
|
|
// fallbackLocale: 'en-US',
|
|
// messages,
|
|
// });
|
|
|
|
const app = createApp(App);
|
|
const pinia = createPinia();
|
|
app.use(pinia);
|
|
|
|
// Initialize Sentry
|
|
Sentry.init({
|
|
app,
|
|
dsn: import.meta.env.VITE_SENTRY_DSN,
|
|
integrations: [
|
|
new BrowserTracing({
|
|
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
|
|
tracingOrigins: ['localhost', /^\//],
|
|
}),
|
|
],
|
|
// Set tracesSampleRate to 1.0 to capture 100% of transactions for performance monitoring.
|
|
// We recommend adjusting this value in production
|
|
tracesSampleRate: 1.0,
|
|
// Set environment
|
|
environment: import.meta.env.MODE,
|
|
});
|
|
|
|
// Initialize auth state before mounting the app
|
|
const authStore = useAuthStore();
|
|
if (authStore.accessToken) {
|
|
authStore.fetchCurrentUser().catch(error => {
|
|
console.error('Failed to initialize current user state:', error);
|
|
// The fetchCurrentUser action handles token clearing on failure.
|
|
});
|
|
}
|
|
|
|
app.use(router);
|
|
// app.use(i18n);
|
|
|
|
// Make API instance globally available (optional, prefer provide/inject or store)
|
|
app.config.globalProperties.$api = api;
|
|
app.config.globalProperties.$axios = globalAxios; // The original axios instance if needed
|
|
|
|
app.mount('#app'); |