Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
103 commits
Select commit Hold shift + click to select a range
5551306
fix(alerts): five ways a page was lost or left open
Makisuo Nov 24, 2026
16ff264
wip(on-call): gaps, departed members and chain tiers
Makisuo Nov 24, 2026
dd837a1
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
dcb5e52
fix(alerts): close the gaps a review found in the lost-page fixes
Makisuo Nov 24, 2026
2fc74cd
fix(on-call): a step that reaches nobody no longer goes unnoticed
Makisuo Nov 24, 2026
c7882c1
feat(web): warn about coverage gaps and departed people on on-call sc…
Makisuo Nov 24, 2026
4d2c6f2
fix(slo): burn alerts that hold through an outage and do not fire on …
Makisuo Nov 24, 2026
fa3074e
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
53f50c4
Merge remote-tracking branch 'origin/main' into alerts/lost-pages
Makisuo Nov 24, 2026
6878c1d
fix(on-call): review fixes for gap handling
Makisuo Nov 24, 2026
6e20154
Merge branch 'alerts/oncall-gaps-ui' into alerts/oncall-gaps
Makisuo Nov 24, 2026
d0cf95b
style(on-call): format the member notifier
Makisuo Nov 24, 2026
b66923d
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
b6e28fb
wip(alerts): manual resolve and time to acknowledge
Makisuo Nov 24, 2026
9606c97
fix(slo): review fixes for the burn and budget alerts
Makisuo Nov 24, 2026
10224cc
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
3c2ac87
feat(mcp): resolve_alert_incident resolves an open incident by hand
Makisuo Nov 24, 2026
47fa2ac
feat(web): SLO pages show capped tiers, the spent budget alert and SL…
Makisuo Nov 24, 2026
d9b69e8
Merge branch 'slo/alert-correctness-ui' into slo/alert-correctness
Makisuo Nov 24, 2026
d59ac62
fix(web): tier readings count recorded spans, as the evaluator does
Makisuo Nov 24, 2026
0ea2bf2
Merge remote-tracking branch 'origin/main' into alerts/lost-pages
Makisuo Nov 24, 2026
31ab3d2
fix(alerts): all-clears on rule delete cover every paged destination …
Makisuo Nov 24, 2026
9b5fe37
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
294bf0c
fix(on-call): review fixes for chains that reach nobody
Makisuo Nov 24, 2026
62f53d0
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
bde33d7
style(alerts): format after the merge
Makisuo Nov 24, 2026
a28c54b
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
4ab0b4b
feat(alerts): resolve an incident by hand from the dashboard, and sho…
Makisuo Nov 24, 2026
96645b0
fix(alerts): review fixes for the resolve by hand
Makisuo Nov 24, 2026
a198643
Merge remote-tracking branch 'origin/main' into alerts/lost-pages
Makisuo Nov 24, 2026
7bdf929
test(browser): wire goldens follow the SDK version
Makisuo Nov 24, 2026
443b627
ci: size the ai test lanes at 1.5s per file
Makisuo Nov 24, 2026
04fbd34
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
e2ee2c0
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
30842bd
test(slo): record the new SLO SQL and check the recorded span count a…
Makisuo Nov 24, 2026
fd675ab
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
2e2868e
feat(on-call): a private calendar feed per schedule
Makisuo Nov 24, 2026
18c432a
test(domain): the v2 incident contract fixture carries first_acknowle…
Makisuo Nov 24, 2026
841bb01
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
6f2e730
feat(web): the schedule page makes, replaces and turns off its calend…
Makisuo Nov 24, 2026
e848ac9
docs(alerting): on-call schedules and escalation chains
Makisuo Nov 24, 2026
ed9e402
fix(on-call): review fixes for the calendar feed
Makisuo Nov 24, 2026
79284af
Merge remote-tracking branch 'origin/fix/browser-wire-golden-version'…
Makisuo Nov 24, 2026
65189b8
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
1629cf9
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
c1cd272
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
af24040
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
dd9b37f
feat(on-call): a page to a person also reaches their phone
Makisuo Nov 24, 2026
7562fd3
fix(alerts): second round of review fixes for lost pages
Makisuo Nov 24, 2026
afe24b5
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
682a4de
fix(on-call): say that a departed person's shifts go uncovered when n…
Makisuo Nov 24, 2026
fe6ce9c
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
4d2eade
fix(slo): review fixes for budget recovery, incident thresholds and s…
Makisuo Nov 24, 2026
f329c2d
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
b0ac455
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
9902564
fix(alerts): review fixes for resolve by hand
Makisuo Nov 24, 2026
76cfa39
fix(on-call): review fixes for the calendar feed
Makisuo Nov 24, 2026
fbe86d8
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
540a4cf
fix(on-call): a device read that failed is a failed phone page, not a…
Makisuo Nov 24, 2026
b01a24b
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
e0c7c20
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
5c1845d
Merge remote-tracking branch 'origin/main' into alerts/lost-pages
Makisuo Nov 24, 2026
d48b741
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
351b5a2
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
e11c5a6
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
fa89d52
test(api): give the member notifier its push service in the v2 alert …
Makisuo Nov 24, 2026
3e3f024
fix(mcp): the coverage warning names the gap window the server report…
Makisuo Nov 24, 2026
720bcae
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
5b9f480
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
dc16334
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
1a7a43a
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
b6a5c5f
fix(on-call): a phone page on a deployment without push says so
Makisuo Nov 24, 2026
6864371
fix(alerts): a skipped post earns no all-clear on rule deletion, and …
Makisuo Nov 24, 2026
dc2e03d
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
17e9b68
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
8c3cefa
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
20ba262
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
ee8fee2
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
90b70b8
fix(alerts): relink an all-clear that outlives its rule while in flig…
Makisuo Nov 24, 2026
f200c3d
Merge branch 'alerts/lost-pages' into alerts/oncall-gaps
Makisuo Nov 24, 2026
7f6e404
Merge branch 'alerts/oncall-gaps' into slo/alert-correctness
Makisuo Nov 24, 2026
5be044e
fix(slo): a held tier says it has no events or too few to judge, and …
Makisuo Nov 24, 2026
247ed8d
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
4f38875
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
122e8bc
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
bb67f9c
fix(slo): a budget incident names no group, though it is stored with …
Makisuo Nov 24, 2026
ad35090
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
9afebef
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
9c15fe2
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
07e6937
fix(on-call): a calendar link someone else turned off stops showing a…
Makisuo Nov 24, 2026
4a6860e
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
86c6fab
fix(on-call): a phone Apple just called dead is not reported as no ph…
Makisuo Nov 24, 2026
9ff4b11
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
b2a2041
test(on-call): leaving the calendar feed question sends nothing, and …
Makisuo Nov 24, 2026
3912cfc
perf(on-call): a phone page reads the member's own devices, not the o…
Makisuo Nov 24, 2026
8e578e2
Merge main after #3013 was squash-merged
Makisuo Nov 24, 2026
4f208e8
Merge remote-tracking branch 'origin/main' into slo/alert-correctness
Makisuo Nov 24, 2026
0059290
Merge branch 'slo/alert-correctness' into alerts/incident-actions
Makisuo Nov 24, 2026
16b682a
Merge main after #3017 was squash-merged
Makisuo Nov 24, 2026
4b8b434
Merge branch 'alerts/incident-actions' into oncall/calendar-feed
Makisuo Nov 24, 2026
4d8d519
Merge main after #3018 was squash-merged
Makisuo Nov 24, 2026
744c497
Merge branch 'oncall/calendar-feed' into oncall/mobile-paging
Makisuo Nov 24, 2026
bebe88c
Merge main after #3023 was squash-merged
Makisuo Nov 24, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/ai/src/mcp/tools/get-incident-timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function formatTimestamp(iso: string | null): string | undefined {
}

