From 00f36c2ab4dbc609c3eb56897c80abb5d506b79f Mon Sep 17 00:00:00 2001 From: chatasweetie Date: Tue, 19 May 2026 15:01:43 -0700 Subject: [PATCH 1/4] post github action testing, update messaging and add tagging logic --- .github/scripts/telemetry-pr-check.js | 59 +++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 7 deletions(-) diff --git a/.github/scripts/telemetry-pr-check.js b/.github/scripts/telemetry-pr-check.js index 31eb9f56fd85..1c3598fac112 100644 --- a/.github/scripts/telemetry-pr-check.js +++ b/.github/scripts/telemetry-pr-check.js @@ -9,21 +9,21 @@ */ const fs = require('node:fs'); +const REVIEWER_LOGIN = 'chatasweetie'; const COMMENT_MARKER = ''; const COMMENT_BODY_WITH_PRIVACY_UPDATE = `${COMMENT_MARKER} -THIS IS A TEST | @chatasweetie is testing this functionality -Thanks for contributing to PowerToys. This change might include a new or modified telemetry event, and we want to help make sure you can get your data end to end. +Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event, and we want to help make sure that post the merger of this PR you do the next steps: -1. Reach out to Jessica (@chatasweetie) to follow up on the next steps to add these telemetry events to our pipelines.`; +- [ ] Reach out to Jessica (@chatasweetie) to follow up on the next steps, https://aka.ms/next-steps +`; const COMMENT_BODY_WITHOUT_PRIVACY_UPDATE = `${COMMENT_MARKER} -THIS IS A TEST | @chatasweetie is testing this functionality -Thanks for contributing to PowerToys. This change might include a new or modified telemetry event, and we want to help make sure you can get your data end to end. +Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event, and we want to help make sure that this PR contains the necessary elements: -1. Make sure to add your telemetry events to DATA_AND_PRIVACY.md. +- [ ] Add your telemetry events to DATA_AND_PRIVACY.md within this PR. -2. Reach out to Jessica (@chatasweetie) to follow up on the next steps to add these telemetry events to our pipelines.`; +- [ ] Reach out to Jessica (@chatasweetie) to follow up on the next step, https://aka.ms/next-steps`; const TELEMETRY_PATH_PATTERNS = [ /(^|\/)trace\.(h|hpp|cpp|cs)$/i, @@ -191,6 +191,48 @@ async function getAllPullFiles(apiBaseUrl, repository, pullNumber) { return files; } +async function getPullRequest(apiBaseUrl, repository, pullNumber) { + const url = `${apiBaseUrl}/repos/${repository}/pulls/${pullNumber}`; + const pullRequest = await apiRequest(url); + if (!pullRequest || typeof pullRequest !== 'object') { + throw new Error('Unexpected response while fetching pull request details.'); + } + return pullRequest; +} + +async function ensureReviewerRequested(apiBaseUrl, repository, pullNumber, pullRequest) { + const authorLogin = String(pullRequest?.user?.login || '').toLowerCase(); + const targetReviewer = REVIEWER_LOGIN.toLowerCase(); + + if (authorLogin === targetReviewer) { + console.log(`Skipping reviewer request: ${REVIEWER_LOGIN} is the PR author.`); + return; + } + + const requestedReviewers = Array.isArray(pullRequest?.requested_reviewers) + ? pullRequest.requested_reviewers + : []; + const alreadyRequested = requestedReviewers.some( + (reviewer) => String(reviewer?.login || '').toLowerCase() === targetReviewer + ); + + if (alreadyRequested) { + console.log(`Reviewer ${REVIEWER_LOGIN} is already requested.`); + return; + } + + const url = `${apiBaseUrl}/repos/${repository}/pulls/${pullNumber}/requested_reviewers`; + try { + await apiRequest(url, 'POST', { reviewers: [REVIEWER_LOGIN] }); + console.log(`Requested reviewer ${REVIEWER_LOGIN}.`); + } catch (error) { + // Reviewer request should not fail the telemetry guidance workflow. + console.warn( + `Unable to request reviewer ${REVIEWER_LOGIN}: ${error instanceof Error ? error.message : String(error)}` + ); + } +} + async function findExistingTelemetryComment(apiBaseUrl, repository, pullNumber) { let page = 1; @@ -310,6 +352,9 @@ async function main() { ); } + const pullRequest = await getPullRequest(parsedApiBaseUrl.origin, repository, pullNumber); + await ensureReviewerRequested(parsedApiBaseUrl.origin, repository, pullNumber, pullRequest); + const commentBody = dataAndPrivacyChanged ? COMMENT_BODY_WITH_PRIVACY_UPDATE : COMMENT_BODY_WITHOUT_PRIVACY_UPDATE; From 65afb06e9264c1fc9dffe5e759e0e986b2f90857 Mon Sep 17 00:00:00 2001 From: chatasweetie Date: Wed, 20 May 2026 09:04:14 -0700 Subject: [PATCH 2/4] update guidance comment templates for grammar and consistency --- .github/scripts/telemetry-pr-check.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/scripts/telemetry-pr-check.js b/.github/scripts/telemetry-pr-check.js index 1c3598fac112..23f129f89081 100644 --- a/.github/scripts/telemetry-pr-check.js +++ b/.github/scripts/telemetry-pr-check.js @@ -13,17 +13,17 @@ const REVIEWER_LOGIN = 'chatasweetie'; const COMMENT_MARKER = ''; const COMMENT_BODY_WITH_PRIVACY_UPDATE = `${COMMENT_MARKER} -Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event, and we want to help make sure that post the merger of this PR you do the next steps: +Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event. After this PR is merged, please follow these next steps: -- [ ] Reach out to Jessica (@chatasweetie) to follow up on the next steps, https://aka.ms/next-steps +- [ ] Reach out to Jessica (@chatasweetie) to follow up on the next steps: https://aka.ms/next-steps `; const COMMENT_BODY_WITHOUT_PRIVACY_UPDATE = `${COMMENT_MARKER} -Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event, and we want to help make sure that this PR contains the necessary elements: +Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event. Please ensure the following before merging: - [ ] Add your telemetry events to DATA_AND_PRIVACY.md within this PR. -- [ ] Reach out to Jessica (@chatasweetie) to follow up on the next step, https://aka.ms/next-steps`; +- [ ] Reach out to Jessica (@chatasweetie) to follow up on the next steps: https://aka.ms/next-steps`; const TELEMETRY_PATH_PATTERNS = [ /(^|\/)trace\.(h|hpp|cpp|cs)$/i, From 7e45cad8636a3bf4705c4d030067f4efd8dd72b4 Mon Sep 17 00:00:00 2001 From: chatasweetie Date: Wed, 20 May 2026 09:10:36 -0700 Subject: [PATCH 3/4] made REVIEWER single source of truth for tagging and comment --- .github/scripts/telemetry-pr-check.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/scripts/telemetry-pr-check.js b/.github/scripts/telemetry-pr-check.js index 23f129f89081..f02872d3710f 100644 --- a/.github/scripts/telemetry-pr-check.js +++ b/.github/scripts/telemetry-pr-check.js @@ -10,12 +10,13 @@ const fs = require('node:fs'); const REVIEWER_LOGIN = 'chatasweetie'; +const REVIEWER_MENTION = `@${REVIEWER_LOGIN}`; const COMMENT_MARKER = ''; const COMMENT_BODY_WITH_PRIVACY_UPDATE = `${COMMENT_MARKER} Thank you for contributing to PowerToys. We've detected that this PR might include a new or modified telemetry event. After this PR is merged, please follow these next steps: -- [ ] Reach out to Jessica (@chatasweetie) to follow up on the next steps: https://aka.ms/next-steps +- [ ] Reach out to Jessica (${REVIEWER_MENTION}) to follow up on the next steps: https://aka.ms/next-steps `; const COMMENT_BODY_WITHOUT_PRIVACY_UPDATE = `${COMMENT_MARKER} @@ -23,7 +24,7 @@ Thank you for contributing to PowerToys. We've detected that this PR might inclu - [ ] Add your telemetry events to DATA_AND_PRIVACY.md within this PR. -- [ ] Reach out to Jessica (@chatasweetie) to follow up on the next steps: https://aka.ms/next-steps`; +- [ ] Reach out to Jessica (${REVIEWER_MENTION}) to follow up on the next steps: https://aka.ms/next-steps`; const TELEMETRY_PATH_PATTERNS = [ /(^|\/)trace\.(h|hpp|cpp|cs)$/i, From 514400701b72f286b3943abe0cbcac62486ff08e Mon Sep 17 00:00:00 2001 From: chatasweetie Date: Wed, 20 May 2026 09:12:54 -0700 Subject: [PATCH 4/4] add try/catch and warning logs --- .github/scripts/telemetry-pr-check.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/scripts/telemetry-pr-check.js b/.github/scripts/telemetry-pr-check.js index f02872d3710f..92d31c139618 100644 --- a/.github/scripts/telemetry-pr-check.js +++ b/.github/scripts/telemetry-pr-check.js @@ -353,8 +353,15 @@ async function main() { ); } - const pullRequest = await getPullRequest(parsedApiBaseUrl.origin, repository, pullNumber); - await ensureReviewerRequested(parsedApiBaseUrl.origin, repository, pullNumber, pullRequest); + try { + const pullRequest = await getPullRequest(parsedApiBaseUrl.origin, repository, pullNumber); + await ensureReviewerRequested(parsedApiBaseUrl.origin, repository, pullNumber, pullRequest); + } catch (error) { + console.warn( + 'Failed to fetch PR details or request reviewer; continuing to post telemetry guidance comment.' + ); + console.warn(error instanceof Error ? error.stack || error.message : error); + } const commentBody = dataAndPrivacyChanged ? COMMENT_BODY_WITH_PRIVACY_UPDATE