sendEmotionEvent method
Implementation
Future<void> sendEmotionEvent(
Hit aiHit, {
Function(Exception?)? completion,
}) async {
// Set the visitor Id
aiHit.visitorId = visitorId;
aiHit.anonymousId = anonymousId;
// Create url
String urlString = Endpoints.EmotionAiUrl;
Flagship.logger(Level.DEBUG, 'Sending emotion AI events : ' + urlString);
try {
var response = await service?.sendHttpRequest(
RequestType.Post,
urlString,
Endpoints.getFSHeader(Flagship.sharedInstance().apiKey ?? ""),
jsonEncode(aiHit.bodyTrack),
timeoutMs: TIMEOUT_REQUEST);
switch (response?.statusCode) {
case 200:
case 204:
case 201:
Flagship.logger(Level.INFO, HIT_SUCCESS);
DataUsageTracking.sharedInstance()
.processTroubleShootingEAIEvent(null, aiHit, response);
break;
default:
Flagship.logger(Level.ERROR, HIT_FAILED);
DataUsageTracking.sharedInstance().processTroubleShootingEAIEvent(
null, aiHit, response,
onFailed: true);
}
} catch (error) {
Flagship.logger(
Level.EXCEPTIONS, EXCEPTION.replaceFirst("%s", "$error") + urlString);
Flagship.logger(Level.ERROR, HIT_FAILED);
}
}