const channelLabel = (channel: string): string =>
channel === "email" ? "email" : `${Str.capitalize(channel)} DM`
channel === "email" ? "email" : channel === "push" ? "phone" : `${Str.capitalize(channel)} DM`

interface PageRow {
readonly userId: string
Expand Down
15 changes: 8 additions & 7 deletions apps/api/src/routes/v2/alchemy-provider.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,17 +170,17 @@ const makeHarness = () => {
const alertRulesLive = AlertRulesService.layer.pipe(
Layer.provide(Layer.mergeAll(testDb.layer, runtimeLive)),
)
// Incident pushes and the pages a chain step sends to a person's phone.
const mobilePushLive = Layer.effect(MobilePushService, MobilePushService.make).pipe(
Layer.provide(
Layer.mergeAll(ApnsClient.layer, MobileDevicesService.layer, LiveActivitiesService.layer),
),
)
const alertsLive = Layer.effect(AlertsService, AlertsService.make).pipe(
Layer.provide(InvestigationStarter.layer),
Layer.provide(FetchHttpClient.layer),
Layer.provide(ChatAlertPoster.layer),
Layer.provide(
Layer.effect(MobilePushService, MobilePushService.make).pipe(
Layer.provide(
Layer.mergeAll(ApnsClient.layer, MobileDevicesService.layer, LiveActivitiesService.layer),
),
),
),
Layer.provide(mobilePushLive),
Layer.provide(
Layer.mergeAll(
envLive,
Expand All @@ -199,6 +199,7 @@ const makeHarness = () => {
alertRulesLive,
Layer.effect(AlertMemberNotifier, AlertMemberNotifier.make).pipe(
Layer.provide(ChatAlertPoster.layer),
Layer.provide(mobilePushLive),
Layer.provide(
Layer.mergeAll(envLive, testDb.layer, runtimeLive, emailLive, orgMembersLive),
),
Expand Down
15 changes: 8 additions & 7 deletions apps/api/src/routes/v2/alerts.http.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,17 +183,17 @@ const makeHarness = (
const alertRulesLive = AlertRulesService.layer.pipe(
Layer.provide(Layer.mergeAll(testDb.layer, runtimeLive)),
)
// Incident pushes and the pages a chain step sends to a person's phone.
const mobilePushLive = Layer.effect(MobilePushService, MobilePushService.make).pipe(
Layer.provide(
Layer.mergeAll(ApnsClient.layer, MobileDevicesService.layer, LiveActivitiesService.layer),
),
)
const alertsLive = Layer.effect(AlertsService, AlertsService.make).pipe(
Layer.provide(InvestigationStarter.layer),
Layer.provide(FetchHttpClient.layer),
Layer.provide(ChatAlertPoster.layer),
Layer.provide(
Layer.effect(MobilePushService, MobilePushService.make).pipe(
Layer.provide(
Layer.mergeAll(ApnsClient.layer, MobileDevicesService.layer, LiveActivitiesService.layer),
),
),
),
Layer.provide(mobilePushLive),
Layer.provide(
Layer.mergeAll(
envLive,
Expand All @@ -212,6 +212,7 @@ const makeHarness = (
alertRulesLive,
Layer.effect(AlertMemberNotifier, AlertMemberNotifier.make).pipe(
Layer.provide(ChatAlertPoster.layer),
Layer.provide(mobilePushLive),
Layer.provide(
Layer.mergeAll(envLive, testDb.layer, runtimeLive, emailLive, orgMembersLive),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ A chain can have up to 10 steps, each with up to 10 targets and a wait of up to
| Target | Who is paged |
| ----------- | ------------------------------------------------------------------------------------------------------------- |
| Destination | A [notification destination](/docs/alerting/notification-destinations): a channel, PagerDuty, a webhook. |
| Person | One member, by email, and by direct message in a chat workspace they have linked their account in. |
| Person | One member: by email, by a push to their phones if they use the Maple app, and by direct message in a chat workspace they have linked their account in. |
| Schedule | Whoever an [on-call schedule](/docs/alerting/on-call-schedules) says is on call when the step comes up. |

Who is on call is read when the step fires, not when the chain was saved or the incident opened.
Expand Down
52 changes: 50 additions & 2 deletions packages/backend/src/services/alerts/AlertMemberNotifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
import { summarizeCause } from "@maple/backend/platform/describe-cause"
import { makeDbExecute } from "@maple/backend/platform/db-execute"
import { EmailService } from "@maple/backend/platform/EmailService"
import { MobilePushService } from "@maple/backend/services/push/MobilePushService"
import { Env } from "@maple/backend/platform/Env"
import { OrgMembersService, type OrgMember } from "@maple/backend/services/org/OrgMembersService"
import { buildAlertEmailContent } from "./alert-email"
import { PUSH_CHANNEL } from "./alert-escalation-runs"
import { makePersistenceError } from "./alert-persistence"
import { AlertRuntime } from "./AlertRuntime"
import { ChatAlertPoster } from "./ChatAlertPoster"
Expand All @@ -56,6 +58,10 @@
noEmail: "No email address is known for this member",
emailFailed: "The email could not be sent",
unreadable: "The stored page could not be read",
pushFailed: "The push could not be sent",
noPhone: "No phone is registered for this member",
pushNotConfigured: "Push is not set up on this deployment",
phoneGone: "The member's phone no longer accepts pushes",
noChatAccount: "The page names no chat account",
noWorkspaceKnowsUser: "No linked chat workspace could reach this member",
chatAuth: "The chat workspace refused Maple's credentials",
Expand Down Expand Up @@ -178,6 +184,7 @@
const orgMembers = yield* OrgMembersService
const email = yield* EmailService
const chat = yield* ChatAlertPoster
const mobilePush = yield* MobilePushService
const dbExecute = makeDbExecute(database, "AlertMemberNotifier", makePersistenceError)

const claimable = (
Expand Down Expand Up @@ -319,6 +326,38 @@
* Identities do not record their workspace, so each of the org's workspaces on the
* connector is tried, oldest first; only "no such user" moves on to the next one.
*/
/** The member's own phones. A phone that has gone since the step queued this is no failure. */
const sendPush = (row: AlertMemberNotificationRow, input: ChatAlertCardInput) =>

Check notice on line 330 in packages/backend/src/services/alerts/AlertMemberNotifier.ts

View check run for this annotation

Maple Review Bot / Maple / review

maintainability: `sendDirectMessage`'s doc comment now heads `sendPush`

The block at 326-328 describes trying each of the org's chat workspaces in turn, and `sendPush` now sits directly under it, so its doc reads as being about chat. `sendDirectMessage` at 361 is left with no doc at all.
Effect.gen(function* () {
const context = input.context
const summary = yield* mobilePush.pageMember({
orgId: row.orgId,
userId: row.userId,
incidentId: row.incidentId,
ruleId: context.ruleId,
title: `You are paged · ${context.ruleName}`,
body: `${context.severity === "critical" ? "Critical" : "Warning"} incident, unacknowledged. Open it to acknowledge.`,
linkUrl: input.linkUrl,
collapseId: `page:${row.incidentId}`,
})
Comment thread
Makisuo marked this conversation as resolved.
Resolved
// Without push credentials nothing was tried: say that, not that the member has no phone.
const attempt: Attempt = !summary.configured
? { status: "skipped", message: FailureMessages.pushNotConfigured }
: summary.sent > 0
? { status: "sent" }
: summary.failed > 0
? failure(FailureMessages.pushFailed, true)
: {
status: "skipped",
// A token Apple called dead was just switched off: that is not "no phone".
message:
summary.unregistered > 0
? FailureMessages.phoneGone
: FailureMessages.noPhone,
}
return attempt
})

const sendDirectMessage = (
row: AlertMemberNotificationRow,
payload: MemberPayload,
Expand Down Expand Up @@ -439,7 +478,9 @@
members(row.orgId),
payload.value.recipient.lastResort === true,
)
: yield* sendDirectMessage(row, payload.value, input.value)
: row.channel === PUSH_CHANNEL
? yield* sendPush(row, input.value)
: yield* sendDirectMessage(row, payload.value, input.value)
const attemptedAt = yield* runtime.now
if (attempt.status === "sent") {
yield* settle(row, claimedAt, { status: "sent", attemptedAt, errorMessage: null })
Expand Down Expand Up @@ -567,6 +608,13 @@
},
) {
static readonly layer = Layer.effect(this, this.make).pipe(
Layer.provide(Layer.mergeAll(OrgMembersService.layer, EmailService.layer, ChatAlertPoster.layer)),
Layer.provide(
Layer.mergeAll(
OrgMembersService.layer,
EmailService.layer,
ChatAlertPoster.layer,
MobilePushService.layer,
),
),
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import {
tracesRow,
alertServices,
} from "./alerts-service-test-support"
import type { MemberPagePush } from "@maple/backend/services/push/MobilePushService"

const trackedDbs: TestDb[] = []
afterEach(() => cleanupTestDbs(trackedDbs))
Expand Down Expand Up @@ -206,6 +207,11 @@ const layerFor = (
readonly directory?: Array<OrgMember>
readonly email?: (typeof EmailService)["Service"]
readonly deliveryTimeoutMs?: number
/** Records the pages pushed to members' phones; `memberPagesFail` lets none of them land. */
readonly memberPages?: Array<MemberPagePush>
readonly memberPagesFail?: boolean
readonly memberPagesUnconfigured?: boolean
readonly memberPagesApple?: { down: boolean }
} = {},
) => {
const directory = options.directory ?? [...MEMBERS]
Expand All @@ -218,6 +224,16 @@ const layerFor = (
{
fetch: okFetch,
...(timeoutMs === undefined ? undefined : { deliveryTimeoutMs: () => timeoutMs }),
...(options.memberPages === undefined ? undefined : { memberPages: options.memberPages }),
...(options.memberPagesFail === undefined
? undefined
: { memberPagesFail: options.memberPagesFail }),
...(options.memberPagesUnconfigured === undefined
? undefined
: { memberPagesUnconfigured: options.memberPagesUnconfigured }),
...(options.memberPagesApple === undefined
? undefined
: { memberPagesApple: options.memberPagesApple }),
},
options.email ?? stubEmailService(emails),
ChatAlertPoster.layer.pipe(
Expand Down Expand Up @@ -747,6 +763,147 @@ describe("escalation pages the on-call", () => {
})
})

/** A phone `userId` registered the Maple app on; `disabled` marks its token dead. */
const registerPhone = (testDb: TestDb, orgId: OrgId, userId: string, disabled = false) =>
Effect.promise(() =>
executeSql(
testDb,
`insert into mobile_devices
(id, org_id, user_id, platform, token, environment, bundle_id, preferences,
disabled_at, last_seen_at, created_at, updated_at)
values (gen_random_uuid()::text, $1, $2, 'ios', md5(random()::text), 'production',
'dev.maple.app', '{}'::jsonb, $3, now(), now(), now())`,
[orgId, userId, disabled ? new Date(NOW).toISOString() : null],
),
)

it.effect("pages the on-call person's phone as well, and only a phone that can still be pushed", () => {
const testDb = createTestDb(trackedDbs)
const state = { tracesAggregateRows: errorRate(10) }
const emails: Array<SentEmail> = []
const memberPages: Array<MemberPagePush> = []
return Effect.gen(function* () {
const chat = yield* makeChat
yield* TestClock.setTime(NOW)
return yield* Effect.gen(function* () {
// Step 2 pages Ben (on call today) and Chen; Ben has the app, Chen's token is dead.
const { alerts, orgId } = yield* setup("org_page_phone", testDb, {
secondStep: [
{ type: "user", userId: ben },
{ type: "user", userId: chen },
],
})
yield* registerPhone(testDb, orgId, ben)
yield* registerPhone(testDb, orgId, chen, true)
yield* ticks(alerts, 10)

assert.deepStrictEqual(
Arr.map(memberPages, (page) => [page.userId, page.title]),
[[ben, "You are paged · Checkout error rate"]],
)
const pushRows = Arr.filter(yield* pageRows(testDb, orgId), (row) => row.channel === "push")
assert.deepStrictEqual(
Arr.map(pushRows, (row) => [row.user_id, row.status]),
[[ben, "sent"]],
)
// The email still goes to both: the phone is one more way in, not a replacement.
assert.sameMembers(
Arr.map(emails, (email) => email.to),
["ben@acme.test", "chen@acme.test"],
)
}).pipe(Effect.provide(layerFor(testDb, state, emails, chat, { memberPages })))
})
})

it.effect("settles a phone page nobody's phone took as skipped, with why", () => {
const testDb = createTestDb(trackedDbs)
const state = { tracesAggregateRows: errorRate(10) }
const emails: Array<SentEmail> = []
const memberPages: Array<MemberPagePush> = []
return Effect.gen(function* () {
const chat = yield* makeChat
yield* TestClock.setTime(NOW)
return yield* Effect.gen(function* () {
const { alerts, orgId } = yield* setup("org_page_phone_gone", testDb, {
secondStep: [{ type: "user", userId: ben }],
})
yield* registerPhone(testDb, orgId, ben)
yield* ticks(alerts, 10)
const pushRows = Arr.filter(yield* pageRows(testDb, orgId), (row) => row.channel === "push")
assert.deepStrictEqual(
Arr.map(pushRows, (row) => [row.status, row.error_message]),
[["skipped", "The member's phone no longer accepts pushes"]],
)
}).pipe(
Effect.provide(layerFor(testDb, state, emails, chat, { memberPages, memberPagesFail: true })),
)
})
})

it.effect("retries a phone page Apple could not take, and sends it", () => {
const testDb = createTestDb(trackedDbs)
const state = { tracesAggregateRows: errorRate(10) }
const emails: Array<SentEmail> = []
const memberPages: Array<MemberPagePush> = []
const apple = { down: true }
return Effect.gen(function* () {
const chat = yield* makeChat
yield* TestClock.setTime(NOW)
return yield* Effect.gen(function* () {
const { alerts, orgId } = yield* setup("org_page_phone_retry", testDb, {
secondStep: [{ type: "user", userId: ben }],
})
yield* registerPhone(testDb, orgId, ben)
yield* ticks(alerts, 10)
const push = Effect.map(pageRows(testDb, orgId), (rows) =>
Arr.map(
Arr.filter(rows, (row) => row.channel === "push"),
(row) => [row.status, row.attempt_number, row.error_message],
),
)
assert.deepStrictEqual(yield* push, [["queued", 1, "The push could not be sent"]])
apple.down = false
yield* ticks(alerts, 2)
assert.deepStrictEqual(yield* push, [["sent", 2, null]])
}).pipe(
Effect.provide(
layerFor(testDb, state, emails, chat, { memberPages, memberPagesApple: apple }),
),
)
})
})

it.effect("a phone page on a deployment without push says so, not that the member has no phone", () => {
const testDb = createTestDb(trackedDbs)
const state = { tracesAggregateRows: errorRate(10) }
const emails: Array<SentEmail> = []
const memberPages: Array<MemberPagePush> = []
return Effect.gen(function* () {
const chat = yield* makeChat
yield* TestClock.setTime(NOW)
return yield* Effect.gen(function* () {
const { alerts, orgId } = yield* setup("org_page_phone_unconfigured", testDb, {
secondStep: [{ type: "user", userId: ben }],
})
yield* registerPhone(testDb, orgId, ben)
yield* ticks(alerts, 10)
const pushRows = Arr.filter(yield* pageRows(testDb, orgId), (row) => row.channel === "push")
assert.deepStrictEqual(
Arr.map(pushRows, (row) => [row.status, row.error_message]),
[["skipped", "Push is not set up on this deployment"]],
)
}).pipe(
Effect.provide(
layerFor(testDb, state, emails, chat, {
memberPages,
memberPagesFail: true,
memberPagesUnconfigured: true,
}),
),
)
})
})

it.effect("refuses to delete a schedule a running escalation still pages", () => {
const testDb = createTestDb(trackedDbs)
const state = { tracesAggregateRows: errorRate(10) }
Expand Down
Loading
Loading