git-watchtower 2.1.6 → 2.1.7
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/config.js +9 -2
- package/src/telemetry/index.js +19 -14
package/package.json
CHANGED
package/src/telemetry/config.js
CHANGED
|
@@ -31,7 +31,7 @@ function getConfigPath() {
|
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Load telemetry config from disk
|
|
34
|
-
* @returns {{ telemetryEnabled: boolean, distinctId
|
|
34
|
+
* @returns {{ telemetryEnabled: boolean, distinctId?: string, promptedAt: string } | null}
|
|
35
35
|
*/
|
|
36
36
|
function loadTelemetryConfig() {
|
|
37
37
|
try {
|
|
@@ -48,7 +48,14 @@ function loadTelemetryConfig() {
|
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* Save telemetry config to disk
|
|
51
|
-
*
|
|
51
|
+
*
|
|
52
|
+
* `distinctId` is optional: when the user declines telemetry we persist
|
|
53
|
+
* `{ telemetryEnabled: false, promptedAt }` only — no persistent identifier
|
|
54
|
+
* lands on disk for declining users. `getOrCreateDistinctId` already
|
|
55
|
+
* handles the missing case by minting a fresh UUID if the user later
|
|
56
|
+
* opts in.
|
|
57
|
+
*
|
|
58
|
+
* @param {{ telemetryEnabled: boolean, distinctId?: string, promptedAt: string }} config
|
|
52
59
|
*/
|
|
53
60
|
function saveTelemetryConfig(config) {
|
|
54
61
|
const dir = getConfigDir();
|
package/src/telemetry/index.js
CHANGED
|
@@ -58,25 +58,30 @@ async function promptIfNeeded(promptYesNo) {
|
|
|
58
58
|
console.log('\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518');
|
|
59
59
|
console.log('');
|
|
60
60
|
|
|
61
|
-
const distinctId = config.getOrCreateDistinctId();
|
|
62
|
-
|
|
63
|
-
// Fire analytics_prompt_shown event — always sent regardless of user's choice
|
|
64
|
-
analytics.captureAlways('analytics_prompt_shown', distinctId);
|
|
65
|
-
|
|
66
61
|
const answer = await promptYesNo('Enable anonymous telemetry to help improve Git Watchtower?', false);
|
|
67
62
|
|
|
68
|
-
// Fire analytics_decision event — always sent so we know opt-in/out rates
|
|
69
|
-
analytics.captureAlways('analytics_decision', distinctId, { opted_in: answer });
|
|
70
|
-
|
|
71
|
-
config.saveTelemetryConfig({
|
|
72
|
-
telemetryEnabled: answer,
|
|
73
|
-
distinctId,
|
|
74
|
-
promptedAt: new Date().toISOString(),
|
|
75
|
-
});
|
|
76
|
-
|
|
77
63
|
if (answer) {
|
|
64
|
+
// Consent given: assign and persist a stable distinctId, then fire the
|
|
65
|
+
// prompt-shown and decision events so opt-in rates are observable.
|
|
66
|
+
const distinctId = config.getOrCreateDistinctId();
|
|
67
|
+
analytics.captureAlways('analytics_prompt_shown', distinctId);
|
|
68
|
+
analytics.captureAlways('analytics_decision', distinctId, { opted_in: true });
|
|
69
|
+
config.saveTelemetryConfig({
|
|
70
|
+
telemetryEnabled: true,
|
|
71
|
+
distinctId,
|
|
72
|
+
promptedAt: new Date().toISOString(),
|
|
73
|
+
});
|
|
78
74
|
console.log(' Thank you! Telemetry enabled.\n');
|
|
79
75
|
} else {
|
|
76
|
+
// No consent: don't ship any events to PostHog and don't persist a
|
|
77
|
+
// distinctId on disk. Previously the prompt-shown and decision events
|
|
78
|
+
// fired regardless of the answer, tagged with the user's persistent
|
|
79
|
+
// distinctId — which contradicted the README's "anonymous, opt-in"
|
|
80
|
+
// pitch and meant declining users still showed up in analytics.
|
|
81
|
+
config.saveTelemetryConfig({
|
|
82
|
+
telemetryEnabled: false,
|
|
83
|
+
promptedAt: new Date().toISOString(),
|
|
84
|
+
});
|
|
80
85
|
console.log(' No problem! Telemetry disabled.\n');
|
|
81
86
|
}
|
|
82
87
|
}
|