@befaas/lib
Advanced tools
Comparing version 8.10.0 to 8.11.0
@@ -1,6 +0,6 @@ | ||
## 8.10.0 (2022-04-27) | ||
## 8.11.0 (2022-04-27) | ||
#### Feature | ||
* add google publisher endpoint (da38a3c5) | ||
* add safeStringify (c129d3c6) | ||
@@ -50,3 +50,3 @@ { | ||
}, | ||
"version": "8.10.0" | ||
"version": "8.11.0" | ||
} |
@@ -58,5 +58,21 @@ const _ = require('lodash') | ||
JSON.safeStringify = (obj, indent = 2) => { | ||
let cache = []; | ||
const retVal = JSON.stringify( | ||
obj, | ||
(key, value) => | ||
typeof value === "object" && value !== null | ||
? cache.includes(value) | ||
? undefined // Duplicate reference found, discard key | ||
: cache.push(value) && value // Store value in our collection | ||
: value, | ||
indent | ||
); | ||
cache = null; | ||
return retVal; | ||
}; | ||
function logEventAndAttachContext (ctx, event, dbBindToMeasure) { | ||
console.log("ctxEntry: \n" + JSON.stringify(ctx, null, 2)); | ||
console.log("eventEntry: \n" + JSON.stringify(event, null, 2)); | ||
console.log("ctxEntry: \n" + JSON.safeStringify(ctx, 2)); | ||
console.log("eventEntry: \n" + JSON.safeStringify(event, 2)); | ||
const contextId = event.Records[0].Sns.MessageAttributes.contextId.Value || helper.generateRandomID() | ||
@@ -63,0 +79,0 @@ const xPair = event.Records[0].Sns.MessageAttributes.xPair.Value || 'undefined-x-pair' |
55111335
474