logViewItem method

Future<void> logViewItem({
  1. required String itemId,
  2. required String itemName,
  3. required String itemCategory,
  4. String? itemLocationId,
  5. double? price,
  6. int? quantity,
  7. String? currency,
  8. double? value,
  9. String? flightNumber,
  10. int? numberOfPassengers,
  11. int? numberOfNights,
  12. int? numberOfRooms,
  13. String? origin,
  14. String? destination,
  15. String? startDate,
  16. String? endDate,
  17. String? searchTerm,
  18. String? travelClass,
})

Logs the standard view_item event.

This event signifies that some content was shown to the user. This content may be a product, a webpage or just a simple image or text. Use the appropriate parameters to contextualize the event. Use this event to discover the most popular items viewed in your app. Note: If you supply the value parameter, you must also supply the currency parameter so that revenue metrics can be computed accurately.

See: https://firebase.google.com/docs/reference/android/com/google/firebase/analytics/FirebaseAnalytics.Event.html#VIEW_ITEM

Implementation

Future<void> logViewItem({
  required String itemId,
  required String itemName,
  required String itemCategory,
  String? itemLocationId,
  double? price,
  int? quantity,
  String? currency,
  double? value,
  String? flightNumber,
  int? numberOfPassengers,
  int? numberOfNights,
  int? numberOfRooms,
  String? origin,
  String? destination,
  String? startDate,
  String? endDate,
  String? searchTerm,
  String? travelClass,
}) {
  _requireValueAndCurrencyTogether(value, currency);

  return logEvent(
    name: 'view_item',
    parameters: filterOutNulls(<String, Object?>{
      _ITEM_ID: itemId,
      _ITEM_NAME: itemName,
      _ITEM_CATEGORY: itemCategory,
      _ITEM_LOCATION_ID: itemLocationId,
      _PRICE: price,
      _QUANTITY: quantity,
      _CURRENCY: currency,
      _VALUE: value,
      _FLIGHT_NUMBER: flightNumber,
      _NUMBER_OF_PASSENGERS: numberOfPassengers,
      _NUMBER_OF_NIGHTS: numberOfNights,
      _NUMBER_OF_ROOMS: numberOfRooms,
      _ORIGIN: origin,
      _DESTINATION: destination,
      _START_DATE: startDate,
      _END_DATE: endDate,
      _SEARCH_TERM: searchTerm,
      _TRAVEL_CLASS: travelClass,
    }),
  );
}