in source/custom-resource/lib/dynamo-helper.js [30:69]
dynamoHelper.prototype.seedData = function(tableName, region, cb) {
let docClient = new aws.DynamoDB.DocumentClient({
region: region
});
let seedData = [
{ MetricType:'event_count', AmendmentStrategy:'add', IsSet:true, IsWholeNumber:true, LatestEventTimestamp:0 },
{ MetricType:'hourly_events', AmendmentStrategy:'replace_existing', IsSet:true, IsWholeNumber:true, LatestEventTimestamp:0 },
{ MetricType:'top_pages', AmendmentStrategy:'add', IsSet:true, IsWholeNumber:true, LatestEventTimestamp:0 },
{ MetricType:'visitor_count', AmendmentStrategy:'add', IsSet:false, IsWholeNumber:true, LatestEventTimestamp:0 },
{ MetricType:'referral_count', AmendmentStrategy:'add', IsSet:true, IsWholeNumber:true, LatestEventTimestamp:0 },
{ MetricType:'event_anomaly', AmendmentStrategy:'replace', IsSet:false, IsWholeNumber:false, LatestEventTimestamp:0 },
{ MetricType:'agent_count', AmendmentStrategy:'add', IsSet:true, IsWholeNumber:true, LatestEventTimestamp:0 }
]
let hasError = false;
for (let i = 0; i < seedData.length; i++) {
if (!hasError) {
let item = seedData[i];
let metricDetailParams = {
TableName: tableName,
Item: item,
ConditionExpression: 'attribute_not_exists(MetricType)'
};
docClient.put(metricDetailParams, (err, data) => {
if (err) {
hasError = true;
console.log(err);
cb(err);
return;
}
});
}
}
cb(null, 'SUCCESS');
};