logEvent static method
dynamic
logEvent(
- String event, {
- bool isRequest = false,
- bool success = false,
- bool failure = false,
- String endPoint = "",
- dynamic header,
- dynamic request,
- dynamic queryParameters,
- String? requestDate,
- dynamic response,
- String? responseDate,
- String? errorDescription,
- String? exceptionParamName,
- bool isCameraRequired = false,
- String? cameraPermission,
- bool isLocationRequired = false,
- String? locationPermission,
- String? preciseLocationPermission,
- String? microphonePermission,
- bool isNotificationRequired = false,
- String? notificationPermission,
- String? status,
- DioException? error,
- String? screenName,
- String? buttonName,
- String? transactionId,
- bool isFinal = false,
Implementation
static logEvent(
String event, {
bool isRequest = false,
bool success = false,
bool failure = false,
String endPoint = "",
dynamic header,
dynamic request,
dynamic queryParameters,
String? requestDate,
dynamic response,
String? responseDate,
String? errorDescription,
String? exceptionParamName,
bool isCameraRequired = false,
String? cameraPermission,
bool isLocationRequired = false,
String? locationPermission,
String? preciseLocationPermission,
String? microphonePermission,
bool isNotificationRequired = false,
String? notificationPermission,
String? status,
DioException? error,
String? screenName,
String? buttonName,
String? transactionId,
bool isFinal = false,
}) async {
try {
final storage = GetStorage();
String logTimeSearch =
"${DateFormat("dd-MM-yyyy hh:mm").format(DateTime.now())}-${SecureStorageService.readSecureData(
SecureStorageService.userId,
) ?? ""}-${UDID.getSCreenShortCode(UDID.getUDID())}";
// String customStackTrace = "";
// FirebaseCrashlytics.instance.setCustomKey(
// "endPoint",
// endPoint,
// );
// FirebaseCrashlytics.instance.setCustomKey(
// "screenName",
// screenName ?? "N?A",
// );
// FirebaseCrashlytics.instance.setCustomKey(
// "buttonName",
// buttonName ?? "",
// );
// FirebaseCrashlytics.instance.setCustomKey(
// "userName",
// storage.read("FULL_NAME") ?? "",
// );
// FirebaseCrashlytics.instance.setCustomKey(
// "userId",
// storage.read("USER_ID") ?? "",
// );
// FirebaseCrashlytics.instance.setCustomKey(
// "env",
// getEnvironment(ApiConstant.baseUrl),
// );
// FirebaseCrashlytics.instance.setCustomKey(
// "x-trace-id",
// UDID.getTraceId(),
// );
// customStackTrace = "${screenName ?? ""} ${buttonName ?? ""} $endPoint";
// await FirebaseCrashlytics.instance
// .recordError(
// failure
// ? error?.message ?? "$event - $endPoint"
// : "$event - $endPoint - ${storage.read("USER_ID") ?? ""} - ${storage.read("FULL_NAME") ?? ""}",
// failure
// ? StackTrace.fromString(customStackTrace)
// : StackTrace.fromString("$event - $endPoint"),
// reason: failure ? error?.message : "$event - $endPoint",
// information: [
// "userId: ${storage.read("USER_ID") ?? ""}",
// "userName: ${storage.read("FULL_NAME") ?? ""}",
// "mobileNo: ${storage.read("MOBILE_NO") ?? ""}",
// "partnerId: ${storage.read("PARTNER_ID_LOGIN") ?? ""}",
// "designation: ${storage.read("DESIGNATION_ID") ?? ""}",
// "endPointUrl: $endPoint",
// "requestDateAndTime: ${requestDate ?? ""}",
// "response: ${failure ? response : ""}",
// "responseDateAndTime: ${responseDate ?? ""}",
// "exceptionParamName: ${failure ? error?.type : ""}",
// "status: ${isRequest ? "REQUEST" : success ? "SUCCESS" : "FAILURE"}",
// "eventName: $event",
// "screenName: $screenName",
// "buttonName: $buttonName",
// "transactionId: $transactionId",
// "x-request-txn-id : ${UDID.getUDID()}",
// "x-trace-id : ${UDID.getTraceId()}"
// ],
// fatal: true,
// )
// .then((_) {
// debugPrint("success on logging the then event");
// });
ApiClient(baseUrl: ApiConstant.baseUrl, isLogRequired: false).logCrash(
body: {
"buttonName": buttonName,
"createdTime": DateFormat("dd-MM-yyyy hh:mm").format(DateTime.now()),
"endPointUrl": endPoint,
"env": getEnvironment(ApiConstant.baseUrl),
"eventName": getEventName(isFinal: isFinal),
"logTimeSearch": logTimeSearch,
// "request": request ?? "",
"requestDateAndTime": requestDate,
// "response": response ?? "",
"responseDateAndTime": responseDate,
"screenName": screenName,
"status": event == "SCAN_ERROR_EVENT"
? "SCAN_ERROR_EVENT"
: success
? "SUCCESS"
: "FAILURE",
"transactionId": transactionId ?? "",
"userId": "${SecureStorageService.readSecureData(
SecureStorageService.userId,
) ?? ""}",
"partnerId": "${SecureStorageService.readSecureData(
SecureStorageService.partnerIdLogin,
) ?? ""}",
"mobileNo": "${SecureStorageService.readSecureData(
SecureStorageService.mobileNo,
) ?? ""}",
"x-request-txn-id": UDID.getUDID(),
"x-trace-id": UDID.getTraceId(),
"appName": "dealer",
},
).then((onValue) {
ConditionalLogs().customLog("loging to ffm-analytics-svc success");
});
ConditionalLogs().customLog("success on logging the event");
} catch (e) {
ConditionalLogs().customLog("error on logging the event $e");
}
}