Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.replace(/[@\.]/g, '_')
.split('_')
.reverse()
.join('_');
// END TODO
// TODO: Create record object to be inserted into Spanner
// USe Spanner.float() to convert the score property
const record = {
feedbackId: `${rev_email}_${quiz}_${timestamp}`,
email,
quiz,
timestamp,
rating,
score: Spanner.float(score),
feedback,
};
// END TODO
// TODO: Insert the record into the table using await
// use try {} catch {} and check for err.code==6 to trap
// insert errors caused by duplicated PubSub messages
try {
console.log('Saving feedback');
await feedbackTable.insert(record);
} catch (err) {
if (err.code === 6 ) {
console.log("Duplicate message - feedback already saved");
} else {
console.error('ERROR processing feedback:', err);
}