getCampaigns method
Future<Campaigns>
getCampaigns(
- String envId,
- String visitorId,
- String? anonymousId,
- bool hasConsented,
- 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));
// Send Keys context when the consent is true && the panic mode is not activated
if (hasConsented && bucketingObject.panic == false) {
// Send the context
_sendKeyContext(envId, visitorId, context);
}
return bucketVariations(visitorId, bucketingObject, context);
} else {
Flagship.logger(Level.ALL, "Flagship, Failed to synchronize");
return Campaigns(visitorId, false, []);
}
}