-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For issues with certain labels, closing triggers a CSAT survey commen…
…t to gather customer satisfaction. (#1704)
- Loading branch information
1 parent
81ec9fc
commit ad92857
Showing
5 changed files
with
127 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: 'CSAT survey' | ||
on: | ||
issues: | ||
types: | ||
- closed | ||
|
||
permissions: | ||
contents: read | ||
issues: write | ||
pull-requests: write | ||
|
||
jobs: | ||
welcome: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
const script = require('./\.github/workflows/scripts/csat.js') | ||
script({github, context}) |
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,14 @@ | ||
let CONSTANT_VALUES = { | ||
MODULE: { | ||
CSAT: { | ||
YES:'Yes', | ||
NO:'No', | ||
BASE_URL: 'https://docs.google.com/forms/d/e/1FAIpQLSdHag0RVFS7UXzZkKcsFCKOcX8raCupKK9RHSlYxp5U8lSJbQ/viewform?', | ||
SATISFACTION_PARAM: 'entry.492125872=', | ||
ISSUEID_PARAM: '&entry.243948740=', | ||
MSG: 'Are you satisfied with the resolution of your issue?', | ||
CSAT_LABELS: ['type:bug', 'type:build/install', 'type:support', 'type:others', 'type:docs-bug', 'type:performance', 'type:feature'] | ||
} | ||
} | ||
}; | ||
module.exports = CONSTANT_VALUES; |
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,34 @@ | ||
|
||
const CONSTANT_VALUES = require('./constant'); | ||
/** | ||
* Invoked from staleCSAT.js and CSAT.yaml file to | ||
* post survey link in closed issue. | ||
* @param {!object} Object - gitHub and context contains the information about the | ||
* current and context and github APIs using their built-in library functions. | ||
*/ | ||
module.exports = async ({ github, context }) => { | ||
const issue = context.payload.issue.html_url; | ||
let base_url = CONSTANT_VALUES.MODULE.CSAT.BASE_URL; | ||
//Loop over all ths label present in issue and check if specific label is present for survey link. | ||
for (const label of context.payload.issue.labels) { | ||
if (CONSTANT_VALUES.MODULE.CSAT.CSAT_LABELS.includes(label.name)) { | ||
console.log(`label-${label.name}, posting CSAT survey for issue =${issue}`); | ||
const yesCsat = `<a href="${base_url + CONSTANT_VALUES.MODULE.CSAT.SATISFACTION_PARAM + | ||
CONSTANT_VALUES.MODULE.CSAT.YES + | ||
CONSTANT_VALUES.MODULE.CSAT.ISSUEID_PARAM + issue}"> ${CONSTANT_VALUES.MODULE.CSAT.YES}</a>`; | ||
|
||
const noCsat = `<a href="${base_url + CONSTANT_VALUES.MODULE.CSAT.SATISFACTION_PARAM + | ||
CONSTANT_VALUES.MODULE.CSAT.NO + | ||
CONSTANT_VALUES.MODULE.CSAT.ISSUEID_PARAM + issue}"> ${CONSTANT_VALUES.MODULE.CSAT.NO}</a>`; | ||
const comment = CONSTANT_VALUES.MODULE.CSAT.MSG + '\n' + yesCsat + '\n' + | ||
noCsat + '\n'; | ||
let issueNumber = context.issue.number ?? context.payload.issue.number; | ||
await github.rest.issues.createComment({ | ||
issue_number: issueNumber, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: comment | ||
}); | ||
} | ||
} | ||
}; |
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,52 @@ | ||
|
||
const csat = require('./csat.js'); | ||
const CONSTANT = require("./constant.js"); | ||
/** | ||
*When stale bot closes the issue this function will | ||
*invoke and post CSAT link on the issue. | ||
*This function will fetch all the issues closed within 10 minutes and | ||
*post the survey link if survey link is not posted already. | ||
* @param {!object} Object - gitHub and context contains the information about | ||
*the current and context and github APIs using their built-in library | ||
*functions. | ||
*/ | ||
module.exports = async ({ github, context }) => { | ||
let date = new Date(); | ||
let totalMilliSeconds = date.getTime(); | ||
let minutes = 10; | ||
let millisecondsToSubtract = minutes * 60 * 1000; | ||
let closeTime = totalMilliSeconds-millisecondsToSubtract; | ||
let newDate = new Date(closeTime); | ||
let ISOCloseTime = newDate.toISOString(); | ||
// Fetch all the issue closed with in 10 mins. | ||
let closeTimeIssues = await github.rest.issues.listForRepo({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
state:"closed", | ||
labels:"stale", | ||
since:ISOCloseTime | ||
}); | ||
let ISSUESLIST = closeTimeIssues.data; | ||
console.log(`Fetching all the closed within ${minutes} minutes.`); | ||
console.log(ISSUESLIST); | ||
for(let i=0;i<ISSUESLIST.length;i++){ | ||
if(ISSUESLIST[i].node_id && ISSUESLIST[i].node_id.indexOf("PR") !=-1) | ||
continue; | ||
// Fetch last comments for the issues. | ||
let comments = await github.rest.issues.listComments({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: ISSUESLIST[i].number | ||
}); | ||
let noOfComments = comments.data.length; | ||
let lastComment = comments.data[noOfComments-1]; | ||
let strCom = JSON.stringify(lastComment); | ||
if(strCom.indexOf(CONSTANT.MODULE.CSAT.MSG) == -1){ | ||
context.payload.issue = {}; | ||
context.payload.issue.number = ISSUESLIST[i].number; | ||
context.payload.issue.labels = ISSUESLIST[i].labels; | ||
context.payload.issue.html_url = ISSUESLIST[i].html_url; | ||
csat({github, context}); | ||
} | ||
} | ||
}; |
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