sw-tools / checkin-service

Checks the user in to a flight
MIT License
9 stars 3 forks source link

Logging changes #20

Closed aaron-pham closed 2 years ago

aaron-pham commented 2 years ago

Currently, the logging looks like this for checkin attempts:

2022-02-23T16:55:34.525Z    c6590d54-2112-5a54-9749-57c448237b84    INFO    Failed to fetch checkin data on attempt 0 of 80 at February 23, 2022, 4:55:34 PM UTC with error: HTTPError: Response code 400 (Bad Request)
    at Request.<anonymous> (/var/task/node_modules/got/dist/source/as-promise/index.js:117:42)
    at processTicksAndRejections (internal/process/task_queues.js:95:5) {
  code: 'ERR_NON_2XX_3XX_RESPONSE',
  timings: {
    start: 1645635333614,
    socket: 1645635333615,
    lookup: 1645635333615,
    connect: 1645635333622,
    secureConnect: 1645635333630,
    upload: 1645635333630,
    response: 1645635334518,
    end: 1645635334521,
    error: undefined,
    abort: undefined,
    phases: {
      wait: 1,
      dns: 0,
      tcp: 7,
      tls: 8,
      request: 0,
      firstByte: 888,
      download: 3,
      total: 907
    }
  }
}

Before, it looked like this:

2022-02-12T20:04:56.074Z    5b70e155-806f-4200-8a0c-d1c96e8c8f76    INFO    Failed on attempt 1 of 79 at February 12, 2022, 8:04:56 PM UTC with error: 
{
    "code": 400308191,
    "message": "Sorry! This reservation is not eligible for check in.",
    "messageKey": "ERROR__AIR_TRAVEL__BEFORE_CHECKIN_WINDOW",
    "header": null,
    "httpStatusCode": "BAD_REQUEST",
    "requestId": "6FDDCA70-8C3E-11EC-BB37-CB7B12CD8FBA:D8PqHfq2RICJcR-cVZ65IQ:mweb",
    "infoList": []
}

I think the old error message is much more useful and gives us southwest's human readable message. This could help signal to us if our headers are expired or something, or if the checkin is just not ready yet.

There was a bit of changes to how the project actually did the request to the checkin api, so we'd likely need to figure out how to log the entire message based on the "new" way.