Skip to content

Logging Request Error Events

Captures and log errors that occur during HTTP requests. It helps with tracking and debugging failed network interactions.

Usage

ts
eventPublisher.logRequestErrorEvent({
  eventId: "ApiRequestError",
  eventDescription: "Failed API Request",
  request: request?.body,
  response: response,
  url: config.url,
  errorMessage: response?.message,
  method: "GET",
  status: Number(code),
  sectionName: "EverydayEssentials",
  subSectionName: "Shop",
  userId: "02412345332",
  userEmail: "[email protected]",
  userName: "Addo Odame",
  userLocationLat: 37.7749,
  userLocationLong: 122.4194,
  userLocationName: "Kokomlele",
  userGender: "M",
  userCountry: "GH",
  extrasObject: {
    zone: "Adenta-Lakeside",
    station: "Madina",
  },
});

TIP

For detailed instructions on setting up the event publisher, refer to the documentation.

Object Properties

Parameter NameDescription
eventIdThe unique identifier for the event. This should always be in PascalCase
eventDescriptionA description of the event.
urlThe URL of the request.
methodThe HTTP method of the request.
statusThe HTTP status code of the response.
requestThe request object.
responseThe response object.
errorMessageError stack trace string
sectionNameThe name of the section where the event occurred.
subSectionNameThe name of the subsection where the event occurred.
userIdThe unique identifier for the user. This is usually the user's phone number
userEmailThe email of the user.
userNameThe name of the user.
userLocationLatThe latitude of the user's location.
userLocationLongThe longitude of the user's location.
userLocationNameThe name of the user's location.
userGenderThe gender of the user.
userCountryThe country of the user.
extrasObjectAn object containing extra data for the event. These are product specific details that you'll want to record for every event