logPurchase method

Future<void> logPurchase({
  1. String? currency,
  2. String? coupon,
  3. double? value,
  4. List<AnalyticsEventItem>? items,
  5. double? tax,
  6. double? shipping,
  7. String? transactionId,
  8. String? affiliation,
  9. Map<String, Object?>? parameters,
  10. AnalyticsCallOptions? callOptions,
})

Logs the standard purchase event.

This event signifies that an item(s) was purchased by a user. Note: This is different from the in-app purchase event, which is reported automatically for Google Play-based apps.

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

Implementation

Future<void> logPurchase({
  String? currency,
  String? coupon,
  double? value,
  List<AnalyticsEventItem>? items,
  double? tax,
  double? shipping,
  String? transactionId,
  String? affiliation,
  Map<String, Object?>? parameters,
  AnalyticsCallOptions? callOptions,
}) {
  _requireValueAndCurrencyTogether(value, currency);

  _assertParameterTypesAreCorrect(parameters);
  _assertItemsParameterTypesAreCorrect(items);

  return _delegate.logEvent(
    name: 'purchase',
    parameters: filterOutNulls(<String, Object?>{
      _CURRENCY: currency,
      _COUPON: coupon,
      _VALUE: value,
      _ITEMS: _marshalItems(items),
      _TAX: tax,
      _SHIPPING: shipping,
      _TRANSACTION_ID: transactionId,
      _AFFILIATION: affiliation,
      if (parameters != null) ...parameters,
    }),
    callOptions: callOptions,
  );
}