import { init as plausibleInit } from '@plausible-analytics/tracker';

const ANALYTICS_AUTO_CAPTURE_PAGEVIEWS = true;
const ANALYTICS_DOMAIN = 'schmelczer.dev';
// Self-hosted Plausible proxy. The non-standard `/status` path is deliberate:
// the default `/api/event` path is on adblocker filter lists.
const ANALYTICS_ENDPOINT = 'https://stats.schmelczer.dev/status';
const ANALYTICS_LOGGING = import.meta.env.DEV;

try {
  plausibleInit({
    domain: ANALYTICS_DOMAIN,
    endpoint: ANALYTICS_ENDPOINT,
    autoCapturePageviews: ANALYTICS_AUTO_CAPTURE_PAGEVIEWS,
    logging: ANALYTICS_LOGGING,
  });
} catch (error) {
  console.warn('Could not initialize analytics.', error);
}
