mirror of
https://github.com/anthropics/claude-code.git
synced 2025-10-19 03:17:50 +03:00
Add Statsig event logging to GitHub issue workflows
- Log events when issues are closed as duplicates in auto-close script - Log events when duplicate comments are added via dedupe workflow - Log events when new issues are created - Follow existing pattern from code review reactions workflow 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -51,6 +51,42 @@ 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,
|
||||
repo: string,
|
||||
@@ -80,6 +116,14 @@ If this is incorrect, please re-open this issue or create a new one.
|
||||
🤖 Generated with [Claude Code](https://claude.ai/code)`
|
||||
}
|
||||
);
|
||||
|
||||
// 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