/**
 * Base interface for common properties across all ecommerce events
 */
export interface BaseEcommerceEvent {
  event: string;
  ecommerce: UAEcommerceData | GA4EcommerceData;
}

/**
 * Legacy universal analytics data. The actual payload contains more fields, but we
 * only need the ones listed below.
 */
interface UAEcommerceData {
  add: {
    products: {
      name: string;
      category: string;
      price: string;
      quantity: string;
    }[];
    currencyCode: string;
  };
}

/**
 * Google Analytics 4 data. The actual payload contains more fields, but we
 * only need the ones listed below.
 */
interface GA4EcommerceData {
  currency: string;
  items: {
    item_name: string;
    item_category: string;
    price: number;
    quantity: number;
  }[];
}

export interface UAEcommerceEvent extends BaseEcommerceEvent {
  ecommerce: UAEcommerceData;
}

export interface GA4EcommerceEvent extends BaseEcommerceEvent {
  ecommerce: GA4EcommerceData;
}
