MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / trackUpdateFailed

Function trackUpdateFailed

cli/release/index.js:121–163  ·  view source on GitHub ↗

* Track update failure event to PostHog. * Fire-and-forget - errors are silently ignored.

(errorMessage, version, context = {})

Source from the content-addressed store, hash-verified

119 * Fire-and-forget - errors are silently ignored.
120 */
121function trackUpdateFailed(errorMessage, version, context = {}) {
122 try {
123 const posthogConfig = getPostHogConfig()
124 if (!posthogConfig) {
125 return
126 }
127
128 const payload = JSON.stringify({
129 api_key: posthogConfig.apiKey,
130 event: 'cli.update_codebuff_failed',
131 properties: {
132 distinct_id: `anonymous-${CONFIG.homeDir}`,
133 error: errorMessage,
134 version: version || 'unknown',
135 platform: process.platform,
136 arch: process.arch,
137 ...context,
138 },
139 timestamp: new Date().toISOString(),
140 })
141
142 const parsedUrl = new URL(`${posthogConfig.host}/capture/`)
143 const isHttps = parsedUrl.protocol === 'https:'
144 const options = {
145 hostname: parsedUrl.hostname,
146 port: parsedUrl.port || (isHttps ? 443 : 80),
147 path: parsedUrl.pathname + parsedUrl.search,
148 method: 'POST',
149 headers: {
150 'Content-Type': 'application/json',
151 'Content-Length': Buffer.byteLength(payload),
152 },
153 }
154
155 const transport = isHttps ? https : http
156 const req = transport.request(options)
157 req.on('error', () => {}) // Silently ignore errors
158 req.write(payload)
159 req.end()
160 } catch (e) {
161 // Silently ignore any tracking errors
162 }
163}
164
165const PLATFORM_TARGETS = {
166 'linux-x64': `${packageName}-linux-x64.tar.gz`,

Callers 1

downloadBinaryFunction · 0.70

Calls 3

requestMethod · 0.80
getPostHogConfigFunction · 0.70
onMethod · 0.65

Tested by

no test coverage detected