AppmakerDeveloper

How to edit custom events in the Firebase

This document will help you understand how to edit custom events in the Firebase.

Introduction

This document will help you understand how to edit custom events in the Firebase.

You can see the list of events sent to firebase here

Steps

  1. Add this filter in the eventsHelper.js file in the your-theme/helpers/eventsHelper.js file.
  2. Add the following code in the updateFirebaseEvents function.
import { appmaker } from '@appmaker-xyz/core';

function updateFirebaseEvents(){
    appmaker.addFilter(
    'firebaseEventData',
    'custom-events',
    ({ eventName, params, eventObject }) => {
      switch (eventName) {
        case 'view_item':
             console.log('params', params); // params is an object object which contains the sending event attributes of the event.
          console.log('eventObject', eventObject); // eventObject is an object that contains whole data for the event.
          // example of updating the event params object using the eventObject
          params.items[0].item_id = eventObject?.product_sku?.value;
          break;
        case 'add_to_cart':
          eventName = 'Add to Cart'; // example of updating the event name
          params.items[0].item_id = eventObject?.product_sku?.value;
          break;
        case 'add_to_wishlist':
          params.items[0].item_id = eventObject?.product_sku?.value;
          break;
        default:
          break;
      }
       // sending the updated params and eventName
      return {
        eventName,
        params,
      };
    },
  );
}
export { updateFirebaseEvents }
  1. call this updateFirebaseEvents function in the your-theme/index.js file activate.

On this page