trackfox-electron 1.0.1 → 1.0.2
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/dist/index.cjs +17 -4
- package/dist/index.js +17 -4
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -119,7 +119,8 @@ var EventQueue = class {
|
|
|
119
119
|
if (this.online) {
|
|
120
120
|
try {
|
|
121
121
|
await this.flush(payload);
|
|
122
|
-
} catch {
|
|
122
|
+
} catch (err) {
|
|
123
|
+
console.error("[TrackFox] send failed, queuing for retry:", err);
|
|
123
124
|
this.queue.push(payload);
|
|
124
125
|
}
|
|
125
126
|
} else {
|
|
@@ -131,7 +132,8 @@ var EventQueue = class {
|
|
|
131
132
|
for (const payload of pending) {
|
|
132
133
|
try {
|
|
133
134
|
await this.flush(payload);
|
|
134
|
-
} catch {
|
|
135
|
+
} catch (err) {
|
|
136
|
+
console.error("[TrackFox] retry failed:", err);
|
|
135
137
|
this.queue.unshift(payload);
|
|
136
138
|
break;
|
|
137
139
|
}
|
|
@@ -202,7 +204,14 @@ var TrackFoxTracker = class {
|
|
|
202
204
|
}
|
|
203
205
|
async send(payload) {
|
|
204
206
|
const url = `${this.options.apiUrl}/api/events`;
|
|
205
|
-
|
|
207
|
+
let fetchFn;
|
|
208
|
+
try {
|
|
209
|
+
const { net } = await import("electron");
|
|
210
|
+
fetchFn = net.fetch.bind(net);
|
|
211
|
+
} catch {
|
|
212
|
+
fetchFn = fetch;
|
|
213
|
+
}
|
|
214
|
+
const response = await fetchFn(url, {
|
|
206
215
|
method: "POST",
|
|
207
216
|
headers: {
|
|
208
217
|
"Content-Type": "application/json",
|
|
@@ -212,7 +221,11 @@ var TrackFoxTracker = class {
|
|
|
212
221
|
},
|
|
213
222
|
body: JSON.stringify(payload)
|
|
214
223
|
});
|
|
215
|
-
if (!response.ok)
|
|
224
|
+
if (!response.ok) {
|
|
225
|
+
const body = await response.text().catch(() => "");
|
|
226
|
+
throw new Error(`TrackFox: HTTP ${response.status}${body ? ` \u2014 ${body}` : ""}`);
|
|
227
|
+
}
|
|
228
|
+
if (this.options?.debug) console.log("[TrackFox] event sent:", payload.type, payload.href);
|
|
216
229
|
}
|
|
217
230
|
};
|
|
218
231
|
var TrackFox = new TrackFoxTracker();
|
package/dist/index.js
CHANGED
|
@@ -83,7 +83,8 @@ var EventQueue = class {
|
|
|
83
83
|
if (this.online) {
|
|
84
84
|
try {
|
|
85
85
|
await this.flush(payload);
|
|
86
|
-
} catch {
|
|
86
|
+
} catch (err) {
|
|
87
|
+
console.error("[TrackFox] send failed, queuing for retry:", err);
|
|
87
88
|
this.queue.push(payload);
|
|
88
89
|
}
|
|
89
90
|
} else {
|
|
@@ -95,7 +96,8 @@ var EventQueue = class {
|
|
|
95
96
|
for (const payload of pending) {
|
|
96
97
|
try {
|
|
97
98
|
await this.flush(payload);
|
|
98
|
-
} catch {
|
|
99
|
+
} catch (err) {
|
|
100
|
+
console.error("[TrackFox] retry failed:", err);
|
|
99
101
|
this.queue.unshift(payload);
|
|
100
102
|
break;
|
|
101
103
|
}
|
|
@@ -166,7 +168,14 @@ var TrackFoxTracker = class {
|
|
|
166
168
|
}
|
|
167
169
|
async send(payload) {
|
|
168
170
|
const url = `${this.options.apiUrl}/api/events`;
|
|
169
|
-
|
|
171
|
+
let fetchFn;
|
|
172
|
+
try {
|
|
173
|
+
const { net } = await import("electron");
|
|
174
|
+
fetchFn = net.fetch.bind(net);
|
|
175
|
+
} catch {
|
|
176
|
+
fetchFn = fetch;
|
|
177
|
+
}
|
|
178
|
+
const response = await fetchFn(url, {
|
|
170
179
|
method: "POST",
|
|
171
180
|
headers: {
|
|
172
181
|
"Content-Type": "application/json",
|
|
@@ -176,7 +185,11 @@ var TrackFoxTracker = class {
|
|
|
176
185
|
},
|
|
177
186
|
body: JSON.stringify(payload)
|
|
178
187
|
});
|
|
179
|
-
if (!response.ok)
|
|
188
|
+
if (!response.ok) {
|
|
189
|
+
const body = await response.text().catch(() => "");
|
|
190
|
+
throw new Error(`TrackFox: HTTP ${response.status}${body ? ` \u2014 ${body}` : ""}`);
|
|
191
|
+
}
|
|
192
|
+
if (this.options?.debug) console.log("[TrackFox] event sent:", payload.type, payload.href);
|
|
180
193
|
}
|
|
181
194
|
};
|
|
182
195
|
var TrackFox = new TrackFoxTracker();
|