-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changes to get staging environment working
While setting up the staging environment, I made these changes. Some are strictly necessary, like the namespace prefixing on fields. Some helped me find those issues, like returning errors from event handlers and logging more details in createWorkItem. ### Medium changes (connection.js and services/Gus/*) Keep GUS api sessions alive for 10 minutes. And add debug logging for SOQL requests (connection.js) Implement namespace prefixes on objects and fields. This should have been implemented when the app started supporting Agile Accelerator, which always has a namespace; not sure why this wasn't done already. (GithubEvents/index.js and ghEvents.js) Wait for event handlers to return before returning from the github webhook. Previously webhooks would return synchronously, before any GUS callouts would be processed. Now, GUS callouts will delay the webhook response and can affect the 2xx/5xx status code. This will help track errors and latency through logs. ### Small changes Add missing peer dependency 'winston' Add logs in createWorkItem that helped diagnose an issue with bug priorities. (GithubEvents/index.js) Use captureRejectionSymbol to mitigate an unhandled promise rejection and avoid app crash. Related to #161.
- Loading branch information
Mike Senn
committed
Feb 26, 2023
1 parent
235360b
commit e390482
Showing
21 changed files
with
198 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
const jsforce = require('jsforce'); | ||
const logger = require('../../services/Logs/logger'); | ||
|
||
let connection; | ||
async function getConnection() { | ||
if (connection) { | ||
return connection; | ||
} | ||
|
||
const conn = new jsforce.Connection({ logLevel: 'DEBUG' }); | ||
try { | ||
await conn.login(process.env.GUS_USERNAME, process.env.GUS_PASSWORD); | ||
connection = conn; | ||
|
||
// Keep connection open, but do reconnect every so often | ||
setTimeout(() => { | ||
connection = null; | ||
logger.info(`Forgetting Gus session`); | ||
}, 10 * 60 * 1000); // 10 minutes | ||
|
||
return conn; | ||
} catch (err) { | ||
logger.error('Error logging into GUS', err); | ||
throw new Error(`Error logging into GUS ${err.message}`); | ||
} | ||
} | ||
|
||
const NAMESPACE_PREFIX = process.env.NAMESPACE_PREFIX | ||
? `${process.env.NAMESPACE_PREFIX}__` | ||
: ''; | ||
|
||
function field(name) { | ||
return `${NAMESPACE_PREFIX}${name}__c`; | ||
} | ||
|
||
module.exports = { | ||
getConnection, | ||
Work: NAMESPACE_PREFIX + 'ADM_Work__c', | ||
Build: NAMESPACE_PREFIX + 'ADM_Build__c', | ||
Changelist: NAMESPACE_PREFIX + 'ADM_Changelist__c', | ||
prefix: NAMESPACE_PREFIX, | ||
field | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.