tlApplicationCustomEvent static method

Future<void> tlApplicationCustomEvent({
  1. required String? eventName,
  2. Map<String, String?>? customData,
  3. int? logLevel,
})

Logs a custom event with optional custom data and log level.

This function sends a custom event message to the native side with the specified event name, custom data, and log level. It uses platform-specific channel communication to invoke the 'customevent' method.

Throws a TealeafException if there is an error during the process, including if there is an issue with the Tealeaf plugin or platform-specific errors.

Example usage:

await tlApplicationCustomEvent(
  eventName: 'ButtonClicked',
  customData: {'buttonName': 'Submit'},
  logLevel: 2,
);

Parameters:

  • eventName: The name of the custom event.
  • customData: A map containing additional custom data for the event (optional).
  • logLevel: The log level for the custom event (optional).

Throws:

Implementation

static Future<void> tlApplicationCustomEvent({
  required String? eventName,
  Map<String, String?>? customData,
  int? logLevel,
}) async {
  if (eventName == null) {
    throw TealeafException.create(code: 6, msg: 'eventName is null');
  }
  try {
    await _channel.invokeMethod('customevent', {
      'eventname': eventName,
      'loglevel': logLevel,
      'data': customData,
    });
  } on PlatformException catch (pe) {
    throw TealeafException(pe,
        msg: 'Unable to process custom event message!');
  }
}