converMapToListOfHits static method

List<BaseHit> converMapToListOfHits(
  1. List<Map> list
)

Implementation

static List<BaseHit> converMapToListOfHits(List<Map> list) {
  List<BaseHit> result = [];
  list.forEach((element) {
    Map subMap = jsonDecode(element['data_hit']);
    switch (subMap['t']) {
      case 'SCREENVIEW':
        result.add(Screen.fromMap(element['id'], subMap));
        break;
      case 'PAGEVIEW':
        result.add(Page.fromMap(element['id'], subMap));
        break;
      case 'EVENT':
        result.add(Event.fromMap(element['id'], subMap));
        break;
      case 'TRANSACTION':
        result.add(Transaction.fromMap(element['id'], subMap));
        break;
      case 'ITEM':
        result.add(Item.fromMap(element['id'], subMap));
        break;
      case 'ACTIVATE':
        result.add(Activate.fromMap(element['id'], subMap));
        break;
      default:
        Flagship.logger(
            Level.ERROR, "Error on convert Map hit to object hits ");
        break;
    }
  });
  return result;
}