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

claude-code / .github / workflows / log-issue-events.yml
68 lines · 2.2 KBRaw
1name: Log GitHub Issue Events
2
3on:
4 issues:
5 types: [opened]
6
7jobs:
8 log-issue-created:
9 runs-on: ubuntu-latest
10 timeout-minutes: 5
11 permissions:
12 contents: read
13 issues: read
14
15 steps:
16 - name: Log issue creation to Statsig
17 env:
18 STATSIG_API_KEY: ${{ secrets.STATSIG_API_KEY }}
19 run: |
20 ISSUE_NUMBER=${{ github.event.issue.number }}
21 REPO=${{ github.repository }}
22 ISSUE_TITLE="${{ github.event.issue.title }}"
23 AUTHOR="${{ github.event.issue.user.login }}"
24 CREATED_AT="${{ github.event.issue.created_at }}"
25
26 if [ -z "$STATSIG_API_KEY" ]; then
27 echo "STATSIG_API_KEY not found, skipping Statsig logging"
28 exit 0
29 fi
30
31 # Prepare the event payload
32 EVENT_PAYLOAD=$(jq -n \
33 --arg issue_number "$ISSUE_NUMBER" \
34 --arg repo "$REPO" \
35 --arg title "$ISSUE_TITLE" \
36 --arg author "$AUTHOR" \
37 --arg created_at "$CREATED_AT" \
38 '{
39 events: [{
40 eventName: "github_issue_created",
41 value: 1,
42 metadata: {
43 repository: $repo,
44 issue_number: ($issue_number | tonumber),
45 issue_title: $title,
46 issue_author: $author,
47 created_at: $created_at
48 },
49 time: (now | floor | tostring)
50 }]
51 }')
52
53 # Send to Statsig API
54 echo "Logging issue creation to Statsig for issue #${ISSUE_NUMBER}"
55
56 RESPONSE=$(curl -s -w "\n%{http_code}" -X POST https://events.statsigapi.net/v1/log_event \
57 -H "Content-Type: application/json" \
58 -H "STATSIG-API-KEY: ${STATSIG_API_KEY}" \
59 -d "$EVENT_PAYLOAD")
60
61 HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
62 BODY=$(echo "$RESPONSE" | head -n-1)
63
64 if [ "$HTTP_CODE" -eq 200 ] || [ "$HTTP_CODE" -eq 202 ]; then
65 echo "Successfully logged issue creation for issue #${ISSUE_NUMBER}"
66 else
67 echo "Failed to log issue creation for issue #${ISSUE_NUMBER}. HTTP ${HTTP_CODE}: ${BODY}"
68 fi