@logtape/sentry 1.1.0-dev.324 → 1.1.0-dev.332

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/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/sentry",
3
- "version": "1.1.0-dev.324+017000e7",
3
+ "version": "1.1.0-dev.332+cfc70069",
4
4
  "license": "MIT",
5
5
  "exports": {
6
6
  ".": "./src/mod.ts"
package/dist/mod.cjs CHANGED
@@ -18,11 +18,11 @@ function getParameterizedString(record) {
18
18
  const paramStr = new String(result);
19
19
  paramStr.__sentry_template_string__ = tplString;
20
20
  paramStr.__sentry_template_values__ = tplValues;
21
- return result;
21
+ return paramStr;
22
22
  }
23
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
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
26
  * falls back to {@link JSON.stringify}.
27
27
  *
28
28
  * @param value The value to inspect.
@@ -31,7 +31,7 @@ function getParameterizedString(record) {
31
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
32
  /**
33
33
  * Gets a LogTape sink that sends logs to Sentry.
34
- * @param client The Sentry client. If omitted, the global default client is
34
+ * @param client The Sentry client. If omitted, the global default client is
35
35
  * used.
36
36
  * @returns A LogTape sink that sends logs to Sentry.
37
37
  */
package/dist/mod.d.cts CHANGED
@@ -1,17 +1,18 @@
1
1
  import { Sink } from "@logtape/logtape";
2
- import { Client } from "@sentry/core";
2
+ import { EventHint, ParameterizedString, Scope, SeverityLevel } from "@sentry/core";
3
3
 
4
4
  //#region src/mod.d.ts
5
-
5
+ interface SentryClientLike {
6
+ captureException: (exception: unknown, hint?: EventHint, scope?: Scope) => string;
7
+ captureMessage: (message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, scope?: Scope) => string;
8
+ }
6
9
  /**
7
10
  * Gets a LogTape sink that sends logs to Sentry.
8
- * @param client The Sentry client. If omitted, the global default client is
11
+ * @param client The Sentry client. If omitted, the global default client is
9
12
  * used.
10
13
  * @returns A LogTape sink that sends logs to Sentry.
11
14
  */
12
- declare function getSentrySink(client?: Client): Sink;
13
- //# sourceMappingURL=mod.d.ts.map
14
-
15
+ declare function getSentrySink(client?: SentryClientLike): Sink;
15
16
  //#endregion
16
17
  export { getSentrySink };
17
18
  //# sourceMappingURL=mod.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuDA;;;;AAAoD,iBAApC,aAAA,CAAoC,MAAA,CAAA,EAAb,MAAa,CAAA,EAAJ,IAAI"}
1
+ {"version":3,"file":"mod.d.cts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;UAqDU,gBAAA;gDAGC,mBACC;EAJF,cAAA,EAAA,CAAA,OAAgB,EAOb,mBAPa,EAAA,KAAA,CAAA,EAQd,aARc,EAAA,IAAA,CAAA,EASf,SATe,EAAA,KAAA,CAAA,EAUd,KAVc,EAAA,GAAA,MAAA;;;;;;;;AAUT,iBAUD,aAAA,CAVC,MAAA,CAAA,EAUsB,gBAVtB,CAAA,EAUyC,IAVzC"}
package/dist/mod.d.ts CHANGED
@@ -1,17 +1,18 @@
1
- import { Client } from "@sentry/core";
1
+ import { EventHint, ParameterizedString, Scope, SeverityLevel } from "@sentry/core";
2
2
  import { Sink } from "@logtape/logtape";
3
3
 
4
4
  //#region src/mod.d.ts
5
-
5
+ interface SentryClientLike {
6
+ captureException: (exception: unknown, hint?: EventHint, scope?: Scope) => string;
7
+ captureMessage: (message: ParameterizedString, level?: SeverityLevel, hint?: EventHint, scope?: Scope) => string;
8
+ }
6
9
  /**
7
10
  * Gets a LogTape sink that sends logs to Sentry.
8
- * @param client The Sentry client. If omitted, the global default client is
11
+ * @param client The Sentry client. If omitted, the global default client is
9
12
  * used.
10
13
  * @returns A LogTape sink that sends logs to Sentry.
11
14
  */
12
- declare function getSentrySink(client?: Client): Sink;
13
- //# sourceMappingURL=mod.d.ts.map
14
-
15
+ declare function getSentrySink(client?: SentryClientLike): Sink;
15
16
  //#endregion
16
17
  export { getSentrySink };
17
18
  //# sourceMappingURL=mod.d.ts.map
package/dist/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;;;;AAuDA;;;;AAAoD,iBAApC,aAAA,CAAoC,MAAA,CAAA,EAAb,MAAa,CAAA,EAAJ,IAAI"}
1
+ {"version":3,"file":"mod.d.ts","names":[],"sources":["../src/mod.ts"],"sourcesContent":[],"mappings":";;;;UAqDU,gBAAA;gDAGC,mBACC;EAJF,cAAA,EAAA,CAAA,OAAgB,EAOb,mBAPa,EAAA,KAAA,CAAA,EAQd,aARc,EAAA,IAAA,CAAA,EASf,SATe,EAAA,KAAA,CAAA,EAUd,KAVc,EAAA,GAAA,MAAA;;;;;;;;AAUT,iBAUD,aAAA,CAVC,MAAA,CAAA,EAUsB,gBAVtB,CAAA,EAUyC,IAVzC"}
package/dist/mod.js CHANGED
@@ -17,11 +17,11 @@ function getParameterizedString(record) {
17
17
  const paramStr = new String(result);
18
18
  paramStr.__sentry_template_string__ = tplString;
19
19
  paramStr.__sentry_template_values__ = tplValues;
20
- return result;
20
+ return paramStr;
21
21
  }
22
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
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
25
  * falls back to {@link JSON.stringify}.
26
26
  *
27
27
  * @param value The value to inspect.
@@ -30,7 +30,7 @@ function getParameterizedString(record) {
30
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
31
  /**
32
32
  * Gets a LogTape sink that sends logs to Sentry.
33
- * @param client The Sentry client. If omitted, the global default client is
33
+ * @param client The Sentry client. If omitted, the global default client is
34
34
  * used.
35
35
  * @returns A LogTape sink that sends logs to Sentry.
36
36
  */
package/dist/mod.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.js","names":["record: LogRecord","tplValues: string[]","inspect: (value: unknown) => string","client?: Client"],"sources":["../src/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"}
1
+ {"version":3,"file":"mod.js","names":["record: LogRecord","tplValues: string[]","inspect: (value: unknown) => string","client?: SentryClientLike"],"sources":["../src/mod.ts"],"sourcesContent":["import type { LogRecord, Sink } from \"@logtape/logtape\";\nimport {\n type EventHint,\n getClient,\n type ParameterizedString,\n type Scope,\n type SeverityLevel,\n} from \"@sentry/core\";\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 paramStr;\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\ninterface SentryClientLike {\n captureException: (\n exception: unknown,\n hint?: EventHint,\n scope?: Scope,\n ) => string;\n captureMessage: (\n message: ParameterizedString,\n level?: SeverityLevel,\n hint?: EventHint,\n scope?: Scope,\n ) => string;\n}\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?: SentryClientLike): 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":";;;AASA,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;;;;;;;AAsBX,SAAgB,cAAcC,QAAiC;AAC7D,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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/sentry",
3
- "version": "1.1.0-dev.324+017000e7",
3
+ "version": "1.1.0-dev.332+cfc70069",
4
4
  "description": "LogTape Sentry sink",
5
5
  "keywords": [
6
6
  "LogTape",
@@ -41,7 +41,7 @@
41
41
  },
42
42
  "sideEffects": false,
43
43
  "peerDependencies": {
44
- "@logtape/logtape": "1.1.0-dev.324+017000e7"
44
+ "@logtape/logtape": "1.1.0-dev.332+cfc70069"
45
45
  },
46
46
  "dependencies": {
47
47
  "@sentry/core": "^9.28.1"
package/src/mod.ts CHANGED
@@ -1,7 +1,11 @@
1
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";
2
+ import {
3
+ type EventHint,
4
+ getClient,
5
+ type ParameterizedString,
6
+ type Scope,
7
+ type SeverityLevel,
8
+ } from "@sentry/core";
5
9
 
6
10
  function getParameterizedString(record: LogRecord): ParameterizedString {
7
11
  let result = "";
@@ -21,12 +25,12 @@ function getParameterizedString(record: LogRecord): ParameterizedString {
21
25
  const paramStr = new String(result) as ParameterizedString;
22
26
  paramStr.__sentry_template_string__ = tplString;
23
27
  paramStr.__sentry_template_values__ = tplValues;
24
- return result;
28
+ return paramStr;
25
29
  }
26
30
 
27
31
  /**
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
32
+ * A platform-specific inspect function. In Deno, this is {@link Deno.inspect},
33
+ * and in Node.js/Bun it is {@link util.inspect}. If neither is available, it
30
34
  * falls back to {@link JSON.stringify}.
31
35
  *
32
36
  * @param value The value to inspect.
@@ -47,13 +51,27 @@ const inspect: (value: unknown) => string =
47
51
  ? globalThis.util.inspect
48
52
  : JSON.stringify;
49
53
 
54
+ interface SentryClientLike {
55
+ captureException: (
56
+ exception: unknown,
57
+ hint?: EventHint,
58
+ scope?: Scope,
59
+ ) => string;
60
+ captureMessage: (
61
+ message: ParameterizedString,
62
+ level?: SeverityLevel,
63
+ hint?: EventHint,
64
+ scope?: Scope,
65
+ ) => string;
66
+ }
67
+
50
68
  /**
51
69
  * Gets a LogTape sink that sends logs to Sentry.
52
- * @param client The Sentry client. If omitted, the global default client is
70
+ * @param client The Sentry client. If omitted, the global default client is
53
71
  * used.
54
72
  * @returns A LogTape sink that sends logs to Sentry.
55
73
  */
56
- export function getSentrySink(client?: Client): Sink {
74
+ export function getSentrySink(client?: SentryClientLike): Sink {
57
75
  return (record: LogRecord) => {
58
76
  const message = getParameterizedString(record);
59
77
  if (client == null) client = getClient();