feat!: API options object support to control sentry handling; removal of logger.sentry.
# Conflicts: # README.md # src/logger.ts # src/sinks/sentry.ts # test/logger.test.ts
This commit is contained in:
+1
-2
@@ -1,9 +1,8 @@
|
||||
# [0.10.0](https://git.mifi.dev/mifi/logger/compare/v0.9.3...v0.10.0) (2026-08-05)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **logger:** add explicit Sentry event channel ([44f4716](https://git.mifi.dev/mifi/logger/commit/44f471653e8d4045e87886da1e1bbe04edbd60af))
|
||||
- **logger:** add explicit Sentry event channel ([44f4716](https://git.mifi.dev/mifi/logger/commit/44f471653e8d4045e87886da1e1bbe04edbd60af))
|
||||
|
||||
## [0.9.3](https://git.mifi.dev/mifi/logger/compare/v0.9.2...v0.9.3) (2026-08-05)
|
||||
|
||||
|
||||
@@ -101,12 +101,12 @@ The Sentry adapter has **no SDK dependency**. Provide the SDK your application a
|
||||
|
||||
Destination policy when `sentry` is configured and `sinks` is not:
|
||||
|
||||
| Runtime + environment | Console | Sentry |
|
||||
| ---------------------- | ------------------------------- | ------------------------------------------- |
|
||||
| Production **browser** | Off | Issues for errors; optional Logs |
|
||||
| Production **Node** | On (stderr for errors) | Issues for errors; optional Logs |
|
||||
| Staging | On (default `warn`+) | Issues for errors; optional Logs |
|
||||
| Development | On | Nothing |
|
||||
| Runtime + environment | Console | Sentry |
|
||||
| ---------------------- | ---------------------- | -------------------------------- |
|
||||
| Production **browser** | Off | Issues for errors; optional Logs |
|
||||
| Production **Node** | On (stderr for errors) | Issues for errors; optional Logs |
|
||||
| Staging | On (default `warn`+) | Issues for errors; optional Logs |
|
||||
| Development | On | Nothing |
|
||||
|
||||
### Issues vs Logs
|
||||
|
||||
@@ -143,10 +143,10 @@ logger.info("investigating", { orderId }, { sentry: true }); // force Logs
|
||||
logger.error("expected", err, { suppressSentry: true }); // console only (when enabled)
|
||||
```
|
||||
|
||||
| Option | Effect |
|
||||
| ----------------- | ---------------------------------------------------------------------- |
|
||||
| `sentry: true` | Force this event to Sentry Logs (ignores Logs threshold; not for errors) |
|
||||
| `suppressSentry: true` | Skip creating a Sentry Issue for an error |
|
||||
| Option | Effect |
|
||||
| ---------------------- | ------------------------------------------------------------------------ |
|
||||
| `sentry: true` | Force this event to Sentry Logs (ignores Logs threshold; not for errors) |
|
||||
| `suppressSentry: true` | Skip creating a Sentry Issue for an error |
|
||||
|
||||
A last argument is treated as options only when every key is `sentry` or `suppressSentry`. Prefer the third-argument form when you also pass data.
|
||||
|
||||
|
||||
+1
-3
@@ -196,9 +196,7 @@ function resolveSentrySinkOptions(
|
||||
options: LoggerOptions,
|
||||
): { logs: boolean; logLevel: LogLevel } | undefined {
|
||||
if (options.environment === "development") return undefined;
|
||||
const candidate = options.sentry
|
||||
? options.sentry
|
||||
: options.sinks?.find(isSentrySinkLike);
|
||||
const candidate = options.sentry ? options.sentry : options.sinks?.find(isSentrySinkLike);
|
||||
if (!candidate) return undefined;
|
||||
if (isSentrySinkLike(candidate)) {
|
||||
return {
|
||||
|
||||
+1
-4
@@ -165,10 +165,7 @@ export function toSentryLogPayload(event: LogEvent): {
|
||||
* logger.error("expected", err, { suppressSentry: true });
|
||||
* ```
|
||||
*/
|
||||
export function createSentrySink(
|
||||
sentry: SentryLike,
|
||||
options: SentrySinkOptions = {},
|
||||
): SentrySink {
|
||||
export function createSentrySink(sentry: SentryLike, options: SentrySinkOptions = {}): SentrySink {
|
||||
return {
|
||||
kind: "sentry",
|
||||
options,
|
||||
|
||||
+3
-1
@@ -180,7 +180,9 @@ describe("createLogger", () => {
|
||||
logger.info("probe", { sentry: true });
|
||||
expect(destination.events).toHaveLength(2);
|
||||
expect(
|
||||
destination.events.every((event) => !event.sendToSentryIssue && !event.sendToSentryLogs),
|
||||
destination.events.every(
|
||||
(event) => !event.sendToSentryIssue && !event.sendToSentryLogs,
|
||||
),
|
||||
).toBe(true);
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user