@logwolf/client-js 1.0.0 → 1.1.0

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.
@@ -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
- toJson(): string;
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 shouldCapture;
126
+ private sleep;
127
+ private fetchWithTimeout;
101
128
  /**
102
- * This bypasses `sampleRate` and `errorSampleRate`, every created event is sent to the server!
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
- create(p: LogwolfEvent): Promise<void>;
136
+ capture(event: LogwolfEvent): boolean;
105
137
  /**
106
- * A captured event is subject to `sampleRate` and `errorSampleRate`, not all captured events are sent to the server!
138
+ * Sends an event immediately, bypassing sampling and the queue.
139
+ * Awaitable — resolves when the server has accepted the event.
107
140
  */
108
- capture(p: LogwolfEvent): Promise<void>;
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 };
@@ -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,90 @@ 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
- this.config = config;
86
+ this.config = LogwolfConfigSchema.parse(config);
87
+ // Pre-compute base URL once to avoid repeated allocations per request.
88
+ this.baseUrl = new URL(this.config.url);
76
89
  }
77
- getHeaders() {
78
- const headers = { 'Content-Type': 'application/json' };
79
- if (this.config.apiKey) {
80
- headers['Authorization'] = `Bearer ${this.config.apiKey}`;
90
+ // --- Private: helpers ---
91
+ shouldCapture(event) {
92
+ switch (event.severity) {
93
+ case 'error':
94
+ return this.config.errorSampleRate === undefined || event.random >= 1 - this.config.errorSampleRate;
95
+ case 'critical':
96
+ return true;
97
+ default:
98
+ return this.config.sampleRate === undefined || event.random >= 1 - this.config.sampleRate;
81
99
  }
82
- return headers;
100
+ }
101
+ getHeaders() {
102
+ return {
103
+ 'Content-Type': 'application/json',
104
+ Authorization: `Bearer ${this.config.apiKey}`,
105
+ };
83
106
  }
84
107
  handleResponse(r) {
85
108
  if (r.error)
86
109
  throw new Error(r.message);
87
110
  return r.data;
88
111
  }
89
- shouldCapture(e) {
90
- switch (e.severity) {
91
- case 'error':
92
- return this.config.errorSampleRate === undefined || e.random >= 1 - this.config.errorSampleRate;
93
- case 'critical':
94
- return true;
95
- default:
96
- return this.config.sampleRate === undefined || e.random >= 1 - this.config.sampleRate;
97
- }
112
+ sleep(ms) {
113
+ return new Promise((resolve) => setTimeout(resolve, ms));
114
+ }
115
+ async fetchWithTimeout(url, init) {
116
+ const controller = new AbortController();
117
+ const id = setTimeout(() => controller.abort(), this.config.requestTimeoutMs);
118
+ return fetch(url, { ...init, signal: controller.signal }).finally(() => clearTimeout(id));
98
119
  }
120
+ // --- Public API ---
99
121
  /**
100
- * This bypasses `sampleRate` and `errorSampleRate`, every created event is sent to the server!
122
+ * Enqueues an event for batched delivery. Respects sampleRate and
123
+ * errorSampleRate. Returns true if the event was accepted into the queue,
124
+ * false if it was dropped (either by sampling or queue cap).
125
+ *
126
+ * capture() is synchronous and returns immediately — delivery happens in
127
+ * the background. Call flush() before process exit to drain the queue.
101
128
  */
102
- async create(p) {
103
- const url = new URL('/logs', this.config.url);
104
- const res = await fetch(url, { method: 'POST', headers: this.getHeaders(), body: p.toJson() })
105
- .then((r) => r.json())
106
- .then((r) => this.handleResponse(r));
107
- return res;
129
+ capture(event) {
130
+ if (!this.shouldCapture(event))
131
+ return false;
132
+ return this.enqueue(event);
108
133
  }
109
134
  /**
110
- * A captured event is subject to `sampleRate` and `errorSampleRate`, not all captured events are sent to the server!
135
+ * Sends an event immediately, bypassing sampling and the queue.
136
+ * Awaitable — resolves when the server has accepted the event.
111
137
  */
112
- async capture(p) {
113
- if (!this.shouldCapture(p))
114
- return;
115
- return await this.create(p);
138
+ async create(event) {
139
+ event.stop();
140
+ const url = new URL('/logs', this.baseUrl);
141
+ const res = await this.fetchWithTimeout(url, {
142
+ method: 'POST',
143
+ headers: this.getHeaders(),
144
+ body: JSON.stringify(event.toObject()),
145
+ })
146
+ .then((r) => r.json())
147
+ .then((r) => this.handleResponse(r));
148
+ return res;
116
149
  }
117
150
  async getAll(p) {
118
151
  const params = p ? PaginationSchema.encode(p) : '';
119
- const url = new URL('/logs?' + params, this.config.url);
120
- const res = await fetch(url, { method: 'GET', headers: this.getHeaders() })
152
+ const url = new URL('/logs?' + params, this.baseUrl);
153
+ const res = await this.fetchWithTimeout(url, { method: 'GET', headers: this.getHeaders() })
121
154
  .then((r) => r.json())
122
155
  .then((r) => this.handleResponse(r));
123
156
  return z.array(LogwolfEventSchema).parse(res);
124
157
  }
125
158
  async getOne(id) {
126
- const res = this.getAll().then((r) => {
127
- return r.find((i) => i.id === id);
128
- });
129
- return res;
159
+ return this.getAll().then((r) => r.find((i) => i.id === id));
130
160
  }
131
161
  async delete(dto) {
132
- const url = new URL('/logs', this.config.url);
133
- const res = await fetch(url, {
162
+ const url = new URL('/logs', this.baseUrl);
163
+ const res = await this.fetchWithTimeout(url, {
134
164
  method: 'DELETE',
135
165
  headers: this.getHeaders(),
136
166
  body: JSON.stringify(DeleteLogwolfEventDTOSchema.parse(dto)),
@@ -139,6 +169,104 @@ class Logwolf {
139
169
  .then((r) => this.handleResponse(r));
140
170
  return res;
141
171
  }
172
+ /**
173
+ * Flushes all queued events immediately. Call this before process exit
174
+ * or page unload to avoid losing buffered events.
175
+ *
176
+ * If a background flush is already in progress, waits for it to complete
177
+ * before flushing any remaining events — so all enqueued events are sent.
178
+ */
179
+ async flush() {
180
+ if (this.flushPromise)
181
+ await this.flushPromise;
182
+ if (this.queue.length > 0)
183
+ await this.flushQueue();
184
+ }
185
+ /**
186
+ * Clears the flush interval and prevents further background flushing.
187
+ * Call this to allow Node.js to exit cleanly, or in test teardown.
188
+ * Any queued events that haven't been flushed will be lost — call
189
+ * flush() first if you need to drain the queue.
190
+ */
191
+ destroy() {
192
+ if (this.flushTimer !== null) {
193
+ clearInterval(this.flushTimer);
194
+ this.flushTimer = null;
195
+ }
196
+ }
197
+ // --- Private: queue management ---
198
+ enqueue(event) {
199
+ // Stop the stopwatch at enqueue time — this is the correct moment.
200
+ event.stop();
201
+ // Enforce the queue cap: drop the oldest event to make room.
202
+ if (this.queue.length >= this.config.maxQueueSize) {
203
+ const dropped = this.queue.splice(0, 1);
204
+ this.config.onDropped?.(dropped, 'queue_full');
205
+ }
206
+ this.queue.push(event);
207
+ // Start the flush timer lazily on first enqueue.
208
+ if (this.flushTimer === null) {
209
+ this.flushTimer = setInterval(() => {
210
+ this.flushQueue().catch(() => {
211
+ // Errors are handled inside flushQueue; this prevents
212
+ // unhandled promise rejection from the interval callback.
213
+ });
214
+ }, this.config.flushIntervalMs);
215
+ }
216
+ // Flush immediately if the batch size threshold is reached.
217
+ if (this.queue.length >= this.config.maxBatchSize) {
218
+ this.flushQueue().catch(() => { });
219
+ }
220
+ return true;
221
+ }
222
+ flushQueue() {
223
+ if (this.flushPromise !== null || this.queue.length === 0)
224
+ return Promise.resolve();
225
+ // Drain the queue into a local batch atomically. Any events captured
226
+ // during the flush go into the next batch.
227
+ const batch = this.queue.splice(0, this.queue.length);
228
+ this.flushPromise = this.sendBatchWithRetry(batch)
229
+ .catch(() => {
230
+ // All retries exhausted — notify caller via onDropped.
231
+ this.config.onDropped?.(batch, 'send_failed');
232
+ })
233
+ .finally(() => {
234
+ this.flushPromise = null;
235
+ });
236
+ return this.flushPromise;
237
+ }
238
+ async sendBatchWithRetry(batch) {
239
+ const url = new URL('/logs/batch', this.baseUrl);
240
+ const body = JSON.stringify(batch.map((ev) => ev.toObject()));
241
+ let lastError;
242
+ for (let attempt = 0; attempt <= this.config.retryDelaysMs.length; attempt++) {
243
+ try {
244
+ const response = await this.fetchWithTimeout(url, {
245
+ method: 'POST',
246
+ headers: this.getHeaders(),
247
+ body,
248
+ });
249
+ // 401/403 — bad key, do not retry, surface immediately.
250
+ if (response.status === 401 || response.status === 403) {
251
+ this.config.onDropped?.(batch, `auth_error_${response.status}`);
252
+ return;
253
+ }
254
+ if (response.ok)
255
+ return;
256
+ // Non-2xx that isn't an auth error — retry.
257
+ lastError = new Error(`Server returned ${response.status}`);
258
+ }
259
+ catch (err) {
260
+ // Network error — retry.
261
+ lastError = err;
262
+ }
263
+ // Wait before the next attempt, unless this was the last one.
264
+ if (attempt < this.config.retryDelaysMs.length) {
265
+ await this.sleep(this.config.retryDelaysMs[attempt]);
266
+ }
267
+ }
268
+ throw lastError;
269
+ }
142
270
  }
143
271
 
144
272
  class LogwolfEvent {
@@ -149,6 +277,7 @@ class LogwolfEvent {
149
277
  severity;
150
278
  tags;
151
279
  data = {};
280
+ _duration = null;
152
281
  constructor(props) {
153
282
  this.name = props.name;
154
283
  this.severity = props.severity;
@@ -157,6 +286,18 @@ class LogwolfEvent {
157
286
  this.data = props.data;
158
287
  }
159
288
  }
289
+ /**
290
+ * Stops the stopwatch. Duration is frozen from construction to this call.
291
+ * Called automatically by `capture()` and `create()` — you only need to
292
+ * call this manually if you want to stop the clock before those methods.
293
+ *
294
+ * Calling `stop()` more than once is a no-op; the first call wins.
295
+ */
296
+ stop() {
297
+ if (this._duration === null) {
298
+ this._duration = Math.floor(performance.now() - this.start);
299
+ }
300
+ }
160
301
  setName(n) {
161
302
  this.name = n;
162
303
  }
@@ -172,9 +313,8 @@ class LogwolfEvent {
172
313
  addTag(t) {
173
314
  this.tags.push(t);
174
315
  }
175
- toJson() {
176
- const now = performance.now();
177
- const duration = Math.floor(now - this.start);
316
+ toObject() {
317
+ const duration = this._duration ?? Math.floor(performance.now() - this.start);
178
318
  const encoded = CreateLogwolfEventDTOSchema.encode({
179
319
  name: this.name,
180
320
  severity: this.severity,
@@ -182,7 +322,7 @@ class LogwolfEvent {
182
322
  data: this.data,
183
323
  duration: duration,
184
324
  });
185
- return JSON.stringify(encoded);
325
+ return encoded;
186
326
  }
187
327
  }
188
328
 
@@ -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;AACt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AAK,CAAC;AACrD,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,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 // Pre-compute base URL once to avoid repeated allocations per request.\n this.baseUrl = new URL(this.config.url);\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,IA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CAAC,IAAI,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.0.0",
3
+ "version": "1.1.0",
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
- "license": "ISC",
17
- "author": "jpricardo",
18
- "type": "module",
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
- "directories": {
27
- "lib": "lib"
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": "^12.3.0",
37
- "@types/node": "^25.0.3",
38
- "@vitest/coverage-v8": "^4.0.16",
39
- "prettier": "^3.7.4",
40
- "rollup": "^4.54.0",
41
- "rollup-plugin-dts": "^6.3.0",
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": "^5.9.3",
44
- "vitest": "^4.0.16"
45
- },
46
- "dependencies": {
47
- "zod": "^4.3.4"
51
+ "typescript": "6.0.3",
52
+ "vitest": "4.1.4"
48
53
  }
49
54
  }