@classytic/notifications 2.4.0 → 2.5.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/CHANGELOG.md CHANGED
@@ -2,6 +2,27 @@
2
2
 
3
3
  All notable changes to `@classytic/notifications` will be documented in this file.
4
4
 
5
+ ## [2.5.0] — 2026-08-26
6
+
7
+ ### Fixed — send-failure log now walks the `cause` chain
8
+
9
+ A real incident — `"Unsupported state or unable to authenticate data"` logged six
10
+ times per order with no frame, no layer — took an afternoon to trace because the
11
+ delivery log and the logger both recorded only `err.message`. Several components in
12
+ the path decrypt something, so the message fit all of them equally.
13
+
14
+ The fix splits the two concerns:
15
+
16
+ - **`result.error`** (persisted, operator-facing) — still the bare message. A stack
17
+ in an audit record is noise; raw vendor text in a persisted field violates the
18
+ house rule on normalised stored errors.
19
+ - **`logger.error`** — now walks the `cause` chain (up to depth 4) and appends the
20
+ first four stack frames of each `Error` node. An adapter that wraps a provider
21
+ error puts the real origin in `cause`; printing only the outer message hid the
22
+ layer you actually needed.
23
+
24
+ The split is covered by `tests/send-failure-diagnostics.test.ts`.
25
+
5
26
  ## [2.4.0] - 2026-08-17
6
27
 
7
28
  ### Fixed — `providerMessageId` now works the way 2.3.0 claimed
package/dist/index.mjs CHANGED
@@ -324,7 +324,31 @@ var NotificationService = class {
324
324
  duration: Date.now() - start
325
325
  };
326
326
  const message = err instanceof Error ? err.message : String(err);
327
- this.logger.error(`[${channel.name}] Failed: ${message}`);
327
+ /**
328
+ * Log the ORIGIN, persist only the message.
329
+ *
330
+ * The returned `error` string is what ends up in the delivery log, which
331
+ * is an operator-facing audit record — a raw stack there would be noise
332
+ * at best and leak vendor internals at worst. But a bare message is not
333
+ * diagnosable either: `"Unsupported state or unable to authenticate
334
+ * data"` (Node's AES-GCM failure) took an afternoon to trace precisely
335
+ * because the delivery row recorded that string and nothing else — no
336
+ * frame, no cause, no indication of which of several decrypting layers
337
+ * produced it, and the message never reached a log at all beyond this
338
+ * one line.
339
+ *
340
+ * So the split follows the house rule: normalise what is stored, and log
341
+ * the detail separately. `cause` is walked because an adapter that wraps
342
+ * a provider error puts the real origin there, and printing only the
343
+ * outer message hides exactly the layer you need.
344
+ */
345
+ const detail = [];
346
+ let cursor = err;
347
+ for (let depth = 0; cursor instanceof Error && depth < 4; depth++) {
348
+ detail.push(`${depth === 0 ? "error" : `cause[${depth}]`}: ${cursor.name}: ${cursor.message}` + (cursor.stack ? `\n${cursor.stack.split("\n").slice(1, 5).join("\n")}` : ""));
349
+ cursor = cursor.cause;
350
+ }
351
+ this.logger.error(`[${channel.name}] Failed: ${message}\n${detail.join("\n")}`);
328
352
  return {
329
353
  status: "failed",
330
354
  channel: channel.name,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/notifications",
3
- "version": "2.4.0",
3
+ "version": "2.5.0",
4
4
  "description": "Multi-channel notifications (Email, SMS, Push, Webhook) with rate limiting, delivery tracking, queue adapters, channel fallback, templates, retry — zero required dependencies",
5
5
  "type": "module",
6
6
  "sideEffects": false,