import type { ErrorEvent } from '@sentry/core';

/** Shared Sentry/GlitchTip options — no session replay, no PII in payloads. */
export function sentrySharedOptions() {
  return {
    sendDefaultPii: false as const,
    tracesSampleRate: 0,
    replaysSessionSampleRate: 0,
    replaysOnErrorSampleRate: 0,
    beforeSend(event: ErrorEvent): ErrorEvent {
      if (event.request) {
        delete event.request.cookies;
        delete event.request.data;
        if (event.request.headers) {
          delete event.request.headers.cookie;
          delete event.request.headers.authorization;
          delete event.request.headers.Authorization;
        }
      }
      if (event.user) {
        delete event.user.email;
        delete event.user.ip_address;
        delete event.user.username;
      }
      return event;
    },
  };
}
