create-sonicjs 3.0.0-beta.8 → 3.0.0-beta.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/telemetry.js +10 -5
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-sonicjs",
3
- "version": "3.0.0-beta.8",
3
+ "version": "3.0.0-beta.9",
4
4
  "description": "Create a new SonicJS application with zero configuration",
5
5
  "type": "module",
6
6
  "bin": {
package/src/telemetry.js CHANGED
@@ -76,6 +76,8 @@ async function initTelemetry() {
76
76
  }
77
77
  }
78
78
 
79
+ const pendingRequests = []
80
+
79
81
  /**
80
82
  * Track an event using custom SonicJS stats endpoint
81
83
  */
@@ -105,12 +107,13 @@ async function track(event, properties = {}) {
105
107
  }
106
108
  }
107
109
 
108
- // Fire and forget - don't block on response
109
- fetch(`${TELEMETRY_ENDPOINT}/v1/events`, {
110
+ const req = fetch(`${TELEMETRY_ENDPOINT}/v1/events`, {
110
111
  method: 'POST',
111
112
  headers: { 'Content-Type': 'application/json' },
112
113
  body: JSON.stringify(payload)
113
- }).catch(() => {}) // Silent fail
114
+ }).catch(() => {})
115
+
116
+ pendingRequests.push(req)
114
117
 
115
118
  if (DEBUG) {
116
119
  console.log('[Telemetry] Tracked:', event, payload)
@@ -124,10 +127,12 @@ async function track(event, properties = {}) {
124
127
  }
125
128
 
126
129
  /**
127
- * Shutdown telemetry (no-op for fetch-based telemetry)
130
+ * Shutdown telemetry — flush pending requests (max 3s wait)
128
131
  */
129
132
  async function shutdown() {
130
- // No-op - fetch requests are fire and forget
133
+ if (pendingRequests.length === 0) return
134
+ const timeout = new Promise(resolve => setTimeout(resolve, 3000))
135
+ await Promise.race([Promise.all(pendingRequests), timeout])
131
136
  }
132
137
 
133
138
  /**