|
|
|
|
@ -138,8 +138,7 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
} else {}
|
|
|
|
|
|
|
|
|
|
if (body.containsKey('isDentalAllowedBackend')) {
|
|
|
|
|
body['isDentalAllowedBackend'] =
|
|
|
|
|
body.containsKey('isDentalAllowedBackend') ? body['isDentalAllowedBackend'] ?? IS_DENTAL_ALLOWED_BACKEND : IS_DENTAL_ALLOWED_BACKEND;
|
|
|
|
|
body['isDentalAllowedBackend'] = body.containsKey('isDentalAllowedBackend') ? body['isDentalAllowedBackend'] ?? IS_DENTAL_ALLOWED_BACKEND : IS_DENTAL_ALLOWED_BACKEND;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!body.containsKey('IsPublicRequest')) {
|
|
|
|
|
@ -271,11 +270,11 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'POST');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_socket_exception');
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
@ -283,19 +282,19 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
final message = e.message.contains('Connection reset by peer') ? LocaleKeys.networkConnectionReset.tr() : LocaleKeys.networkErrorMessage.tr();
|
|
|
|
|
onFailure(message, -1, failureType: ConnectivityFailure(message));
|
|
|
|
|
_analytics.errorTracking.log(endPoint, error: "ClientException: $e");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Enhanced Clarity logging
|
|
|
|
|
Clarity.setCustomTag('api_err_type', 'client_exception');
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'POST');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_client_exception');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} on TimeoutException catch (_) {
|
|
|
|
|
final message = LocaleKeys.networkTimeout.tr();
|
|
|
|
|
@ -307,36 +306,36 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'POST');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_timeout');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
final message = LocaleKeys.networkUnknownError.tr();
|
|
|
|
|
onFailure(message, -1, failureType: ConnectivityFailure(message));
|
|
|
|
|
_analytics.errorTracking.log(endPoint, error: "UnknownException: $e");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Enhanced Clarity logging for unknown errors
|
|
|
|
|
Clarity.setCustomTag('api_err_type', 'unknown_exception');
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'POST');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Truncate exception message for Clarity
|
|
|
|
|
final exceptionMsg = e.toString();
|
|
|
|
|
final truncatedMsg = exceptionMsg.length > 252 ? '...${exceptionMsg.substring(exceptionMsg.length - 252)}' : exceptionMsg;
|
|
|
|
|
Clarity.setCustomTag('api_err_exception', truncatedMsg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_unknown_exception');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -384,24 +383,19 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
onFailure(
|
|
|
|
|
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
|
|
|
|
|
statusCode,
|
|
|
|
|
failureType:
|
|
|
|
|
UnAuthenticatedUserFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'] ?? "User is not Authenticated", url: url),
|
|
|
|
|
failureType: UnAuthenticatedUserFailure(parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'] ?? "User is not Authenticated", url: url),
|
|
|
|
|
);
|
|
|
|
|
// logApiEndpointError(endPoint, "session logged out", statusCode);
|
|
|
|
|
}
|
|
|
|
|
if (isAllowAny) {
|
|
|
|
|
onSuccess(parsed, statusCode,
|
|
|
|
|
messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
} else if (parsed['IsAuthenticated'] == null) {
|
|
|
|
|
if (parsed['isSMSSent'] == true) {
|
|
|
|
|
onSuccess(parsed, statusCode,
|
|
|
|
|
messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
} else if (parsed['MessageStatus'] == 1) {
|
|
|
|
|
onSuccess(parsed, statusCode,
|
|
|
|
|
messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
} else if (parsed['Result'] == 'OK') {
|
|
|
|
|
onSuccess(parsed, statusCode,
|
|
|
|
|
messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
} else {
|
|
|
|
|
onFailure(
|
|
|
|
|
parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'],
|
|
|
|
|
@ -411,8 +405,7 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
logApiEndpointError(endPoint, parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage'], statusCode);
|
|
|
|
|
}
|
|
|
|
|
} else if (parsed['MessageStatus'] == 1 || parsed['SMSLoginRequired'] == true) {
|
|
|
|
|
onSuccess(parsed, statusCode,
|
|
|
|
|
messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
}
|
|
|
|
|
// else if (parsed['IsAuthenticated'] == false) {
|
|
|
|
|
// onFailure(
|
|
|
|
|
@ -424,8 +417,7 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
// }
|
|
|
|
|
else if (parsed['MessageStatus'] == 2 && parsed['IsAuthenticated']) {
|
|
|
|
|
if (parsed['SameClinicApptList'] != null) {
|
|
|
|
|
onSuccess(parsed, statusCode,
|
|
|
|
|
messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
} else {
|
|
|
|
|
if (parsed['message'] == null && parsed['ErrorEndUserMessage'] == null) {
|
|
|
|
|
if (parsed['ErrorSearchMsg'] == null) {
|
|
|
|
|
@ -459,8 +451,7 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (parsed['SameClinicApptList'] != null) {
|
|
|
|
|
onSuccess(parsed, statusCode,
|
|
|
|
|
messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
onSuccess(parsed, statusCode, messageStatus: parsed['MessageStatus'], errorMessage: parsed['ErrorEndUserMessage'] ?? parsed['ErrorMessage']);
|
|
|
|
|
} else {
|
|
|
|
|
if (parsed['message'] != null) {
|
|
|
|
|
onFailure(
|
|
|
|
|
@ -537,74 +528,74 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
final message = e.message.contains('Connection reset by peer') ? LocaleKeys.networkConnectionReset.tr() : LocaleKeys.networkErrorMessage.tr();
|
|
|
|
|
onFailure(message, -1);
|
|
|
|
|
_analytics.errorTracking.log(endPoint, error: "SocketException: $e");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Clarity logging for GET requests
|
|
|
|
|
Clarity.setCustomTag('api_err_type', 'socket_exception');
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'GET');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_get_socket_exception');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} on http.ClientException catch (e) {
|
|
|
|
|
final message = e.message.contains('Connection reset by peer') ? LocaleKeys.networkConnectionReset.tr() : LocaleKeys.networkErrorMessage.tr();
|
|
|
|
|
onFailure(message, -1);
|
|
|
|
|
_analytics.errorTracking.log(endPoint, error: "ClientException: $e");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.setCustomTag('api_err_type', 'client_exception');
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'GET');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_get_client_exception');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} on TimeoutException catch (_) {
|
|
|
|
|
final message = LocaleKeys.networkTimeout.tr();
|
|
|
|
|
onFailure(message, -1);
|
|
|
|
|
_analytics.errorTracking.log(endPoint, error: "TimeoutException");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.setCustomTag('api_err_type', 'timeout');
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'GET');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_get_timeout');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
} catch (e) {
|
|
|
|
|
final message = LocaleKeys.networkUnknownError.tr();
|
|
|
|
|
onFailure(message, -1);
|
|
|
|
|
_analytics.errorTracking.log(endPoint, error: "UnknownException: $e");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.setCustomTag('api_err_type', 'unknown_exception');
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'GET');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
final exceptionMsg = e.toString();
|
|
|
|
|
final truncatedMsg = exceptionMsg.length > 252 ? '...${exceptionMsg.substring(exceptionMsg.length - 252)}' : exceptionMsg;
|
|
|
|
|
Clarity.setCustomTag('api_err_exception', truncatedMsg);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_get_unknown_exception');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -614,18 +605,18 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
if (statusCode < 200 || statusCode >= 400) {
|
|
|
|
|
onFailure(LocaleKeys.networkErrorWhileFetching.tr(), statusCode);
|
|
|
|
|
logApiEndpointError(endPoint, LocaleKeys.networkErrorWhileFetching.tr(), statusCode);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Clarity logging for GET status code errors
|
|
|
|
|
Clarity.setCustomTag('api_err_type', 'status_code_error');
|
|
|
|
|
Clarity.setCustomTag('api_err_url', _getEndofUrl(url.trim()));
|
|
|
|
|
Clarity.setCustomTag('api_err_endpoint', _getEndpointName(endPoint));
|
|
|
|
|
Clarity.setCustomTag('api_err_method', 'GET');
|
|
|
|
|
Clarity.setCustomTag('api_err_status', statusCode.toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (_appState.isAuthenticated) {
|
|
|
|
|
Clarity.setCustomTag('api_err_user_id', _appState.getAuthenticatedUser()!.patientId.toString());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Clarity.sendCustomEvent('api_get_status_error');
|
|
|
|
|
} else {
|
|
|
|
|
var parsed = json.decode(utf8.decode(response.bodyBytes));
|
|
|
|
|
@ -813,7 +804,7 @@ class ApiClientImp implements ApiClient {
|
|
|
|
|
// Extract the last part of the endpoint path for cleaner tracking
|
|
|
|
|
const int clarityLimit = 100;
|
|
|
|
|
final cleanEndpoint = endpoint.split('/').last;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (cleanEndpoint.length <= clarityLimit) return cleanEndpoint;
|
|
|
|
|
return '...${cleanEndpoint.substring(cleanEndpoint.length - (clarityLimit - 3))}';
|
|
|
|
|
}
|
|
|
|
|
|