deepline 0.3.87 → 0.3.88
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/bundling-sources/sdk/src/client.ts +2 -2
- package/dist/bundling-sources/sdk/src/monitor-fleet-contract.ts +1 -1
- package/dist/bundling-sources/sdk/src/plays/bundle-play-file.ts +1 -1
- package/dist/bundling-sources/sdk/src/release.ts +1 -1
- package/dist/bundling-sources/shared_libs/monitors/org-monitor-limits.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/runtime-env.ts +0 -6
- package/dist/bundling-sources/shared_libs/play-runtime/tool-http-errors.ts +1 -1
- package/dist/bundling-sources/shared_libs/play-runtime/tool-result.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/authoring-contract.ts +0 -302
- package/dist/bundling-sources/shared_libs/plays/email-status.ts +1 -1
- package/dist/bundling-sources/shared_libs/plays/tool-category-descriptions.ts +2 -2
- package/dist/bundling-sources/shared_libs/runtime-env.ts +0 -6
- package/dist/cli/index.js +4 -6
- package/dist/cli/index.mjs +4 -6
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/install-integrity.json +2 -45
- package/package.json +1 -3
- package/dist/bundling-sources/shared_libs/integration-contracts/AGENTS.md +0 -9
- package/dist/bundling-sources/shared_libs/integration-contracts/README.md +0 -3
- package/dist/bundling-sources/shared_libs/integration-contracts/index.ts +0 -2
- package/dist/bundling-sources/shared_libs/monitors/analytics-install-guides.ts +0 -77
- package/dist/bundling-sources/shared_libs/monitors/billing/charges.ts +0 -125
- package/dist/bundling-sources/shared_libs/monitors/billing/policy-builders.ts +0 -686
- package/dist/bundling-sources/shared_libs/monitors/billing/pricing.ts +0 -54
- package/dist/bundling-sources/shared_libs/monitors/billing/public-pricing.ts +0 -72
- package/dist/bundling-sources/shared_libs/monitors/billing/session.ts +0 -45
- package/dist/bundling-sources/shared_libs/monitors/billing/state.ts +0 -454
- package/dist/bundling-sources/shared_libs/monitors/billing/tamradar.ts +0 -260
- package/dist/bundling-sources/shared_libs/monitors/billing/types.ts +0 -215
- package/dist/bundling-sources/shared_libs/monitors/callback-security.ts +0 -333
- package/dist/bundling-sources/shared_libs/monitors/cursor-page.ts +0 -42
- package/dist/bundling-sources/shared_libs/monitors/framework-managed-payload-fields.ts +0 -71
- package/dist/bundling-sources/shared_libs/monitors/generated/provider-monitor-callback-admission-targets.ts +0 -16
- package/dist/bundling-sources/shared_libs/monitors/http-error-response.ts +0 -267
- package/dist/bundling-sources/shared_libs/monitors/inbound-publish-key.ts +0 -39
- package/dist/bundling-sources/shared_libs/monitors/inbound-queue.ts +0 -82
- package/dist/bundling-sources/shared_libs/monitors/lifecycle-notifications.ts +0 -473
- package/dist/bundling-sources/shared_libs/monitors/package.json +0 -29
- package/dist/bundling-sources/shared_libs/monitors/provider-callback-verification.ts +0 -1125
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-capability.ts +0 -964
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-consumer-health.ts +0 -56
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-errors.ts +0 -131
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-identity-claims.ts +0 -527
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-legacy-aliases.ts +0 -16
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-priority-execution.ts +0 -56
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-public-aliases.ts +0 -28
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-runtime-read-eligibility.ts +0 -38
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-status.ts +0 -10
- package/dist/bundling-sources/shared_libs/monitors/provider-monitor-upstream-identity.ts +0 -112
- package/dist/bundling-sources/shared_libs/monitors/provider-webhook-monitor-runtime.ts +0 -300
- package/dist/bundling-sources/shared_libs/monitors/quickstart-prompts.ts +0 -22
- package/dist/bundling-sources/shared_libs/monitors/snitcher-install-validation.ts +0 -93
- package/dist/bundling-sources/shared_libs/monitors/snitcher-ip2company.ts +0 -332
- package/dist/bundling-sources/shared_libs/monitors/snitcher-radar.ts +0 -221
- package/dist/bundling-sources/shared_libs/monitors/starter-templates.ts +0 -105
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-guidance.ts +0 -73
- package/dist/bundling-sources/shared_libs/monitors/tracking-provider-integrations.ts +0 -81
- package/dist/bundling-sources/shared_libs/monitors/tsconfig.json +0 -10
- package/dist/bundling-sources/shared_libs/security/header-safe-env.ts +0 -28
- package/dist/bundling-sources/shared_libs/security/secret-redaction.ts +0 -267
- /package/dist/bundling-sources/shared_libs/{integration-contracts/bettercontact/execution-policy.ts → integrations/bettercontact-execution-policy.ts} +0 -0
- /package/dist/bundling-sources/shared_libs/{integration-contracts/theirstack/execution-policy.ts → integrations/theirstack-execution-policy.ts} +0 -0
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
// Internal Slack notifications for monitor / triggered-play lifecycle + activity.
|
|
2
|
-
//
|
|
3
|
-
// These are thin, best-effort helpers (mirroring
|
|
4
|
-
// `src/lib/plays/team-notifications.ts`) that build a Slack payload via
|
|
5
|
-
// `buildSlackActivityPayload` and dispatch it through `sendSlackEventSafe` on
|
|
6
|
-
// one of two internal channels:
|
|
7
|
-
//
|
|
8
|
-
// - `monitor_activity` (#deepline-monitor-activity)
|
|
9
|
-
// monitor created/deployed, monitor activity (every hit), triggered play
|
|
10
|
-
// published, monitor disabled, monitor deleted.
|
|
11
|
-
// - `monitor_error_activity` (#deepline-monitor-error-activity)
|
|
12
|
-
// monitor entered error state, activity-processing/dispatch failures.
|
|
13
|
-
//
|
|
14
|
-
// LOCKED DECISIONS encoded here:
|
|
15
|
-
// - Volume: EVERY single activity hit posts. No throttling/batching.
|
|
16
|
-
// - Internal actor: alerts fire even for getaero.io / deepline.com staff
|
|
17
|
-
// (we set `bypassInternalActorBlock`), BUT synthetic `@deepline.local`
|
|
18
|
-
// dev-bootstrap test orgs are always suppressed (see
|
|
19
|
-
// `shouldSuppressMonitorActor` + the transport-level guard in
|
|
20
|
-
// `slack-events.ts`).
|
|
21
|
-
// - Environments: ALL (dev + preview + prod). The two channels declare
|
|
22
|
-
// `requiredEnv: 'all'` in `slack-events.ts`, so they post in local dev too.
|
|
23
|
-
// - Spend: NEVER include provider spend. These payloads carry only keys,
|
|
24
|
-
// counts, and trigger metadata — no provider-cost fields.
|
|
25
|
-
|
|
26
|
-
import { after } from 'next/server';
|
|
27
|
-
import {
|
|
28
|
-
buildSlackActivityPayload,
|
|
29
|
-
isSyntheticActorEmail,
|
|
30
|
-
sendSlackEventSafe,
|
|
31
|
-
} from '@/lib/slack-events';
|
|
32
|
-
import { getRuntimeEnv } from '@/lib/runtime-env';
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Schedule a best-effort Slack dispatch WITHOUT blocking the caller. The
|
|
36
|
-
* monitor-activity path is on the provider-webhook ack hot path, so the actual
|
|
37
|
-
* Slack POST must run in the background. We prefer Next's `after()` (runs after
|
|
38
|
-
* the response is flushed) and fall back to a detached promise when no request
|
|
39
|
-
* scope is active (e.g. tests, crons, non-Next callers). Either way the dispatch
|
|
40
|
-
* never throws into the ack/write path.
|
|
41
|
-
*/
|
|
42
|
-
function scheduleSlackDispatch(run: () => Promise<unknown>): void {
|
|
43
|
-
const detach = () => {
|
|
44
|
-
void run().catch((error) => {
|
|
45
|
-
console.warn('[monitor-lifecycle.slack_dispatch_failed]', {
|
|
46
|
-
error: error instanceof Error ? error.message : String(error),
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
// `after` must be called synchronously inside a request/render scope. Outside
|
|
51
|
-
// a scope it throws synchronously, so we catch and fall back to a detached
|
|
52
|
-
// promise (tests, crons, non-Next callers).
|
|
53
|
-
try {
|
|
54
|
-
after(run);
|
|
55
|
-
} catch {
|
|
56
|
-
detach();
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export type MonitorTriggerType = 'webhook' | 'cron' | 'sqlListeners';
|
|
61
|
-
|
|
62
|
-
export type MonitorActivitySource =
|
|
63
|
-
| 'provider_webhook_callback'
|
|
64
|
-
| 'crm_webhook_callback'
|
|
65
|
-
| 'sql_listener'
|
|
66
|
-
| 'scheduled_monitor_sync'
|
|
67
|
-
| string;
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* One monitor-activity hit (a webhook callback / SQL-listener firing / CRM
|
|
71
|
-
* webhook / scheduled sync that wrote rows and/or dispatched plays).
|
|
72
|
-
*
|
|
73
|
-
* NOTE: deliberately no provider-cost field. Pass only keys and counts.
|
|
74
|
-
*/
|
|
75
|
-
export type MonitorActivityNotification = {
|
|
76
|
-
orgId: string;
|
|
77
|
-
/** Stable Deepline-managed monitor key, when known. */
|
|
78
|
-
monitorKey?: string | null;
|
|
79
|
-
/** Source provider (e.g. "instantly", "theirstack"). */
|
|
80
|
-
provider?: string | null;
|
|
81
|
-
/** Source capability / monitor tool capability, when known. */
|
|
82
|
-
sourceCapability?: string | null;
|
|
83
|
-
/** Short label identifying the write site. */
|
|
84
|
-
source: MonitorActivitySource;
|
|
85
|
-
/** Count of typed rows written by the monitor writer for this hit. */
|
|
86
|
-
rowsWritten?: number | null;
|
|
87
|
-
/** Count of plays dispatched off the rows this hit wrote. */
|
|
88
|
-
playsDispatched?: number | null;
|
|
89
|
-
/** Names of plays dispatched, best-effort (deduped). */
|
|
90
|
-
playNames?: string[] | null;
|
|
91
|
-
/** Actor email when one is available (often absent for webhook callbacks). */
|
|
92
|
-
actorEmail?: string | null;
|
|
93
|
-
requestedAt?: string;
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
/**
|
|
97
|
-
* The injectable dispatcher seam for monitor-activity notifications. The default
|
|
98
|
-
* builds a Slack payload and sends it on `monitor_activity`. Tests (and the gold
|
|
99
|
-
* E2E) capture at THIS seam rather than mocking fetch / standing up a fake Slack
|
|
100
|
-
* server, so they assert the exact `{ orgId, monitorKey, rowsWritten,
|
|
101
|
-
* playsDispatched }` shape that reaches the notifier.
|
|
102
|
-
*/
|
|
103
|
-
export type MonitorActivityNotifier = (
|
|
104
|
-
notification: MonitorActivityNotification,
|
|
105
|
-
) => void | Promise<void>;
|
|
106
|
-
|
|
107
|
-
let activityNotifierOverride: MonitorActivityNotifier | null = null;
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Override the monitor-activity notifier (test seam). Returns a restore fn.
|
|
111
|
-
*/
|
|
112
|
-
export function setMonitorActivityNotifier(
|
|
113
|
-
notifier: MonitorActivityNotifier | null,
|
|
114
|
-
): () => void {
|
|
115
|
-
const previous = activityNotifierOverride;
|
|
116
|
-
activityNotifierOverride = notifier;
|
|
117
|
-
return () => {
|
|
118
|
-
activityNotifierOverride = previous;
|
|
119
|
-
};
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
export function resolveMonitorActivityNotifier(): MonitorActivityNotifier {
|
|
123
|
-
return activityNotifierOverride ?? defaultMonitorActivityNotifier;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Central actor rule. We WANT alerts for real customers AND for getaero.io /
|
|
128
|
-
* deepline.com internal staff, so callers set `bypassInternalActorBlock` on the
|
|
129
|
-
* payload. The one identity we always drop is the synthetic `@deepline.local`
|
|
130
|
-
* dev-bootstrap test org. `slack-events.ts` enforces the same suppression at the
|
|
131
|
-
* transport layer; this lets us skip the build/dispatch work entirely.
|
|
132
|
-
*/
|
|
133
|
-
export function shouldSuppressMonitorActor(
|
|
134
|
-
actorEmail: string | null | undefined,
|
|
135
|
-
): boolean {
|
|
136
|
-
return isSyntheticActorEmail(actorEmail);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
function normalizeCount(value: number | null | undefined): number | null {
|
|
140
|
-
if (typeof value !== 'number' || !Number.isFinite(value)) return null;
|
|
141
|
-
return Math.max(0, Math.trunc(value));
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function monitorLabel(input: {
|
|
145
|
-
monitorKey?: string | null;
|
|
146
|
-
provider?: string | null;
|
|
147
|
-
sourceCapability?: string | null;
|
|
148
|
-
}): string {
|
|
149
|
-
const key = input.monitorKey?.trim();
|
|
150
|
-
const capability =
|
|
151
|
-
input.sourceCapability?.trim() ||
|
|
152
|
-
(input.provider?.trim() ? input.provider.trim() : '');
|
|
153
|
-
if (key && capability) return `${key} (${capability})`;
|
|
154
|
-
return key || capability || '(unknown monitor)';
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
const defaultMonitorActivityNotifier: MonitorActivityNotifier = (
|
|
158
|
-
notification,
|
|
159
|
-
) => {
|
|
160
|
-
if (shouldSuppressMonitorActor(notification.actorEmail)) return;
|
|
161
|
-
const requestedAt = notification.requestedAt ?? new Date().toISOString();
|
|
162
|
-
const runtimeEnv = getRuntimeEnv();
|
|
163
|
-
const rowsWritten = normalizeCount(notification.rowsWritten);
|
|
164
|
-
const playsDispatched = normalizeCount(notification.playsDispatched);
|
|
165
|
-
const label = monitorLabel(notification);
|
|
166
|
-
const playNames = (notification.playNames ?? []).filter(Boolean);
|
|
167
|
-
const primary =
|
|
168
|
-
`${label} | rows ${rowsWritten ?? 0} | plays ${playsDispatched ?? 0}`.trim();
|
|
169
|
-
|
|
170
|
-
// Build the payload now (cheap), dispatch the Slack POST off the ack hot path.
|
|
171
|
-
const payload = buildSlackActivityPayload({
|
|
172
|
-
source: `monitor_activity:${notification.source}`,
|
|
173
|
-
activityTitle: 'Monitor activity:',
|
|
174
|
-
activityPrimary: primary,
|
|
175
|
-
requestedAt,
|
|
176
|
-
fallbackText: `Monitor activity - ${label} | rows ${rowsWritten ?? 0} | plays ${playsDispatched ?? 0} | ${notification.source}`,
|
|
177
|
-
fields: [
|
|
178
|
-
{ label: 'Monitor', value: notification.monitorKey ?? null },
|
|
179
|
-
{ label: 'Provider', value: notification.provider ?? null },
|
|
180
|
-
{ label: 'Capability', value: notification.sourceCapability ?? null },
|
|
181
|
-
{ label: 'Source', value: notification.source },
|
|
182
|
-
{ label: 'Rows written', value: rowsWritten },
|
|
183
|
-
{ label: 'Plays dispatched', value: playsDispatched },
|
|
184
|
-
{
|
|
185
|
-
label: 'Plays',
|
|
186
|
-
value: playNames.length > 0 ? playNames.join(', ') : null,
|
|
187
|
-
},
|
|
188
|
-
{ label: 'Org ID', value: notification.orgId },
|
|
189
|
-
{ label: 'Actor', value: notification.actorEmail ?? null },
|
|
190
|
-
{ label: 'Environment', value: runtimeEnv },
|
|
191
|
-
],
|
|
192
|
-
extra: {
|
|
193
|
-
orgId: notification.orgId,
|
|
194
|
-
monitorKey: notification.monitorKey ?? null,
|
|
195
|
-
provider: notification.provider ?? null,
|
|
196
|
-
sourceCapability: notification.sourceCapability ?? null,
|
|
197
|
-
source: notification.source,
|
|
198
|
-
rowsWritten,
|
|
199
|
-
playsDispatched,
|
|
200
|
-
actorEmail: notification.actorEmail ?? null,
|
|
201
|
-
runtimeEnv,
|
|
202
|
-
// Alert real customers AND getaero.io / deepline.com staff. The
|
|
203
|
-
// synthetic `@deepline.local` actor is dropped above and by transport.
|
|
204
|
-
bypassInternalActorBlock: true,
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
scheduleSlackDispatch(() => sendSlackEventSafe('monitor_activity', payload));
|
|
208
|
-
};
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Monitor activity (EVERY hit) -> #deepline-monitor-activity.
|
|
212
|
-
* Shared by all activity sources (provider webhook callback, CRM webhook,
|
|
213
|
-
* SQL-listener firings, scheduled provider sync). Best-effort: never throws.
|
|
214
|
-
*/
|
|
215
|
-
export async function notifyMonitorActivity(
|
|
216
|
-
notification: MonitorActivityNotification,
|
|
217
|
-
): Promise<void> {
|
|
218
|
-
try {
|
|
219
|
-
await resolveMonitorActivityNotifier()(notification);
|
|
220
|
-
} catch (error) {
|
|
221
|
-
console.warn('[monitor-lifecycle.activity_notify_failed]', {
|
|
222
|
-
org_id: notification.orgId,
|
|
223
|
-
source: notification.source,
|
|
224
|
-
error: error instanceof Error ? error.message : String(error),
|
|
225
|
-
});
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Monitor created/deployed -> #deepline-monitor-activity.
|
|
231
|
-
*/
|
|
232
|
-
export async function notifyMonitorDeployed(input: {
|
|
233
|
-
orgId: string;
|
|
234
|
-
monitorKey: string;
|
|
235
|
-
tool?: string | null;
|
|
236
|
-
name?: string | null;
|
|
237
|
-
actorEmail?: string | null;
|
|
238
|
-
mode?: string | null;
|
|
239
|
-
requestedAt?: string;
|
|
240
|
-
}): Promise<void> {
|
|
241
|
-
if (shouldSuppressMonitorActor(input.actorEmail)) return;
|
|
242
|
-
const requestedAt = input.requestedAt ?? new Date().toISOString();
|
|
243
|
-
const runtimeEnv = getRuntimeEnv();
|
|
244
|
-
const displayName = input.name?.trim() || input.monitorKey;
|
|
245
|
-
const tool = input.tool?.trim() || '(unknown tool)';
|
|
246
|
-
const primary = `${displayName} | ${tool}`;
|
|
247
|
-
await sendSlackEventSafe(
|
|
248
|
-
'monitor_activity',
|
|
249
|
-
buildSlackActivityPayload({
|
|
250
|
-
source: 'monitor_deployed',
|
|
251
|
-
activityTitle: 'Monitor deployed:',
|
|
252
|
-
activityPrimary: primary,
|
|
253
|
-
requestedAt,
|
|
254
|
-
fallbackText: `Monitor deployed - ${displayName} | ${tool} | org ${input.orgId}`,
|
|
255
|
-
fields: [
|
|
256
|
-
{ label: 'Monitor', value: input.monitorKey },
|
|
257
|
-
{ label: 'Name', value: input.name ?? null },
|
|
258
|
-
{ label: 'Tool', value: input.tool ?? null },
|
|
259
|
-
{ label: 'Mode', value: input.mode ?? null },
|
|
260
|
-
{ label: 'Org ID', value: input.orgId },
|
|
261
|
-
{ label: 'Actor', value: input.actorEmail ?? null },
|
|
262
|
-
{ label: 'Environment', value: runtimeEnv },
|
|
263
|
-
],
|
|
264
|
-
extra: {
|
|
265
|
-
orgId: input.orgId,
|
|
266
|
-
monitorKey: input.monitorKey,
|
|
267
|
-
tool: input.tool ?? null,
|
|
268
|
-
actorEmail: input.actorEmail ?? null,
|
|
269
|
-
email: input.actorEmail ?? null,
|
|
270
|
-
runtimeEnv,
|
|
271
|
-
bypassInternalActorBlock: true,
|
|
272
|
-
},
|
|
273
|
-
}),
|
|
274
|
-
);
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
/**
|
|
278
|
-
* Triggered play published (cron / webhook / sqlListeners) ->
|
|
279
|
-
* #deepline-monitor-activity. Only fire when the published bindings actually
|
|
280
|
-
* declare a trigger; the caller gates on that.
|
|
281
|
-
*/
|
|
282
|
-
export async function notifyTriggeredPlayPublished(input: {
|
|
283
|
-
orgId: string;
|
|
284
|
-
playName: string;
|
|
285
|
-
triggerTypes: MonitorTriggerType[];
|
|
286
|
-
liveVersion?: number | null;
|
|
287
|
-
actorEmail?: string | null;
|
|
288
|
-
requestedAt?: string;
|
|
289
|
-
}): Promise<void> {
|
|
290
|
-
if (shouldSuppressMonitorActor(input.actorEmail)) return;
|
|
291
|
-
const triggerTypes = [...new Set(input.triggerTypes)].filter(Boolean);
|
|
292
|
-
if (triggerTypes.length === 0) return;
|
|
293
|
-
const requestedAt = input.requestedAt ?? new Date().toISOString();
|
|
294
|
-
const runtimeEnv = getRuntimeEnv();
|
|
295
|
-
const triggerLabel = triggerTypes.join(', ');
|
|
296
|
-
const primary = `${input.playName} | triggers: ${triggerLabel}`;
|
|
297
|
-
await sendSlackEventSafe(
|
|
298
|
-
'monitor_activity',
|
|
299
|
-
buildSlackActivityPayload({
|
|
300
|
-
source: 'triggered_play_published',
|
|
301
|
-
activityTitle: 'Triggered play published:',
|
|
302
|
-
activityPrimary: primary,
|
|
303
|
-
requestedAt,
|
|
304
|
-
fallbackText: `Triggered play published - ${input.playName} | triggers ${triggerLabel} | org ${input.orgId}`,
|
|
305
|
-
fields: [
|
|
306
|
-
{ label: 'Play', value: input.playName },
|
|
307
|
-
{ label: 'Trigger type', value: triggerLabel },
|
|
308
|
-
{
|
|
309
|
-
label: 'Live version',
|
|
310
|
-
value:
|
|
311
|
-
typeof input.liveVersion === 'number' ? input.liveVersion : null,
|
|
312
|
-
},
|
|
313
|
-
{ label: 'Org ID', value: input.orgId },
|
|
314
|
-
{ label: 'Actor', value: input.actorEmail ?? null },
|
|
315
|
-
{ label: 'Environment', value: runtimeEnv },
|
|
316
|
-
],
|
|
317
|
-
extra: {
|
|
318
|
-
orgId: input.orgId,
|
|
319
|
-
playName: input.playName,
|
|
320
|
-
triggerTypes,
|
|
321
|
-
liveVersion: input.liveVersion ?? null,
|
|
322
|
-
actorEmail: input.actorEmail ?? null,
|
|
323
|
-
email: input.actorEmail ?? null,
|
|
324
|
-
runtimeEnv,
|
|
325
|
-
bypassInternalActorBlock: true,
|
|
326
|
-
},
|
|
327
|
-
}),
|
|
328
|
-
);
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
/**
|
|
332
|
-
* Monitor disabled -> #deepline-monitor-activity.
|
|
333
|
-
*/
|
|
334
|
-
export async function notifyMonitorDisabled(input: {
|
|
335
|
-
orgId: string;
|
|
336
|
-
monitorKey: string;
|
|
337
|
-
reason?: string | null;
|
|
338
|
-
actorEmail?: string | null;
|
|
339
|
-
requestedAt?: string;
|
|
340
|
-
}): Promise<void> {
|
|
341
|
-
await notifyMonitorLifecycleState({
|
|
342
|
-
event: 'disabled',
|
|
343
|
-
title: 'Monitor disabled:',
|
|
344
|
-
source: 'monitor_disabled',
|
|
345
|
-
orgId: input.orgId,
|
|
346
|
-
monitorKey: input.monitorKey,
|
|
347
|
-
reason: input.reason ?? null,
|
|
348
|
-
actorEmail: input.actorEmail ?? null,
|
|
349
|
-
requestedAt: input.requestedAt,
|
|
350
|
-
channel: 'monitor_activity',
|
|
351
|
-
});
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
/**
|
|
355
|
-
* Monitor deleted -> #deepline-monitor-activity.
|
|
356
|
-
*/
|
|
357
|
-
export async function notifyMonitorDeleted(input: {
|
|
358
|
-
orgId: string;
|
|
359
|
-
monitorKey: string;
|
|
360
|
-
actorEmail?: string | null;
|
|
361
|
-
requestedAt?: string;
|
|
362
|
-
}): Promise<void> {
|
|
363
|
-
await notifyMonitorLifecycleState({
|
|
364
|
-
event: 'deleted',
|
|
365
|
-
title: 'Monitor deleted:',
|
|
366
|
-
source: 'monitor_deleted',
|
|
367
|
-
orgId: input.orgId,
|
|
368
|
-
monitorKey: input.monitorKey,
|
|
369
|
-
reason: null,
|
|
370
|
-
actorEmail: input.actorEmail ?? null,
|
|
371
|
-
requestedAt: input.requestedAt,
|
|
372
|
-
channel: 'monitor_activity',
|
|
373
|
-
});
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
/**
|
|
377
|
-
* Monitor entered error state -> #deepline-monitor-error-activity.
|
|
378
|
-
* Also used for activity-processing / dispatch failures.
|
|
379
|
-
*/
|
|
380
|
-
export async function notifyMonitorError(input: {
|
|
381
|
-
orgId: string;
|
|
382
|
-
monitorKey?: string | null;
|
|
383
|
-
provider?: string | null;
|
|
384
|
-
sourceCapability?: string | null;
|
|
385
|
-
reason?: string | null;
|
|
386
|
-
detail?: string | null;
|
|
387
|
-
source?: string;
|
|
388
|
-
actorEmail?: string | null;
|
|
389
|
-
requestedAt?: string;
|
|
390
|
-
}): Promise<void> {
|
|
391
|
-
if (shouldSuppressMonitorActor(input.actorEmail)) return;
|
|
392
|
-
const requestedAt = input.requestedAt ?? new Date().toISOString();
|
|
393
|
-
const runtimeEnv = getRuntimeEnv();
|
|
394
|
-
const label = monitorLabel(input);
|
|
395
|
-
const reason = input.reason?.trim() || 'error';
|
|
396
|
-
const primary = `${label} | ${reason}`;
|
|
397
|
-
await sendSlackEventSafe(
|
|
398
|
-
'monitor_error_activity',
|
|
399
|
-
buildSlackActivityPayload({
|
|
400
|
-
source: input.source?.trim() || 'monitor_error',
|
|
401
|
-
activityTitle: 'Monitor error:',
|
|
402
|
-
activityPrimary: primary,
|
|
403
|
-
requestedAt,
|
|
404
|
-
fallbackText: `Monitor error - ${label} | ${reason} | org ${input.orgId}${input.detail ? ` | ${input.detail}` : ''}`,
|
|
405
|
-
fields: [
|
|
406
|
-
{ label: 'Monitor', value: input.monitorKey ?? null },
|
|
407
|
-
{ label: 'Provider', value: input.provider ?? null },
|
|
408
|
-
{ label: 'Capability', value: input.sourceCapability ?? null },
|
|
409
|
-
{ label: 'Reason', value: reason },
|
|
410
|
-
{ label: 'Detail', value: input.detail ?? null },
|
|
411
|
-
{ label: 'Org ID', value: input.orgId },
|
|
412
|
-
{ label: 'Actor', value: input.actorEmail ?? null },
|
|
413
|
-
{ label: 'Environment', value: runtimeEnv },
|
|
414
|
-
],
|
|
415
|
-
extra: {
|
|
416
|
-
orgId: input.orgId,
|
|
417
|
-
monitorKey: input.monitorKey ?? null,
|
|
418
|
-
provider: input.provider ?? null,
|
|
419
|
-
sourceCapability: input.sourceCapability ?? null,
|
|
420
|
-
reason,
|
|
421
|
-
actorEmail: input.actorEmail ?? null,
|
|
422
|
-
email: input.actorEmail ?? null,
|
|
423
|
-
runtimeEnv,
|
|
424
|
-
bypassInternalActorBlock: true,
|
|
425
|
-
},
|
|
426
|
-
}),
|
|
427
|
-
);
|
|
428
|
-
}
|
|
429
|
-
|
|
430
|
-
async function notifyMonitorLifecycleState(input: {
|
|
431
|
-
event: 'disabled' | 'deleted';
|
|
432
|
-
title: string;
|
|
433
|
-
source: string;
|
|
434
|
-
orgId: string;
|
|
435
|
-
monitorKey: string;
|
|
436
|
-
reason: string | null;
|
|
437
|
-
actorEmail: string | null;
|
|
438
|
-
requestedAt?: string;
|
|
439
|
-
channel: 'monitor_activity';
|
|
440
|
-
}): Promise<void> {
|
|
441
|
-
if (shouldSuppressMonitorActor(input.actorEmail)) return;
|
|
442
|
-
const requestedAt = input.requestedAt ?? new Date().toISOString();
|
|
443
|
-
const runtimeEnv = getRuntimeEnv();
|
|
444
|
-
const primary = input.reason
|
|
445
|
-
? `${input.monitorKey} | ${input.reason}`
|
|
446
|
-
: input.monitorKey;
|
|
447
|
-
await sendSlackEventSafe(
|
|
448
|
-
input.channel,
|
|
449
|
-
buildSlackActivityPayload({
|
|
450
|
-
source: input.source,
|
|
451
|
-
activityTitle: input.title,
|
|
452
|
-
activityPrimary: primary,
|
|
453
|
-
requestedAt,
|
|
454
|
-
fallbackText: `Monitor ${input.event} - ${input.monitorKey} | org ${input.orgId}`,
|
|
455
|
-
fields: [
|
|
456
|
-
{ label: 'Monitor', value: input.monitorKey },
|
|
457
|
-
{ label: 'Reason', value: input.reason },
|
|
458
|
-
{ label: 'Org ID', value: input.orgId },
|
|
459
|
-
{ label: 'Actor', value: input.actorEmail ?? null },
|
|
460
|
-
{ label: 'Environment', value: runtimeEnv },
|
|
461
|
-
],
|
|
462
|
-
extra: {
|
|
463
|
-
orgId: input.orgId,
|
|
464
|
-
monitorKey: input.monitorKey,
|
|
465
|
-
event: input.event,
|
|
466
|
-
actorEmail: input.actorEmail ?? null,
|
|
467
|
-
email: input.actorEmail ?? null,
|
|
468
|
-
runtimeEnv,
|
|
469
|
-
bypassInternalActorBlock: true,
|
|
470
|
-
},
|
|
471
|
-
}),
|
|
472
|
-
);
|
|
473
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@deepline/monitors",
|
|
3
|
-
"version": "0.0.0",
|
|
4
|
-
"private": true,
|
|
5
|
-
"type": "module",
|
|
6
|
-
"exports": {
|
|
7
|
-
"./billing/*": "./billing/*.ts",
|
|
8
|
-
"./*.js": "./*.ts",
|
|
9
|
-
"./*": "./*.ts"
|
|
10
|
-
},
|
|
11
|
-
"scripts": {
|
|
12
|
-
"build": "tsc -p tsconfig.json --noEmit",
|
|
13
|
-
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
14
|
-
},
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"@deepline/billing": "workspace:*",
|
|
17
|
-
"@deepline/ingestion-v2": "workspace:*",
|
|
18
|
-
"@deepline/plays": "workspace:*",
|
|
19
|
-
"next": "16.3.0-canary.60",
|
|
20
|
-
"pg": "^8.19.0",
|
|
21
|
-
"react": "19.2.5"
|
|
22
|
-
},
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/node": "^20.0.0",
|
|
25
|
-
"@types/pg": "^8.16.0",
|
|
26
|
-
"@types/react": "^19.2.14",
|
|
27
|
-
"typescript": "^6.0.2"
|
|
28
|
-
}
|
|
29
|
-
}
|