@kenkaiiii/error-mom 0.3.1 → 0.3.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.
@@ -1,6 +1,6 @@
1
1
  // src/shared.ts
2
2
  var SDK_NAME = "@kenkaiiii/error-mom";
3
- var SDK_VERSION = "0.3.1";
3
+ var SDK_VERSION = "0.3.2";
4
4
  var MAX_BREADCRUMBS = 50;
5
5
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
6
6
  var URL_CREDENTIAL = /([?&](?:token|key|secret|password|code)=)[^&\s]*/gi;
package/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ module.exports = __toCommonJS(index_exports);
26
26
 
27
27
  // src/shared.ts
28
28
  var SDK_NAME = "@kenkaiiii/error-mom";
29
- var SDK_VERSION = "0.3.1";
29
+ var SDK_VERSION = "0.3.2";
30
30
  var MAX_BREADCRUMBS = 50;
31
31
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
32
32
  var URL_CREDENTIAL = /([?&](?:token|key|secret|password|code)=)[^&\s]*/gi;
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ import {
8
8
  printable,
9
9
  redactString,
10
10
  wrapFunction
11
- } from "./chunk-W4XR2RLN.js";
11
+ } from "./chunk-GHOIVBTK.js";
12
12
 
13
13
  // src/index.ts
14
14
  var clients = /* @__PURE__ */ new Map();
package/dist/node.cjs CHANGED
@@ -24,13 +24,14 @@ __export(node_exports, {
24
24
  });
25
25
  module.exports = __toCommonJS(node_exports);
26
26
  var import_node_crypto = require("crypto");
27
+ var import_node_fs = require("fs");
27
28
  var import_promises = require("fs/promises");
28
29
  var import_node_os = require("os");
29
30
  var import_node_path = require("path");
30
31
 
31
32
  // src/shared.ts
32
33
  var SDK_NAME = "@kenkaiiii/error-mom";
33
- var SDK_VERSION = "0.3.1";
34
+ var SDK_VERSION = "0.3.2";
34
35
  var MAX_BREADCRUMBS = 50;
35
36
  var SECRET_KEY = /authorization|cookie|password|passwd|secret|token|api[-_]?key|session/i;
36
37
  var URL_CREDENTIAL = /([?&](?:token|key|secret|password|code)=)[^&\s]*/gi;
@@ -297,10 +298,25 @@ var NodeClient = class {
297
298
  const onRejection = (reason) => {
298
299
  this.captureError(reason, { culprit: "unhandledRejection" });
299
300
  };
301
+ const onExit = () => {
302
+ this.persistQueueSync();
303
+ };
300
304
  process.on("uncaughtExceptionMonitor", onUncaught);
301
305
  process.on("unhandledRejection", onRejection);
306
+ process.on("exit", onExit);
302
307
  this.handlers.push(() => process.off("uncaughtExceptionMonitor", onUncaught));
303
308
  this.handlers.push(() => process.off("unhandledRejection", onRejection));
309
+ this.handlers.push(() => process.off("exit", onExit));
310
+ }
311
+ persistQueueSync() {
312
+ if (this.queue.length === 0) return;
313
+ try {
314
+ (0, import_node_fs.mkdirSync)(this.options.spoolDirectory, { recursive: true });
315
+ const contents = this.queue.map((event) => JSON.stringify(event)).join("\n");
316
+ (0, import_node_fs.writeFileSync)(this.spoolFile, `${contents}
317
+ `, { mode: 384 });
318
+ } catch {
319
+ }
304
320
  }
305
321
  captureFetchFailures() {
306
322
  if (this.options.captureFailedRequests === false || typeof fetch === "undefined") return;
package/dist/node.js CHANGED
@@ -8,10 +8,11 @@ import {
8
8
  printable,
9
9
  redactString,
10
10
  wrapFunction
11
- } from "./chunk-W4XR2RLN.js";
11
+ } from "./chunk-GHOIVBTK.js";
12
12
 
13
13
  // src/node.ts
14
14
  import { createHash } from "crypto";
15
+ import { mkdirSync, writeFileSync } from "fs";
15
16
  import { mkdir, readFile, rename, writeFile, appendFile } from "fs/promises";
16
17
  import { homedir } from "os";
17
18
  import { join } from "path";
@@ -108,10 +109,25 @@ var NodeClient = class {
108
109
  const onRejection = (reason) => {
109
110
  this.captureError(reason, { culprit: "unhandledRejection" });
110
111
  };
112
+ const onExit = () => {
113
+ this.persistQueueSync();
114
+ };
111
115
  process.on("uncaughtExceptionMonitor", onUncaught);
112
116
  process.on("unhandledRejection", onRejection);
117
+ process.on("exit", onExit);
113
118
  this.handlers.push(() => process.off("uncaughtExceptionMonitor", onUncaught));
114
119
  this.handlers.push(() => process.off("unhandledRejection", onRejection));
120
+ this.handlers.push(() => process.off("exit", onExit));
121
+ }
122
+ persistQueueSync() {
123
+ if (this.queue.length === 0) return;
124
+ try {
125
+ mkdirSync(this.options.spoolDirectory, { recursive: true });
126
+ const contents = this.queue.map((event) => JSON.stringify(event)).join("\n");
127
+ writeFileSync(this.spoolFile, `${contents}
128
+ `, { mode: 384 });
129
+ } catch {
130
+ }
115
131
  }
116
132
  captureFetchFailures() {
117
133
  if (this.options.captureFailedRequests === false || typeof fetch === "undefined") return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kenkaiiii/error-mom",
3
- "version": "0.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "Automatic browser and Node.js error capture for self-hosted Error Mom",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",