cchubber 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cchubber",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "description": "What you spent. Why you spent it. Is that normal. — Claude Code usage diagnosis with beautiful HTML reports.",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli/index.js CHANGED
@@ -164,8 +164,9 @@ async function main() {
164
164
 
165
165
  // Anonymous telemetry (opt out: --no-telemetry or CC_HUBBER_TELEMETRY=0)
166
166
  if (shouldSendTelemetry(flags)) {
167
- sendTelemetry(report);
168
- console.log(' ○ Anonymous stats shared (opt out: --no-telemetry)');
167
+ console.log(' ○ Sharing anonymous stats...');
168
+ await sendTelemetry(report);
169
+ console.log(' ✓ Stats shared (opt out: --no-telemetry)');
169
170
  }
170
171
 
171
172
  const outputPath = flags.output || join(process.cwd(), 'cchubber-report.html');
package/src/telemetry.js CHANGED
@@ -136,24 +136,29 @@ export function sendTelemetry(report) {
136
136
  ...gatherEnvironmentData(),
137
137
  };
138
138
 
139
- // Fire and forget never blocks the CLI
140
- try {
141
- const data = JSON.stringify(payload);
142
- const url = new URL(TELEMETRY_URL);
143
- const req = https.request({
144
- hostname: url.hostname,
145
- path: url.pathname,
146
- method: 'POST',
147
- headers: { 'Content-Type': 'application/json', 'Content-Length': data.length },
148
- });
149
- req.on('error', () => {}); // silent fail
150
- req.setTimeout(3000, () => req.destroy());
151
- req.write(data);
152
- req.end();
153
- markTelemetrySent();
154
- } catch {
155
- // never crash on telemetry
156
- }
139
+ // Returns a promise that resolves when the request completes (or times out)
140
+ // CLI must await this before exiting, otherwise the process kills the request
141
+ return new Promise((resolve) => {
142
+ try {
143
+ const data = JSON.stringify(payload);
144
+ const url = new URL(TELEMETRY_URL);
145
+ const req = https.request({
146
+ hostname: url.hostname,
147
+ path: url.pathname,
148
+ method: 'POST',
149
+ headers: { 'Content-Type': 'application/json', 'Content-Length': Buffer.byteLength(data) },
150
+ }, (res) => {
151
+ res.resume(); // drain response
152
+ res.on('end', () => { markTelemetrySent(); resolve(); });
153
+ });
154
+ req.on('error', () => resolve()); // silent fail, still resolve
155
+ req.setTimeout(4000, () => { req.destroy(); resolve(); });
156
+ req.write(data);
157
+ req.end();
158
+ } catch {
159
+ resolve(); // never block on telemetry failure
160
+ }
161
+ });
157
162
  }
158
163
 
159
164
  function costBucket(cost) {