/**
 * Google Analytics G4 - Confira a documentação para conferir todos os eventos e parâmetros
 * Doc. Google Analytics 4:  https://developers.google.com/tag-manager/ecommerce-ga4
 * Doc. Universal Analytics: https://developers.google.com/tag-manager/enhanced-ecommerce
 * @param {('view_item' | 'add_to_cart' | 'remove_from_cart' | 'begin_checkout' | 'add_shipping_info' | 'add_payment_info' | 'purchase')} eventName Nome do evento
 * @param {object} params Parâmetros de cada evento
 */

export default function(eventName, params) {
  if (!eventName || !params || typeof window.dataLayer === 'undefined') {
    return;
  }

  window.dataLayer.push({ecommerce: null});
  window.dataLayer.push({event: eventName,
    ecommerce: params });
}
