import type { UAEcommerceEvent } from 'src/application/models';

/**
 * Checks if an event is a legacy Universal Analytics ecommerce event.
 *
 * @param data The event to check.
 *
 * @returns True if the event is a legacy UA ecommerce event, false otherwise.
 */
export const isLegacyUAEcommerceEvent = (data: unknown): data is UAEcommerceEvent =>
  data != null &&
  typeof data === 'object' &&
  'ecommerce' in data &&
  data.ecommerce != null &&
  typeof data.ecommerce === 'object' &&
  'add' in data.ecommerce &&
  typeof data.ecommerce.add === 'object';
