@logtape/sentry 0.1.0 → 0.2.0-dev.8

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 CHANGED
@@ -26,11 +26,11 @@ Installation
26
26
  The package is available on [JSR] and [npm].
27
27
 
28
28
  ~~~~ bash
29
- deno add @logtape/sentry # for Deno
30
- npm add @logtape/sentry # for npm
31
- pnpm add @logtape/sentry # for pnpm
32
- yarn add @logtape/sentry # for Yarn
33
- bun add @logtape/sentry # for Bun
29
+ deno add jsr:@logtape/sentry # for Deno
30
+ npm add @logtape/sentry # for npm
31
+ pnpm add @logtape/sentry # for pnpm
32
+ yarn add @logtape/sentry # for Yarn
33
+ bun add @logtape/sentry # for Bun
34
34
  ~~~~
35
35
 
36
36
 
@@ -50,7 +50,7 @@ await configure({
50
50
  },
51
51
  filters: {},
52
52
  loggers: [
53
- { category: [], sinks: ["sentry"], level: "debug" },
53
+ { category: [], sinks: ["sentry"], lowestLevel: "trace" },
54
54
  ],
55
55
  });
56
56
  ~~~~
@@ -72,7 +72,7 @@ await configure({
72
72
  },
73
73
  filters: {},
74
74
  loggers: [
75
- { category: [], sinks: ["sentry"], level: "debug" },
75
+ { category: [], sinks: ["sentry"], lowestLevel: "trace" },
76
76
  ],
77
77
  });
78
78
  ~~~~
@@ -81,6 +81,19 @@ await configure({
81
81
  Changelog
82
82
  ---------
83
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
+
84
97
  ### Version 0.1.0
85
98
 
86
99
  Initial release. Released on November 26, 2024.
package/esm/mod.js CHANGED
@@ -51,8 +51,22 @@ const inspect =
51
51
  */
52
52
  export function getSentrySink(client) {
53
53
  return (record) => {
54
+ const message = getParameterizedString(record);
54
55
  if (client == null)
55
56
  client = getClient();
56
- client?.captureMessage(getParameterizedString(record), record.level, { data: record.properties });
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
+ }
57
71
  };
58
72
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logtape/sentry",
3
- "version": "0.1.0",
3
+ "version": "0.2.0-dev.8+78b714f1",
4
4
  "description": "LogTape Sentry Sink",
5
5
  "keywords": [
6
6
  "LogTape",
@@ -42,9 +42,8 @@
42
42
  "https://github.com/sponsors/dahlia"
43
43
  ],
44
44
  "dependencies": {
45
- "@logtape/logtape": "^0.8.0",
46
- "@sentry/core": "^8.40.0",
47
- "@sentry/types": "^8.40.0"
45
+ "@logtape/logtape": "^0.12.0-dev.186",
46
+ "@sentry/core": "^9.28.1"
48
47
  },
49
48
  "devDependencies": {
50
49
  "@types/node": "^20.9.0",
package/script/mod.js CHANGED
@@ -77,8 +77,22 @@ const inspect =
77
77
  */
78
78
  function getSentrySink(client) {
79
79
  return (record) => {
80
+ const message = getParameterizedString(record);
80
81
  if (client == null)
81
82
  client = (0, core_1.getClient)();
82
- client?.captureMessage(getParameterizedString(record), record.level, { data: record.properties });
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
+ }
83
97
  };
84
98
  }
package/types/mod.d.ts CHANGED
@@ -1,11 +1,10 @@
1
1
  import type { Sink } from "@logtape/logtape";
2
- import { type BaseClient } from "@sentry/core";
3
- import type { ClientOptions } from "@sentry/types";
2
+ import { type Client } from "@sentry/core";
4
3
  /**
5
4
  * Gets a LogTape sink that sends logs to Sentry.
6
5
  * @param client The Sentry client. If omitted, the global default client is
7
6
  * used.
8
7
  * @returns A LogTape sink that sends logs to Sentry.
9
8
  */
10
- export declare function getSentrySink(client?: BaseClient<ClientOptions>): Sink;
9
+ export declare function getSentrySink(client?: Client): Sink;
11
10
  //# sourceMappingURL=mod.d.ts.map
@@ -1 +1 @@
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,UAAU,EAAa,MAAM,cAAc,CAAC;AAC1D,OAAO,KAAK,EAAE,aAAa,EAAuB,MAAM,eAAe,CAAC;AAgDxE;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,UAAU,CAAC,aAAa,CAAC,GAAG,IAAI,CAStE"}
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"}