recordView static method

  1. @Deprecated('This function is deprecated, please use "startView" of Countly.instance.views instead')
Future<String?> recordView(
  1. String view, [
  2. Map<String, Object>? segmentation
])

Record custom view to Countly.

String view - name of the view Map<String, Object> segmentation - allows to add optional segmentation, Supported data type for segmentation values are String, int, double and bool

Implementation

@Deprecated('This function is deprecated, please use "startView" of Countly.instance.views instead')
static Future<String?> recordView(String view, [Map<String, Object>? segmentation]) async {
  if (!_instance._countlyState.isInitialized) {
    String message = '"initWithConfig" must be called before "recordView"';
    log('recordView, $message', logLevel: LogLevel.ERROR);
    return message;
  }
  int segCount = segmentation != null ? segmentation.length : 0;
  log('Calling "recordView":[$view] with segmentation Count:[$segCount]');
  if (view.isEmpty) {
    String error = 'recordView, Trying to record view with empty view name, ignoring request';
    log(error);
    return 'Error : $error';
  }
  List<String> args = [];
  args.add(view);
  if (segmentation != null) {
    segmentation.forEach((k, v) {
      if (v is String || v is int || v is double || v is bool) {
        args.add(k);
        args.add(v.toString());
      } else {
        log('recordView, unsupported segmentation data type [${v.runtimeType}], View [$view]', logLevel: LogLevel.WARNING);
      }
    });
  }

  final String? result = await _channel.invokeMethod('recordView', <String, dynamic>{'data': json.encode(args)});

  return result;
}