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
Consolidate GitHub issue closure events
| @@ -115,14 +115,10 @@ | ||
| 115 | 115 | CLOSED_AUTOMATICALLY="true" |
| 116 | 116 | fi |
| 117 | 117 | |
| 118 | - # Check if closed as duplicate by looking for duplicate label or state_reason | |
| 118 | + # Check if closed as duplicate by state_reason | |
| 119 | 119 | 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" | |
| 126 | 122 | fi |
| 127 | 123 | |
| 128 | 124 | # Prepare the event payload |
| @@ -51,42 +51,7 @@ | ||
| 51 | 51 | return match ? parseInt(match[1], 10) : null; |
| 52 | 52 | } |
| 53 | 53 | |
| 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 | - } | |
| 60 | 54 | |
| 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 | - | |
| 90 | 55 | async function closeIssueAsDuplicate( |
| 91 | 56 | owner: string, |
| 92 | 57 | repo: string, |
| @@ -100,7 +65,8 @@ | ||
| 100 | 65 | 'PATCH', |
| 101 | 66 | { |
| 102 | 67 | state: 'closed', |
| 103 | - state_reason: 'not_planned' | |
| 68 | + state_reason: 'duplicate', | |
| 69 | + labels: ['duplicate'] | |
| 104 | 70 | } |
| 105 | 71 | ); |
| 106 | 72 | |
| @@ -117,13 +83,6 @@ | ||
| 117 | 83 | } |
| 118 | 84 | ); |
| 119 | 85 | |
| 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 | - }); | |
| 127 | 86 | } |
| 128 | 87 | |
| 129 | 88 | async function autoCloseDuplicates(): Promise<void> { |