diff --git a/vue-app/.env.example b/vue-app/.env.example index ed8ba9ee7..161df5589 100644 --- a/vue-app/.env.example +++ b/vue-app/.env.example @@ -33,4 +33,6 @@ VUE_APP_OPERATOR= # Google Service Account credentials in JSON format GOOGLE_APPLICATION_CREDENTIALS= # Spreadsheet ID to send recipients data -VUE_APP_GOOGLE_SPREADSHEET_ID= \ No newline at end of file +VUE_APP_GOOGLE_SPREADSHEET_ID= +# Select the sheet's name to write the data, by default 'Raw' +GOOGLE_SHEET_NAME= \ No newline at end of file diff --git a/vue-app/src/lambda/recipient.js b/vue-app/src/lambda/recipient.js index 0bad9f37b..f4545ea37 100644 --- a/vue-app/src/lambda/recipient.js +++ b/vue-app/src/lambda/recipient.js @@ -1,5 +1,7 @@ import { GoogleSpreadsheet } from 'google-spreadsheet' +const GOOGLE_SHEET_NAME = process.env.GOOGLE_SHEET_NAME || 'Raw' + /** * Creates an object row from a RecipientApplicationData. A row is a key-value * object where the keys are composed by the concatenation of the nested keys. @@ -52,7 +54,7 @@ exports.handler = async function (event) { await doc.useServiceAccountAuth(creds) await doc.loadInfo() - const sheet = doc.sheetsByIndex[0] + const sheet = doc.sheetsByTitle[GOOGLE_SHEET_NAME] const row = recipientToRow(recipient) await sheet.addRow(row)