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

/**
 * Checks if an event is a Google Analytics 4 ecommerce event.
 *
 * @param data The event to check.
 *
 * @returns True if the event is a GA4 ecommerce event, false otherwise.
 */
export const isGA4EcommerceEvent = (data: unknown): data is GA4EcommerceEvent =>
  typeof data === 'object' &&
  data != null &&
  'ecommerce' in data &&
  data.ecommerce != null &&
  typeof data.ecommerce === 'object' &&
  'items' in data.ecommerce &&
  Array.isArray(data.ecommerce.items);
