sendHit method
Implementation
Future<void> sendHit(BaseHit pHit) async {
if (pHit.isValid() == true) {
// Create url
String urlString = Endpoints.EVENT;
try {
var response = await service.sendHttpRequest(
RequestType.Post,
urlString,
Endpoints.getFSHeader(this.apiKey),
jsonEncode(pHit.bodyTrack),
timeoutMs: TIMEOUT_REQUEST);
switch (response.statusCode) {
case 200:
case 204:
case 201:
Flagship.logger(Level.INFO, HIT_SUCCESS);
break;
default:
Flagship.logger(Level.ERROR, HIT_FAILED);
this.onCacheHit(pHit);
}
} catch (error) {
DataUsageTracking.sharedInstance()
.processTroubleShootingException(null, error);
Flagship.logger(Level.EXCEPTIONS,
EXCEPTION.replaceFirst("%s", "$error") + urlString);
Flagship.logger(Level.ERROR, HIT_FAILED);
}
} else {
Flagship.logger(Level.ERROR, "Hit not valid");
}
}