Added Server Action in Axios HTTP request traces
MODIFY
src/types/Server.ts
src/types/Server.ts
export enum ServerAction {
UNKNOWN_ACTION = 'Unknown',
+ SAP_CONCUR_REQUEST = 'SapConcurRequest',
+ RECAPTCHA_REQUEST = 'RecaptchaRequest',
+ GREENCOM_REQUEST = 'GreencomRequest',
+ STRIPE_REQUEST = 'StripeRequest',
+ IOTHINK_REQUEST = 'IOThinkRequest',
+ LACROIX_REQUEST = 'LacroixRequest',
+ EV_DATABASE_REQUEST = 'EVDatabaseRequest',
+ WIT_REQUEST = 'WitRequest',
+ SAP_SMART_CHARGING_REQUEST = 'SapSmartChargingRequest',
+
DEPRECATED_REST_ENDPOINT = 'DeprecatedRestEndpoint',
LOGIN = 'Login',
LOGOUT = 'Logout',
@@ -146,6 +156,7 @@ export enum ServerAction {
OCPI_UPDATE_CREDENTIALS = 'OcpiUpdateCredentials',
OCPI_DELETE_CREDENTIALS = 'OcpiDeleteCredentials',
+ OCPI_CPO_REQUEST = 'OcpiCpoRequest',
OCPI_CPO_GET_SERVICES = 'OcpiCpoGetServices',
OCPI_CPO_COMMAND = 'OcpiCpoCommand',
OCPI_CPO_UPDATE_STATUS = 'OcpiCpoUpdateStatus',
@@ -166,6 +177,7 @@ export enum ServerAction {
OCPI_CPO_AUTHORIZE_TOKEN = 'OcpiCpoAuthorizeToken',
OCPI_CPO_GET_TARIFFS = 'OcpiCpoGetTariffs',
+ OCPI_EMSP_REQUEST = 'OcpiEmspRequest',
OCPI_EMSP_GET_SERVICES = 'OcpiEmspGetServices',
OCPI_EMSP_COMMAND = 'OcpiEmspCommand',
OCPI_EMSP_AUTHORIZE_TOKEN = 'OcpiEmspAuthorizeToken',
@@ -185,6 +197,7 @@ export enum ServerAction {
OCPI_EMSP_UNLOCK_CONNECTOR = 'OcpiEmspUnlockConnector',
OCPI_EMSP_GET_TARIFF = 'OcpiEmspGetTariff',
+ OICP_CPO_REQUEST = 'OicpCpoRequest',
OICP_SETTINGS = 'OicpSettings',
OICP_ENDPOINT_CREATE = 'OicpEndpointCreate',
OICP_ENDPOINT_PING = 'OicpEndpointPing',

MODIFY
src/utils/Logging.ts
src/utils/Logging.ts
@@ -472,14 +472,14 @@ export default class Logging {
httpUrl: request.url,
httpMethod: request.method.toLocaleUpperCase(),
reqSizeKb: sizeOfRequestDataKB,
- action: ServerAction.HTTP_REQUEST,
+ action: Utils.getAxiosActionFromURL(request.url),
})
);
const message = `Axios HTTP Request - '${Utils.last5Chars(performanceID)}' >> Req ${(sizeOfRequestDataKB > 0) ? sizeOfRequestDataKB : '?'} KB - ${request.method.toLocaleUpperCase()} '${request.url}'`;
Utils.isDevelopmentEnv() && Logging.logConsoleInfo(message);
await Logging.logDebug({
tenantID: tenant.id,
- action: ServerAction.HTTP_REQUEST,
+ action: Utils.getAxiosActionFromURL(request.url),
module: Constants.MODULE_AXIOS, method: 'interceptor',
message,
detailedMessages: {
@@ -545,7 +545,7 @@ export default class Logging {
try {
await Logging.logDebug({
tenantID: tenant.id,
- action: ServerAction.HTTP_RESPONSE,
+ action: Utils.getAxiosActionFromURL(response.config.url),
message,
module: Constants.MODULE_AXIOS, method: 'logAxiosResponse',
detailedMessages: {
@@ -568,7 +568,7 @@ export default class Logging {
} catch (error) {
await Logging.logDebug({
tenantID: tenant.id,
- action: ServerAction.HTTP_RESPONSE,
+ action: Utils.getAxiosActionFromURL(response.config.url),
message: `Axios HTTP Response - ${(executionDurationMillis > 0) ? executionDurationMillis : '?'} ms - Res ${(sizeOfResponseDataKB > 0) ? sizeOfResponseDataKB : '?'} KB << ${response.config.method.toLocaleUpperCase()}/${response.status} '${response.config.url}'`,
module: Constants.MODULE_AXIOS, method: 'logAxiosResponse',
detailedMessages: {

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -1511,6 +1511,60 @@ export default class Utils {
return PerformanceRecordGroup.UNKNOWN;
}
+ public static getAxiosActionFromURL(url: string): ServerAction {
+ if (!url) {
+ return ServerAction.HTTP_REQUEST;
+ }
+ // OCPI
+ if (url.includes('ocpi/cpo')) {
+ return ServerAction.OCPI_CPO_REQUEST;
+ }
+ if (url.includes('ocpi/emsp')) {
+ return ServerAction.OCPI_EMSP_REQUEST;
+ }
+ // Hubject
+ if (url.includes('hubject')) {
+ return ServerAction.OICP_CPO_REQUEST;
+ }
+ // Concur
+ if (url.includes('concursolutions')) {
+ return ServerAction.SAP_CONCUR_REQUEST;
+ }
+ // Recaptcha
+ if (url.includes('recaptcha')) {
+ return ServerAction.RECAPTCHA_REQUEST;
+ }
+ // Greencom
+ if (url.includes('gcn-eibp')) {
+ return ServerAction.GREENCOM_REQUEST;
+ }
+ // Stripe
+ if (url.includes('stripe')) {
+ return ServerAction.STRIPE_REQUEST;
+ }
+ // ioThink
+ if (url.includes('kheiron')) {
+ return ServerAction.IOTHINK_REQUEST;
+ }
+ // Lacroix
+ if (url.includes('esoftlink ')) {
+ return ServerAction.LACROIX_REQUEST;
+ }
+ // EV Database
+ if (url.includes('ev-database')) {
+ return ServerAction.EV_DATABASE_REQUEST;
+ }
+ // WIT
+ if (url.includes('wit-datacenter')) {
+ return ServerAction.WIT_REQUEST;
+ }
+ // SAP Smart Charging
+ if (url.includes('smart-charging')) {
+ return ServerAction.SAP_SMART_CHARGING_REQUEST;
+ }
+ return ServerAction.HTTP_REQUEST;
+ }
+
public static buildPerformanceRecord(params: {
tenantSubdomain?: string; durationMs?: number; resSizeKb?: number; reqSizeKb?: number;
action: ServerAction|string; group?: PerformanceRecordGroup; httpUrl?: string;

Added Server Action in Axios HTTP request traces