snow-flow 10.0.71 → 10.0.73
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/usage/anonymous-telemetry.ts +18 -24
package/package.json
CHANGED
|
@@ -34,11 +34,11 @@ async function sendPing(payload: Record<string, unknown>): Promise<void> {
|
|
|
34
34
|
method: "POST",
|
|
35
35
|
headers: { "Content-Type": "application/json" },
|
|
36
36
|
body: JSON.stringify(payload),
|
|
37
|
-
signal: AbortSignal.timeout(
|
|
37
|
+
signal: AbortSignal.timeout(3_000),
|
|
38
38
|
})
|
|
39
|
-
log.info("telemetry ping sent", { status: response.status })
|
|
39
|
+
log.info("telemetry ping sent", { status: response.status, type: payload.type })
|
|
40
40
|
} catch (error) {
|
|
41
|
-
log.info("telemetry ping failed", { error: String(error) })
|
|
41
|
+
log.info("telemetry ping failed", { error: String(error), type: payload.type })
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
|
|
@@ -59,6 +59,7 @@ export namespace AnonymousTelemetry {
|
|
|
59
59
|
let messageCount = 0
|
|
60
60
|
let configDisabled = false
|
|
61
61
|
const startTime = Date.now()
|
|
62
|
+
const sessionId = crypto.randomUUID()
|
|
62
63
|
|
|
63
64
|
const unsubs = [
|
|
64
65
|
Bus.subscribe(MessageV2.Event.Updated, (event) => {
|
|
@@ -66,22 +67,17 @@ export namespace AnonymousTelemetry {
|
|
|
66
67
|
}),
|
|
67
68
|
]
|
|
68
69
|
|
|
69
|
-
|
|
70
|
-
const startPayload = {
|
|
70
|
+
const basePayload = {
|
|
71
71
|
machineId,
|
|
72
|
+
sessionId,
|
|
72
73
|
version: Installation.VERSION,
|
|
73
74
|
channel: Installation.CHANNEL,
|
|
74
75
|
os: process.platform,
|
|
75
76
|
arch: process.arch,
|
|
76
|
-
sessionDurationSec: 0,
|
|
77
|
-
messageCount: 0,
|
|
78
|
-
timestamp: Date.now(),
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
log.info("anonymous telemetry initializing", { machineId: machineId.slice(0, 8) + "..." })
|
|
82
80
|
|
|
83
|
-
// Check config opt-out in background, send start ping regardless
|
|
84
|
-
// (if config says disabled, we skip the dispose ping)
|
|
85
81
|
Config.get()
|
|
86
82
|
.then((config) => {
|
|
87
83
|
if (config.telemetry === false) {
|
|
@@ -92,12 +88,11 @@ export namespace AnonymousTelemetry {
|
|
|
92
88
|
return
|
|
93
89
|
}
|
|
94
90
|
log.info("anonymous telemetry active, sending start ping")
|
|
95
|
-
sendPing(
|
|
91
|
+
sendPing({ ...basePayload, type: "start", sessionDurationSec: 0, messageCount: 0, timestamp: Date.now() })
|
|
96
92
|
})
|
|
97
93
|
.catch(() => {
|
|
98
|
-
// Config unavailable — send ping anyway (opt-in by default)
|
|
99
94
|
log.info("anonymous telemetry active (config unavailable), sending start ping")
|
|
100
|
-
sendPing(
|
|
95
|
+
sendPing({ ...basePayload, type: "start", sessionDurationSec: 0, messageCount: 0, timestamp: Date.now() })
|
|
101
96
|
})
|
|
102
97
|
|
|
103
98
|
return {
|
|
@@ -105,8 +100,14 @@ export namespace AnonymousTelemetry {
|
|
|
105
100
|
unsubs,
|
|
106
101
|
startTime,
|
|
107
102
|
machineId,
|
|
108
|
-
|
|
109
|
-
|
|
103
|
+
sessionId,
|
|
104
|
+
basePayload,
|
|
105
|
+
get messageCount() {
|
|
106
|
+
return messageCount
|
|
107
|
+
},
|
|
108
|
+
get configDisabled() {
|
|
109
|
+
return configDisabled
|
|
110
|
+
},
|
|
110
111
|
}
|
|
111
112
|
},
|
|
112
113
|
async (current) => {
|
|
@@ -115,16 +116,9 @@ export namespace AnonymousTelemetry {
|
|
|
115
116
|
|
|
116
117
|
const sessionDurationSec = Math.round((Date.now() - current.startTime) / 1000)
|
|
117
118
|
|
|
118
|
-
// Re-check config opt-out before sending dispose ping
|
|
119
|
-
const config = await Config.get().catch(() => undefined)
|
|
120
|
-
if (config?.telemetry === false) return
|
|
121
|
-
|
|
122
119
|
await sendPing({
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
channel: Installation.CHANNEL,
|
|
126
|
-
os: process.platform,
|
|
127
|
-
arch: process.arch,
|
|
120
|
+
...current.basePayload,
|
|
121
|
+
type: "end",
|
|
128
122
|
sessionDurationSec,
|
|
129
123
|
messageCount: current.messageCount,
|
|
130
124
|
timestamp: Date.now(),
|