spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

Merge pull request #5569 from anthropics/boris/limcBrowse files
Consolidate GitHub issue closure events
Boris Cherny authored on Aug 11, 2025 · GitHub committed on Aug 11, 2025 parents 2dbf1e9 + 4a04589 · commit 5300e12135ba
2 changed files+5 -50compared with 2dbf1e9
M.github/workflows/log-issue-events.yml
Mscripts/auto-close-duplicates.ts
@@ -115,14 +115,10 @@
115115 CLOSED_AUTOMATICALLY="true"
116116 fi
117117
118- # Check if closed as duplicate by looking for duplicate label or state_reason
118+ # Check if closed as duplicate by state_reason
119119 CLOSED_AS_DUPLICATE="false"
120- if [ "$STATE_REASON" = "not_planned" ]; then
121- # Check if issue has duplicate label
122- LABELS=$(echo "$ISSUE_DATA" | jq -r '.labels[] | select(.name | test("duplicate"; "i")) | .name')
123- if [ -n "$LABELS" ]; then
124- CLOSED_AS_DUPLICATE="true"
125- fi
120+ if [ "$STATE_REASON" = "duplicate" ]; then
121+ CLOSED_AS_DUPLICATE="true"
126122 fi
127123
128124 # Prepare the event payload
@@ -51,42 +51,7 @@
5151 return match ? parseInt(match[1], 10) : null;
5252 }
5353
54-async function logStatsigEvent(eventName: string, value: number, metadata: Record<string, any>): Promise<void> {
55- const statsigApiKey = process.env.STATSIG_API_KEY;
56- if (!statsigApiKey) {
57- console.log("[DEBUG] STATSIG_API_KEY not found, skipping Statsig logging");
58- return;
59- }
6054
61- const eventPayload = {
62- events: [{
63- eventName,
64- value,
65- metadata,
66- time: Math.floor(Date.now()).toString()
67- }]
68- };
69-
70- try {
71- const response = await fetch('https://events.statsigapi.net/v1/log_event', {
72- method: 'POST',
73- headers: {
74- 'Content-Type': 'application/json',
75- 'STATSIG-API-KEY': statsigApiKey
76- },
77- body: JSON.stringify(eventPayload)
78- });
79-
80- if (response.ok) {
81- console.log(`[DEBUG] Successfully logged Statsig event: ${eventName}`);
82- } else {
83- console.log(`[DEBUG] Failed to log Statsig event: ${response.status} ${response.statusText}`);
84- }
85- } catch (error) {
86- console.log(`[DEBUG] Error logging to Statsig: ${error}`);
87- }
88-}
89-
9055 async function closeIssueAsDuplicate(
9156 owner: string,
9257 repo: string,
@@ -100,7 +65,8 @@
10065 'PATCH',
10166 {
10267 state: 'closed',
103- state_reason: 'not_planned'
68+ state_reason: 'duplicate',
69+ labels: ['duplicate']
10470 }
10571 );
10672
@@ -117,13 +83,6 @@
11783 }
11884 );
11985
120- // Log to Statsig
121- await logStatsigEvent('github_issue_closed_as_duplicate', 1, {
122- repository: `${owner}/${repo}`,
123- issue_number: issueNumber,
124- duplicate_of_issue: duplicateOfNumber,
125- closed_by: 'auto-close-script'
126- });
12786 }
12887
12988 async function autoCloseDuplicates(): Promise<void> {