@@ -304,7 +304,7 @@ function constructBaseLogData(
304304 event . requestContext . http . method ;
305305 }
306306
307- logData . request . apiVerion = options . getApiVersion ( event , context ) ;
307+ logData . request . apiVersion = options . getApiVersion ( event , context ) ;
308308
309309 if ( isV1 ) {
310310 logData . request . ipAddress =
@@ -364,6 +364,20 @@ function constructBaseLogData(
364364 return logData ;
365365}
366366
367+ function determineIsEventVersionV1 ( event ) {
368+ if ( event . version === '1.0' ) {
369+ return true ;
370+ }
371+ // per aws event spec https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
372+ // events suppose to have version specified.
373+ // For some reason, the version is not specified in some cases.
374+ // so we use heuristic below.
375+ if ( event . httpMethod ) {
376+ return true ;
377+ }
378+
379+ return false ;
380+ }
367381
368382function logEvent ( event , context , err , result , options , moesifController ) {
369383 // v1 has httpMethod, v2 has requestContext
@@ -382,7 +396,7 @@ function logEvent(event, context, err, result, options, moesifController) {
382396 return Promise . resolve ( ) ;
383397 }
384398
385- const isV1 = event . version === '1.0' ;
399+ const isV1 = determineIsEventVersionV1 ( event ) ;
386400
387401 var logData = constructBaseLogData (
388402 event ,
0 commit comments