// Non-enumerable flag used by every ILogger implementation to skip
// already-reported errors. The flag is non-enumerable so JSON.stringify
// and {...err} spread won't surface it.

const REPORTED = "__sentryReported" as const;

export function isReported(err: unknown): boolean {
  return (
    err !== null &&
    typeof err === "object" &&
    Boolean((err as Record<string, unknown>)[REPORTED])
  );
}

export function markReported(err: unknown): void {
  if (err !== null && typeof err === "object" && !isReported(err)) {
    Object.defineProperty(err, REPORTED, {
      value: true,
      enumerable: false,
      configurable: false,
      writable: false,
    });
  }
}
