mirror of
https://github.com/anthropics/claude-code.git
synced 2025-10-19 03:17:50 +03:00
Consolidate GitHub issue closure events to prevent duplicates
- Remove duplicate Statsig logging from auto-close-duplicates.ts - GitHub workflow now handles all issue closures uniformly - Add 'duplicate' label to ensure proper detection by workflow - Prevents double-logging when script closes issues 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -51,41 +51,6 @@ function extractDuplicateIssueNumber(commentBody: string): number | null {
|
||||
return match ? parseInt(match[1], 10) : null;
|
||||
}
|
||||
|
||||
async function logStatsigEvent(eventName: string, value: number, metadata: Record<string, any>): Promise<void> {
|
||||
const statsigApiKey = process.env.STATSIG_API_KEY;
|
||||
if (!statsigApiKey) {
|
||||
console.log("[DEBUG] STATSIG_API_KEY not found, skipping Statsig logging");
|
||||
return;
|
||||
}
|
||||
|
||||
const eventPayload = {
|
||||
events: [{
|
||||
eventName,
|
||||
value,
|
||||
metadata,
|
||||
time: Math.floor(Date.now()).toString()
|
||||
}]
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await fetch('https://events.statsigapi.net/v1/log_event', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'STATSIG-API-KEY': statsigApiKey
|
||||
},
|
||||
body: JSON.stringify(eventPayload)
|
||||
});
|
||||
|
||||
if (response.ok) {
|
||||
console.log(`[DEBUG] Successfully logged Statsig event: ${eventName}`);
|
||||
} else {
|
||||
console.log(`[DEBUG] Failed to log Statsig event: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(`[DEBUG] Error logging to Statsig: ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
async function closeIssueAsDuplicate(
|
||||
owner: string,
|
||||
@@ -100,7 +65,8 @@ async function closeIssueAsDuplicate(
|
||||
'PATCH',
|
||||
{
|
||||
state: 'closed',
|
||||
state_reason: 'not_planned'
|
||||
state_reason: 'not_planned',
|
||||
labels: ['duplicate']
|
||||
}
|
||||
);
|
||||
|
||||
@@ -117,13 +83,6 @@ If this is incorrect, please re-open this issue or create a new one.
|
||||
}
|
||||
);
|
||||
|
||||
// Log to Statsig
|
||||
await logStatsigEvent('github_issue_closed_as_duplicate', 1, {
|
||||
repository: `${owner}/${repo}`,
|
||||
issue_number: issueNumber,
|
||||
duplicate_of_issue: duplicateOfNumber,
|
||||
closed_by: 'auto-close-script'
|
||||
});
|
||||
}
|
||||
|
||||
async function autoCloseDuplicates(): Promise<void> {
|
||||
|
||||
Reference in New Issue
Block a user