trackUserLogout method
Implementation
Future<void> trackUserLogout({Map<String, dynamic>? payload}) async {
await queue.add(() async {
try {
var alias =
(Platform.isIOS) ? "ios_notification" : "android_notification";
var deletePayload = <String, dynamic>{
"_delete_media": {alias: ""}
};
payload?.forEach((key, val) {
deletePayload[key] = val;
});
final previousDestination = await _createTrackingDestination();
final wasLoggedIn =
previousDestination.sessionType == _TrackingSessionType.login;
custID = null;
loginContact = null;
Pam.customerID = "";
_resetIdentityMismatch();
_sessionVersion++;
await _removePreferenceSafely(
SaveKey.customerID, "REMOVE CUSTOMER ID ERROR");
await _removePreferenceSafely(
SaveKey.loginContactID, "REMOVE LOGIN CONTACT ID ERROR");
final deleteResponse = await _postTrackerTo(
"delete_media", deletePayload, previousDestination);
if (deleteResponse.error != null) {
return;
}
if (wasLoggedIn) {
await _postTrackerTo("logout", payload, previousDestination);
}
} catch (error, stackTrace) {
_createInternalErrorResponse("USER LOGOUT ERROR", error, stackTrace);
}
});
}