-
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 (#166)
* Changes to get staging environment working Fixes #165. 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. * prettier rules say single quotes * use jsforce auto-refresh Also log and throw all rejections from handlers
- Loading branch information
Mike Senn
authored
Apr 5, 2023
1 parent
235360b
commit 1e29547
Showing
23 changed files
with
225 additions
and
203 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
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,37 @@ | ||
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 { | ||
// jsforce connection will auto-refresh if session expires | ||
await conn.login(process.env.GUS_USERNAME, process.env.GUS_PASSWORD); | ||
connection = conn; | ||
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 | ||
}; |
Oops, something went wrong.