TypeScript

The library exposes the various type interfaces for logging events to Analytics. The interface map below outlines the various event names and their interfaces:

type AnalyticsEventMap = {
  add_payment_info: AnalyticsPaymentInfo;
  purchase: AnalyticsPurchaseOrRefund;
  refund: AnalyticsPurchaseOrRefund;
  screen_view: AnalyticsScreenView;
  search: AnalyticsSearchOrViewSearchResults;
  view_search_results: AnalyticsSearchOrViewSearchResults;
  select_content: AnalyticsSelectContent;
  select_item: AnalyticsSelectItem;
  select_promotion: AnalyticsPromotion;
  view_promotion: AnalyticsPromotion;
  set_checkout_option: AnalyticsSetCheckoutOption;
  share: AnalyticsShare;
  sign_up: AnalyticsSignUp;
  timing_complete: AnalyticsTimingComplete;
  add_shipping_info: AnalyticsAddShippingInfo;
  view_cart: AnalyticsViewCartItem;
  view_item: AnalyticsViewCartItem;
  view_item_list: AnalyticsViewItemList;
};

When logging an event, the name will be mapped as the params for the mutation:

const mutation = useAnalyticsLogEvent(analytics, "screen_view");

// Params now accepts AnalyticsScreenView
mutation.mutate({
  params: {
    firebase_screen: "Search",
    firebase_screen_class: "SearchPage",
  },
});