@logtape/sentry 0.2.0-dev.8 → 0.12.0-dev.193
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 +3 -24
- package/deno.json +14 -0
- package/dist/_virtual/rolldown_runtime.cjs +30 -0
- package/dist/mod.cjs +53 -0
- package/dist/mod.d.cts +17 -0
- package/dist/mod.d.cts.map +1 -0
- package/dist/mod.d.ts +17 -0
- package/dist/mod.d.ts.map +1 -0
- package/dist/mod.js +53 -0
- package/dist/mod.js.map +1 -0
- package/mod.ts +78 -0
- package/package.json +28 -27
- package/tsdown.config.ts +11 -0
- package/esm/_dnt.shims.js +0 -57
- package/esm/mod.js +0 -72
- package/esm/package.json +0 -3
- package/script/_dnt.shims.js +0 -60
- package/script/mod.js +0 -98
- package/script/package.json +0 -3
- package/types/_dnt.shims.d.ts +0 -2
- package/types/_dnt.shims.d.ts.map +0 -1
- package/types/mod.d.ts +0 -10
- package/types/mod.d.ts.map +0 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
This package provides an [Sentry] sink for [LogTape]. It allows you to
|
|
9
9
|
capture your LogTape logs and send them to Sentry.
|
|
10
10
|
|
|
11
|
-

