Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/dashbot-amazon-alexa.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,29 @@ function DashBotAmazonAlexa(apiKey, urlRoot, debug, printErrors) {

that.logOutgoing = function(event, response, context) {
var timestamp = new Date().getTime();
// get session attributes
var eventAttributes = event && event.session && event.session.attributes || {};
var responseAttributes = response && response.sessionAttributes || {};
// clone event and response
var trimmedEvent = _.cloneDeep(event);
var trimmedResponse = _.cloneDeep(response);
// remove extra attribute values from event
for (var eventKey in eventAttributes) {
if (eventAttributes.hasOwnProperty(eventKey) && eventKey !== 'STATE') {
delete trimmedEvent.session.attributes[eventKey];
}
}
// remove extra attribute values from response
for (var responseKey in responseAttributes) {
if (responseAttributes.hasOwnProperty(responseKey) && responseKey !== 'STATE') {
delete trimmedResponse.sessionAttributes[responseKey];
}
}
var data = {
dashbot_timestamp: timestamp,
event: event,
event: trimmedEvent,
context: context,
response: response
response: trimmedResponse
};
return internalLogOutgoing(data, 'npm');
};
Expand Down Expand Up @@ -120,4 +138,4 @@ function DashBotAmazonAlexa(apiKey, urlRoot, debug, printErrors) {

}

module.exports = DashBotAmazonAlexa;
module.exports = DashBotAmazonAlexa;