Skip to content

Commit

Permalink
Repo Gardening: ping in slack for issues labeled customer report (#41…
Browse files Browse the repository at this point in the history
…027)

* Repo Gardening: ping in slack for issues labeled customer report

Internal references:

- p1736823216576659-slack-C01UW7SB411
- pfVjQF-su-p2

* Update wording

---------

Co-authored-by: Ikem <66711744+inaikem@users.noreply.github.com>

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/12769983934

Upstream-Ref: Automattic/jetpack@af9a01e
  • Loading branch information
jeherve authored and matticbot committed Jan 14, 2025
1 parent 592e215 commit f166897
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This is an alpha version! The changes listed here are not final.
- AI Labeling: allow plugin-specific feature labels as well.
- Board triage: add automatic triage to Fediverse project board.
- Prompt for labels: update conditions to include "[<plugin> Feature]" labels.
- Support References: send Slack message when an issue is labeled as customer report.
- Support references: stop gathering p2 comments in list of support references.
- Updated package dependencies.

Expand Down
30 changes: 24 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -50135,13 +50135,19 @@ async function createOrUpdateComment( payload, octokit, issueReferences, issueCo
/**
* Add a label to the issue, if it does not exist yet.
*
* @param {GitHub} octokit - Initialized Octokit REST client.
* @param {string} ownerLogin - Repository owner login.
* @param {string} repo - Repository name.
* @param {number} number - Issue number.
* @param {WebhookPayloadIssue} payload - Issue or issue comment event payload.
* @param {GitHub} octokit - Initialized Octokit REST client.
* @return {Promise<void>}
*/
async function addHappinessLabel( octokit, ownerLogin, repo, number ) {
async function addHappinessLabel( payload, octokit ) {
const {
issue: { number },
repository: {
name: repo,
owner: { login: ownerLogin },
},
} = payload;

const happinessLabel = 'Customer Report';

const labels = await getLabels( octokit, ownerLogin, repo, number );
Expand All @@ -50159,6 +50165,18 @@ async function addHappinessLabel( octokit, ownerLogin, repo, number ) {
issue_number: number,
labels: [ happinessLabel ],
} );

// Send Slack notification, if we have the necessary tokens.
// No Slack tokens, we won't be able to escalate. Bail.
const slackToken = getInput( 'slack_token' );
const channel = getInput( 'slack_quality_channel' );
if ( ! slackToken || ! channel ) {
return false;
}

const message = `This issue has been labeled as a Customer Report. Please complete first-line triage within 24 hours.`;
const slackMessageFormat = formatSlackMessage( payload, channel, message );
await sendSlackMessage( message, channel, payload, slackMessageFormat );
}

/**
Expand Down Expand Up @@ -50187,7 +50205,7 @@ async function gatherSupportReferences( payload, octokit ) {
if ( issueReferences.length > 0 ) {
debug( `gather-support-references: Found ${ issueReferences.length } references.` );
await createOrUpdateComment( payload, octokit, issueReferences, issueComments );
await addHappinessLabel( octokit, owner.login, repo, number );
await addHappinessLabel( payload, octokit );
}
}

Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

30 changes: 24 additions & 6 deletions src/tasks/gather-support-references/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,19 @@ async function createOrUpdateComment( payload, octokit, issueReferences, issueCo
/**
* Add a label to the issue, if it does not exist yet.
*
* @param {GitHub} octokit - Initialized Octokit REST client.
* @param {string} ownerLogin - Repository owner login.
* @param {string} repo - Repository name.
* @param {number} number - Issue number.
* @param {WebhookPayloadIssue} payload - Issue or issue comment event payload.
* @param {GitHub} octokit - Initialized Octokit REST client.
* @return {Promise<void>}
*/
async function addHappinessLabel( octokit, ownerLogin, repo, number ) {
async function addHappinessLabel( payload, octokit ) {
const {
issue: { number },
repository: {
name: repo,
owner: { login: ownerLogin },
},
} = payload;

const happinessLabel = 'Customer Report';

const labels = await getLabels( octokit, ownerLogin, repo, number );
Expand All @@ -436,6 +442,18 @@ async function addHappinessLabel( octokit, ownerLogin, repo, number ) {
issue_number: number,
labels: [ happinessLabel ],
} );

// Send Slack notification, if we have the necessary tokens.
// No Slack tokens, we won't be able to escalate. Bail.
const slackToken = getInput( 'slack_token' );
const channel = getInput( 'slack_quality_channel' );
if ( ! slackToken || ! channel ) {
return false;
}

const message = `This issue has been labeled as a Customer Report. Please complete first-line triage within 24 hours.`;
const slackMessageFormat = formatSlackMessage( payload, channel, message );
await sendSlackMessage( message, channel, payload, slackMessageFormat );
}

/**
Expand Down Expand Up @@ -464,7 +482,7 @@ async function gatherSupportReferences( payload, octokit ) {
if ( issueReferences.length > 0 ) {
debug( `gather-support-references: Found ${ issueReferences.length } references.` );
await createOrUpdateComment( payload, octokit, issueReferences, issueComments );
await addHappinessLabel( octokit, owner.login, repo, number );
await addHappinessLabel( payload, octokit );
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/tasks/gather-support-references/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Happiness Engineers can comment on issues to add references to support interactions with customers that would like to be updated whenever the problem is solved.

This task creates a new comment that lists all support references found in all comments on the issue. If it finds a support reference, it will also add a label to the issue, "Customer Report".
This task creates a new comment that lists all support references found in all comments on the issue. If it finds a support reference, it will also add a label to the issue, "Customer Report". When that label is added, we warn the triage team in Slack.

The tasks also monitors the number of support references it has gathered:

Expand Down

0 comments on commit f166897

Please sign in to comment.