@logwolf/client-js 1.0.0 → 1.1.1
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/logwolf-client.d.ts +57 -8
- package/dist/logwolf-client.js +182 -41
- package/dist/logwolf-client.js.map +1 -1
- package/package.json +26 -21
package/dist/logwolf-client.d.ts
CHANGED
|
@@ -55,6 +55,12 @@ declare const LogwolfConfigSchema: z.ZodObject<{
|
|
|
55
55
|
apiKey: z.ZodString;
|
|
56
56
|
sampleRate: z.ZodOptional<z.ZodNumber>;
|
|
57
57
|
errorSampleRate: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
flushIntervalMs: z.ZodNumber;
|
|
59
|
+
maxBatchSize: z.ZodNumber;
|
|
60
|
+
maxQueueSize: z.ZodNumber;
|
|
61
|
+
retryDelaysMs: z.ZodArray<z.ZodNumber>;
|
|
62
|
+
requestTimeoutMs: z.ZodNumber;
|
|
63
|
+
onDropped: z.ZodOptional<z.ZodFunction<z.ZodTuple<readonly [z.ZodArray<z.ZodAny>, z.ZodString], null>, z.core.$ZodFunctionOut>>;
|
|
58
64
|
}, z.core.$strip>;
|
|
59
65
|
type LogwolfConfig = z.infer<typeof LogwolfConfigSchema>;
|
|
60
66
|
declare const LogwolfEventDTOSchema: z.ZodObject<{
|
|
@@ -83,35 +89,78 @@ declare class LogwolfEvent {
|
|
|
83
89
|
severity: LogwolfEventDTO['severity'];
|
|
84
90
|
readonly tags: LogwolfEventDTO['tags'];
|
|
85
91
|
readonly data: NonNullable<LogwolfEventDTO['data']>;
|
|
92
|
+
private _duration;
|
|
86
93
|
constructor(props: LogwolfEventDTO);
|
|
94
|
+
/**
|
|
95
|
+
* Stops the stopwatch. Duration is frozen from construction to this call.
|
|
96
|
+
* Called automatically by `capture()` and `create()` — you only need to
|
|
97
|
+
* call this manually if you want to stop the clock before those methods.
|
|
98
|
+
*
|
|
99
|
+
* Calling `stop()` more than once is a no-op; the first call wins.
|
|
100
|
+
*/
|
|
101
|
+
stop(): void;
|
|
87
102
|
setName(n: string): void;
|
|
88
103
|
setSeverity(s: Severity): void;
|
|
89
104
|
set(key: string, value: unknown): void;
|
|
90
105
|
get(key: string): any;
|
|
91
106
|
addTag(t: string): void;
|
|
92
|
-
|
|
107
|
+
toObject(): {
|
|
108
|
+
severity: "info" | "warning" | "error" | "critical";
|
|
109
|
+
data: string;
|
|
110
|
+
name: string;
|
|
111
|
+
tags: string[];
|
|
112
|
+
duration?: number | undefined;
|
|
113
|
+
};
|
|
93
114
|
}
|
|
94
115
|
|
|
95
116
|
declare class Logwolf {
|
|
96
117
|
private readonly config;
|
|
118
|
+
private readonly baseUrl;
|
|
119
|
+
private queue;
|
|
120
|
+
private flushTimer;
|
|
121
|
+
private flushPromise;
|
|
97
122
|
constructor(config: LogwolfConfig);
|
|
123
|
+
private shouldCapture;
|
|
98
124
|
private getHeaders;
|
|
99
125
|
private handleResponse;
|
|
100
|
-
private
|
|
126
|
+
private sleep;
|
|
127
|
+
private fetchWithTimeout;
|
|
101
128
|
/**
|
|
102
|
-
*
|
|
129
|
+
* Enqueues an event for batched delivery. Respects sampleRate and
|
|
130
|
+
* errorSampleRate. Returns true if the event was accepted into the queue,
|
|
131
|
+
* false if it was dropped (either by sampling or queue cap).
|
|
132
|
+
*
|
|
133
|
+
* capture() is synchronous and returns immediately — delivery happens in
|
|
134
|
+
* the background. Call flush() before process exit to drain the queue.
|
|
103
135
|
*/
|
|
104
|
-
|
|
136
|
+
capture(event: LogwolfEvent): boolean;
|
|
105
137
|
/**
|
|
106
|
-
*
|
|
138
|
+
* Sends an event immediately, bypassing sampling and the queue.
|
|
139
|
+
* Awaitable — resolves when the server has accepted the event.
|
|
107
140
|
*/
|
|
108
|
-
|
|
141
|
+
create(event: LogwolfEvent): Promise<void>;
|
|
109
142
|
getAll(p?: Pagination): Promise<LogwolfEventData[]>;
|
|
110
143
|
getOne(id: string): Promise<LogwolfEventData | undefined>;
|
|
111
144
|
delete(dto: DeleteLogwolfEventDTO): Promise<void>;
|
|
145
|
+
/**
|
|
146
|
+
* Flushes all queued events immediately. Call this before process exit
|
|
147
|
+
* or page unload to avoid losing buffered events.
|
|
148
|
+
*
|
|
149
|
+
* If a background flush is already in progress, waits for it to complete
|
|
150
|
+
* before flushing any remaining events — so all enqueued events are sent.
|
|
151
|
+
*/
|
|
152
|
+
flush(): Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* Clears the flush interval and prevents further background flushing.
|
|
155
|
+
* Call this to allow Node.js to exit cleanly, or in test teardown.
|
|
156
|
+
* Any queued events that haven't been flushed will be lost — call
|
|
157
|
+
* flush() first if you need to drain the queue.
|
|
158
|
+
*/
|
|
159
|
+
destroy(): void;
|
|
160
|
+
private enqueue;
|
|
161
|
+
private flushQueue;
|
|
162
|
+
private sendBatchWithRetry;
|
|
112
163
|
}
|
|
113
164
|
|
|
114
|
-
//# sourceMappingURL=index.d.ts.map
|
|
115
|
-
|
|
116
165
|
export { CreateLogwolfEventDTOSchema, DeleteLogwolfEventDTOSchema, Logwolf, LogwolfConfigSchema, LogwolfDatetimeSchema, LogwolfEvent, LogwolfEventDTOSchema, LogwolfEventDataSchema, LogwolfEventSchema, LogwolfEventSeveritySchema, PaginationSchema, Logwolf as default };
|
|
117
166
|
export type { CreateLogwolfEventDTO, DeleteLogwolfEventDTO, LogwolfApiResponse, LogwolfConfig, LogwolfEventDTO, LogwolfEventData, Pagination, Severity };
|
package/dist/logwolf-client.js
CHANGED
|
@@ -42,9 +42,16 @@ const CreateLogwolfEventDTOSchema = LogwolfEventSchema.pick({
|
|
|
42
42
|
const DeleteLogwolfEventDTOSchema = LogwolfEventSchema.pick({ id: true });
|
|
43
43
|
const LogwolfConfigSchema = z.object({
|
|
44
44
|
url: z.url(),
|
|
45
|
-
apiKey: z.string().startsWith('lw_'),
|
|
45
|
+
apiKey: z.string().startsWith('lw_').min(10),
|
|
46
46
|
sampleRate: z.number().positive().lte(1).optional(),
|
|
47
47
|
errorSampleRate: z.number().positive().lte(1).optional(),
|
|
48
|
+
// Batching options
|
|
49
|
+
flushIntervalMs: z.number().positive(),
|
|
50
|
+
maxBatchSize: z.number().positive(),
|
|
51
|
+
maxQueueSize: z.number().positive(),
|
|
52
|
+
retryDelaysMs: z.number().gte(0).array(),
|
|
53
|
+
requestTimeoutMs: z.number().positive(),
|
|
54
|
+
onDropped: z.function({ input: [z.any().array(), z.string()] }).optional(),
|
|
48
55
|
});
|
|
49
56
|
const LogwolfEventDTOSchema = LogwolfEventSchema.pick({
|
|
50
57
|
name: true,
|
|
@@ -70,67 +77,91 @@ const PaginationSchema = z.codec(z.instanceof(URLSearchParams), z.object({
|
|
|
70
77
|
|
|
71
78
|
class Logwolf {
|
|
72
79
|
config;
|
|
80
|
+
baseUrl;
|
|
81
|
+
// Queue holds stopped LogwolfEvent instances ready to be flushed.
|
|
82
|
+
queue = [];
|
|
83
|
+
flushTimer = null;
|
|
84
|
+
flushPromise = null;
|
|
73
85
|
constructor(config) {
|
|
74
|
-
LogwolfConfigSchema.parse(config);
|
|
75
|
-
|
|
86
|
+
this.config = LogwolfConfigSchema.parse(config);
|
|
87
|
+
// Normalize to a trailing slash so relative paths append correctly.
|
|
88
|
+
const raw = this.config.url;
|
|
89
|
+
this.baseUrl = new URL(raw.endsWith('/') ? raw : raw + '/');
|
|
76
90
|
}
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
91
|
+
// --- Private: helpers ---
|
|
92
|
+
shouldCapture(event) {
|
|
93
|
+
switch (event.severity) {
|
|
94
|
+
case 'error':
|
|
95
|
+
return this.config.errorSampleRate === undefined || event.random >= 1 - this.config.errorSampleRate;
|
|
96
|
+
case 'critical':
|
|
97
|
+
return true;
|
|
98
|
+
default:
|
|
99
|
+
return this.config.sampleRate === undefined || event.random >= 1 - this.config.sampleRate;
|
|
81
100
|
}
|
|
82
|
-
|
|
101
|
+
}
|
|
102
|
+
getHeaders() {
|
|
103
|
+
return {
|
|
104
|
+
'Content-Type': 'application/json',
|
|
105
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
106
|
+
};
|
|
83
107
|
}
|
|
84
108
|
handleResponse(r) {
|
|
85
109
|
if (r.error)
|
|
86
110
|
throw new Error(r.message);
|
|
87
111
|
return r.data;
|
|
88
112
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
return this.config.sampleRate === undefined || e.random >= 1 - this.config.sampleRate;
|
|
97
|
-
}
|
|
113
|
+
sleep(ms) {
|
|
114
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
115
|
+
}
|
|
116
|
+
async fetchWithTimeout(url, init) {
|
|
117
|
+
const controller = new AbortController();
|
|
118
|
+
const id = setTimeout(() => controller.abort(), this.config.requestTimeoutMs);
|
|
119
|
+
return fetch(url, { ...init, signal: controller.signal }).finally(() => clearTimeout(id));
|
|
98
120
|
}
|
|
121
|
+
// --- Public API ---
|
|
99
122
|
/**
|
|
100
|
-
*
|
|
123
|
+
* Enqueues an event for batched delivery. Respects sampleRate and
|
|
124
|
+
* errorSampleRate. Returns true if the event was accepted into the queue,
|
|
125
|
+
* false if it was dropped (either by sampling or queue cap).
|
|
126
|
+
*
|
|
127
|
+
* capture() is synchronous and returns immediately — delivery happens in
|
|
128
|
+
* the background. Call flush() before process exit to drain the queue.
|
|
101
129
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
.then((r) => this.handleResponse(r));
|
|
107
|
-
return res;
|
|
130
|
+
capture(event) {
|
|
131
|
+
if (!this.shouldCapture(event))
|
|
132
|
+
return false;
|
|
133
|
+
return this.enqueue(event);
|
|
108
134
|
}
|
|
109
135
|
/**
|
|
110
|
-
*
|
|
136
|
+
* Sends an event immediately, bypassing sampling and the queue.
|
|
137
|
+
* Awaitable — resolves when the server has accepted the event.
|
|
111
138
|
*/
|
|
112
|
-
async
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
139
|
+
async create(event) {
|
|
140
|
+
event.stop();
|
|
141
|
+
const url = new URL('logs', this.baseUrl);
|
|
142
|
+
const res = await this.fetchWithTimeout(url, {
|
|
143
|
+
method: 'POST',
|
|
144
|
+
headers: this.getHeaders(),
|
|
145
|
+
body: JSON.stringify(event.toObject()),
|
|
146
|
+
})
|
|
147
|
+
.then((r) => r.json())
|
|
148
|
+
.then((r) => this.handleResponse(r));
|
|
149
|
+
return res;
|
|
116
150
|
}
|
|
117
151
|
async getAll(p) {
|
|
118
152
|
const params = p ? PaginationSchema.encode(p) : '';
|
|
119
|
-
const url = new URL('
|
|
120
|
-
const res = await
|
|
153
|
+
const url = new URL('logs?' + params, this.baseUrl);
|
|
154
|
+
const res = await this.fetchWithTimeout(url, { method: 'GET', headers: this.getHeaders() })
|
|
121
155
|
.then((r) => r.json())
|
|
122
156
|
.then((r) => this.handleResponse(r));
|
|
123
157
|
return z.array(LogwolfEventSchema).parse(res);
|
|
124
158
|
}
|
|
125
159
|
async getOne(id) {
|
|
126
|
-
|
|
127
|
-
return r.find((i) => i.id === id);
|
|
128
|
-
});
|
|
129
|
-
return res;
|
|
160
|
+
return this.getAll().then((r) => r.find((i) => i.id === id));
|
|
130
161
|
}
|
|
131
162
|
async delete(dto) {
|
|
132
|
-
const url = new URL('
|
|
133
|
-
const res = await
|
|
163
|
+
const url = new URL('logs', this.baseUrl);
|
|
164
|
+
const res = await this.fetchWithTimeout(url, {
|
|
134
165
|
method: 'DELETE',
|
|
135
166
|
headers: this.getHeaders(),
|
|
136
167
|
body: JSON.stringify(DeleteLogwolfEventDTOSchema.parse(dto)),
|
|
@@ -139,6 +170,104 @@ class Logwolf {
|
|
|
139
170
|
.then((r) => this.handleResponse(r));
|
|
140
171
|
return res;
|
|
141
172
|
}
|
|
173
|
+
/**
|
|
174
|
+
* Flushes all queued events immediately. Call this before process exit
|
|
175
|
+
* or page unload to avoid losing buffered events.
|
|
176
|
+
*
|
|
177
|
+
* If a background flush is already in progress, waits for it to complete
|
|
178
|
+
* before flushing any remaining events — so all enqueued events are sent.
|
|
179
|
+
*/
|
|
180
|
+
async flush() {
|
|
181
|
+
if (this.flushPromise)
|
|
182
|
+
await this.flushPromise;
|
|
183
|
+
if (this.queue.length > 0)
|
|
184
|
+
await this.flushQueue();
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Clears the flush interval and prevents further background flushing.
|
|
188
|
+
* Call this to allow Node.js to exit cleanly, or in test teardown.
|
|
189
|
+
* Any queued events that haven't been flushed will be lost — call
|
|
190
|
+
* flush() first if you need to drain the queue.
|
|
191
|
+
*/
|
|
192
|
+
destroy() {
|
|
193
|
+
if (this.flushTimer !== null) {
|
|
194
|
+
clearInterval(this.flushTimer);
|
|
195
|
+
this.flushTimer = null;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// --- Private: queue management ---
|
|
199
|
+
enqueue(event) {
|
|
200
|
+
// Stop the stopwatch at enqueue time — this is the correct moment.
|
|
201
|
+
event.stop();
|
|
202
|
+
// Enforce the queue cap: drop the oldest event to make room.
|
|
203
|
+
if (this.queue.length >= this.config.maxQueueSize) {
|
|
204
|
+
const dropped = this.queue.splice(0, 1);
|
|
205
|
+
this.config.onDropped?.(dropped, 'queue_full');
|
|
206
|
+
}
|
|
207
|
+
this.queue.push(event);
|
|
208
|
+
// Start the flush timer lazily on first enqueue.
|
|
209
|
+
if (this.flushTimer === null) {
|
|
210
|
+
this.flushTimer = setInterval(() => {
|
|
211
|
+
this.flushQueue().catch(() => {
|
|
212
|
+
// Errors are handled inside flushQueue; this prevents
|
|
213
|
+
// unhandled promise rejection from the interval callback.
|
|
214
|
+
});
|
|
215
|
+
}, this.config.flushIntervalMs);
|
|
216
|
+
}
|
|
217
|
+
// Flush immediately if the batch size threshold is reached.
|
|
218
|
+
if (this.queue.length >= this.config.maxBatchSize) {
|
|
219
|
+
this.flushQueue().catch(() => { });
|
|
220
|
+
}
|
|
221
|
+
return true;
|
|
222
|
+
}
|
|
223
|
+
flushQueue() {
|
|
224
|
+
if (this.flushPromise !== null || this.queue.length === 0)
|
|
225
|
+
return Promise.resolve();
|
|
226
|
+
// Drain the queue into a local batch atomically. Any events captured
|
|
227
|
+
// during the flush go into the next batch.
|
|
228
|
+
const batch = this.queue.splice(0, this.queue.length);
|
|
229
|
+
this.flushPromise = this.sendBatchWithRetry(batch)
|
|
230
|
+
.catch(() => {
|
|
231
|
+
// All retries exhausted — notify caller via onDropped.
|
|
232
|
+
this.config.onDropped?.(batch, 'send_failed');
|
|
233
|
+
})
|
|
234
|
+
.finally(() => {
|
|
235
|
+
this.flushPromise = null;
|
|
236
|
+
});
|
|
237
|
+
return this.flushPromise;
|
|
238
|
+
}
|
|
239
|
+
async sendBatchWithRetry(batch) {
|
|
240
|
+
const url = new URL('logs/batch', this.baseUrl);
|
|
241
|
+
const body = JSON.stringify(batch.map((ev) => ev.toObject()));
|
|
242
|
+
let lastError;
|
|
243
|
+
for (let attempt = 0; attempt <= this.config.retryDelaysMs.length; attempt++) {
|
|
244
|
+
try {
|
|
245
|
+
const response = await this.fetchWithTimeout(url, {
|
|
246
|
+
method: 'POST',
|
|
247
|
+
headers: this.getHeaders(),
|
|
248
|
+
body,
|
|
249
|
+
});
|
|
250
|
+
// 401/403 — bad key, do not retry, surface immediately.
|
|
251
|
+
if (response.status === 401 || response.status === 403) {
|
|
252
|
+
this.config.onDropped?.(batch, `auth_error_${response.status}`);
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
if (response.ok)
|
|
256
|
+
return;
|
|
257
|
+
// Non-2xx that isn't an auth error — retry.
|
|
258
|
+
lastError = new Error(`Server returned ${response.status}`);
|
|
259
|
+
}
|
|
260
|
+
catch (err) {
|
|
261
|
+
// Network error — retry.
|
|
262
|
+
lastError = err;
|
|
263
|
+
}
|
|
264
|
+
// Wait before the next attempt, unless this was the last one.
|
|
265
|
+
if (attempt < this.config.retryDelaysMs.length) {
|
|
266
|
+
await this.sleep(this.config.retryDelaysMs[attempt]);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
throw lastError;
|
|
270
|
+
}
|
|
142
271
|
}
|
|
143
272
|
|
|
144
273
|
class LogwolfEvent {
|
|
@@ -149,6 +278,7 @@ class LogwolfEvent {
|
|
|
149
278
|
severity;
|
|
150
279
|
tags;
|
|
151
280
|
data = {};
|
|
281
|
+
_duration = null;
|
|
152
282
|
constructor(props) {
|
|
153
283
|
this.name = props.name;
|
|
154
284
|
this.severity = props.severity;
|
|
@@ -157,6 +287,18 @@ class LogwolfEvent {
|
|
|
157
287
|
this.data = props.data;
|
|
158
288
|
}
|
|
159
289
|
}
|
|
290
|
+
/**
|
|
291
|
+
* Stops the stopwatch. Duration is frozen from construction to this call.
|
|
292
|
+
* Called automatically by `capture()` and `create()` — you only need to
|
|
293
|
+
* call this manually if you want to stop the clock before those methods.
|
|
294
|
+
*
|
|
295
|
+
* Calling `stop()` more than once is a no-op; the first call wins.
|
|
296
|
+
*/
|
|
297
|
+
stop() {
|
|
298
|
+
if (this._duration === null) {
|
|
299
|
+
this._duration = Math.floor(performance.now() - this.start);
|
|
300
|
+
}
|
|
301
|
+
}
|
|
160
302
|
setName(n) {
|
|
161
303
|
this.name = n;
|
|
162
304
|
}
|
|
@@ -172,9 +314,8 @@ class LogwolfEvent {
|
|
|
172
314
|
addTag(t) {
|
|
173
315
|
this.tags.push(t);
|
|
174
316
|
}
|
|
175
|
-
|
|
176
|
-
const
|
|
177
|
-
const duration = Math.floor(now - this.start);
|
|
317
|
+
toObject() {
|
|
318
|
+
const duration = this._duration ?? Math.floor(performance.now() - this.start);
|
|
178
319
|
const encoded = CreateLogwolfEventDTOSchema.encode({
|
|
179
320
|
name: this.name,
|
|
180
321
|
severity: this.severity,
|
|
@@ -182,7 +323,7 @@ class LogwolfEvent {
|
|
|
182
323
|
data: this.data,
|
|
183
324
|
duration: duration,
|
|
184
325
|
});
|
|
185
|
-
return
|
|
326
|
+
return encoded;
|
|
186
327
|
}
|
|
187
328
|
}
|
|
188
329
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logwolf-client.js","sources":["lib/schema.js","lib/client.js","lib/event.js"],"sourcesContent":["import z from 'zod';\nexport const LogwolfEventSeveritySchema = z.enum(['info', 'warning', 'error', 'critical']);\nexport const LogwolfEventDataSchema = z.codec(z.string(), z.record(z.string(), z.any()), {\n decode: (jsonString, ctx) => {\n try {\n return JSON.parse(jsonString);\n }\n catch (err) {\n ctx.issues.push({\n code: 'invalid_format',\n format: 'json',\n input: jsonString,\n message: err.message,\n });\n return z.NEVER;\n }\n },\n encode: (value) => JSON.stringify(value),\n});\nexport const LogwolfDatetimeSchema = z.codec(z.iso.datetime(), z.date(), {\n decode: (isoString) => new Date(isoString),\n encode: (date) => date.toISOString(),\n});\nexport const LogwolfEventSchema = z.object({\n id: z.string(),\n name: z.string(),\n severity: LogwolfEventSeveritySchema,\n tags: z.array(z.string()),\n data: LogwolfEventDataSchema,\n duration: z.int().optional(),\n created_at: LogwolfDatetimeSchema,\n updated_at: LogwolfDatetimeSchema,\n});\nexport const CreateLogwolfEventDTOSchema = LogwolfEventSchema.pick({\n name: true,\n severity: true,\n tags: true,\n data: true,\n duration: true,\n});\nexport const DeleteLogwolfEventDTOSchema = LogwolfEventSchema.pick({ id: true });\nexport const LogwolfConfigSchema = z.object({\n url: z.url(),\n apiKey: z.string().startsWith('lw_'),\n sampleRate: z.number().positive().lte(1).optional(),\n errorSampleRate: z.number().positive().lte(1).optional(),\n});\nexport const LogwolfEventDTOSchema = LogwolfEventSchema.pick({\n name: true,\n severity: true,\n tags: true,\n data: true,\n}).partial({\n data: true,\n});\nexport const PaginationSchema = z.codec(z.instanceof(URLSearchParams), z.object({\n page: z.number().positive(),\n pageSize: z.number().positive(),\n}), {\n encode: (v) => {\n return new URLSearchParams({ page: '' + v.page, pageSize: '' + v.pageSize });\n },\n decode: (v) => {\n const page = v.get('page') ?? '0';\n const pageSize = v.get('pageSize') ?? '0';\n return { page: parseInt(page), pageSize: parseInt(pageSize) };\n },\n});\n//# sourceMappingURL=schema.js.map","import z from 'zod';\nimport { DeleteLogwolfEventDTOSchema, LogwolfConfigSchema, LogwolfEventSchema, PaginationSchema, } from './schema';\nexport class Logwolf {\n config;\n constructor(config) {\n LogwolfConfigSchema.parse(config);\n this.config = config;\n }\n getHeaders() {\n const headers = { 'Content-Type': 'application/json' };\n if (this.config.apiKey) {\n headers['Authorization'] = `Bearer ${this.config.apiKey}`;\n }\n return headers;\n }\n handleResponse(r) {\n if (r.error)\n throw new Error(r.message);\n return r.data;\n }\n shouldCapture(e) {\n switch (e.severity) {\n case 'error':\n return this.config.errorSampleRate === undefined || e.random >= 1 - this.config.errorSampleRate;\n case 'critical':\n return true;\n default:\n return this.config.sampleRate === undefined || e.random >= 1 - this.config.sampleRate;\n }\n }\n /**\n * This bypasses `sampleRate` and `errorSampleRate`, every created event is sent to the server!\n */\n async create(p) {\n const url = new URL('/logs', this.config.url);\n const res = await fetch(url, { method: 'POST', headers: this.getHeaders(), body: p.toJson() })\n .then((r) => r.json())\n .then((r) => this.handleResponse(r));\n return res;\n }\n /**\n * A captured event is subject to `sampleRate` and `errorSampleRate`, not all captured events are sent to the server!\n */\n async capture(p) {\n if (!this.shouldCapture(p))\n return;\n return await this.create(p);\n }\n async getAll(p) {\n const params = p ? PaginationSchema.encode(p) : '';\n const url = new URL('/logs?' + params, this.config.url);\n const res = await fetch(url, { method: 'GET', headers: this.getHeaders() })\n .then((r) => r.json())\n .then((r) => this.handleResponse(r));\n return z.array(LogwolfEventSchema).parse(res);\n }\n async getOne(id) {\n const res = this.getAll().then((r) => {\n return r.find((i) => i.id === id);\n });\n return res;\n }\n async delete(dto) {\n const url = new URL('/logs', this.config.url);\n const res = await fetch(url, {\n method: 'DELETE',\n headers: this.getHeaders(),\n body: JSON.stringify(DeleteLogwolfEventDTOSchema.parse(dto)),\n })\n .then((r) => r.json())\n .then((r) => this.handleResponse(r));\n return res;\n }\n}\n//# sourceMappingURL=client.js.map","import { CreateLogwolfEventDTOSchema } from './schema';\nexport class LogwolfEvent {\n random = Math.random();\n start = performance.now();\n createdAt = new Date();\n name;\n severity;\n tags;\n data = {};\n constructor(props) {\n this.name = props.name;\n this.severity = props.severity;\n this.tags = props.tags;\n if (props.data) {\n this.data = props.data;\n }\n }\n setName(n) {\n this.name = n;\n }\n setSeverity(s) {\n this.severity = s;\n }\n set(key, value) {\n this.data[key] = value;\n }\n get(key) {\n return this.data[key];\n }\n addTag(t) {\n this.tags.push(t);\n }\n toJson() {\n const now = performance.now();\n const duration = Math.floor(now - this.start);\n const encoded = CreateLogwolfEventDTOSchema.encode({\n name: this.name,\n severity: this.severity,\n tags: Array.from(new Set(this.tags)),\n data: this.data,\n duration: duration,\n });\n return JSON.stringify(encoded);\n }\n}\n//# sourceMappingURL=event.js.map"],"names":[],"mappings":";;AACY,MAAC,0BAA0B,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC;AAC7E,MAAC,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE;AACzF,IAAI,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK;AACjC,QAAQ,IAAI;AACZ,YAAY,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;AACzC,QAAQ;AACR,QAAQ,OAAO,GAAG,EAAE;AACpB,YAAY,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC;AAC5B,gBAAgB,IAAI,EAAE,gBAAgB;AACtC,gBAAgB,MAAM,EAAE,MAAM;AAC9B,gBAAgB,KAAK,EAAE,UAAU;AACjC,gBAAgB,OAAO,EAAE,GAAG,CAAC,OAAO;AACpC,aAAa,CAAC;AACd,YAAY,OAAO,C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,CAAC,QAAQ;AACnC,YAAY,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChD,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;AAC3B,YAAY,QAAQ,EAAE,QAAQ;AAC9B,SAAS,CAAC;AACV,QAAQ,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;AACtC,IAAI;AACJ;;;;"}
|
|
1
|
+
{"version":3,"file":"logwolf-client.js","sources":["lib/schema.js","lib/client.js","lib/event.js"],"sourcesContent":["import z from 'zod';\nexport const LogwolfEventSeveritySchema = z.enum(['info', 'warning', 'error', 'critical']);\nexport const LogwolfEventDataSchema = z.codec(z.string(), z.record(z.string(), z.any()), {\n decode: (jsonString, ctx) => {\n try {\n return JSON.parse(jsonString);\n }\n catch (err) {\n ctx.issues.push({\n code: 'invalid_format',\n format: 'json',\n input: jsonString,\n message: err.message,\n });\n return z.NEVER;\n }\n },\n encode: (value) => JSON.stringify(value),\n});\nexport const LogwolfDatetimeSchema = z.codec(z.iso.datetime(), z.date(), {\n decode: (isoString) => new Date(isoString),\n encode: (date) => date.toISOString(),\n});\nexport const LogwolfEventSchema = z.object({\n id: z.string(),\n name: z.string(),\n severity: LogwolfEventSeveritySchema,\n tags: z.array(z.string()),\n data: LogwolfEventDataSchema,\n duration: z.int().optional(),\n created_at: LogwolfDatetimeSchema,\n updated_at: LogwolfDatetimeSchema,\n});\nexport const CreateLogwolfEventDTOSchema = LogwolfEventSchema.pick({\n name: true,\n severity: true,\n tags: true,\n data: true,\n duration: true,\n});\nexport const DeleteLogwolfEventDTOSchema = LogwolfEventSchema.pick({ id: true });\nexport const LogwolfConfigSchema = z.object({\n url: z.url(),\n apiKey: z.string().startsWith('lw_').min(10),\n sampleRate: z.number().positive().lte(1).optional(),\n errorSampleRate: z.number().positive().lte(1).optional(),\n // Batching options\n flushIntervalMs: z.number().positive(),\n maxBatchSize: z.number().positive(),\n maxQueueSize: z.number().positive(),\n retryDelaysMs: z.number().gte(0).array(),\n requestTimeoutMs: z.number().positive(),\n onDropped: z.function({ input: [z.any().array(), z.string()] }).optional(),\n});\nexport const LogwolfEventDTOSchema = LogwolfEventSchema.pick({\n name: true,\n severity: true,\n tags: true,\n data: true,\n}).partial({\n data: true,\n});\nexport const PaginationSchema = z.codec(z.instanceof(URLSearchParams), z.object({\n page: z.number().positive(),\n pageSize: z.number().positive(),\n}), {\n encode: (v) => {\n return new URLSearchParams({ page: '' + v.page, pageSize: '' + v.pageSize });\n },\n decode: (v) => {\n const page = v.get('page') ?? '0';\n const pageSize = v.get('pageSize') ?? '0';\n return { page: parseInt(page), pageSize: parseInt(pageSize) };\n },\n});\n//# sourceMappingURL=schema.js.map","import z from 'zod';\nimport { DeleteLogwolfEventDTOSchema, LogwolfConfigSchema, LogwolfEventSchema, PaginationSchema, } from './schema';\nexport class Logwolf {\n config;\n baseUrl;\n // Queue holds stopped LogwolfEvent instances ready to be flushed.\n queue = [];\n flushTimer = null;\n flushPromise = null;\n constructor(config) {\n this.config = LogwolfConfigSchema.parse(config);\n // Normalize to a trailing slash so relative paths append correctly.\n const raw = this.config.url;\n this.baseUrl = new URL(raw.endsWith('/') ? raw : raw + '/');\n }\n // --- Private: helpers ---\n shouldCapture(event) {\n switch (event.severity) {\n case 'error':\n return this.config.errorSampleRate === undefined || event.random >= 1 - this.config.errorSampleRate;\n case 'critical':\n return true;\n default:\n return this.config.sampleRate === undefined || event.random >= 1 - this.config.sampleRate;\n }\n }\n getHeaders() {\n return {\n 'Content-Type': 'application/json',\n Authorization: `Bearer ${this.config.apiKey}`,\n };\n }\n handleResponse(r) {\n if (r.error)\n throw new Error(r.message);\n return r.data;\n }\n sleep(ms) {\n return new Promise((resolve) => setTimeout(resolve, ms));\n }\n async fetchWithTimeout(url, init) {\n const controller = new AbortController();\n const id = setTimeout(() => controller.abort(), this.config.requestTimeoutMs);\n return fetch(url, { ...init, signal: controller.signal }).finally(() => clearTimeout(id));\n }\n // --- Public API ---\n /**\n * Enqueues an event for batched delivery. Respects sampleRate and\n * errorSampleRate. Returns true if the event was accepted into the queue,\n * false if it was dropped (either by sampling or queue cap).\n *\n * capture() is synchronous and returns immediately — delivery happens in\n * the background. Call flush() before process exit to drain the queue.\n */\n capture(event) {\n if (!this.shouldCapture(event))\n return false;\n return this.enqueue(event);\n }\n /**\n * Sends an event immediately, bypassing sampling and the queue.\n * Awaitable — resolves when the server has accepted the event.\n */\n async create(event) {\n event.stop();\n const url = new URL('logs', this.baseUrl);\n const res = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers: this.getHeaders(),\n body: JSON.stringify(event.toObject()),\n })\n .then((r) => r.json())\n .then((r) => this.handleResponse(r));\n return res;\n }\n async getAll(p) {\n const params = p ? PaginationSchema.encode(p) : '';\n const url = new URL('logs?' + params, this.baseUrl);\n const res = await this.fetchWithTimeout(url, { method: 'GET', headers: this.getHeaders() })\n .then((r) => r.json())\n .then((r) => this.handleResponse(r));\n return z.array(LogwolfEventSchema).parse(res);\n }\n async getOne(id) {\n return this.getAll().then((r) => r.find((i) => i.id === id));\n }\n async delete(dto) {\n const url = new URL('logs', this.baseUrl);\n const res = await this.fetchWithTimeout(url, {\n method: 'DELETE',\n headers: this.getHeaders(),\n body: JSON.stringify(DeleteLogwolfEventDTOSchema.parse(dto)),\n })\n .then((r) => r.json())\n .then((r) => this.handleResponse(r));\n return res;\n }\n /**\n * Flushes all queued events immediately. Call this before process exit\n * or page unload to avoid losing buffered events.\n *\n * If a background flush is already in progress, waits for it to complete\n * before flushing any remaining events — so all enqueued events are sent.\n */\n async flush() {\n if (this.flushPromise)\n await this.flushPromise;\n if (this.queue.length > 0)\n await this.flushQueue();\n }\n /**\n * Clears the flush interval and prevents further background flushing.\n * Call this to allow Node.js to exit cleanly, or in test teardown.\n * Any queued events that haven't been flushed will be lost — call\n * flush() first if you need to drain the queue.\n */\n destroy() {\n if (this.flushTimer !== null) {\n clearInterval(this.flushTimer);\n this.flushTimer = null;\n }\n }\n // --- Private: queue management ---\n enqueue(event) {\n // Stop the stopwatch at enqueue time — this is the correct moment.\n event.stop();\n // Enforce the queue cap: drop the oldest event to make room.\n if (this.queue.length >= this.config.maxQueueSize) {\n const dropped = this.queue.splice(0, 1);\n this.config.onDropped?.(dropped, 'queue_full');\n }\n this.queue.push(event);\n // Start the flush timer lazily on first enqueue.\n if (this.flushTimer === null) {\n this.flushTimer = setInterval(() => {\n this.flushQueue().catch(() => {\n // Errors are handled inside flushQueue; this prevents\n // unhandled promise rejection from the interval callback.\n });\n }, this.config.flushIntervalMs);\n }\n // Flush immediately if the batch size threshold is reached.\n if (this.queue.length >= this.config.maxBatchSize) {\n this.flushQueue().catch(() => { });\n }\n return true;\n }\n flushQueue() {\n if (this.flushPromise !== null || this.queue.length === 0)\n return Promise.resolve();\n // Drain the queue into a local batch atomically. Any events captured\n // during the flush go into the next batch.\n const batch = this.queue.splice(0, this.queue.length);\n this.flushPromise = this.sendBatchWithRetry(batch)\n .catch(() => {\n // All retries exhausted — notify caller via onDropped.\n this.config.onDropped?.(batch, 'send_failed');\n })\n .finally(() => {\n this.flushPromise = null;\n });\n return this.flushPromise;\n }\n async sendBatchWithRetry(batch) {\n const url = new URL('logs/batch', this.baseUrl);\n const body = JSON.stringify(batch.map((ev) => ev.toObject()));\n let lastError;\n for (let attempt = 0; attempt <= this.config.retryDelaysMs.length; attempt++) {\n try {\n const response = await this.fetchWithTimeout(url, {\n method: 'POST',\n headers: this.getHeaders(),\n body,\n });\n // 401/403 — bad key, do not retry, surface immediately.\n if (response.status === 401 || response.status === 403) {\n this.config.onDropped?.(batch, `auth_error_${response.status}`);\n return;\n }\n if (response.ok)\n return;\n // Non-2xx that isn't an auth error — retry.\n lastError = new Error(`Server returned ${response.status}`);\n }\n catch (err) {\n // Network error — retry.\n lastError = err;\n }\n // Wait before the next attempt, unless this was the last one.\n if (attempt < this.config.retryDelaysMs.length) {\n await this.sleep(this.config.retryDelaysMs[attempt]);\n }\n }\n throw lastError;\n }\n}\n//# sourceMappingURL=client.js.map","import { CreateLogwolfEventDTOSchema } from './schema';\nexport class LogwolfEvent {\n random = Math.random();\n start = performance.now();\n createdAt = new Date();\n name;\n severity;\n tags;\n data = {};\n _duration = null;\n constructor(props) {\n this.name = props.name;\n this.severity = props.severity;\n this.tags = props.tags;\n if (props.data) {\n this.data = props.data;\n }\n }\n /**\n * Stops the stopwatch. Duration is frozen from construction to this call.\n * Called automatically by `capture()` and `create()` — you only need to\n * call this manually if you want to stop the clock before those methods.\n *\n * Calling `stop()` more than once is a no-op; the first call wins.\n */\n stop() {\n if (this._duration === null) {\n this._duration = Math.floor(performance.now() - this.start);\n }\n }\n setName(n) {\n this.name = n;\n }\n setSeverity(s) {\n this.severity = s;\n }\n set(key, value) {\n this.data[key] = value;\n }\n get(key) {\n return this.data[key];\n }\n addTag(t) {\n this.tags.push(t);\n }\n toObject() {\n const duration = this._duration ?? Math.floor(performance.now() - this.start);\n const encoded = CreateLogwolfEventDTOSchema.encode({\n name: this.name,\n severity: this.severity,\n tags: Array.from(new Set(this.tags)),\n data: this.data,\n duration: duration,\n });\n return encoded;\n }\n}\n//# sourceMappingURL=event.js.map"],"names":[],"mappings":";;AACY,MAAC,0BAA0B,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC;AAC7E,MAAC,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE;AACzF,IAAI,MAAM,EAAE,CAAC,UAAU,EAAE,GAAG,KAAK;AACjC,QAAQ,IAAI;AACZ,YAAY,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;AACzC,QAAQ;AACR,QAAQ,OAAO,GAAG,EAAE;AACpB,YAAY,GAAG,CAAC,MAAM,CAA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I,CAAC,IAAI,CAAC,CAAC,CAAC;AACzB,IAAI;AACJ,IAAI,QAAQ,GAAG;AACf,QAAQ,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,IAAI,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC;AACrF,QAAQ,MAAM,OAAO,GAAG,2BAA2B,CAAC,MAAM,CAAC;AAC3D,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;AAC3B,YAAY,QAAQ,EAAE,IAAI,CAAC,QAAQ;AACnC,YAAY,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAChD,YAAY,IAAI,EAAE,IAAI,CAAC,IAAI;AAC3B,YAAY,QAAQ,EAAE,QAAQ;AAC9B,SAAS,CAAC;AACV,QAAQ,OAAO,OAAO;AACtB,IAAI;AACJ;;;;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logwolf/client-js",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "JavaScript client for Logwolf",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"logwolf"
|
|
@@ -9,41 +9,46 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/jpricardo/logwolf/issues"
|
|
11
11
|
},
|
|
12
|
+
"license": "ISC",
|
|
13
|
+
"author": "jpricardo",
|
|
12
14
|
"repository": {
|
|
13
15
|
"type": "git",
|
|
14
16
|
"url": "git+https://github.com/jpricardo/logwolf.git"
|
|
15
17
|
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"main": "./dist/logwolf-client.js",
|
|
20
|
-
"types": "./dist/logwolf-client.d.ts",
|
|
18
|
+
"directories": {
|
|
19
|
+
"lib": "lib"
|
|
20
|
+
},
|
|
21
21
|
"files": [
|
|
22
22
|
"./dist/logwolf-client.d.ts",
|
|
23
23
|
"./dist/logwolf-client.js",
|
|
24
24
|
"./dist/logwolf-client.js.map"
|
|
25
25
|
],
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
"type": "module",
|
|
27
|
+
"main": "./dist/logwolf-client.js",
|
|
28
|
+
"types": "./dist/logwolf-client.d.ts",
|
|
29
29
|
"scripts": {
|
|
30
30
|
"build": "tsc && rollup -c",
|
|
31
31
|
"test": "vitest",
|
|
32
32
|
"coverage": "vitest run --coverage",
|
|
33
|
-
"prepublishOnly": "npm run build"
|
|
33
|
+
"prepublishOnly": "npm run build",
|
|
34
|
+
"lint": "oxlint",
|
|
35
|
+
"lint:fix": "oxlint --fix",
|
|
36
|
+
"format": "oxfmt",
|
|
37
|
+
"format:check": "oxfmt --check"
|
|
38
|
+
},
|
|
39
|
+
"dependencies": {
|
|
40
|
+
"zod": "^4.3.6"
|
|
34
41
|
},
|
|
35
42
|
"devDependencies": {
|
|
36
|
-
"@rollup/plugin-typescript": "
|
|
37
|
-
"@types/node": "
|
|
38
|
-
"@vitest/coverage-v8": "
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"rollup
|
|
43
|
+
"@rollup/plugin-typescript": "12.3.0",
|
|
44
|
+
"@types/node": "24",
|
|
45
|
+
"@vitest/coverage-v8": "4.1.4",
|
|
46
|
+
"oxfmt": "0.45.0",
|
|
47
|
+
"oxlint": "1.60.0",
|
|
48
|
+
"rollup": "4.60.1",
|
|
49
|
+
"rollup-plugin-dts": "^6.4.1",
|
|
42
50
|
"tslib": "^2.8.1",
|
|
43
|
-
"typescript": "
|
|
44
|
-
"vitest": "
|
|
45
|
-
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"zod": "^4.3.4"
|
|
51
|
+
"typescript": "6.0.3",
|
|
52
|
+
"vitest": "4.1.4"
|
|
48
53
|
}
|
|
49
54
|
}
|