@debugkit/sdk 0.0.0-stage → 0.2.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.
- package/README.md +228 -2
- package/dist/chunk-3WRI3DI2.js +41 -0
- package/dist/chunk-3WRI3DI2.js.map +1 -0
- package/dist/chunk-5C7KJJNO.js +651 -0
- package/dist/chunk-5C7KJJNO.js.map +1 -0
- package/dist/chunk-EGCXLOFH.cjs +663 -0
- package/dist/chunk-EGCXLOFH.cjs.map +1 -0
- package/dist/chunk-HO3JW55K.js +79 -0
- package/dist/chunk-HO3JW55K.js.map +1 -0
- package/dist/chunk-NJ6DTUVX.cjs +83 -0
- package/dist/chunk-NJ6DTUVX.cjs.map +1 -0
- package/dist/chunk-YELZOB7J.cjs +45 -0
- package/dist/chunk-YELZOB7J.cjs.map +1 -0
- package/dist/client-ekzlpWIR.d.cts +220 -0
- package/dist/client-ekzlpWIR.d.ts +220 -0
- package/dist/expo-router.cjs +13 -0
- package/dist/expo-router.cjs.map +1 -0
- package/dist/expo-router.d.cts +10 -0
- package/dist/expo-router.d.ts +10 -0
- package/dist/expo-router.js +11 -0
- package/dist/expo-router.js.map +1 -0
- package/dist/expo.cjs +97 -0
- package/dist/expo.cjs.map +1 -0
- package/dist/expo.d.cts +14 -0
- package/dist/expo.d.ts +14 -0
- package/dist/expo.js +47 -0
- package/dist/expo.js.map +1 -0
- package/dist/index.cjs +40 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +11 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/node.cjs +140 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +20 -0
- package/dist/node.d.ts +20 -0
- package/dist/node.js +100 -0
- package/dist/node.js.map +1 -0
- package/dist/react-native.cjs +38 -0
- package/dist/react-native.cjs.map +1 -0
- package/dist/react-native.d.cts +51 -0
- package/dist/react-native.d.ts +51 -0
- package/dist/react-native.js +5 -0
- package/dist/react-native.js.map +1 -0
- package/dist/react.cjs +25 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +50 -0
- package/dist/react.d.ts +50 -0
- package/dist/react.js +4 -0
- package/dist/react.js.map +1 -0
- package/expo/package.json +6 -0
- package/expo-router/package.json +6 -0
- package/node/package.json +6 -0
- package/package.json +121 -3
- package/react/package.json +6 -0
- package/react-native/package.json +6 -0
package/dist/expo.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { initReactNative } from './chunk-HO3JW55K.js';
|
|
2
|
+
export { initReactNative, nativeContext, trackReactNavigation } from './chunk-HO3JW55K.js';
|
|
3
|
+
export { DebugErrorBoundary, trackTanStackRouter, useDebugNavigation } from './chunk-3WRI3DI2.js';
|
|
4
|
+
import { deBug, mergeContext } from './chunk-5C7KJJNO.js';
|
|
5
|
+
export { deBug } from './chunk-5C7KJJNO.js';
|
|
6
|
+
import * as Application from 'expo-application';
|
|
7
|
+
import * as Device from 'expo-device';
|
|
8
|
+
|
|
9
|
+
function osName2(raw) {
|
|
10
|
+
const n = (raw != null ? raw : "").toLowerCase();
|
|
11
|
+
if (n.includes("android")) return "android";
|
|
12
|
+
if (n === "ios" || n === "ipados") return "ios";
|
|
13
|
+
return n || "unknown";
|
|
14
|
+
}
|
|
15
|
+
var DEVICE_TYPES = { 1: "phone", 2: "tablet", 3: "desktop", 4: "tv" };
|
|
16
|
+
function expoContext() {
|
|
17
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
18
|
+
return {
|
|
19
|
+
os: Device.osVersion ? { name: osName2(Device.osName), version: Device.osVersion } : void 0,
|
|
20
|
+
device: {
|
|
21
|
+
model: (_a = Device.modelName) != null ? _a : void 0,
|
|
22
|
+
manufacturer: (_b = Device.manufacturer) != null ? _b : void 0,
|
|
23
|
+
brand: (_c = Device.brand) != null ? _c : void 0,
|
|
24
|
+
isEmulator: !Device.isDevice,
|
|
25
|
+
memoryMb: Device.totalMemory ? Math.round(Device.totalMemory / 1024 / 1024) : void 0,
|
|
26
|
+
type: (_e = DEVICE_TYPES[(_d = Device.deviceType) != null ? _d : 0]) != null ? _e : "unknown"
|
|
27
|
+
},
|
|
28
|
+
app: {
|
|
29
|
+
version: (_f = Application.nativeApplicationVersion) != null ? _f : void 0,
|
|
30
|
+
build: (_g = Application.nativeBuildVersion) != null ? _g : void 0
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
function initExpo(options, client = deBug) {
|
|
35
|
+
var _a;
|
|
36
|
+
const ctx = expoContext();
|
|
37
|
+
const merged = mergeContext(ctx, (_a = options.context) != null ? _a : {});
|
|
38
|
+
if (!ctx.os) delete merged.os;
|
|
39
|
+
return initReactNative(
|
|
40
|
+
{ ...options, app: { ...ctx.app, ...options.app }, context: merged },
|
|
41
|
+
client
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { expoContext, initExpo };
|
|
46
|
+
//# sourceMappingURL=expo.js.map
|
|
47
|
+
//# sourceMappingURL=expo.js.map
|
package/dist/expo.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/expo.ts"],"names":["osName"],"mappings":";;;;;;;;AAQA,SAASA,QAAO,GAAA,EAA4B;AAC1C,EAAA,MAAM,CAAA,GAAA,CAAK,GAAA,IAAA,IAAA,GAAA,GAAA,GAAO,EAAA,EAAI,WAAA,EAAY;AAClC,EAAA,IAAI,CAAA,CAAE,QAAA,CAAS,SAAS,CAAA,EAAG,OAAO,SAAA;AAClC,EAAA,IAAI,CAAA,KAAM,KAAA,IAAS,CAAA,KAAM,QAAA,EAAU,OAAO,KAAA;AAC1C,EAAA,OAAO,CAAA,IAAK,SAAA;AACd;AAEA,IAAM,YAAA,GAAe,EAAE,CAAA,EAAG,OAAA,EAAS,GAAG,QAAA,EAAU,CAAA,EAAG,SAAA,EAAW,CAAA,EAAG,IAAA,EAAK;AAG/D,SAAS,WAAA,GAA4B;AA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WAAA,EAAY;AACxB,EAAA,MAAM,SAAS,YAAA,CAAa,GAAA,EAAA,CAAK,aAAQ,OAAA,KAAR,IAAA,GAAA,EAAA,GAAmB,EAAE,CAAA;AAEtD,EAAA,IAAI,CAAC,GAAA,CAAI,EAAA,EAAI,OAAQ,MAAA,CAA4B,EAAA;AACjD,EAAA,OAAO,eAAA;AAAA,IACL,EAAE,GAAG,OAAA,EAAS,GAAA,EAAK,EAAE,GAAI,GAAA,CAAI,GAAA,EAAgB,GAAG,OAAA,CAAQ,GAAA,EAAI,EAAoC,SAAS,MAAA,EAAO;AAAA,IAChH;AAAA,GACF;AACF","file":"expo.js","sourcesContent":["import * as Application from \"expo-application\";\nimport * as Device from \"expo-device\";\nimport { deBug, type DebugClient } from \"./index\";\nimport { mergeContext, type ContextPatch } from \"./context\";\nimport { initReactNative, type ReactNativeInitOptions } from \"./react-native\";\n\nexport * from \"./react-native\";\n\nfunction osName(raw: string | null): string {\n const n = (raw ?? \"\").toLowerCase();\n if (n.includes(\"android\")) return \"android\";\n if (n === \"ios\" || n === \"ipados\") return \"ios\";\n return n || \"unknown\"; // web: the browser's OS, e.g. \"mac os\"\n}\n\nconst DEVICE_TYPES = { 1: \"phone\", 2: \"tablet\", 3: \"desktop\", 4: \"tv\" } as const;\n\n/** Device and app context from expo-device and expo-application. */\nexport function expoContext(): ContextPatch {\n return {\n os: Device.osVersion ? { name: osName(Device.osName), version: Device.osVersion } : undefined,\n device: {\n model: Device.modelName ?? undefined,\n manufacturer: Device.manufacturer ?? undefined,\n brand: Device.brand ?? undefined,\n isEmulator: !Device.isDevice,\n memoryMb: Device.totalMemory ? Math.round(Device.totalMemory / 1024 / 1024) : undefined,\n type: DEVICE_TYPES[(Device.deviceType ?? 0) as keyof typeof DEVICE_TYPES] ?? \"unknown\",\n },\n app: {\n version: Application.nativeApplicationVersion ?? undefined,\n build: Application.nativeBuildVersion ?? undefined,\n } as ContextPatch[\"app\"],\n };\n}\n\n/** Initialise deBug in an Expo app. Device, OS and app version are filled in automatically. */\nexport function initExpo(options: Omit<ReactNativeInitOptions, \"deviceInfo\">, client: DebugClient = deBug): DebugClient {\n const ctx = expoContext();\n const merged = mergeContext(ctx, options.context ?? {});\n // Drop undefined os so the react-native fallback is kept when expo-device has no data (e.g. web).\n if (!ctx.os) delete (merged as { os?: unknown }).os;\n return initReactNative(\n { ...options, app: { ...(ctx.app as object), ...options.app } as ReactNativeInitOptions[\"app\"], context: merged },\n client,\n );\n}\n"]}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkEGCXLOFH_cjs = require('./chunk-EGCXLOFH.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "DebugClient", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () { return chunkEGCXLOFH_cjs.DebugClient; }
|
|
10
|
+
});
|
|
11
|
+
Object.defineProperty(exports, "SDK_NAME", {
|
|
12
|
+
enumerable: true,
|
|
13
|
+
get: function () { return chunkEGCXLOFH_cjs.SDK_NAME; }
|
|
14
|
+
});
|
|
15
|
+
Object.defineProperty(exports, "SDK_VERSION", {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return chunkEGCXLOFH_cjs.SDK_VERSION; }
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports, "browserContext", {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return chunkEGCXLOFH_cjs.browserContext; }
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(exports, "deBug", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
get: function () { return chunkEGCXLOFH_cjs.deBug; }
|
|
26
|
+
});
|
|
27
|
+
Object.defineProperty(exports, "mergeContext", {
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: function () { return chunkEGCXLOFH_cjs.mergeContext; }
|
|
30
|
+
});
|
|
31
|
+
Object.defineProperty(exports, "normaliseUrl", {
|
|
32
|
+
enumerable: true,
|
|
33
|
+
get: function () { return chunkEGCXLOFH_cjs.normaliseUrl; }
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(exports, "parseStack", {
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: function () { return chunkEGCXLOFH_cjs.parseStack; }
|
|
38
|
+
});
|
|
39
|
+
//# sourceMappingURL=index.cjs.map
|
|
40
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.cjs"}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { D as DebugClient } from './client-ekzlpWIR.cjs';
|
|
2
|
+
export { A as AutoCaptureOptions, C as ContextPatch, E as EventMeta, I as InitOptions, N as NetworkOptions, Q as QueueStorage, S as SDK_NAME, a as SDK_VERSION, b as browserContext, m as mergeContext, n as normaliseUrl } from './client-ekzlpWIR.cjs';
|
|
3
|
+
export { Breadcrumb, EventInput, Severity, StackFrame, parseStack } from '@debugkit/schema/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Default client. Framework entry points (`/react`, `/react-native`, `/expo`, `/node`) use this
|
|
7
|
+
* same instance, so `import { deBug } from "@debugkit/sdk"` works everywhere.
|
|
8
|
+
*/
|
|
9
|
+
declare const deBug: DebugClient;
|
|
10
|
+
|
|
11
|
+
export { DebugClient, deBug };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { D as DebugClient } from './client-ekzlpWIR.js';
|
|
2
|
+
export { A as AutoCaptureOptions, C as ContextPatch, E as EventMeta, I as InitOptions, N as NetworkOptions, Q as QueueStorage, S as SDK_NAME, a as SDK_VERSION, b as browserContext, m as mergeContext, n as normaliseUrl } from './client-ekzlpWIR.js';
|
|
3
|
+
export { Breadcrumb, EventInput, Severity, StackFrame, parseStack } from '@debugkit/schema/core';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Default client. Framework entry points (`/react`, `/react-native`, `/expo`, `/node`) use this
|
|
7
|
+
* same instance, so `import { deBug } from "@debugkit/sdk"` works everywhere.
|
|
8
|
+
*/
|
|
9
|
+
declare const deBug: DebugClient;
|
|
10
|
+
|
|
11
|
+
export { DebugClient, deBug };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js"}
|
package/dist/node.cjs
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkEGCXLOFH_cjs = require('./chunk-EGCXLOFH.cjs');
|
|
4
|
+
var dc = require('diagnostics_channel');
|
|
5
|
+
var os = require('os');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var dc__default = /*#__PURE__*/_interopDefault(dc);
|
|
10
|
+
var os__default = /*#__PURE__*/_interopDefault(os);
|
|
11
|
+
|
|
12
|
+
function nodeContext() {
|
|
13
|
+
return {
|
|
14
|
+
os: { name: os__default.default.platform(), version: os__default.default.release() },
|
|
15
|
+
runtime: { name: "node", version: process.versions.node },
|
|
16
|
+
device: { type: "unknown", memoryMb: Math.round(os__default.default.totalmem() / 1024 / 1024) },
|
|
17
|
+
timezone: chunkEGCXLOFH_cjs.timezone()
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
var installed = false;
|
|
21
|
+
function initNode(options, client = chunkEGCXLOFH_cjs.deBug) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const { captureProcessErrors = true, shutdownTimeoutMs = 2e3, ...rest } = options;
|
|
24
|
+
const auto = rest.autoCapture === false ? false : { console: false, ...typeof rest.autoCapture === "object" ? rest.autoCapture : {} };
|
|
25
|
+
client.init({ ...rest, autoCapture: auto === false ? false : { ...auto, errors: false }, context: chunkEGCXLOFH_cjs.mergeContext(nodeContext(), (_a = rest.context) != null ? _a : {}) });
|
|
26
|
+
if (client.autoCapture.network) instrumentNodeHttp(client, (_b = rest.captureServerErrors) != null ? _b : true);
|
|
27
|
+
if (!captureProcessErrors || installed) return client;
|
|
28
|
+
installed = true;
|
|
29
|
+
const flushThenExit = async (err) => {
|
|
30
|
+
await Promise.race([client.flush(), new Promise((r) => setTimeout(r, shutdownTimeoutMs))]);
|
|
31
|
+
console.error(err);
|
|
32
|
+
process.exit(1);
|
|
33
|
+
};
|
|
34
|
+
process.on("uncaughtException", (err) => {
|
|
35
|
+
client.error(err, { handled: false, fatal: true, tags: { source: "uncaughtException" } });
|
|
36
|
+
void flushThenExit(err);
|
|
37
|
+
});
|
|
38
|
+
process.on("unhandledRejection", (reason) => {
|
|
39
|
+
client.error(reason, { handled: false, tags: { source: "unhandledRejection" } });
|
|
40
|
+
if (process.listenerCount("unhandledRejection") === 1) void flushThenExit(reason);
|
|
41
|
+
});
|
|
42
|
+
process.on("beforeExit", () => void client.flush());
|
|
43
|
+
return client;
|
|
44
|
+
}
|
|
45
|
+
var httpInstrumented = false;
|
|
46
|
+
function instrumentNodeHttp(client, captureServer) {
|
|
47
|
+
var _a;
|
|
48
|
+
if (httpInstrumented || typeof ((_a = dc__default.default) == null ? void 0 : _a.subscribe) !== "function") return;
|
|
49
|
+
httpInstrumented = true;
|
|
50
|
+
const sink = client.sink();
|
|
51
|
+
const urlOf = (r) => {
|
|
52
|
+
var _a2, _b, _c, _d, _e;
|
|
53
|
+
return `${(_a2 = r.protocol) != null ? _a2 : "http:"}//${String((_d = (_c = (_b = r.getHeader) == null ? void 0 : _b.call(r, "host")) != null ? _c : r.host) != null ? _d : "")}${(_e = r.path) != null ? _e : ""}`;
|
|
54
|
+
};
|
|
55
|
+
dc__default.default.subscribe("http.client.request.start", (m) => {
|
|
56
|
+
const r = m.request;
|
|
57
|
+
r.__debugStart = Date.now();
|
|
58
|
+
r.__debugStack = new Error().stack;
|
|
59
|
+
});
|
|
60
|
+
dc__default.default.subscribe("http.client.response.finish", (m) => {
|
|
61
|
+
var _a2, _b;
|
|
62
|
+
const { request: r, response } = m;
|
|
63
|
+
const url = urlOf(r);
|
|
64
|
+
if (sink.ignored(url)) return;
|
|
65
|
+
sink.request({ method: (_a2 = r.method) != null ? _a2 : "GET", url, status: response.statusCode, durationMs: Date.now() - ((_b = r.__debugStart) != null ? _b : Date.now()), stack: r.__debugStack });
|
|
66
|
+
});
|
|
67
|
+
dc__default.default.subscribe("http.client.request.error", (m) => {
|
|
68
|
+
var _a2, _b;
|
|
69
|
+
const { request: r, error } = m;
|
|
70
|
+
const url = urlOf(r);
|
|
71
|
+
if (sink.ignored(url)) return;
|
|
72
|
+
sink.request({ method: (_a2 = r.method) != null ? _a2 : "GET", url, error, durationMs: Date.now() - ((_b = r.__debugStart) != null ? _b : Date.now()), stack: r.__debugStack });
|
|
73
|
+
});
|
|
74
|
+
if (!captureServer) return;
|
|
75
|
+
dc__default.default.subscribe("http.server.request.start", (m) => {
|
|
76
|
+
m.request.__debugStart = Date.now();
|
|
77
|
+
});
|
|
78
|
+
dc__default.default.subscribe("http.server.response.finish", (m) => {
|
|
79
|
+
var _a2, _b, _c, _d;
|
|
80
|
+
const { request: r, response } = m;
|
|
81
|
+
const status = (_a2 = response.statusCode) != null ? _a2 : 0;
|
|
82
|
+
if (status < 500) return;
|
|
83
|
+
const url = chunkEGCXLOFH_cjs.normaliseUrl((_b = r.url) != null ? _b : "/");
|
|
84
|
+
const method = ((_c = r.method) != null ? _c : "GET").toUpperCase();
|
|
85
|
+
client.captureError(
|
|
86
|
+
{ name: "HttpServerError", message: `${method} ${url} responded ${status}`, frames: [] },
|
|
87
|
+
{ handled: true, tags: { source: "http-server" } },
|
|
88
|
+
{ method, url, status, durationMs: Date.now() - ((_d = r.__debugStart) != null ? _d : Date.now()) }
|
|
89
|
+
);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function withDebug(flow, fn, client = chunkEGCXLOFH_cjs.deBug) {
|
|
93
|
+
return async (...args) => {
|
|
94
|
+
try {
|
|
95
|
+
return await fn(...args);
|
|
96
|
+
} catch (err) {
|
|
97
|
+
client.error(err, { flow, handled: false });
|
|
98
|
+
await client.flush();
|
|
99
|
+
throw err;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
Object.defineProperty(exports, "DebugClient", {
|
|
105
|
+
enumerable: true,
|
|
106
|
+
get: function () { return chunkEGCXLOFH_cjs.DebugClient; }
|
|
107
|
+
});
|
|
108
|
+
Object.defineProperty(exports, "SDK_NAME", {
|
|
109
|
+
enumerable: true,
|
|
110
|
+
get: function () { return chunkEGCXLOFH_cjs.SDK_NAME; }
|
|
111
|
+
});
|
|
112
|
+
Object.defineProperty(exports, "SDK_VERSION", {
|
|
113
|
+
enumerable: true,
|
|
114
|
+
get: function () { return chunkEGCXLOFH_cjs.SDK_VERSION; }
|
|
115
|
+
});
|
|
116
|
+
Object.defineProperty(exports, "browserContext", {
|
|
117
|
+
enumerable: true,
|
|
118
|
+
get: function () { return chunkEGCXLOFH_cjs.browserContext; }
|
|
119
|
+
});
|
|
120
|
+
Object.defineProperty(exports, "deBug", {
|
|
121
|
+
enumerable: true,
|
|
122
|
+
get: function () { return chunkEGCXLOFH_cjs.deBug; }
|
|
123
|
+
});
|
|
124
|
+
Object.defineProperty(exports, "mergeContext", {
|
|
125
|
+
enumerable: true,
|
|
126
|
+
get: function () { return chunkEGCXLOFH_cjs.mergeContext; }
|
|
127
|
+
});
|
|
128
|
+
Object.defineProperty(exports, "normaliseUrl", {
|
|
129
|
+
enumerable: true,
|
|
130
|
+
get: function () { return chunkEGCXLOFH_cjs.normaliseUrl; }
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(exports, "parseStack", {
|
|
133
|
+
enumerable: true,
|
|
134
|
+
get: function () { return chunkEGCXLOFH_cjs.parseStack; }
|
|
135
|
+
});
|
|
136
|
+
exports.initNode = initNode;
|
|
137
|
+
exports.nodeContext = nodeContext;
|
|
138
|
+
exports.withDebug = withDebug;
|
|
139
|
+
//# sourceMappingURL=node.cjs.map
|
|
140
|
+
//# sourceMappingURL=node.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node.ts"],"names":["os","timezone","deBug","mergeContext","dc","_a","normaliseUrl"],"mappings":";;;;;;;;;;;AAOO,SAAS,WAAA,GAA4B;AAC1C,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,EAAE,IAAA,EAAMA,mBAAA,CAAG,UAAS,EAAG,OAAA,EAASA,mBAAA,CAAG,OAAA,EAAQ,EAAE;AAAA,IACjD,SAAS,EAAE,IAAA,EAAM,QAAQ,OAAA,EAAS,OAAA,CAAQ,SAAS,IAAA,EAAK;AAAA,IACxD,MAAA,EAAQ,EAAE,IAAA,EAAM,SAAA,EAAW,QAAA,EAAU,IAAA,CAAK,KAAA,CAAMA,mBAAA,CAAG,QAAA,EAAS,GAAI,IAAA,GAAO,IAAI,CAAA,EAAE;AAAA,IAC7E,UAAUC,0BAAA;AAAS,GACrB;AACF;AAWA,IAAI,SAAA,GAAY,KAAA;AAGT,SAAS,QAAA,CAAS,OAAA,EAA0B,MAAA,GAAsBC,uBAAA,EAAoB;AA5B7F,EAAA,IAAA,EAAA,EAAA,EAAA;AA6BE,EAAA,MAAM,EAAE,oBAAA,GAAuB,IAAA,EAAM,oBAAoB,GAAA,EAAM,GAAG,MAAK,GAAI,OAAA;AAC3E,EAAA,MAAM,OAAO,IAAA,CAAK,WAAA,KAAgB,KAAA,GAAQ,KAAA,GAAQ,EAAE,OAAA,EAAS,KAAA,EAAO,GAAI,OAAO,KAAK,WAAA,KAAgB,QAAA,GAAW,IAAA,CAAK,WAAA,GAAc,EAAC,EAAG;AAEtI,EAAA,MAAA,CAAO,IAAA,CAAK,EAAE,GAAG,IAAA,EAAM,WAAA,EAAa,SAAS,KAAA,GAAQ,KAAA,GAAQ,EAAE,GAAG,IAAA,EAAM,MAAA,EA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AAM,MAAM,EAAE,MAAA,EAAQ,eAAc,EAAE;AAAA,MACjD,EAAE,MAAA,EAAQ,GAAA,EAAK,MAAA,EAAQ,UAAA,EAAY,IAAA,CAAK,GAAA,EAAI,IAAA,CAAK,EAAA,GAAA,CAAA,CAAE,YAAA,KAAF,IAAA,GAAA,EAAA,GAAkB,IAAA,CAAK,KAAI,CAAA;AAAG,KACjF;AAAA,EACF,CAAC,CAAA;AACH;AAEO,SAAS,SAAA,CAAkC,IAAA,EAAc,EAAA,EAAgC,MAAA,GAAsBJ,uBAAA,EAAO;AAC3H,EAAA,OAAO,UAAU,IAAA,KAAwB;AACvC,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,EAAA,CAAG,GAAG,IAAI,CAAA;AAAA,IACzB,SAAS,GAAA,EAAK;AACZ,MAAA,MAAA,CAAO,MAAM,GAAA,EAAK,EAAE,IAAA,EAAM,OAAA,EAAS,OAAO,CAAA;AAC1C,MAAA,MAAM,OAAO,KAAA,EAAM;AACnB,MAAA,MAAM,GAAA;AAAA,IACR;AAAA,EACF,CAAA;AACF","file":"node.cjs","sourcesContent":["import dc from \"node:diagnostics_channel\";\nimport os from \"node:os\";\nimport { deBug, type DebugClient, type InitOptions } from \"./index\";\nimport { mergeContext, timezone, type ContextPatch } from \"./context\";\nimport { normaliseUrl } from \"./auto\";\n\n/** Context for Node servers (TanStack Start server functions, Next API routes, Express ...). */\nexport function nodeContext(): ContextPatch {\n return {\n os: { name: os.platform(), version: os.release() },\n runtime: { name: \"node\", version: process.versions.node },\n device: { type: \"unknown\", memoryMb: Math.round(os.totalmem() / 1024 / 1024) },\n timezone: timezone(),\n };\n}\n\nexport interface NodeInitOptions extends InitOptions {\n /** Capture uncaught exceptions and unhandled rejections, then exit like Node would. Default true. */\n captureProcessErrors?: boolean;\n /** Max time to wait for a final flush before exiting on a fatal error. Default 2000ms. */\n shutdownTimeoutMs?: number;\n /** Report responses your server sends with a 5xx status. Default true (needs `autoCapture.network`). */\n captureServerErrors?: boolean;\n}\n\nlet installed = false;\n\n/** Initialise deBug on a Node server. */\nexport function initNode(options: NodeInitOptions, client: DebugClient = deBug): DebugClient {\n const { captureProcessErrors = true, shutdownTimeoutMs = 2000, ...rest } = options;\n const auto = rest.autoCapture === false ? false : { console: false, ...(typeof rest.autoCapture === \"object\" ? rest.autoCapture : {}) };\n // Process-level hooks below replace the browser-style global handlers.\n client.init({ ...rest, autoCapture: auto === false ? false : { ...auto, errors: false }, context: mergeContext(nodeContext(), rest.context ?? {}) });\n if (client.autoCapture.network) instrumentNodeHttp(client, rest.captureServerErrors ?? true);\n if (!captureProcessErrors || installed) return client;\n installed = true;\n\n const flushThenExit = async (err: unknown) => {\n await Promise.race([client.flush(), new Promise((r) => setTimeout(r, shutdownTimeoutMs))]);\n console.error(err);\n process.exit(1);\n };\n // Adding these listeners disables Node's default crash, so we re-create it after flushing.\n process.on(\"uncaughtException\", (err) => {\n client.error(err, { handled: false, fatal: true, tags: { source: \"uncaughtException\" } });\n void flushThenExit(err);\n });\n process.on(\"unhandledRejection\", (reason) => {\n client.error(reason, { handled: false, tags: { source: \"unhandledRejection\" } });\n if (process.listenerCount(\"unhandledRejection\") === 1) void flushThenExit(reason);\n });\n process.on(\"beforeExit\", () => void client.flush());\n return client;\n}\n\n/**\n * Wrap a server handler so any error it throws is reported (and re-thrown).\n * Good for TanStack Start server functions and route handlers:\n * .handler(withDebug(\"checkout.payment\", async ({ data }) => { ... }))\n */\ntype ClientReq = { method?: string; protocol?: string; host?: string; path?: string; getHeader?(n: string): unknown; __debugStart?: number; __debugStack?: string };\ntype ServerReq = { method?: string; url?: string; __debugStart?: number };\nlet httpInstrumented = false;\n\n/**\n * Outgoing requests made with node:http/https (axios, got, SDKs) and responses this server\n * sends, through Node's diagnostics channels. `fetch` is covered by the shared instrumentation.\n */\nfunction instrumentNodeHttp(client: DebugClient, captureServer: boolean) {\n if (httpInstrumented || typeof dc?.subscribe !== \"function\") return;\n httpInstrumented = true;\n const sink = client.sink();\n // The Host header keeps a non-default port; request.host doesn't.\n const urlOf = (r: ClientReq) => `${r.protocol ?? \"http:\"}//${String(r.getHeader?.(\"host\") ?? r.host ?? \"\")}${r.path ?? \"\"}`;\n dc.subscribe(\"http.client.request.start\", (m) => {\n const r = (m as { request: ClientReq }).request;\n r.__debugStart = Date.now();\n r.__debugStack = new Error().stack;\n });\n dc.subscribe(\"http.client.response.finish\", (m) => {\n const { request: r, response } = m as { request: ClientReq; response: { statusCode?: number } };\n const url = urlOf(r);\n if (sink.ignored(url)) return;\n sink.request({ method: r.method ?? \"GET\", url, status: response.statusCode, durationMs: Date.now() - (r.__debugStart ?? Date.now()), stack: r.__debugStack });\n });\n dc.subscribe(\"http.client.request.error\", (m) => {\n const { request: r, error } = m as { request: ClientReq; error: unknown };\n const url = urlOf(r);\n if (sink.ignored(url)) return;\n sink.request({ method: r.method ?? \"GET\", url, error, durationMs: Date.now() - (r.__debugStart ?? Date.now()), stack: r.__debugStack });\n });\n if (!captureServer) return;\n dc.subscribe(\"http.server.request.start\", (m) => {\n (m as { request: ServerReq }).request.__debugStart = Date.now();\n });\n dc.subscribe(\"http.server.response.finish\", (m) => {\n const { request: r, response } = m as { request: ServerReq; response: { statusCode?: number } };\n const status = response.statusCode ?? 0;\n if (status < 500) return;\n const url = normaliseUrl(r.url ?? \"/\");\n const method = (r.method ?? \"GET\").toUpperCase();\n client.captureError(\n { name: \"HttpServerError\", message: `${method} ${url} responded ${status}`, frames: [] },\n { handled: true, tags: { source: \"http-server\" } },\n { method, url, status, durationMs: Date.now() - (r.__debugStart ?? Date.now()) },\n );\n });\n}\n\nexport function withDebug<A extends unknown[], R>(flow: string, fn: (...args: A) => Promise<R>, client: DebugClient = deBug) {\n return async (...args: A): Promise<R> => {\n try {\n return await fn(...args);\n } catch (err) {\n client.error(err, { flow, handled: false });\n await client.flush();\n throw err;\n }\n };\n}\n\nexport * from \"./index\";\n"]}
|
package/dist/node.d.cts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { deBug } from './index.cjs';
|
|
2
|
+
import { I as InitOptions, D as DebugClient, C as ContextPatch } from './client-ekzlpWIR.cjs';
|
|
3
|
+
export { A as AutoCaptureOptions, E as EventMeta, N as NetworkOptions, Q as QueueStorage, S as SDK_NAME, a as SDK_VERSION, b as browserContext, m as mergeContext, n as normaliseUrl } from './client-ekzlpWIR.cjs';
|
|
4
|
+
export { Breadcrumb, EventInput, Severity, StackFrame, parseStack } from '@debugkit/schema/core';
|
|
5
|
+
|
|
6
|
+
/** Context for Node servers (TanStack Start server functions, Next API routes, Express ...). */
|
|
7
|
+
declare function nodeContext(): ContextPatch;
|
|
8
|
+
interface NodeInitOptions extends InitOptions {
|
|
9
|
+
/** Capture uncaught exceptions and unhandled rejections, then exit like Node would. Default true. */
|
|
10
|
+
captureProcessErrors?: boolean;
|
|
11
|
+
/** Max time to wait for a final flush before exiting on a fatal error. Default 2000ms. */
|
|
12
|
+
shutdownTimeoutMs?: number;
|
|
13
|
+
/** Report responses your server sends with a 5xx status. Default true (needs `autoCapture.network`). */
|
|
14
|
+
captureServerErrors?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Initialise deBug on a Node server. */
|
|
17
|
+
declare function initNode(options: NodeInitOptions, client?: DebugClient): DebugClient;
|
|
18
|
+
declare function withDebug<A extends unknown[], R>(flow: string, fn: (...args: A) => Promise<R>, client?: DebugClient): (...args: A) => Promise<R>;
|
|
19
|
+
|
|
20
|
+
export { ContextPatch, DebugClient, InitOptions, type NodeInitOptions, initNode, nodeContext, withDebug };
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { deBug } from './index.js';
|
|
2
|
+
import { I as InitOptions, D as DebugClient, C as ContextPatch } from './client-ekzlpWIR.js';
|
|
3
|
+
export { A as AutoCaptureOptions, E as EventMeta, N as NetworkOptions, Q as QueueStorage, S as SDK_NAME, a as SDK_VERSION, b as browserContext, m as mergeContext, n as normaliseUrl } from './client-ekzlpWIR.js';
|
|
4
|
+
export { Breadcrumb, EventInput, Severity, StackFrame, parseStack } from '@debugkit/schema/core';
|
|
5
|
+
|
|
6
|
+
/** Context for Node servers (TanStack Start server functions, Next API routes, Express ...). */
|
|
7
|
+
declare function nodeContext(): ContextPatch;
|
|
8
|
+
interface NodeInitOptions extends InitOptions {
|
|
9
|
+
/** Capture uncaught exceptions and unhandled rejections, then exit like Node would. Default true. */
|
|
10
|
+
captureProcessErrors?: boolean;
|
|
11
|
+
/** Max time to wait for a final flush before exiting on a fatal error. Default 2000ms. */
|
|
12
|
+
shutdownTimeoutMs?: number;
|
|
13
|
+
/** Report responses your server sends with a 5xx status. Default true (needs `autoCapture.network`). */
|
|
14
|
+
captureServerErrors?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** Initialise deBug on a Node server. */
|
|
17
|
+
declare function initNode(options: NodeInitOptions, client?: DebugClient): DebugClient;
|
|
18
|
+
declare function withDebug<A extends unknown[], R>(flow: string, fn: (...args: A) => Promise<R>, client?: DebugClient): (...args: A) => Promise<R>;
|
|
19
|
+
|
|
20
|
+
export { ContextPatch, DebugClient, InitOptions, type NodeInitOptions, initNode, nodeContext, withDebug };
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { deBug, timezone, mergeContext, normaliseUrl } from './chunk-5C7KJJNO.js';
|
|
2
|
+
export { DebugClient, SDK_NAME, SDK_VERSION, browserContext, deBug, mergeContext, normaliseUrl, parseStack } from './chunk-5C7KJJNO.js';
|
|
3
|
+
import dc from 'diagnostics_channel';
|
|
4
|
+
import os from 'os';
|
|
5
|
+
|
|
6
|
+
function nodeContext() {
|
|
7
|
+
return {
|
|
8
|
+
os: { name: os.platform(), version: os.release() },
|
|
9
|
+
runtime: { name: "node", version: process.versions.node },
|
|
10
|
+
device: { type: "unknown", memoryMb: Math.round(os.totalmem() / 1024 / 1024) },
|
|
11
|
+
timezone: timezone()
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
var installed = false;
|
|
15
|
+
function initNode(options, client = deBug) {
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const { captureProcessErrors = true, shutdownTimeoutMs = 2e3, ...rest } = options;
|
|
18
|
+
const auto = rest.autoCapture === false ? false : { console: false, ...typeof rest.autoCapture === "object" ? rest.autoCapture : {} };
|
|
19
|
+
client.init({ ...rest, autoCapture: auto === false ? false : { ...auto, errors: false }, context: mergeContext(nodeContext(), (_a = rest.context) != null ? _a : {}) });
|
|
20
|
+
if (client.autoCapture.network) instrumentNodeHttp(client, (_b = rest.captureServerErrors) != null ? _b : true);
|
|
21
|
+
if (!captureProcessErrors || installed) return client;
|
|
22
|
+
installed = true;
|
|
23
|
+
const flushThenExit = async (err) => {
|
|
24
|
+
await Promise.race([client.flush(), new Promise((r) => setTimeout(r, shutdownTimeoutMs))]);
|
|
25
|
+
console.error(err);
|
|
26
|
+
process.exit(1);
|
|
27
|
+
};
|
|
28
|
+
process.on("uncaughtException", (err) => {
|
|
29
|
+
client.error(err, { handled: false, fatal: true, tags: { source: "uncaughtException" } });
|
|
30
|
+
void flushThenExit(err);
|
|
31
|
+
});
|
|
32
|
+
process.on("unhandledRejection", (reason) => {
|
|
33
|
+
client.error(reason, { handled: false, tags: { source: "unhandledRejection" } });
|
|
34
|
+
if (process.listenerCount("unhandledRejection") === 1) void flushThenExit(reason);
|
|
35
|
+
});
|
|
36
|
+
process.on("beforeExit", () => void client.flush());
|
|
37
|
+
return client;
|
|
38
|
+
}
|
|
39
|
+
var httpInstrumented = false;
|
|
40
|
+
function instrumentNodeHttp(client, captureServer) {
|
|
41
|
+
var _a;
|
|
42
|
+
if (httpInstrumented || typeof ((_a = dc) == null ? void 0 : _a.subscribe) !== "function") return;
|
|
43
|
+
httpInstrumented = true;
|
|
44
|
+
const sink = client.sink();
|
|
45
|
+
const urlOf = (r) => {
|
|
46
|
+
var _a2, _b, _c, _d, _e;
|
|
47
|
+
return `${(_a2 = r.protocol) != null ? _a2 : "http:"}//${String((_d = (_c = (_b = r.getHeader) == null ? void 0 : _b.call(r, "host")) != null ? _c : r.host) != null ? _d : "")}${(_e = r.path) != null ? _e : ""}`;
|
|
48
|
+
};
|
|
49
|
+
dc.subscribe("http.client.request.start", (m) => {
|
|
50
|
+
const r = m.request;
|
|
51
|
+
r.__debugStart = Date.now();
|
|
52
|
+
r.__debugStack = new Error().stack;
|
|
53
|
+
});
|
|
54
|
+
dc.subscribe("http.client.response.finish", (m) => {
|
|
55
|
+
var _a2, _b;
|
|
56
|
+
const { request: r, response } = m;
|
|
57
|
+
const url = urlOf(r);
|
|
58
|
+
if (sink.ignored(url)) return;
|
|
59
|
+
sink.request({ method: (_a2 = r.method) != null ? _a2 : "GET", url, status: response.statusCode, durationMs: Date.now() - ((_b = r.__debugStart) != null ? _b : Date.now()), stack: r.__debugStack });
|
|
60
|
+
});
|
|
61
|
+
dc.subscribe("http.client.request.error", (m) => {
|
|
62
|
+
var _a2, _b;
|
|
63
|
+
const { request: r, error } = m;
|
|
64
|
+
const url = urlOf(r);
|
|
65
|
+
if (sink.ignored(url)) return;
|
|
66
|
+
sink.request({ method: (_a2 = r.method) != null ? _a2 : "GET", url, error, durationMs: Date.now() - ((_b = r.__debugStart) != null ? _b : Date.now()), stack: r.__debugStack });
|
|
67
|
+
});
|
|
68
|
+
if (!captureServer) return;
|
|
69
|
+
dc.subscribe("http.server.request.start", (m) => {
|
|
70
|
+
m.request.__debugStart = Date.now();
|
|
71
|
+
});
|
|
72
|
+
dc.subscribe("http.server.response.finish", (m) => {
|
|
73
|
+
var _a2, _b, _c, _d;
|
|
74
|
+
const { request: r, response } = m;
|
|
75
|
+
const status = (_a2 = response.statusCode) != null ? _a2 : 0;
|
|
76
|
+
if (status < 500) return;
|
|
77
|
+
const url = normaliseUrl((_b = r.url) != null ? _b : "/");
|
|
78
|
+
const method = ((_c = r.method) != null ? _c : "GET").toUpperCase();
|
|
79
|
+
client.captureError(
|
|
80
|
+
{ name: "HttpServerError", message: `${method} ${url} responded ${status}`, frames: [] },
|
|
81
|
+
{ handled: true, tags: { source: "http-server" } },
|
|
82
|
+
{ method, url, status, durationMs: Date.now() - ((_d = r.__debugStart) != null ? _d : Date.now()) }
|
|
83
|
+
);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function withDebug(flow, fn, client = deBug) {
|
|
87
|
+
return async (...args) => {
|
|
88
|
+
try {
|
|
89
|
+
return await fn(...args);
|
|
90
|
+
} catch (err) {
|
|
91
|
+
client.error(err, { flow, handled: false });
|
|
92
|
+
await client.flush();
|
|
93
|
+
throw err;
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export { initNode, nodeContext, withDebug };
|
|
99
|
+
//# sourceMappingURL=node.js.map
|
|
100
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/node.ts"],"names":["_a"],"mappings":";;;;;AAOO,SAAS,WAAA,GAA4B;AAC1C,EAAA,OAAO;AAAA,IACL,EAAA,EAAI,EAAE,IAAA,EAAM,EAAA,CAAG,UAAS,EAAG,OAAA,EAAS,EAAA,CAAG,OAAA,EAAQ,EAAE;AAAA,IACjD,SAAS,EAAE,IAAA,EAAM,QAAQ,OAAA,EAAS,OAAA,CAAQ,SAAS,IAAA,EAAK;AAAA,IACxD,MAAA,EAAQ,EAAE,IAAA,EAAM,SAAA,EAAW,QAAA,EAAU,IAAA,CAAK,KAAA,CAAM,EAAA,CAAG,QAAA,EAAS,GAAI,IAAA,GAAO,IAAI,CAAA,EAAE;AAAA,IAC7E,UAAU,QAAA;AAAS,GACrB;AACF;AAWA,IAAI,SAAA,GAAY,KAAA;AAGT,SAAS,QAAA,CAAS,OAAA,EAA0B,MAAA,GAAsB,KAAA,EAAoB;AA5B7F,EAAA,IAAA,EAAA,EAAA,EAAA;AA6BE,EAAA,MAAM,EAAE,oBAAA,GAAuB,IAAA,EAAM,oBAAoB,GAAA,EAAM,G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GAAA,CAAA,CAAU,EAAA,GAAA,CAAA,CAAE,MAAA,KAAF,IAAA,GAAA,EAAA,GAAY,OAAO,WAAA,EAAY;AAC/C,IAAA,MAAA,CAAO,YAAA;AAAA,MACL,EAAE,IAAA,EAAM,iBAAA,EAAmB,OAAA,EAAS,CAAA,EAAG,MAAM,CAAA,CAAA,EAAI,GAAG,CAAA,WAAA,EAAc,MAAM,CAAA,CAAA,EAAI,MAAA,EAAQ,EAAC,EAAE;AAAA,MACvF,EAAE,OAAA,EAAS,IAAA,EAAM,MAAM,EAAE,MAAA,EAAQ,eAAc,EAAE;AAAA,MACjD,EAAE,MAAA,EAAQ,GAAA,EAAK,MAAA,EAAQ,UAAA,EAAY,IAAA,CAAK,GAAA,EAAI,IAAA,CAAK,EAAA,GAAA,CAAA,CAAE,YAAA,KAAF,IAAA,GAAA,EAAA,GAAkB,IAAA,CAAK,KAAI,CAAA;AAAG,KACjF;AAAA,EACF,CAAC,CAAA;AACH;AAEO,SAAS,SAAA,CAAkC,IAAA,EAAc,EAAA,EAAgC,MAAA,GAAsB,KAAA,EAAO;AAC3H,EAAA,OAAO,UAAU,IAAA,KAAwB;AACvC,IAAA,IAAI;AACF,MAAA,OAAO,MAAM,EAAA,CAAG,GAAG,IAAI,CAAA;AAAA,IACzB,SAAS,GAAA,EAAK;AACZ,MAAA,MAAA,CAAO,MAAM,GAAA,EAAK,EAAE,IAAA,EAAM,OAAA,EAAS,OAAO,CAAA;AAC1C,MAAA,MAAM,OAAO,KAAA,EAAM;AACnB,MAAA,MAAM,GAAA;AAAA,IACR;AAAA,EACF,CAAA;AACF","file":"node.js","sourcesContent":["import dc from \"node:diagnostics_channel\";\nimport os from \"node:os\";\nimport { deBug, type DebugClient, type InitOptions } from \"./index\";\nimport { mergeContext, timezone, type ContextPatch } from \"./context\";\nimport { normaliseUrl } from \"./auto\";\n\n/** Context for Node servers (TanStack Start server functions, Next API routes, Express ...). */\nexport function nodeContext(): ContextPatch {\n return {\n os: { name: os.platform(), version: os.release() },\n runtime: { name: \"node\", version: process.versions.node },\n device: { type: \"unknown\", memoryMb: Math.round(os.totalmem() / 1024 / 1024) },\n timezone: timezone(),\n };\n}\n\nexport interface NodeInitOptions extends InitOptions {\n /** Capture uncaught exceptions and unhandled rejections, then exit like Node would. Default true. */\n captureProcessErrors?: boolean;\n /** Max time to wait for a final flush before exiting on a fatal error. Default 2000ms. */\n shutdownTimeoutMs?: number;\n /** Report responses your server sends with a 5xx status. Default true (needs `autoCapture.network`). */\n captureServerErrors?: boolean;\n}\n\nlet installed = false;\n\n/** Initialise deBug on a Node server. */\nexport function initNode(options: NodeInitOptions, client: DebugClient = deBug): DebugClient {\n const { captureProcessErrors = true, shutdownTimeoutMs = 2000, ...rest } = options;\n const auto = rest.autoCapture === false ? false : { console: false, ...(typeof rest.autoCapture === \"object\" ? rest.autoCapture : {}) };\n // Process-level hooks below replace the browser-style global handlers.\n client.init({ ...rest, autoCapture: auto === false ? false : { ...auto, errors: false }, context: mergeContext(nodeContext(), rest.context ?? {}) });\n if (client.autoCapture.network) instrumentNodeHttp(client, rest.captureServerErrors ?? true);\n if (!captureProcessErrors || installed) return client;\n installed = true;\n\n const flushThenExit = async (err: unknown) => {\n await Promise.race([client.flush(), new Promise((r) => setTimeout(r, shutdownTimeoutMs))]);\n console.error(err);\n process.exit(1);\n };\n // Adding these listeners disables Node's default crash, so we re-create it after flushing.\n process.on(\"uncaughtException\", (err) => {\n client.error(err, { handled: false, fatal: true, tags: { source: \"uncaughtException\" } });\n void flushThenExit(err);\n });\n process.on(\"unhandledRejection\", (reason) => {\n client.error(reason, { handled: false, tags: { source: \"unhandledRejection\" } });\n if (process.listenerCount(\"unhandledRejection\") === 1) void flushThenExit(reason);\n });\n process.on(\"beforeExit\", () => void client.flush());\n return client;\n}\n\n/**\n * Wrap a server handler so any error it throws is reported (and re-thrown).\n * Good for TanStack Start server functions and route handlers:\n * .handler(withDebug(\"checkout.payment\", async ({ data }) => { ... }))\n */\ntype ClientReq = { method?: string; protocol?: string; host?: string; path?: string; getHeader?(n: string): unknown; __debugStart?: number; __debugStack?: string };\ntype ServerReq = { method?: string; url?: string; __debugStart?: number };\nlet httpInstrumented = false;\n\n/**\n * Outgoing requests made with node:http/https (axios, got, SDKs) and responses this server\n * sends, through Node's diagnostics channels. `fetch` is covered by the shared instrumentation.\n */\nfunction instrumentNodeHttp(client: DebugClient, captureServer: boolean) {\n if (httpInstrumented || typeof dc?.subscribe !== \"function\") return;\n httpInstrumented = true;\n const sink = client.sink();\n // The Host header keeps a non-default port; request.host doesn't.\n const urlOf = (r: ClientReq) => `${r.protocol ?? \"http:\"}//${String(r.getHeader?.(\"host\") ?? r.host ?? \"\")}${r.path ?? \"\"}`;\n dc.subscribe(\"http.client.request.start\", (m) => {\n const r = (m as { request: ClientReq }).request;\n r.__debugStart = Date.now();\n r.__debugStack = new Error().stack;\n });\n dc.subscribe(\"http.client.response.finish\", (m) => {\n const { request: r, response } = m as { request: ClientReq; response: { statusCode?: number } };\n const url = urlOf(r);\n if (sink.ignored(url)) return;\n sink.request({ method: r.method ?? \"GET\", url, status: response.statusCode, durationMs: Date.now() - (r.__debugStart ?? Date.now()), stack: r.__debugStack });\n });\n dc.subscribe(\"http.client.request.error\", (m) => {\n const { request: r, error } = m as { request: ClientReq; error: unknown };\n const url = urlOf(r);\n if (sink.ignored(url)) return;\n sink.request({ method: r.method ?? \"GET\", url, error, durationMs: Date.now() - (r.__debugStart ?? Date.now()), stack: r.__debugStack });\n });\n if (!captureServer) return;\n dc.subscribe(\"http.server.request.start\", (m) => {\n (m as { request: ServerReq }).request.__debugStart = Date.now();\n });\n dc.subscribe(\"http.server.response.finish\", (m) => {\n const { request: r, response } = m as { request: ServerReq; response: { statusCode?: number } };\n const status = response.statusCode ?? 0;\n if (status < 500) return;\n const url = normaliseUrl(r.url ?? \"/\");\n const method = (r.method ?? \"GET\").toUpperCase();\n client.captureError(\n { name: \"HttpServerError\", message: `${method} ${url} responded ${status}`, frames: [] },\n { handled: true, tags: { source: \"http-server\" } },\n { method, url, status, durationMs: Date.now() - (r.__debugStart ?? Date.now()) },\n );\n });\n}\n\nexport function withDebug<A extends unknown[], R>(flow: string, fn: (...args: A) => Promise<R>, client: DebugClient = deBug) {\n return async (...args: A): Promise<R> => {\n try {\n return await fn(...args);\n } catch (err) {\n client.error(err, { flow, handled: false });\n await client.flush();\n throw err;\n }\n };\n}\n\nexport * from \"./index\";\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkNJ6DTUVX_cjs = require('./chunk-NJ6DTUVX.cjs');
|
|
4
|
+
var chunkYELZOB7J_cjs = require('./chunk-YELZOB7J.cjs');
|
|
5
|
+
var chunkEGCXLOFH_cjs = require('./chunk-EGCXLOFH.cjs');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "initReactNative", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return chunkNJ6DTUVX_cjs.initReactNative; }
|
|
12
|
+
});
|
|
13
|
+
Object.defineProperty(exports, "nativeContext", {
|
|
14
|
+
enumerable: true,
|
|
15
|
+
get: function () { return chunkNJ6DTUVX_cjs.nativeContext; }
|
|
16
|
+
});
|
|
17
|
+
Object.defineProperty(exports, "trackReactNavigation", {
|
|
18
|
+
enumerable: true,
|
|
19
|
+
get: function () { return chunkNJ6DTUVX_cjs.trackReactNavigation; }
|
|
20
|
+
});
|
|
21
|
+
Object.defineProperty(exports, "DebugErrorBoundary", {
|
|
22
|
+
enumerable: true,
|
|
23
|
+
get: function () { return chunkYELZOB7J_cjs.DebugErrorBoundary; }
|
|
24
|
+
});
|
|
25
|
+
Object.defineProperty(exports, "trackTanStackRouter", {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return chunkYELZOB7J_cjs.trackTanStackRouter; }
|
|
28
|
+
});
|
|
29
|
+
Object.defineProperty(exports, "useDebugNavigation", {
|
|
30
|
+
enumerable: true,
|
|
31
|
+
get: function () { return chunkYELZOB7J_cjs.useDebugNavigation; }
|
|
32
|
+
});
|
|
33
|
+
Object.defineProperty(exports, "deBug", {
|
|
34
|
+
enumerable: true,
|
|
35
|
+
get: function () { return chunkEGCXLOFH_cjs.deBug; }
|
|
36
|
+
});
|
|
37
|
+
//# sourceMappingURL=react-native.cjs.map
|
|
38
|
+
//# sourceMappingURL=react-native.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"react-native.cjs"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export { deBug } from './index.cjs';
|
|
2
|
+
import { I as InitOptions, D as DebugClient, C as ContextPatch } from './client-ekzlpWIR.cjs';
|
|
3
|
+
export { DebugErrorBoundary, DebugErrorBoundaryProps, trackTanStackRouter, useDebugNavigation } from './react.cjs';
|
|
4
|
+
import '@debugkit/schema/core';
|
|
5
|
+
import 'react';
|
|
6
|
+
|
|
7
|
+
/** The subset of react-native-device-info we read. Pass the module itself: `import DeviceInfo from "react-native-device-info"`. */
|
|
8
|
+
interface DeviceInfoModule {
|
|
9
|
+
getModel(): string;
|
|
10
|
+
getBrand(): string;
|
|
11
|
+
getVersion(): string;
|
|
12
|
+
getBuildNumber(): string;
|
|
13
|
+
isTablet(): boolean;
|
|
14
|
+
getManufacturerSync?(): string;
|
|
15
|
+
isEmulatorSync?(): boolean;
|
|
16
|
+
getTotalMemorySync?(): number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Context for bare React Native. Reads what `react-native` exposes on its own; pass
|
|
20
|
+
* react-native-device-info for model, app version and memory on both platforms.
|
|
21
|
+
*/
|
|
22
|
+
declare function nativeContext(opts?: {
|
|
23
|
+
deviceInfo?: DeviceInfoModule;
|
|
24
|
+
}): ContextPatch;
|
|
25
|
+
interface ReactNativeInitOptions extends InitOptions {
|
|
26
|
+
deviceInfo?: DeviceInfoModule;
|
|
27
|
+
/**
|
|
28
|
+
* Report unhandled promise rejections (Hermes). Default "production": in development React
|
|
29
|
+
* Native's own yellow-box warning keeps working. `true` captures in development too.
|
|
30
|
+
*/
|
|
31
|
+
captureUnhandledRejections?: boolean | "production";
|
|
32
|
+
}
|
|
33
|
+
/** Initialise deBug in a React Native app (bare or Expo). Fills in device context and flushes when the app is backgrounded. */
|
|
34
|
+
declare function initReactNative(options: ReactNativeInitOptions, client?: DebugClient): DebugClient;
|
|
35
|
+
/** Minimal shape of a React Navigation container ref. */
|
|
36
|
+
interface NavigationRefLike {
|
|
37
|
+
getCurrentRoute(): {
|
|
38
|
+
name: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Breadcrumbs for React Navigation. Spread the result onto your container:
|
|
43
|
+
* const nav = useNavigationContainerRef();
|
|
44
|
+
* <NavigationContainer ref={nav} {...trackReactNavigation(nav)}>
|
|
45
|
+
*/
|
|
46
|
+
declare function trackReactNavigation(ref: NavigationRefLike, client?: DebugClient): {
|
|
47
|
+
onReady: () => void;
|
|
48
|
+
onStateChange: () => void;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { type DeviceInfoModule, type ReactNativeInitOptions, initReactNative, nativeContext, trackReactNavigation };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
export { deBug } from './index.js';
|
|
2
|
+
import { I as InitOptions, D as DebugClient, C as ContextPatch } from './client-ekzlpWIR.js';
|
|
3
|
+
export { DebugErrorBoundary, DebugErrorBoundaryProps, trackTanStackRouter, useDebugNavigation } from './react.js';
|
|
4
|
+
import '@debugkit/schema/core';
|
|
5
|
+
import 'react';
|
|
6
|
+
|
|
7
|
+
/** The subset of react-native-device-info we read. Pass the module itself: `import DeviceInfo from "react-native-device-info"`. */
|
|
8
|
+
interface DeviceInfoModule {
|
|
9
|
+
getModel(): string;
|
|
10
|
+
getBrand(): string;
|
|
11
|
+
getVersion(): string;
|
|
12
|
+
getBuildNumber(): string;
|
|
13
|
+
isTablet(): boolean;
|
|
14
|
+
getManufacturerSync?(): string;
|
|
15
|
+
isEmulatorSync?(): boolean;
|
|
16
|
+
getTotalMemorySync?(): number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Context for bare React Native. Reads what `react-native` exposes on its own; pass
|
|
20
|
+
* react-native-device-info for model, app version and memory on both platforms.
|
|
21
|
+
*/
|
|
22
|
+
declare function nativeContext(opts?: {
|
|
23
|
+
deviceInfo?: DeviceInfoModule;
|
|
24
|
+
}): ContextPatch;
|
|
25
|
+
interface ReactNativeInitOptions extends InitOptions {
|
|
26
|
+
deviceInfo?: DeviceInfoModule;
|
|
27
|
+
/**
|
|
28
|
+
* Report unhandled promise rejections (Hermes). Default "production": in development React
|
|
29
|
+
* Native's own yellow-box warning keeps working. `true` captures in development too.
|
|
30
|
+
*/
|
|
31
|
+
captureUnhandledRejections?: boolean | "production";
|
|
32
|
+
}
|
|
33
|
+
/** Initialise deBug in a React Native app (bare or Expo). Fills in device context and flushes when the app is backgrounded. */
|
|
34
|
+
declare function initReactNative(options: ReactNativeInitOptions, client?: DebugClient): DebugClient;
|
|
35
|
+
/** Minimal shape of a React Navigation container ref. */
|
|
36
|
+
interface NavigationRefLike {
|
|
37
|
+
getCurrentRoute(): {
|
|
38
|
+
name: string;
|
|
39
|
+
} | undefined;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Breadcrumbs for React Navigation. Spread the result onto your container:
|
|
43
|
+
* const nav = useNavigationContainerRef();
|
|
44
|
+
* <NavigationContainer ref={nav} {...trackReactNavigation(nav)}>
|
|
45
|
+
*/
|
|
46
|
+
declare function trackReactNavigation(ref: NavigationRefLike, client?: DebugClient): {
|
|
47
|
+
onReady: () => void;
|
|
48
|
+
onStateChange: () => void;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export { type DeviceInfoModule, type ReactNativeInitOptions, initReactNative, nativeContext, trackReactNavigation };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { initReactNative, nativeContext, trackReactNavigation } from './chunk-HO3JW55K.js';
|
|
2
|
+
export { DebugErrorBoundary, trackTanStackRouter, useDebugNavigation } from './chunk-3WRI3DI2.js';
|
|
3
|
+
export { deBug } from './chunk-5C7KJJNO.js';
|
|
4
|
+
//# sourceMappingURL=react-native.js.map
|
|
5
|
+
//# sourceMappingURL=react-native.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"react-native.js"}
|