[Vuejs]-How to add mixpanel to my SSR quasar project

0👍

The problem was not related to import but the name of the boot file itself. By naming my bootfile mixpanel, my adblocker blocked completely the file from being loaded, breaking the app.

You just need to rename the file to something else and after that you should be able to work with the bootfile directly:

import { boot } from 'quasar/wrappers';
import useAppStore from '@/stores/app';

export default boot(async ({ store, app }) => {
  if (!process.env.CLIENT) return;

  try {
    if (import.meta.env.VITE_MIXPANEL_ENABLED === 'true') {
      const mixpanel = await import('mixpanel-browser');

      // ...

      app.provide('mixpanel', mixpanel);
    }
  } catch (e) {
    console.log('Mixpanel is not able to load');
  }
});

Leave a comment