@runtimescope/collector 0.7.2 → 0.8.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.
@@ -233,6 +233,17 @@ var EventStore = class {
233
233
  return true;
234
234
  });
235
235
  }
236
+ getUIInteractions(filter = {}) {
237
+ const since = filter.sinceSeconds ? Date.now() - filter.sinceSeconds * 1e3 : 0;
238
+ return this.buffer.query((e) => {
239
+ if (e.eventType !== "ui") return false;
240
+ if (filter.sessionId && e.sessionId !== filter.sessionId) return false;
241
+ const ue = e;
242
+ if (ue.timestamp < since) return false;
243
+ if (filter.action && ue.action !== filter.action) return false;
244
+ return true;
245
+ });
246
+ }
236
247
  // ============================================================
237
248
  // Recon event queries — returns the most recent event of each type
238
249
  // ============================================================
@@ -296,8 +307,16 @@ var EventStore = class {
296
307
  };
297
308
 
298
309
  // src/sqlite-store.ts
299
- import Database from "better-sqlite3";
300
310
  import { renameSync, existsSync } from "fs";
311
+ import { createRequire } from "module";
312
+ var DatabaseConstructor;
313
+ function getDatabase() {
314
+ if (!DatabaseConstructor) {
315
+ const require2 = createRequire(import.meta.url);
316
+ DatabaseConstructor = require2("better-sqlite3");
317
+ }
318
+ return DatabaseConstructor;
319
+ }
301
320
  var SqliteStore = class _SqliteStore {
302
321
  db;
303
322
  writeBuffer = [];
@@ -316,8 +335,9 @@ var SqliteStore = class _SqliteStore {
316
335
  this.flushTimer = setInterval(() => this.flush(), flushInterval);
317
336
  }
318
337
  openDatabase(options) {
338
+ const Db = getDatabase();
319
339
  try {
320
- const db = new Database(options.dbPath);
340
+ const db = new Db(options.dbPath);
321
341
  if (options.walMode !== false) {
322
342
  db.pragma("journal_mode = WAL");
323
343
  }
@@ -347,7 +367,7 @@ var SqliteStore = class _SqliteStore {
347
367
  }
348
368
  } catch {
349
369
  }
350
- const db = new Database(options.dbPath);
370
+ const db = new Db(options.dbPath);
351
371
  if (options.walMode !== false) {
352
372
  db.pragma("journal_mode = WAL");
353
373
  }
@@ -643,14 +663,14 @@ var SqliteStore = class _SqliteStore {
643
663
  };
644
664
 
645
665
  // src/sqlite-check.ts
646
- import { createRequire } from "module";
666
+ import { createRequire as createRequire2 } from "module";
647
667
  var _checked = false;
648
668
  var _available = false;
649
669
  function isSqliteAvailable() {
650
670
  if (_checked) return _available;
651
671
  _checked = true;
652
672
  try {
653
- const require2 = createRequire(import.meta.url);
673
+ const require2 = createRequire2(import.meta.url);
654
674
  require2("better-sqlite3");
655
675
  _available = true;
656
676
  } catch {
@@ -2759,6 +2779,15 @@ var HttpServer = class {
2759
2779
  });
2760
2780
  this.json(res, { data: events, count: events.length });
2761
2781
  });
2782
+ this.routes.set("GET /api/events/ui", (_req, res, params) => {
2783
+ const action = params.get("action");
2784
+ const events = this.store.getUIInteractions({
2785
+ action: action ?? void 0,
2786
+ sinceSeconds: numParam(params, "since_seconds"),
2787
+ sessionId: params.get("session_id") ?? void 0
2788
+ });
2789
+ this.json(res, { data: events, count: events.length });
2790
+ });
2762
2791
  this.routes.set("DELETE /api/events", (_req, res) => {
2763
2792
  const result = this.store.clear();
2764
2793
  this.json(res, result);
@@ -2806,6 +2835,9 @@ var HttpServer = class {
2806
2835
  "dom_snapshot",
2807
2836
  "performance",
2808
2837
  "database",
2838
+ "custom",
2839
+ "navigation",
2840
+ "ui",
2809
2841
  "recon_metadata",
2810
2842
  "recon_design_tokens",
2811
2843
  "recon_fonts",
@@ -3124,11 +3156,11 @@ function numParam(params, key) {
3124
3156
  }
3125
3157
 
3126
3158
  // src/pm/pm-store.ts
3127
- import Database2 from "better-sqlite3";
3159
+ import Database from "better-sqlite3";
3128
3160
  var PmStore = class {
3129
3161
  db;
3130
3162
  constructor(options) {
3131
- this.db = new Database2(options.dbPath);
3163
+ this.db = new Database(options.dbPath);
3132
3164
  if (options.walMode !== false) {
3133
3165
  this.db.pragma("journal_mode = WAL");
3134
3166
  }
@@ -4785,4 +4817,4 @@ export {
4785
4817
  parseSessionJsonl,
4786
4818
  ProjectDiscovery
4787
4819
  };
4788
- //# sourceMappingURL=chunk-TUFSIGGJ.js.map
4820
+ //# sourceMappingURL=chunk-BKRGXAJB.js.map