@spfn/notification 0.1.0-beta.3 → 0.1.0-beta.4

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/dist/server.d.ts CHANGED
@@ -759,6 +759,21 @@ interface ErrorSlackOptions {
759
759
  *
760
760
  * Returns a function matching ErrorHandler's onError signature.
761
761
  * Duplicate errors (same name + statusCode + path) within `throttleMs` are suppressed.
762
+ *
763
+ * @deprecated Use `createMonitorErrorHandler()` from `@spfn/monitor/server` instead.
764
+ * It provides DB-backed error tracking with fingerprint deduplication,
765
+ * state-based notifications (new/reopened), and an admin dashboard.
766
+ *
767
+ * Migration:
768
+ * ```typescript
769
+ * // Before
770
+ * import { createErrorSlackNotifier } from '@spfn/notification/server';
771
+ * middleware: { onError: createErrorSlackNotifier() }
772
+ *
773
+ * // After
774
+ * import { createMonitorErrorHandler } from '@spfn/monitor/server';
775
+ * middleware: { onError: createMonitorErrorHandler() }
776
+ * ```
762
777
  */
763
778
  declare function createErrorSlackNotifier(options?: ErrorSlackOptions): (err: Error, ctx: ErrorContext) => Promise<void>;
764
779
 
package/dist/server.js CHANGED
@@ -3879,6 +3879,7 @@ var notificationJobRouter = defineJobRouter({
3879
3879
  });
3880
3880
 
3881
3881
  // src/integrations/error-slack.ts
3882
+ import { hostname } from "os";
3882
3883
  function formatHeaders(headers) {
3883
3884
  const entries = Object.entries(headers);
3884
3885
  if (entries.length === 0) {
@@ -3904,9 +3905,17 @@ var throttleMap = /* @__PURE__ */ new Map();
3904
3905
  function throttleKey(err, ctx) {
3905
3906
  return `${err.name}:${ctx.statusCode}:${ctx.path}`;
3906
3907
  }
3908
+ function getEnvLabel() {
3909
+ const env2 = process.env.NODE_ENV || "unknown";
3910
+ const host = hostname();
3911
+ const dbUrl = process.env.DATABASE_URL || "";
3912
+ const dbName = dbUrl.match(/\/([^/?]+)(\?|$)/)?.[1] || "(unknown)";
3913
+ return `${env2} | ${host} | db:${dbName}`;
3914
+ }
3907
3915
  function defaultFormat(err, ctx, suppressed = 0) {
3916
+ const envLabel = getEnvLabel();
3908
3917
  const emoji = ctx.statusCode >= 500 ? ":rotating_light:" : ":warning:";
3909
- const title = `${emoji} *${err.name || "Error"}* \u2014 ${ctx.statusCode}`;
3918
+ const title = `${emoji} *${err.name || "Error"}* \u2014 ${ctx.statusCode} [${envLabel}]`;
3910
3919
  const fields = [
3911
3920
  { type: "mrkdwn", text: `*Method*
3912
3921
  ${ctx.method}` },
@@ -3965,6 +3974,9 @@ ${ctx.requestId ?? "(none)"}` }
3965
3974
  return { text: title, blocks };
3966
3975
  }
3967
3976
  function createErrorSlackNotifier(options = {}) {
3977
+ console.warn(
3978
+ "[@spfn/notification] createErrorSlackNotifier() is deprecated. Use createMonitorErrorHandler() from @spfn/monitor/server instead."
3979
+ );
3968
3980
  const { minStatusCode = 500, throttleMs = 6e4 } = options;
3969
3981
  return async (err, ctx) => {
3970
3982
  if (ctx.statusCode < minStatusCode) {