cchubber 0.3.8 → 0.3.9
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 +1 -1
- package/src/telemetry.js +15 -0
package/package.json
CHANGED
package/src/telemetry.js
CHANGED
|
@@ -19,9 +19,23 @@ export function shouldSendTelemetry(flags) {
|
|
|
19
19
|
if (flags.noTelemetry) return false;
|
|
20
20
|
if (process.env.CC_HUBBER_TELEMETRY === '0') return false;
|
|
21
21
|
if (process.env.DO_NOT_TRACK === '1') return false;
|
|
22
|
+
|
|
23
|
+
// Throttle: once per 24 hours per machine
|
|
24
|
+
const stampFile = join(homedir(), '.cchubber-last-telemetry');
|
|
25
|
+
try {
|
|
26
|
+
if (existsSync(stampFile)) {
|
|
27
|
+
const last = parseInt(readFileSync(stampFile, 'utf-8').trim());
|
|
28
|
+
if (Date.now() - last < 86400000) return false; // <24h since last send
|
|
29
|
+
}
|
|
30
|
+
} catch {}
|
|
31
|
+
|
|
22
32
|
return true;
|
|
23
33
|
}
|
|
24
34
|
|
|
35
|
+
function markTelemetrySent() {
|
|
36
|
+
try { writeFileSync(join(homedir(), '.cchubber-last-telemetry'), String(Date.now())); } catch {}
|
|
37
|
+
}
|
|
38
|
+
|
|
25
39
|
export function sendTelemetry(report) {
|
|
26
40
|
const payload = {
|
|
27
41
|
v: '0.3.3',
|
|
@@ -136,6 +150,7 @@ export function sendTelemetry(report) {
|
|
|
136
150
|
req.setTimeout(3000, () => req.destroy());
|
|
137
151
|
req.write(data);
|
|
138
152
|
req.end();
|
|
153
|
+
markTelemetrySent();
|
|
139
154
|
} catch {
|
|
140
155
|
// never crash on telemetry
|
|
141
156
|
}
|