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

Function trackUpdateFailed

cli/release-staging/index.js:121–164  ·  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 isStaging: true,
138 ...context,
139 },
140 timestamp: new Date().toISOString(),
141 })
142
143 const parsedUrl = new URL(`${posthogConfig.host}/capture/`)
144 const isHttps = parsedUrl.protocol === 'https:'
145 const options = {
146 hostname: parsedUrl.hostname,
147 port: parsedUrl.port || (isHttps ? 443 : 80),
148 path: parsedUrl.pathname + parsedUrl.search,
149 method: 'POST',
150 headers: {
151 'Content-Type': 'application/json',
152 'Content-Length': Buffer.byteLength(payload),
153 },
154 }
155
156 const transport = isHttps ? https : http
157 const req = transport.request(options)
158 req.on('error', () => {}) // Silently ignore errors
159 req.write(payload)
160 req.end()
161 } catch (e) {
162 // Silently ignore any tracking errors
163 }
164}
165
166const PLATFORM_TARGETS = {
167 '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