@@ -304,7 +304,7 @@ function constructBaseLogData(
304
304
event . requestContext . http . method ;
305
305
}
306
306
307
- logData . request . apiVerion = options . getApiVersion ( event , context ) ;
307
+ logData . request . apiVersion = options . getApiVersion ( event , context ) ;
308
308
309
309
if ( isV1 ) {
310
310
logData . request . ipAddress =
@@ -364,6 +364,24 @@ function constructBaseLogData(
364
364
return logData ;
365
365
}
366
366
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
+ }
367
385
368
386
function logEvent ( event , context , err , result , options , moesifController ) {
369
387
// v1 has httpMethod, v2 has requestContext
@@ -382,7 +400,7 @@ function logEvent(event, context, err, result, options, moesifController) {
382
400
return Promise . resolve ( ) ;
383
401
}
384
402
385
- const isV1 = event . version === '1.0' ;
403
+ const isV1 = determineIsEventVersionV1 ( event ) ;
386
404
387
405
var logData = constructBaseLogData (
388
406
event ,
0 commit comments