@futurewindai/wotchi 0.1.0-beta.2 → 0.1.0-beta.5
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 +102 -25
- package/dist/cjs/core/client.js +370 -21
- package/dist/cjs/core/config.js +177 -18
- package/dist/cjs/core/diagnostics.js +12 -1
- package/dist/cjs/core/group-store.js +15 -1
- package/dist/cjs/core/incident-builder.js +18 -0
- package/dist/cjs/core/incident-policy.js +2 -7
- package/dist/cjs/core/limits.js +13 -0
- package/dist/cjs/core/normalize.js +10 -5
- package/dist/cjs/core/notification-queue.js +20 -3
- package/dist/cjs/core/redact.js +53 -7
- package/dist/cjs/index.js +3 -1
- package/dist/cjs/integrations/express/error-handler.js +2 -1
- package/dist/cjs/integrations/express/index.js +2 -1
- package/dist/cjs/integrations/express/status-observer.js +6 -0
- package/dist/cjs/integrations/nest/exception-filter.js +9 -1
- package/dist/cjs/integrations/nest/index.js +2 -1
- package/dist/cjs/integrations/request-context.js +83 -1
- package/dist/cjs/notifiers/alert-payload.js +20 -0
- package/dist/cjs/notifiers/console.js +85 -15
- package/dist/cjs/notifiers/telegram-format.js +75 -5
- package/dist/cjs/notifiers/webhook-http.js +394 -0
- package/dist/cjs/notifiers/webhook.js +28 -0
- package/dist/esm/core/client.js +370 -21
- package/dist/esm/core/config.js +177 -18
- package/dist/esm/core/diagnostics.js +12 -1
- package/dist/esm/core/group-store.js +15 -1
- package/dist/esm/core/incident-builder.js +18 -0
- package/dist/esm/core/incident-policy.js +2 -7
- package/dist/esm/core/limits.js +10 -0
- package/dist/esm/core/normalize.js +10 -5
- package/dist/esm/core/notification-queue.js +20 -3
- package/dist/esm/core/redact.js +53 -7
- package/dist/esm/index.js +2 -1
- package/dist/esm/integrations/express/error-handler.js +2 -1
- package/dist/esm/integrations/express/index.js +1 -1
- package/dist/esm/integrations/express/status-observer.js +6 -0
- package/dist/esm/integrations/nest/exception-filter.js +9 -1
- package/dist/esm/integrations/nest/index.js +1 -1
- package/dist/esm/integrations/request-context.js +83 -1
- package/dist/esm/notifiers/alert-payload.js +16 -0
- package/dist/esm/notifiers/console.js +85 -15
- package/dist/esm/notifiers/telegram-format.js +75 -5
- package/dist/esm/notifiers/webhook-http.js +387 -0
- package/dist/esm/notifiers/webhook.js +24 -0
- package/dist/types/core/config.d.ts +7 -1
- package/dist/types/core/diagnostics.d.ts +5 -1
- package/dist/types/core/limits.d.ts +10 -0
- package/dist/types/core/notification-queue.d.ts +5 -1
- package/dist/types/core/types.d.ts +95 -1
- package/dist/types/index.d.ts +4 -2
- package/dist/types/integrations/express/index.d.ts +2 -2
- package/dist/types/integrations/nest/index.d.ts +2 -2
- package/dist/types/integrations/request-context.d.ts +3 -0
- package/dist/types/notifiers/alert-payload.d.ts +5 -0
- package/dist/types/notifiers/webhook-http.d.ts +37 -0
- package/dist/types/notifiers/webhook.d.ts +4 -0
- package/dist/types-cjs/core/config.d.cts +7 -1
- package/dist/types-cjs/core/diagnostics.d.cts +5 -1
- package/dist/types-cjs/core/limits.d.cts +10 -0
- package/dist/types-cjs/core/notification-queue.d.cts +5 -1
- package/dist/types-cjs/core/types.d.cts +95 -1
- package/dist/types-cjs/index.d.cts +4 -2
- package/dist/types-cjs/integrations/express/index.d.cts +2 -2
- package/dist/types-cjs/integrations/nest/index.d.cts +2 -2
- package/dist/types-cjs/integrations/request-context.d.cts +3 -0
- package/dist/types-cjs/notifiers/alert-payload.d.cts +5 -0
- package/dist/types-cjs/notifiers/webhook-http.d.cts +37 -0
- package/dist/types-cjs/notifiers/webhook.d.cts +4 -0
- package/package.json +6 -4
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { WotchiRequestContext } from "../core/types.js";
|
|
2
2
|
export interface RequestContextOptions {
|
|
3
3
|
requestIdProperty?: string;
|
|
4
|
+
correlationIdProperty?: string;
|
|
5
|
+
traceContextProperty?: string;
|
|
4
6
|
}
|
|
5
7
|
export declare function normalizeRoutePath(value: unknown): string | undefined;
|
|
6
8
|
export interface RequestContextInput {
|
|
@@ -8,6 +10,7 @@ export interface RequestContextInput {
|
|
|
8
10
|
method?: unknown;
|
|
9
11
|
route?: unknown;
|
|
10
12
|
statusCode?: unknown;
|
|
13
|
+
trace?: unknown;
|
|
11
14
|
options?: RequestContextOptions;
|
|
12
15
|
}
|
|
13
16
|
export declare function buildRequestContext(input: RequestContextInput): WotchiRequestContext | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SafeNormalizedValue } from "../core/normalize.js";
|
|
2
|
+
import type { IncidentAlert } from "../core/types.js";
|
|
3
|
+
export type BoundedAlertPayload = Record<string, SafeNormalizedValue>;
|
|
4
|
+
export declare function toBoundedPayload(value: unknown): BoundedAlertPayload;
|
|
5
|
+
export declare function toBoundedAlertPayload(alert: IncidentAlert): BoundedAlertPayload;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IncidentAlert, WebhookNotifierOptions } from "../core/types.js";
|
|
2
|
+
export interface WebhookRequestOptions {
|
|
3
|
+
protocol: "http:" | "https:";
|
|
4
|
+
hostname: string;
|
|
5
|
+
port?: string;
|
|
6
|
+
method: "POST";
|
|
7
|
+
path: string;
|
|
8
|
+
headers: Record<string, string | number>;
|
|
9
|
+
allowPrivateDestinations?: boolean;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface WebhookResponse {
|
|
13
|
+
statusCode: number;
|
|
14
|
+
headers: Record<string, string | string[] | undefined>;
|
|
15
|
+
body: string;
|
|
16
|
+
}
|
|
17
|
+
export type WebhookRequestFunction = (options: WebhookRequestOptions, body: string, timeoutMs: number) => Promise<WebhookResponse>;
|
|
18
|
+
export interface WebhookSendOptions {
|
|
19
|
+
url: string;
|
|
20
|
+
alert: IncidentAlert;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
allowHttpLoopback?: boolean;
|
|
25
|
+
allowPrivateDestinations?: boolean;
|
|
26
|
+
payloadBuilder?: (alert: Readonly<IncidentAlert>) => unknown;
|
|
27
|
+
}
|
|
28
|
+
export declare function normalizeWebhookOptions(options: WebhookNotifierOptions): {
|
|
29
|
+
url: URL;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
timeoutMs: number;
|
|
32
|
+
maxRetries: number;
|
|
33
|
+
allowHttpLoopback: boolean;
|
|
34
|
+
allowPrivateDestinations: boolean;
|
|
35
|
+
payloadBuilder?: WebhookNotifierOptions["payloadBuilder"];
|
|
36
|
+
};
|
|
37
|
+
export declare function sendWebhookAlert(options: WebhookSendOptions, request?: WebhookRequestFunction): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WebhookNotifierOptions, WotchiNotifier } from "../core/types.js";
|
|
2
|
+
import { type WebhookRequestFunction } from "./webhook-http.js";
|
|
3
|
+
export declare function createWebhookNotifier(options: WebhookNotifierOptions, request?: WebhookRequestFunction): WotchiNotifier;
|
|
4
|
+
export declare function webhookNotifier(options: WebhookNotifierOptions): WotchiNotifier;
|
|
@@ -1,11 +1,17 @@
|
|
|
1
|
-
import type { WotchiConfig, WotchiNotifier } from "./types.js";
|
|
1
|
+
import type { WotchiConfig, WotchiIncidentRule, WotchiLinkTemplates, WotchiNotifier } from "./types.js";
|
|
2
2
|
import { WotchiConfigurationError } from "./errors.js";
|
|
3
3
|
export { WotchiConfigurationError };
|
|
4
4
|
export interface NormalizedWotchiConfig {
|
|
5
5
|
readonly service: string;
|
|
6
6
|
readonly environment: string;
|
|
7
|
+
readonly instance?: string;
|
|
7
8
|
readonly release?: string;
|
|
8
9
|
readonly enabled: boolean;
|
|
10
|
+
readonly filter?: WotchiConfig["filter"];
|
|
11
|
+
readonly fingerprint?: WotchiConfig["fingerprint"];
|
|
12
|
+
readonly beforeSend?: WotchiConfig["beforeSend"];
|
|
13
|
+
readonly links?: Readonly<WotchiLinkTemplates>;
|
|
14
|
+
readonly rules: readonly WotchiIncidentRule[];
|
|
9
15
|
readonly grouping: {
|
|
10
16
|
readonly windowMs: number;
|
|
11
17
|
readonly alertThreshold: number;
|
|
@@ -2,6 +2,10 @@ import type { WotchiDiagnostics } from "./types.js";
|
|
|
2
2
|
export interface DiagnosticsState {
|
|
3
3
|
capturedEvents: number;
|
|
4
4
|
captureFailures: number;
|
|
5
|
+
fingerprintCallbackFailures: number;
|
|
6
|
+
filterFailures: number;
|
|
7
|
+
beforeSendFailures: number;
|
|
8
|
+
eventsSuppressed: number;
|
|
5
9
|
}
|
|
6
10
|
export declare function createDiagnosticsState(): DiagnosticsState;
|
|
7
|
-
export declare function snapshotDiagnostics(state: DiagnosticsState, values: Omit<WotchiDiagnostics, "capturedEvents" | "captureFailures">): Readonly<WotchiDiagnostics>;
|
|
11
|
+
export declare function snapshotDiagnostics(state: DiagnosticsState, values: Omit<WotchiDiagnostics, "capturedEvents" | "captureFailures" | "fingerprintCallbackFailures" | "filterFailures" | "beforeSendFailures" | "eventsSuppressed">): Readonly<WotchiDiagnostics>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const MAX_GROUPS = 10000;
|
|
2
|
+
export declare const MAX_EVENTS_PER_WINDOW = 10000;
|
|
3
|
+
export declare const MAX_PENDING_ALERTS = 10000;
|
|
4
|
+
export declare const MAX_WINDOW_MS: number;
|
|
5
|
+
export declare const MAX_ALERT_THRESHOLD = 1000000;
|
|
6
|
+
export declare const MAX_COOLDOWN_MS: number;
|
|
7
|
+
export declare const MAX_NORMALIZATION_DEPTH = 20;
|
|
8
|
+
export declare const MAX_NORMALIZATION_KEYS = 10000;
|
|
9
|
+
export declare const MAX_NORMALIZATION_STRING_LENGTH = 32768;
|
|
10
|
+
export declare const MAX_NORMALIZATION_STACK_LENGTH = 32768;
|
|
@@ -4,8 +4,12 @@ export interface NotificationQueueOptions {
|
|
|
4
4
|
concurrency: 1;
|
|
5
5
|
onNotifierError?: (error: unknown, notifier: WotchiNotifier) => void;
|
|
6
6
|
}
|
|
7
|
+
export interface NotificationJobResult {
|
|
8
|
+
notifierFailures: number;
|
|
9
|
+
sent: number;
|
|
10
|
+
}
|
|
7
11
|
export interface NotificationQueue {
|
|
8
|
-
enqueue(alert: IncidentAlert, notifiers: readonly WotchiNotifier[]): boolean;
|
|
12
|
+
enqueue(alert: IncidentAlert, notifiers: readonly WotchiNotifier[], onComplete?: (result: NotificationJobResult) => void): boolean;
|
|
9
13
|
flush(timeoutMs?: number): Promise<void>;
|
|
10
14
|
pending(): number;
|
|
11
15
|
alertsQueued(): number;
|
|
@@ -1,10 +1,40 @@
|
|
|
1
1
|
export type IncidentSeverity = "low" | "medium" | "high" | "critical";
|
|
2
2
|
export type WotchiEventKind = "error" | "manual" | "process-monitor";
|
|
3
|
+
export interface WotchiTraceContext {
|
|
4
|
+
traceId?: string;
|
|
5
|
+
spanId?: string;
|
|
6
|
+
}
|
|
3
7
|
export interface WotchiRequestContext extends Record<string, unknown> {
|
|
4
8
|
method?: string;
|
|
5
9
|
route?: string;
|
|
6
10
|
statusCode?: number;
|
|
7
11
|
requestId?: string;
|
|
12
|
+
correlationId?: string;
|
|
13
|
+
trace?: WotchiTraceContext;
|
|
14
|
+
}
|
|
15
|
+
export type WotchiTags = Readonly<Record<string, string>>;
|
|
16
|
+
export interface WotchiLinkTemplates {
|
|
17
|
+
log?: string;
|
|
18
|
+
trace?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface WotchiLinks {
|
|
21
|
+
log?: string;
|
|
22
|
+
trace?: string;
|
|
23
|
+
}
|
|
24
|
+
export type WotchiFingerprintCallback = (event: Readonly<SafeErrorEvent>) => string | undefined;
|
|
25
|
+
export type WotchiFingerprintOverride = string | WotchiFingerprintCallback;
|
|
26
|
+
export type WotchiEventFilter = (event: Readonly<SafeErrorEvent>) => boolean;
|
|
27
|
+
export type WotchiBeforeSend = (alert: Readonly<IncidentAlert>) => IncidentAlert | null | undefined;
|
|
28
|
+
export interface WotchiCaptureOptions {
|
|
29
|
+
fingerprint?: WotchiFingerprintOverride;
|
|
30
|
+
severity?: IncidentSeverity;
|
|
31
|
+
alertThreshold?: number;
|
|
32
|
+
request?: WotchiRequestContext;
|
|
33
|
+
trace?: WotchiTraceContext;
|
|
34
|
+
correlationId?: string;
|
|
35
|
+
operation?: string;
|
|
36
|
+
job?: string;
|
|
37
|
+
tags?: Record<string, unknown>;
|
|
8
38
|
}
|
|
9
39
|
export interface WotchiEventInput {
|
|
10
40
|
level: "error";
|
|
@@ -12,16 +42,28 @@ export interface WotchiEventInput {
|
|
|
12
42
|
message: string;
|
|
13
43
|
error?: unknown;
|
|
14
44
|
alertThreshold?: number;
|
|
45
|
+
severity?: IncidentSeverity;
|
|
46
|
+
fingerprint?: WotchiFingerprintOverride;
|
|
15
47
|
metadata?: Record<string, unknown>;
|
|
16
48
|
context?: Record<string, unknown>;
|
|
17
49
|
request?: WotchiRequestContext;
|
|
50
|
+
trace?: WotchiTraceContext;
|
|
51
|
+
correlationId?: string;
|
|
52
|
+
operation?: string;
|
|
53
|
+
job?: string;
|
|
54
|
+
tags?: Record<string, unknown>;
|
|
18
55
|
}
|
|
19
56
|
export interface SafeErrorEvent {
|
|
20
57
|
id: string;
|
|
21
58
|
timestamp: string;
|
|
22
59
|
service: string;
|
|
23
60
|
environment: string;
|
|
61
|
+
instance?: string;
|
|
24
62
|
release?: string;
|
|
63
|
+
correlationId?: string;
|
|
64
|
+
operation?: string;
|
|
65
|
+
job?: string;
|
|
66
|
+
tags?: WotchiTags;
|
|
25
67
|
error: {
|
|
26
68
|
name: string;
|
|
27
69
|
message: string;
|
|
@@ -29,6 +71,7 @@ export interface SafeErrorEvent {
|
|
|
29
71
|
code?: string;
|
|
30
72
|
};
|
|
31
73
|
request?: WotchiRequestContext;
|
|
74
|
+
trace?: WotchiTraceContext;
|
|
32
75
|
context?: Record<string, unknown>;
|
|
33
76
|
}
|
|
34
77
|
export interface IncidentGroup {
|
|
@@ -53,6 +96,19 @@ export interface IncidentAlert {
|
|
|
53
96
|
occurrences: number;
|
|
54
97
|
service: string;
|
|
55
98
|
environment: string;
|
|
99
|
+
instance?: string;
|
|
100
|
+
release?: string;
|
|
101
|
+
correlationId?: string;
|
|
102
|
+
operation?: string;
|
|
103
|
+
job?: string;
|
|
104
|
+
tags?: WotchiTags;
|
|
105
|
+
error?: SafeErrorEvent["error"] & {
|
|
106
|
+
applicationFrame?: string;
|
|
107
|
+
};
|
|
108
|
+
request?: WotchiRequestContext;
|
|
109
|
+
trace?: WotchiTraceContext;
|
|
110
|
+
context?: Record<string, unknown>;
|
|
111
|
+
links?: WotchiLinks;
|
|
56
112
|
}
|
|
57
113
|
export interface WotchiNotifier {
|
|
58
114
|
readonly name: string;
|
|
@@ -67,11 +123,33 @@ export interface TelegramNotifierOptions {
|
|
|
67
123
|
chatId: string;
|
|
68
124
|
timeoutMs?: number;
|
|
69
125
|
}
|
|
126
|
+
export interface WebhookNotifierOptions {
|
|
127
|
+
url: string;
|
|
128
|
+
headers?: Record<string, string>;
|
|
129
|
+
timeoutMs?: number;
|
|
130
|
+
maxRetries?: number;
|
|
131
|
+
allowHttpLoopback?: boolean;
|
|
132
|
+
allowPrivateDestinations?: boolean;
|
|
133
|
+
payloadBuilder?: (alert: Readonly<IncidentAlert>) => unknown;
|
|
134
|
+
}
|
|
135
|
+
export interface WotchiIncidentRule {
|
|
136
|
+
environment?: string;
|
|
137
|
+
route?: string;
|
|
138
|
+
ignore?: boolean;
|
|
139
|
+
alertThreshold?: number;
|
|
140
|
+
severity?: IncidentSeverity;
|
|
141
|
+
}
|
|
70
142
|
export interface WotchiConfig {
|
|
71
143
|
service: string;
|
|
72
144
|
environment: string;
|
|
145
|
+
instance?: string;
|
|
73
146
|
release?: string;
|
|
74
147
|
enabled?: boolean;
|
|
148
|
+
filter?: WotchiEventFilter;
|
|
149
|
+
fingerprint?: WotchiFingerprintCallback;
|
|
150
|
+
beforeSend?: WotchiBeforeSend;
|
|
151
|
+
links?: WotchiLinkTemplates;
|
|
152
|
+
rules?: readonly WotchiIncidentRule[];
|
|
75
153
|
grouping?: {
|
|
76
154
|
windowMs?: number;
|
|
77
155
|
alertThreshold?: number;
|
|
@@ -100,12 +178,28 @@ export interface WotchiDiagnostics {
|
|
|
100
178
|
alertsDropped: number;
|
|
101
179
|
alertsSent: number;
|
|
102
180
|
notifierFailures: number;
|
|
181
|
+
fingerprintCallbackFailures: number;
|
|
182
|
+
filterFailures: number;
|
|
183
|
+
beforeSendFailures: number;
|
|
184
|
+
eventsSuppressed: number;
|
|
103
185
|
activeGroups: number;
|
|
104
186
|
pendingAlerts: number;
|
|
105
187
|
}
|
|
188
|
+
export type WotchiTestAlertStatus = "sent" | "queue-full" | "timeout" | "notifier-failed";
|
|
189
|
+
export interface WotchiTestAlertResult {
|
|
190
|
+
status: WotchiTestAlertStatus;
|
|
191
|
+
configurationAccepted: true;
|
|
192
|
+
queued: boolean;
|
|
193
|
+
flushed: boolean;
|
|
194
|
+
delivered: boolean;
|
|
195
|
+
notifierFailures: number;
|
|
196
|
+
diagnostics: Readonly<WotchiDiagnostics>;
|
|
197
|
+
error?: string;
|
|
198
|
+
}
|
|
106
199
|
export interface WotchiClient {
|
|
107
|
-
captureException(error: unknown, context?: Record<string, unknown
|
|
200
|
+
captureException(error: unknown, context?: Record<string, unknown>, options?: WotchiCaptureOptions): void;
|
|
108
201
|
captureEvent(event: WotchiEventInput): void;
|
|
202
|
+
testAlert(): Promise<WotchiTestAlertResult>;
|
|
109
203
|
flush(timeoutMs?: number): Promise<void>;
|
|
110
204
|
getDiagnostics(): Readonly<WotchiDiagnostics>;
|
|
111
205
|
}
|
|
@@ -2,8 +2,10 @@ import { createWotchi } from "./core/client.js";
|
|
|
2
2
|
import { registerWotchiProcessMonitor } from "./core/process-monitor.js";
|
|
3
3
|
import { consoleNotifier } from "./notifiers/console.js";
|
|
4
4
|
import { telegramNotifier } from "./notifiers/telegram.js";
|
|
5
|
+
import { webhookNotifier } from "./notifiers/webhook.js";
|
|
5
6
|
export { WotchiConfigurationError } from "./core/errors.js";
|
|
6
7
|
export type { ProcessMonitorHandle } from "./core/process-monitor.js";
|
|
7
8
|
export type { NormalizedWotchiConfig } from "./core/config.js";
|
|
8
|
-
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventInput, WotchiEventKind, WotchiNotifier, WotchiRequestContext, } from "./core/types.js";
|
|
9
|
-
export {
|
|
9
|
+
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiEventKind, WotchiFingerprintOverride, WotchiFingerprintCallback, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "./core/types.js";
|
|
10
|
+
export type { WebhookRequestFunction, WebhookRequestOptions, WebhookResponse, } from "./notifiers/webhook-http.js";
|
|
11
|
+
export { consoleNotifier, createWotchi, registerWotchiProcessMonitor, telegramNotifier, webhookNotifier, };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { WotchiClient } from "../../core/types.js";
|
|
2
2
|
import { createExpressErrorHandler } from "./error-handler.js";
|
|
3
3
|
import type { ExpressWotchiOptions } from "./request-context.js";
|
|
4
|
-
export { consoleNotifier, createWotchi, telegramNotifier } from "../../index.js";
|
|
5
|
-
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventInput, WotchiNotifier, WotchiRequestContext, } from "../../index.js";
|
|
4
|
+
export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.js";
|
|
5
|
+
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiFingerprintCallback, WotchiFingerprintOverride, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "../../index.js";
|
|
6
6
|
export type { ExpressWotchiOptions } from "./request-context.js";
|
|
7
7
|
export type { WotchiStatusClass, WotchiStatusObserverOptions } from "./status-observer.js";
|
|
8
8
|
export { wotchiStatusObserver } from "./status-observer.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { consoleNotifier, createWotchi, telegramNotifier } from "../../index.js";
|
|
1
|
+
export { consoleNotifier, createWotchi, telegramNotifier, webhookNotifier } from "../../index.js";
|
|
2
2
|
export { registerWotchiNest, registerWotchiNestStatusObserver } from "./register.js";
|
|
3
|
-
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventInput, WotchiNotifier, WotchiRequestContext, } from "../../index.js";
|
|
3
|
+
export type { ConsoleNotifierOptions, IncidentAlert, IncidentGroup, IncidentSeverity, SafeErrorEvent, TelegramNotifierOptions, WebhookNotifierOptions, WotchiBeforeSend, WotchiCaptureOptions, WotchiClient, WotchiConfig, WotchiDiagnostics, WotchiEventFilter, WotchiEventInput, WotchiFingerprintCallback, WotchiFingerprintOverride, WotchiIncidentRule, WotchiLinkTemplates, WotchiLinks, WotchiNotifier, WotchiRequestContext, WotchiTags, WotchiTestAlertResult, WotchiTestAlertStatus, WotchiTraceContext, } from "../../index.js";
|
|
4
4
|
export type { NestWotchiApplication, NestWotchiOptions } from "./register.js";
|
|
5
5
|
export type { WotchiStatusClass, WotchiStatusObserverOptions } from "../express/status-observer.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { WotchiRequestContext } from "../core/types.js";
|
|
2
2
|
export interface RequestContextOptions {
|
|
3
3
|
requestIdProperty?: string;
|
|
4
|
+
correlationIdProperty?: string;
|
|
5
|
+
traceContextProperty?: string;
|
|
4
6
|
}
|
|
5
7
|
export declare function normalizeRoutePath(value: unknown): string | undefined;
|
|
6
8
|
export interface RequestContextInput {
|
|
@@ -8,6 +10,7 @@ export interface RequestContextInput {
|
|
|
8
10
|
method?: unknown;
|
|
9
11
|
route?: unknown;
|
|
10
12
|
statusCode?: unknown;
|
|
13
|
+
trace?: unknown;
|
|
11
14
|
options?: RequestContextOptions;
|
|
12
15
|
}
|
|
13
16
|
export declare function buildRequestContext(input: RequestContextInput): WotchiRequestContext | undefined;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { SafeNormalizedValue } from "../core/normalize.js";
|
|
2
|
+
import type { IncidentAlert } from "../core/types.js";
|
|
3
|
+
export type BoundedAlertPayload = Record<string, SafeNormalizedValue>;
|
|
4
|
+
export declare function toBoundedPayload(value: unknown): BoundedAlertPayload;
|
|
5
|
+
export declare function toBoundedAlertPayload(alert: IncidentAlert): BoundedAlertPayload;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { IncidentAlert, WebhookNotifierOptions } from "../core/types.js";
|
|
2
|
+
export interface WebhookRequestOptions {
|
|
3
|
+
protocol: "http:" | "https:";
|
|
4
|
+
hostname: string;
|
|
5
|
+
port?: string;
|
|
6
|
+
method: "POST";
|
|
7
|
+
path: string;
|
|
8
|
+
headers: Record<string, string | number>;
|
|
9
|
+
allowPrivateDestinations?: boolean;
|
|
10
|
+
signal?: AbortSignal;
|
|
11
|
+
}
|
|
12
|
+
export interface WebhookResponse {
|
|
13
|
+
statusCode: number;
|
|
14
|
+
headers: Record<string, string | string[] | undefined>;
|
|
15
|
+
body: string;
|
|
16
|
+
}
|
|
17
|
+
export type WebhookRequestFunction = (options: WebhookRequestOptions, body: string, timeoutMs: number) => Promise<WebhookResponse>;
|
|
18
|
+
export interface WebhookSendOptions {
|
|
19
|
+
url: string;
|
|
20
|
+
alert: IncidentAlert;
|
|
21
|
+
headers?: Record<string, string>;
|
|
22
|
+
timeoutMs?: number;
|
|
23
|
+
maxRetries?: number;
|
|
24
|
+
allowHttpLoopback?: boolean;
|
|
25
|
+
allowPrivateDestinations?: boolean;
|
|
26
|
+
payloadBuilder?: (alert: Readonly<IncidentAlert>) => unknown;
|
|
27
|
+
}
|
|
28
|
+
export declare function normalizeWebhookOptions(options: WebhookNotifierOptions): {
|
|
29
|
+
url: URL;
|
|
30
|
+
headers?: Record<string, string>;
|
|
31
|
+
timeoutMs: number;
|
|
32
|
+
maxRetries: number;
|
|
33
|
+
allowHttpLoopback: boolean;
|
|
34
|
+
allowPrivateDestinations: boolean;
|
|
35
|
+
payloadBuilder?: WebhookNotifierOptions["payloadBuilder"];
|
|
36
|
+
};
|
|
37
|
+
export declare function sendWebhookAlert(options: WebhookSendOptions, request?: WebhookRequestFunction): Promise<void>;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { WebhookNotifierOptions, WotchiNotifier } from "../core/types.js";
|
|
2
|
+
import { type WebhookRequestFunction } from "./webhook-http.js";
|
|
3
|
+
export declare function createWebhookNotifier(options: WebhookNotifierOptions, request?: WebhookRequestFunction): WotchiNotifier;
|
|
4
|
+
export declare function webhookNotifier(options: WebhookNotifierOptions): WotchiNotifier;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futurewindai/wotchi",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.1.0-beta.5",
|
|
4
|
+
"description": "Low-noise error alerts for Node.js, Express, and NestJS applications",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nodejs",
|
|
7
7
|
"typescript",
|
|
@@ -11,7 +11,8 @@
|
|
|
11
11
|
"incident-management",
|
|
12
12
|
"alerting",
|
|
13
13
|
"observability",
|
|
14
|
-
"telegram"
|
|
14
|
+
"telegram",
|
|
15
|
+
"webhook"
|
|
15
16
|
],
|
|
16
17
|
"license": "Apache-2.0",
|
|
17
18
|
"type": "module",
|
|
@@ -62,7 +63,7 @@
|
|
|
62
63
|
"type": "git",
|
|
63
64
|
"url": "git+ssh://git@github.com/FutureWindAI/Wotchi.git"
|
|
64
65
|
},
|
|
65
|
-
"homepage": "https://
|
|
66
|
+
"homepage": "https://github.com/FutureWindAI/Wotchi",
|
|
66
67
|
"bugs": {
|
|
67
68
|
"url": "https://github.com/FutureWindAI/Wotchi/issues"
|
|
68
69
|
},
|
|
@@ -73,6 +74,7 @@
|
|
|
73
74
|
"build:types": "tsc -p tsconfig.types.json",
|
|
74
75
|
"build": "npm run clean && npm run build:esm && npm run build:cjs && npm run build:types && node scripts/prepare-package.mjs",
|
|
75
76
|
"stand": "node scripts/start-test-stand.mjs",
|
|
77
|
+
"stand:production": "node scripts/start-nest-production-stand.mjs",
|
|
76
78
|
"typecheck": "tsc -p tsconfig.base.json --noEmit",
|
|
77
79
|
"lint": "eslint .",
|
|
78
80
|
"format": "prettier --write .",
|