diff --git a/index.js b/index.js index 8adb662cb72e937a82c7dbfaeb518785492c67a2..5e11de559be0aac0f16709cf0f694408d4d62342 100644 --- a/index.js +++ b/index.js @@ -127,19 +127,23 @@ Sentry.init({ }) async function standaloneStart(token, pce) { - const grdfData = await getData(token, pce) - if (!grdfData) { - log('debug', 'No consent or data for load curve') - return + try { + const grdfData = await getData(token, pce) + if (!grdfData) { + log('debug', 'No consent or data for load curve') + return + } + log('debug', 'Process grdf daily data') + const processedLoadData = await processData( + grdfData, + 'com.grandlyon.grdf.day', + ['year', 'month', 'day'] + ) + log('debug', 'Aggregate grdf load data for month and year') + await aggregateMonthAndYearData(processedLoadData) + } catch (error) { + log('error', 'Standalone failed') } - log('debug', 'Process grdf daily data') - const processedLoadData = await processData( - grdfData, - 'com.grandlyon.grdf.day', - ['year', 'month', 'day'] - ) - log('debug', 'Aggregate grdf load data for month and year') - await aggregateMonthAndYearData(processedLoadData) } const manualExecution = diff --git a/onDeleteAccount.js b/onDeleteAccount.js index a4c24ccc176deebb7a5e6614d7e4e99bd965adb3..a213e55da375ccce22da32e9e735b5aff9a780a8 100644 --- a/onDeleteAccount.js +++ b/onDeleteAccount.js @@ -271235,10 +271235,10 @@ async function fetchNewAccessToken(accountSecret) { // split the result into an array of strings containing a single json object // then check if the resulting json has an access_token field // return it if it does or return undefined - return result.match(/.+/g).map(s => { - result = JSON.parse(s) - if (result.access_token) { - return result.access_token + return result.match(/.+/g).map(jsonString => { + const jsonObject = JSON.parse(jsonString) + if (jsonObject.access_token) { + return jsonObject.access_token } }) })