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:
Boris Cherny
2025-08-08 18:26:48 -07:00
parent 22946869b2
commit 5af0b38a92
4 changed files with 162 additions and 0 deletions

View File

@@ -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> {