@@ -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,24 @@ function constructBaseLogData(
364364 return logData ;
365365}
366366
367+ function determineIsEventVersionV1 ( event ) {
368+ if ( event . version === '1.0' ) {
369+ return true ;
370+ }
371+
372+ if ( event . version === '2.0' ) {
373+ return false ;
374+ }
375+ // per aws event spec https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations-lambda.html
376+ // events suppose to have version specified.
377+ // For some reason, the version is not specified in some cases.
378+ // so we use heuristic below.
379+ if ( event . httpMethod ) {
380+ return true ;
381+ }
382+
383+ return false ;
384+ }
367385
368386function logEvent ( event , context , err , result , options , moesifController ) {
369387 // v1 has httpMethod, v2 has requestContext
@@ -382,7 +400,7 @@ function logEvent(event, context, err, result, options, moesifController) {
382400 return Promise . resolve ( ) ;
383401 }
384402
385- const isV1 = event . version === '1.0' ;
403+ const isV1 = determineIsEventVersionV1 ( event ) ;
386404
387405 var logData = constructBaseLogData (
388406 event ,
0 commit comments