|
|
12
12
|
|
|
13
13
|
[JSR]: https://jsr.io/@logtape/sentry
|
|
14
14
|
[JSR badge]: https://jsr.io/badges/@logtape/sentry
|
|
@@ -56,7 +56,8 @@ await configure({
|
|
|
56
56
|
~~~~
|
|
57
57
|
|
|
58
58
|
If you want to explicitly configure the Sentry client, you can pass the
|
|
59
|
-
`Client` instance
|
|
59
|
+
`Client` instance, which is returned by `init()` or `getClient()` functions,
|
|
60
|
+
to the `getSentrySink()` function:
|
|
60
61
|
|
|
61
62
|
~~~~ typescript
|
|
62
63
|
import { configure } from "@logtape/logtape";
|
|
@@ -70,30 +71,8 @@ await configure({
|
|
|
70
71
|
sinks: {
|
|
71
72
|
sentry: getSentrySink(client),
|
|
72
73
|
},
|
|
73
|
-
filters: {},
|
|
74
74
|
loggers: [
|
|
75
75
|
{ category: [], sinks: ["sentry"], lowestLevel: "trace" },
|
|
76
76
|
],
|
|
77
77
|
});
|
|
78
78
|
~~~~
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Changelog
|
|
82
|
-
---------
|
|
83
|
-
|
|
84
|
-
### Version 0.2.0
|
|
85
|
-
|
|
86
|
-
To be released.
|
|
87
|
-
|
|
88
|
-
- The minimum supported version of LogTape is now 0.12.0, which introduces
|
|
89
|
-
`"trace"` log level support.
|
|
90
|
-
|
|
91
|
-
- Log records having `error` property will now be sent to Sentry as
|
|
92
|
-
exceptions. [[#1], [#2] by Martin Becze]
|
|
93
|
-
|
|
94
|
-
[#1]: https://github.com/dahlia/logtape-sentry/issues/1
|
|
95
|
-
[#2]: https://github.com/dahlia/logtape-sentry/pull/2
|
|
96
|
-
|
|
97
|
-
### Version 0.1.0
|
|
98
|
-
|
|
99
|
-
Initial release. Released on November 26, 2024.
|
package/deno.json
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
|
|
25
|
+
Object.defineProperty(exports, '__toESM', {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return __toESM;
|
|
29
|
+
}
|
|
30
|
+
});
|
package/dist/mod.cjs
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('./_virtual/rolldown_runtime.cjs');
|
|
2
|
+
const __sentry_core = require_rolldown_runtime.__toESM(require("@sentry/core"));
|
|
3
|
+
|
|
4
|
+
//#region mod.ts
|
|
5
|
+
function getParameterizedString(record) {
|
|
6
|
+
let result = "";
|
|
7
|
+
let tplString = "";
|
|
8
|
+
const tplValues = [];
|
|
9
|
+
for (let i = 0; i < record.message.length; i++) if (i % 2 === 0) {
|
|
10
|
+
result += record.message[i];
|
|
11
|
+
tplString += String(record.message[i]).replaceAll("%", "%%");
|
|
12
|
+
} else {
|
|
13
|
+
const value = inspect(record.message[i]);
|
|
14
|
+
result += value;
|
|
15
|
+
tplString += `%s`;
|
|
16
|
+
tplValues.push(value);
|
|
17
|
+
}
|
|
18
|
+
const paramStr = new String(result);
|
|
19
|
+
paramStr.__sentry_template_string__ = tplString;
|
|
20
|
+
paramStr.__sentry_template_values__ = tplValues;
|
|
21
|
+
return result;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
25
|
+
* and in Node.js/Bun it is {@link util.inspect}. If neither is available, it
|
|
26
|
+
* falls back to {@link JSON.stringify}.
|
|
27
|
+
*
|
|
28
|
+
* @param value The value to inspect.
|
|
29
|
+
* @returns The string representation of the value.
|
|
30
|
+
*/
|
|
31
|
+
const inspect = "Deno" in globalThis && "inspect" in globalThis.Deno && typeof globalThis.Deno.inspect === "function" ? globalThis.Deno.inspect : "util" in globalThis && "inspect" in globalThis.util && globalThis.util.inspect === "function" ? globalThis.util.inspect : JSON.stringify;
|
|
32
|
+
/**
|
|
33
|
+
* Gets a LogTape sink that sends logs to Sentry.
|
|
34
|
+
* @param client The Sentry client. If omitted, the global default client is
|
|
35
|
+
* used.
|
|
36
|
+
* @returns A LogTape sink that sends logs to Sentry.
|
|
37
|
+
*/
|
|
38
|
+
function getSentrySink(client) {
|
|
39
|
+
return (record) => {
|
|
40
|
+
const message = getParameterizedString(record);
|
|
41
|
+
if (client == null) client = (0, __sentry_core.getClient)();
|
|
42
|
+
if (record.level === "error" && record.properties.error instanceof Error) {
|
|
43
|
+
const { error,...rest } = record.properties;
|
|
44
|
+
client?.captureException(error, { data: {
|
|
45
|
+
message,
|
|
46
|
+
...rest
|
|
47
|
+
} });
|
|
48
|
+
} else client?.captureMessage(message, record.level === "trace" ? "debug" : record.level, { data: record.properties });
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
//#endregion
|
|
53
|
+
exports.getSentrySink = getSentrySink;
|
package/dist/mod.d.cts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Sink } from "@logtape/logtape";
|
|
2
|
+
import { Client } from "@sentry/core";
|
|
3
|
+
|
|
4
|
+
//#region mod.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Gets a LogTape sink that sends logs to Sentry.
|
|
8
|
+
* @param client The Sentry client. If omitted, the global default client is
|
|
9
|
+
* used.
|
|
10
|
+
* @returns A LogTape sink that sends logs to Sentry.
|
|
11
|
+
*/
|
|
12
|
+
declare function getSentrySink(client?: Client): Sink;
|
|
13
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { getSentrySink };
|
|
17
|
+
//# sourceMappingURL=mod.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.cts","names":[],"sources":["../mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuDA;;;;AAAoD,iBAApC,aAAA,CAAoC,MAAA,CAAA,EAAb,MAAa,CAAA,EAAJ,IAAI"}
|
package/dist/mod.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Client } from "@sentry/core";
|
|
2
|
+
import { Sink } from "@logtape/logtape";
|
|
3
|
+
|
|
4
|
+
//#region mod.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Gets a LogTape sink that sends logs to Sentry.
|
|
8
|
+
* @param client The Sentry client. If omitted, the global default client is
|
|
9
|
+
* used.
|
|
10
|
+
* @returns A LogTape sink that sends logs to Sentry.
|
|
11
|
+
*/
|
|
12
|
+
declare function getSentrySink(client?: Client): Sink;
|
|
13
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
14
|
+
|
|
15
|
+
//#endregion
|
|
16
|
+
export { getSentrySink };
|
|
17
|
+
//# sourceMappingURL=mod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.d.ts","names":[],"sources":["../mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuDA;;;;AAAoD,iBAApC,aAAA,CAAoC,MAAA,CAAA,EAAb,MAAa,CAAA,EAAJ,IAAI"}
|
package/dist/mod.js
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { getClient } from "@sentry/core";
|
|
2
|
+
|
|
3
|
+
//#region mod.ts
|
|
4
|
+
function getParameterizedString(record) {
|
|
5
|
+
let result = "";
|
|
6
|
+
let tplString = "";
|
|
7
|
+
const tplValues = [];
|
|
8
|
+
for (let i = 0; i < record.message.length; i++) if (i % 2 === 0) {
|
|
9
|
+
result += record.message[i];
|
|
10
|
+
tplString += String(record.message[i]).replaceAll("%", "%%");
|
|
11
|
+
} else {
|
|
12
|
+
const value = inspect(record.message[i]);
|
|
13
|
+
result += value;
|
|
14
|
+
tplString += `%s`;
|
|
15
|
+
tplValues.push(value);
|
|
16
|
+
}
|
|
17
|
+
const paramStr = new String(result);
|
|
18
|
+
paramStr.__sentry_template_string__ = tplString;
|
|
19
|
+
paramStr.__sentry_template_values__ = tplValues;
|
|
20
|
+
return result;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
24
|
+
* and in Node.js/Bun it is {@link util.inspect}. If neither is available, it
|
|
25
|
+
* falls back to {@link JSON.stringify}.
|
|
26
|
+
*
|
|
27
|
+
* @param value The value to inspect.
|
|
28
|
+
* @returns The string representation of the value.
|
|
29
|
+
*/
|
|
30
|
+
const inspect = "Deno" in globalThis && "inspect" in globalThis.Deno && typeof globalThis.Deno.inspect === "function" ? globalThis.Deno.inspect : "util" in globalThis && "inspect" in globalThis.util && globalThis.util.inspect === "function" ? globalThis.util.inspect : JSON.stringify;
|
|
31
|
+
/**
|
|
32
|
+
* Gets a LogTape sink that sends logs to Sentry.
|
|
33
|
+
* @param client The Sentry client. If omitted, the global default client is
|
|
34
|
+
* used.
|
|
35
|
+
* @returns A LogTape sink that sends logs to Sentry.
|
|
36
|
+
*/
|
|
37
|
+
function getSentrySink(client) {
|
|
38
|
+
return (record) => {
|
|
39
|
+
const message = getParameterizedString(record);
|
|
40
|
+
if (client == null) client = getClient();
|
|
41
|
+
if (record.level === "error" && record.properties.error instanceof Error) {
|
|
42
|
+
const { error,...rest } = record.properties;
|
|
43
|
+
client?.captureException(error, { data: {
|
|
44
|
+
message,
|
|
45
|
+
...rest
|
|
46
|
+
} });
|
|
47
|
+
} else client?.captureMessage(message, record.level === "trace" ? "debug" : record.level, { data: record.properties });
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
//#endregion
|
|
52
|
+
export { getSentrySink };
|
|
53
|
+
//# sourceMappingURL=mod.js.map
|
package/dist/mod.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mod.js","names":["record: LogRecord","tplValues: string[]","inspect: (value: unknown) => string","client?: Client"],"sources":["../mod.ts"],"sourcesContent":["import type { LogRecord, Sink } from \"@logtape/logtape\";\nimport { type Client, getClient, type ParameterizedString } from \"@sentry/core\";\n// deno-lint-ignore no-unused-vars\nimport type util from \"node:util\";\n\nfunction getParameterizedString(record: LogRecord): ParameterizedString {\n let result = \"\";\n let tplString = \"\";\n const tplValues: string[] = [];\n for (let i = 0; i < record.message.length; i++) {\n if (i % 2 === 0) {\n result += record.message[i];\n tplString += String(record.message[i]).replaceAll(\"%\", \"%%\");\n } else {\n const value = inspect(record.message[i]);\n result += value;\n tplString += `%s`;\n tplValues.push(value);\n }\n }\n const paramStr = new String(result) as ParameterizedString;\n paramStr.__sentry_template_string__ = tplString;\n paramStr.__sentry_template_values__ = tplValues;\n return result;\n}\n\n/**\n * A platform-specific inspect function. In Deno, this is {@link Deno.inspect},\n * and in Node.js/Bun it is {@link util.inspect}. If neither is available, it\n * falls back to {@link JSON.stringify}.\n *\n * @param value The value to inspect.\n * @returns The string representation of the value.\n */\nconst inspect: (value: unknown) => string =\n // @ts-ignore: Deno global\n \"Deno\" in globalThis && \"inspect\" in globalThis.Deno &&\n // @ts-ignore: Deno global\n typeof globalThis.Deno.inspect === \"function\"\n // @ts-ignore: Deno global\n ? globalThis.Deno.inspect\n // @ts-ignore: Node.js global\n : \"util\" in globalThis && \"inspect\" in globalThis.util &&\n // @ts-ignore: Node.js global\n globalThis.util.inspect === \"function\"\n // @ts-ignore: Node.js global\n ? globalThis.util.inspect\n : JSON.stringify;\n\n/**\n * Gets a LogTape sink that sends logs to Sentry.\n * @param client The Sentry client. If omitted, the global default client is\n * used.\n * @returns A LogTape sink that sends logs to Sentry.\n */\nexport function getSentrySink(client?: Client): Sink {\n return (record: LogRecord) => {\n const message = getParameterizedString(record);\n if (client == null) client = getClient();\n if (record.level === \"error\" && record.properties.error instanceof Error) {\n const { error, ...rest } = record.properties;\n client?.captureException(error, {\n data: {\n message,\n ...rest,\n },\n });\n } else {\n client?.captureMessage(\n message,\n record.level === \"trace\" ? \"debug\" : record.level,\n {\n data: record.properties,\n },\n );\n }\n };\n}\n"],"mappings":";;;AAKA,SAAS,uBAAuBA,QAAwC;CACtE,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,MAAMC,YAAsB,CAAE;AAC9B,MAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,QAAQ,IACzC,KAAI,IAAI,MAAM,GAAG;AACf,YAAU,OAAO,QAAQ;AACzB,eAAa,OAAO,OAAO,QAAQ,GAAG,CAAC,WAAW,KAAK,KAAK;CAC7D,OAAM;EACL,MAAM,QAAQ,QAAQ,OAAO,QAAQ,GAAG;AACxC,YAAU;AACV,gBAAc;AACd,YAAU,KAAK,MAAM;CACtB;CAEH,MAAM,WAAW,IAAI,OAAO;AAC5B,UAAS,6BAA6B;AACtC,UAAS,6BAA6B;AACtC,QAAO;AACR;;;;;;;;;AAUD,MAAMC,UAEJ,UAAU,cAAc,aAAa,WAAW,eAEvC,WAAW,KAAK,YAAY,aAEjC,WAAW,KAAK,UAEhB,UAAU,cAAc,aAAa,WAAW,QAE9C,WAAW,KAAK,YAAY,aAE9B,WAAW,KAAK,UAChB,KAAK;;;;;;;AAQX,SAAgB,cAAcC,QAAuB;AACnD,QAAO,CAACH,WAAsB;EAC5B,MAAM,UAAU,uBAAuB,OAAO;AAC9C,MAAI,UAAU,KAAM,UAAS,WAAW;AACxC,MAAI,OAAO,UAAU,WAAW,OAAO,WAAW,iBAAiB,OAAO;GACxE,MAAM,EAAE,MAAO,GAAG,MAAM,GAAG,OAAO;AAClC,WAAQ,iBAAiB,OAAO,EAC9B,MAAM;IACJ;IACA,GAAG;GACJ,EACF,EAAC;EACH,MACC,SAAQ,eACN,SACA,OAAO,UAAU,UAAU,UAAU,OAAO,OAC5C,EACE,MAAM,OAAO,WACd,EACF;CAEJ;AACF"}
|
package/mod.ts
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import type { LogRecord, Sink } from "@logtape/logtape";
|
|
2
|
+
import { type Client, getClient, type ParameterizedString } from "@sentry/core";
|
|
3
|
+
// deno-lint-ignore no-unused-vars
|
|
4
|
+
import type util from "node:util";
|
|
5
|
+
|
|
6
|
+
function getParameterizedString(record: LogRecord): ParameterizedString {
|
|
7
|
+
let result = "";
|
|
8
|
+
let tplString = "";
|
|
9
|
+
const tplValues: string[] = [];
|
|
10
|
+
for (let i = 0; i < record.message.length; i++) {
|
|
11
|
+
if (i % 2 === 0) {
|
|
12
|
+
result += record.message[i];
|
|
13
|
+
tplString += String(record.message[i]).replaceAll("%", "%%");
|
|
14
|
+
} else {
|
|
15
|
+
const value = inspect(record.message[i]);
|
|
16
|
+
result += value;
|
|
17
|
+
tplString += `%s`;
|
|
18
|
+
tplValues.push(value);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
const paramStr = new String(result) as ParameterizedString;
|
|
22
|
+
paramStr.__sentry_template_string__ = tplString;
|
|
23
|
+
paramStr.__sentry_template_values__ = tplValues;
|
|
24
|
+
return result;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
29
|
+
* and in Node.js/Bun it is {@link util.inspect}. If neither is available, it
|
|
30
|
+
* falls back to {@link JSON.stringify}.
|
|
31
|
+
*
|
|
32
|
+
* @param value The value to inspect.
|
|
33
|
+
* @returns The string representation of the value.
|
|
34
|
+
*/
|
|
35
|
+
const inspect: (value: unknown) => string =
|
|
36
|
+
// @ts-ignore: Deno global
|
|
37
|
+
"Deno" in globalThis && "inspect" in globalThis.Deno &&
|
|
38
|
+
// @ts-ignore: Deno global
|
|
39
|
+
typeof globalThis.Deno.inspect === "function"
|
|
40
|
+
// @ts-ignore: Deno global
|
|
41
|
+
? globalThis.Deno.inspect
|
|
42
|
+
// @ts-ignore: Node.js global
|
|
43
|
+
: "util" in globalThis && "inspect" in globalThis.util &&
|
|
44
|
+
// @ts-ignore: Node.js global
|
|
45
|
+
globalThis.util.inspect === "function"
|
|
46
|
+
// @ts-ignore: Node.js global
|
|
47
|
+
? globalThis.util.inspect
|
|
48
|
+
: JSON.stringify;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets a LogTape sink that sends logs to Sentry.
|
|
52
|
+
* @param client The Sentry client. If omitted, the global default client is
|
|
53
|
+
* used.
|
|
54
|
+
* @returns A LogTape sink that sends logs to Sentry.
|
|
55
|
+
*/
|
|
56
|
+
export function getSentrySink(client?: Client): Sink {
|
|
57
|
+
return (record: LogRecord) => {
|
|
58
|
+
const message = getParameterizedString(record);
|
|
59
|
+
if (client == null) client = getClient();
|
|
60
|
+
if (record.level === "error" && record.properties.error instanceof Error) {
|
|
61
|
+
const { error, ...rest } = record.properties;
|
|
62
|
+
client?.captureException(error, {
|
|
63
|
+
data: {
|
|
64
|
+
message,
|
|
65
|
+
...rest,
|
|
66
|
+
},
|
|
67
|
+
});
|
|
68
|
+
} else {
|
|
69
|
+
client?.captureMessage(
|
|
70
|
+
message,
|
|
71
|
+
record.level === "trace" ? "debug" : record.level,
|
|
72
|
+
{
|
|
73
|
+
data: record.properties,
|
|
74
|
+
},
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
package/package.json
CHANGED
|
@@ -1,53 +1,54 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@logtape/sentry",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "LogTape Sentry
|
|
3
|
+
"version": "0.12.0-dev.193+bbda61ae",
|
|
4
|
+
"description": "LogTape Sentry sink",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"LogTape",
|
|
7
7
|
"Sentry"
|
|
8
8
|
],
|
|
9
|
+
"license": "MIT",
|
|
9
10
|
"author": {
|
|
10
11
|
"name": "Hong Minhee",
|
|
11
12
|
"email": "hong@minhee.org",
|
|
12
13
|
"url": "https://hongminhee.org/"
|
|
13
14
|
},
|
|
14
|
-
"homepage": "https://
|
|
15
|
+
"homepage": "https://logtape.org/",
|
|
15
16
|
"repository": {
|
|
16
17
|
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/dahlia/logtape
|
|
18
|
+
"url": "git+https://github.com/dahlia/logtape.git",
|
|
19
|
+
"directory": "sentry/"
|
|
18
20
|
},
|
|
19
|
-
"license": "MIT",
|
|
20
21
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/dahlia/logtape
|
|
22
|
+
"url": "https://github.com/dahlia/logtape/issues"
|
|
22
23
|
},
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
"funding": [
|
|
25
|
+
"https://github.com/sponsors/dahlia"
|
|
26
|
+
],
|
|
27
|
+
"type": "module",
|
|
28
|
+
"module": "./dist/mod.js",
|
|
29
|
+
"main": "./dist/mod.cjs",
|
|
30
|
+
"types": "./dist/mod.d.ts",
|
|
26
31
|
"exports": {
|
|
27
32
|
".": {
|
|
28
|
-
"import":
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
"types": "./types/mod.d.ts",
|
|
34
|
-
"default": "./script/mod.js"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
33
|
+
"import": "./dist/mod.js",
|
|
34
|
+
"require": "./dist/mod.cjs",
|
|
35
|
+
"types": "./dist/mod.d.ts"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
37
38
|
},
|
|
38
|
-
"
|
|
39
|
-
"
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@logtape/logtape": "0.12.0-dev.193+bbda61ae"
|
|
40
41
|
},
|
|
41
|
-
"funding": [
|
|
42
|
-
"https://github.com/sponsors/dahlia"
|
|
43
|
-
],
|
|
44
42
|
"dependencies": {
|
|
45
|
-
"@logtape/logtape": "^0.12.0-dev.186",
|
|
46
43
|
"@sentry/core": "^9.28.1"
|
|
47
44
|
},
|
|
48
45
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
-
"
|
|
46
|
+
"@std/dotenv": "npm:@jsr/std__dotenv@^0.225.5",
|
|
47
|
+
"tsdown": "^0.12.7",
|
|
48
|
+
"typescript": "^5.8.3"
|
|
51
49
|
},
|
|
52
|
-
"
|
|
50
|
+
"scripts": {
|
|
51
|
+
"build": "tsdown",
|
|
52
|
+
"prepublish": "tsdown"
|
|
53
|
+
}
|
|
53
54
|
}
|
package/tsdown.config.ts
ADDED
package/esm/_dnt.shims.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
const dntGlobals = {};
|
|
2
|
-
export const dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
3
|
-
function createMergeProxy(baseObj, extObj) {
|
|
4
|
-
return new Proxy(baseObj, {
|
|
5
|
-
get(_target, prop, _receiver) {
|
|
6
|
-
if (prop in extObj) {
|
|
7
|
-
return extObj[prop];
|
|
8
|
-
}
|
|
9
|
-
else {
|
|
10
|
-
return baseObj[prop];
|
|
11
|
-
}
|
|
12
|
-
},
|
|
13
|
-
set(_target, prop, value) {
|
|
14
|
-
if (prop in extObj) {
|
|
15
|
-
delete extObj[prop];
|
|
16
|
-
}
|
|
17
|
-
baseObj[prop] = value;
|
|
18
|
-
return true;
|
|
19
|
-
},
|
|
20
|
-
deleteProperty(_target, prop) {
|
|
21
|
-
let success = false;
|
|
22
|
-
if (prop in extObj) {
|
|
23
|
-
delete extObj[prop];
|
|
24
|
-
success = true;
|
|
25
|
-
}
|
|
26
|
-
if (prop in baseObj) {
|
|
27
|
-
delete baseObj[prop];
|
|
28
|
-
success = true;
|
|
29
|
-
}
|
|
30
|
-
return success;
|
|
31
|
-
},
|
|
32
|
-
ownKeys(_target) {
|
|
33
|
-
const baseKeys = Reflect.ownKeys(baseObj);
|
|
34
|
-
const extKeys = Reflect.ownKeys(extObj);
|
|
35
|
-
const extKeysSet = new Set(extKeys);
|
|
36
|
-
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
37
|
-
},
|
|
38
|
-
defineProperty(_target, prop, desc) {
|
|
39
|
-
if (prop in extObj) {
|
|
40
|
-
delete extObj[prop];
|
|
41
|
-
}
|
|
42
|
-
Reflect.defineProperty(baseObj, prop, desc);
|
|
43
|
-
return true;
|
|
44
|
-
},
|
|
45
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
46
|
-
if (prop in extObj) {
|
|
47
|
-
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
48
|
-
}
|
|
49
|
-
else {
|
|
50
|
-
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
51
|
-
}
|
|
52
|
-
},
|
|
53
|
-
has(_target, prop) {
|
|
54
|
-
return prop in extObj || prop in baseObj;
|
|
55
|
-
},
|
|
56
|
-
});
|
|
57
|
-
}
|
package/esm/mod.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import * as dntShim from "./_dnt.shims.js";
|
|
2
|
-
import { getClient } from "@sentry/core";
|
|
3
|
-
function getParameterizedString(record) {
|
|
4
|
-
let result = "";
|
|
5
|
-
let tplString = "";
|
|
6
|
-
const tplValues = [];
|
|
7
|
-
for (let i = 0; i < record.message.length; i++) {
|
|
8
|
-
if (i % 2 === 0) {
|
|
9
|
-
result += record.message[i];
|
|
10
|
-
tplString += String(record.message[i]).replaceAll("%", "%%");
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
const value = inspect(record.message[i]);
|
|
14
|
-
result += value;
|
|
15
|
-
tplString += `%s`;
|
|
16
|
-
tplValues.push(value);
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
const paramStr = new String(result);
|
|
20
|
-
paramStr.__sentry_template_string__ = tplString;
|
|
21
|
-
paramStr.__sentry_template_values__ = tplValues;
|
|
22
|
-
return result;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
26
|
-
* and in Node.js/Bun it is {@link util.inspect}. If neither is available, it
|
|
27
|
-
* falls back to {@link JSON.stringify}.
|
|
28
|
-
*
|
|
29
|
-
* @param value The value to inspect.
|
|
30
|
-
* @returns The string representation of the value.
|
|
31
|
-
*/
|
|
32
|
-
const inspect =
|
|
33
|
-
// @ts-ignore: Deno global
|
|
34
|
-
"Deno" in dntShim.dntGlobalThis && "inspect" in globalThis.Deno &&
|
|
35
|
-
// @ts-ignore: Deno global
|
|
36
|
-
typeof globalThis.Deno.inspect === "function"
|
|
37
|
-
// @ts-ignore: Deno global
|
|
38
|
-
? globalThis.Deno.inspect
|
|
39
|
-
// @ts-ignore: Node.js global
|
|
40
|
-
: "util" in dntShim.dntGlobalThis && "inspect" in globalThis.util &&
|
|
41
|
-
// @ts-ignore: Node.js global
|
|
42
|
-
globalThis.util.inspect === "function"
|
|
43
|
-
// @ts-ignore: Node.js global
|
|
44
|
-
? globalThis.util.inspect
|
|
45
|
-
: JSON.stringify;
|
|
46
|
-
/**
|
|
47
|
-
* Gets a LogTape sink that sends logs to Sentry.
|
|
48
|
-
* @param client The Sentry client. If omitted, the global default client is
|
|
49
|
-
* used.
|
|
50
|
-
* @returns A LogTape sink that sends logs to Sentry.
|
|
51
|
-
*/
|
|
52
|
-
export function getSentrySink(client) {
|
|
53
|
-
return (record) => {
|
|
54
|
-
const message = getParameterizedString(record);
|
|
55
|
-
if (client == null)
|
|
56
|
-
client = getClient();
|
|
57
|
-
if (record.level === "error" && record.properties.error instanceof Error) {
|
|
58
|
-
const { error, ...rest } = record.properties;
|
|
59
|
-
client?.captureException(error, {
|
|
60
|
-
data: {
|
|
61
|
-
message,
|
|
62
|
-
...rest,
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
client?.captureMessage(message, record.level === "trace" ? "debug" : record.level, {
|
|
68
|
-
data: record.properties,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
}
|
package/esm/package.json
DELETED
package/script/_dnt.shims.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.dntGlobalThis = void 0;
|
|
4
|
-
const dntGlobals = {};
|
|
5
|
-
exports.dntGlobalThis = createMergeProxy(globalThis, dntGlobals);
|
|
6
|
-
function createMergeProxy(baseObj, extObj) {
|
|
7
|
-
return new Proxy(baseObj, {
|
|
8
|
-
get(_target, prop, _receiver) {
|
|
9
|
-
if (prop in extObj) {
|
|
10
|
-
return extObj[prop];
|
|
11
|
-
}
|
|
12
|
-
else {
|
|
13
|
-
return baseObj[prop];
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
set(_target, prop, value) {
|
|
17
|
-
if (prop in extObj) {
|
|
18
|
-
delete extObj[prop];
|
|
19
|
-
}
|
|
20
|
-
baseObj[prop] = value;
|
|
21
|
-
return true;
|
|
22
|
-
},
|
|
23
|
-
deleteProperty(_target, prop) {
|
|
24
|
-
let success = false;
|
|
25
|
-
if (prop in extObj) {
|
|
26
|
-
delete extObj[prop];
|
|
27
|
-
success = true;
|
|
28
|
-
}
|
|
29
|
-
if (prop in baseObj) {
|
|
30
|
-
delete baseObj[prop];
|
|
31
|
-
success = true;
|
|
32
|
-
}
|
|
33
|
-
return success;
|
|
34
|
-
},
|
|
35
|
-
ownKeys(_target) {
|
|
36
|
-
const baseKeys = Reflect.ownKeys(baseObj);
|
|
37
|
-
const extKeys = Reflect.ownKeys(extObj);
|
|
38
|
-
const extKeysSet = new Set(extKeys);
|
|
39
|
-
return [...baseKeys.filter((k) => !extKeysSet.has(k)), ...extKeys];
|
|
40
|
-
},
|
|
41
|
-
defineProperty(_target, prop, desc) {
|
|
42
|
-
if (prop in extObj) {
|
|
43
|
-
delete extObj[prop];
|
|
44
|
-
}
|
|
45
|
-
Reflect.defineProperty(baseObj, prop, desc);
|
|
46
|
-
return true;
|
|
47
|
-
},
|
|
48
|
-
getOwnPropertyDescriptor(_target, prop) {
|
|
49
|
-
if (prop in extObj) {
|
|
50
|
-
return Reflect.getOwnPropertyDescriptor(extObj, prop);
|
|
51
|
-
}
|
|
52
|
-
else {
|
|
53
|
-
return Reflect.getOwnPropertyDescriptor(baseObj, prop);
|
|
54
|
-
}
|
|
55
|
-
},
|
|
56
|
-
has(_target, prop) {
|
|
57
|
-
return prop in extObj || prop in baseObj;
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
}
|
package/script/mod.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.getSentrySink = getSentrySink;
|
|
27
|
-
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
28
|
-
const core_1 = require("@sentry/core");
|
|
29
|
-
function getParameterizedString(record) {
|
|
30
|
-
let result = "";
|
|
31
|
-
let tplString = "";
|
|
32
|
-
const tplValues = [];
|
|
33
|
-
for (let i = 0; i < record.message.length; i++) {
|
|
34
|
-
if (i % 2 === 0) {
|
|
35
|
-
result += record.message[i];
|
|
36
|
-
tplString += String(record.message[i]).replaceAll("%", "%%");
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
39
|
-
const value = inspect(record.message[i]);
|
|
40
|
-
result += value;
|
|
41
|
-
tplString += `%s`;
|
|
42
|
-
tplValues.push(value);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
const paramStr = new String(result);
|
|
46
|
-
paramStr.__sentry_template_string__ = tplString;
|
|
47
|
-
paramStr.__sentry_template_values__ = tplValues;
|
|
48
|
-
return result;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
|
|
52
|
-
* and in Node.js/Bun it is {@link util.inspect}. If neither is available, it
|
|
53
|
-
* falls back to {@link JSON.stringify}.
|
|
54
|
-
*
|
|
55
|
-
* @param value The value to inspect.
|
|
56
|
-
* @returns The string representation of the value.
|
|
57
|
-
*/
|
|
58
|
-
const inspect =
|
|
59
|
-
// @ts-ignore: Deno global
|
|
60
|
-
"Deno" in dntShim.dntGlobalThis && "inspect" in globalThis.Deno &&
|
|
61
|
-
// @ts-ignore: Deno global
|
|
62
|
-
typeof globalThis.Deno.inspect === "function"
|
|
63
|
-
// @ts-ignore: Deno global
|
|
64
|
-
? globalThis.Deno.inspect
|
|
65
|
-
// @ts-ignore: Node.js global
|
|
66
|
-
: "util" in dntShim.dntGlobalThis && "inspect" in globalThis.util &&
|
|
67
|
-
// @ts-ignore: Node.js global
|
|
68
|
-
globalThis.util.inspect === "function"
|
|
69
|
-
// @ts-ignore: Node.js global
|
|
70
|
-
? globalThis.util.inspect
|
|
71
|
-
: JSON.stringify;
|
|
72
|
-
/**
|
|
73
|
-
* Gets a LogTape sink that sends logs to Sentry.
|
|
74
|
-
* @param client The Sentry client. If omitted, the global default client is
|
|
75
|
-
* used.
|
|
76
|
-
* @returns A LogTape sink that sends logs to Sentry.
|
|
77
|
-
*/
|
|
78
|
-
function getSentrySink(client) {
|
|
79
|
-
return (record) => {
|
|
80
|
-
const message = getParameterizedString(record);
|
|
81
|
-
if (client == null)
|
|
82
|
-
client = (0, core_1.getClient)();
|
|
83
|
-
if (record.level === "error" && record.properties.error instanceof Error) {
|
|
84
|
-
const { error, ...rest } = record.properties;
|
|
85
|
-
client?.captureException(error, {
|
|
86
|
-
data: {
|
|
87
|
-
message,
|
|
88
|
-
...rest,
|
|
89
|
-
},
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
client?.captureMessage(message, record.level === "trace" ? "debug" : record.level, {
|
|
94
|
-
data: record.properties,
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
package/script/package.json
DELETED
package/types/_dnt.shims.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"_dnt.shims.d.ts","sourceRoot":"","sources":["../src/_dnt.shims.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,aAAa,gCAA2C,CAAC"}
|
package/types/mod.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Sink } from "@logtape/logtape";
|
|
2
|
-
import { type Client } from "@sentry/core";
|
|
3
|
-
/**
|
|
4
|
-
* Gets a LogTape sink that sends logs to Sentry.
|
|
5
|
-
* @param client The Sentry client. If omitted, the global default client is
|
|
6
|
-
* used.
|
|
7
|
-
* @returns A LogTape sink that sends logs to Sentry.
|
|
8
|
-
*/
|
|
9
|
-
export declare function getSentrySink(client?: Client): Sink;
|
|
10
|
-
//# sourceMappingURL=mod.d.ts.map
|
package/types/mod.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAa,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,EAAE,KAAK,MAAM,EAAuC,MAAM,cAAc,CAAC;AAgDhF;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAsBnD"}
|