getCampaigns method

  1. @override
Future<Campaigns> getCampaigns(
  1. String envId,
  2. String visitorId,
  3. String? anonymousId,
  4. bool hasConsented,
  5. Map<String, Object> context,
)
override

Implementation

@override
Future<Campaigns> getCampaigns(
    String envId,
    String visitorId,
    String? anonymousId,
    bool hasConsented,
    Map<String, Object> context) async {
  // Read File before
  String? jsonString = await _readFile().catchError((error) {
    Flagship.logger(Level.ALL,
        "Error on reading the saved bucketing or the file doesn't exist");
    return null;
  });
  if (jsonString != null) {
    Bucketing bucketingObject = Bucketing.fromJson(json.decode(jsonString));
    return bucketVariations(
        visitorId, bucketingObject, context, assignationHistory ?? {});
  } else {
    Flagship.logger(Level.ALL, "Flagship, Failed to synchronize");
    return Campaigns(visitorId, false, [], null);
  }
}