capture method

  1. @override
Future<void> capture({
  1. required String eventName,
  2. Map<String, Object>? properties,
  3. Map<String, Object>? userProperties,
  4. Map<String, Object>? userPropertiesSetOnce,
})

Implementation

@override
Future<void> capture({
  required String eventName,
  Map<String, Object>? properties,
  Map<String, Object>? userProperties,
  Map<String, Object>? userPropertiesSetOnce,
}) async {
  final extracted = CaptureUtils.extractUserProperties(
    properties: properties,
    userProperties: userProperties,
    userPropertiesSetOnce: userPropertiesSetOnce,
  );

  final extractedProperties = extracted.properties;
  final extractedUserProperties = extracted.userProperties;
  final extractedUserPropertiesSetOnce = extracted.userPropertiesSetOnce;

  final normalizedProperties = extractedProperties != null
      ? PropertyNormalizer.normalize(extractedProperties)
      : null;
  final normalizedUserProperties = extractedUserProperties != null
      ? PropertyNormalizer.normalize(extractedUserProperties)
      : null;
  final normalizedUserPropertiesSetOnce =
      extractedUserPropertiesSetOnce != null
          ? PropertyNormalizer.normalize(extractedUserPropertiesSetOnce)
          : null;

  return handleWebMethodCall(MethodCall('capture', {
    'eventName': eventName,
    if (normalizedProperties != null) 'properties': normalizedProperties,
    if (normalizedUserProperties != null)
      'userProperties': normalizedUserProperties,
    if (normalizedUserPropertiesSetOnce != null)
      'userPropertiesSetOnce': normalizedUserPropertiesSetOnce,
  }));
}