Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
38 changes: 2 additions & 36 deletions apps/landing/src/components/page/sections/UptimeSetup.astro
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,9 @@
* limits a buyer or an agent needs before choosing Maple's checks over a dedicated tool.
*/
import * as m from "../../../paraglide/messages.js";
import { UPTIME_SETUP_WAYS } from "../../../lib/feature-sections";

const ways = [
{
label: m.uptime_setup_way_agent(),
code: `> Add an uptime check for https://api.example.com/health,
every minute, linked to the checkout service.

create_uptime_monitor({
kind: "http",
name: "checkout-api",
url: "https://api.example.com/health",
interval_seconds: 60,
service: "checkout",
})`,
},
{
label: m.uptime_setup_way_terraform(),
code: `resource "maple_uptime_monitor" "checkout_api" {
name = "checkout-api"
interval_seconds = 60
service_name = "checkout"
config = jsonencode({
type = "http"
url = "https://api.example.com/health"
})
}`,
},
{
label: m.uptime_setup_way_api(),
code: `curl https://api.maple.dev/v2/uptime_monitors \\
-H "Authorization: Bearer $MAPLE_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{"name": "checkout-api", "kind": "http",
"config": {"type": "http", "url": "https://api.example.com/health"},
"interval_seconds": 60, "service_name": "checkout"}'`,
},
];
const ways = UPTIME_SETUP_WAYS.map((way) => ({ label: way.label(), code: way.code }));

const facts = [
{ title: m.uptime_setup_fact_1_title(), body: m.uptime_setup_fact_1_body() },
Expand Down
12 changes: 12 additions & 0 deletions apps/landing/src/lib/feature-sections.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { describe, expect, it } from "vitest"
import { sectionMarkdown, UPTIME_SETUP_WAYS } from "./feature-sections"

describe("uptime-setup markdown", () => {
it("prints the check all three ways the lede promises, each as a fenced block", () => {
const md = sectionMarkdown("uptime-setup", new URL("https://maple.dev"))
for (const way of UPTIME_SETUP_WAYS) {
expect(md).toContain(`### ${way.label()}\n\n\`\`\`${way.lang}\n${way.code}\n\`\`\``)
}
expect(md).toContain("https://maple.dev/docs/alerting/uptime-checks")
})
})
59 changes: 59 additions & 0 deletions apps/landing/src/lib/feature-sections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,47 @@ export const K8S_INSTALL_STEPS = [
},
]

/** One uptime check written three ways; the code is runnable, so never translated. */
export const UPTIME_SETUP_WAYS = [
{
label: m.uptime_setup_way_agent,
lang: "text",
code: `> Add an uptime check for https://api.example.com/health,
every minute, linked to the checkout service.

create_uptime_monitor({
kind: "http",
name: "checkout-api",
url: "https://api.example.com/health",
interval_seconds: 60,
service: "checkout",
})`,
},
{
label: m.uptime_setup_way_terraform,
lang: "hcl",
code: `resource "maple_uptime_monitor" "checkout_api" {
name = "checkout-api"
interval_seconds = 60
service_name = "checkout"
config = jsonencode({
type = "http"
url = "https://api.example.com/health"
})
}`,
},
{
label: m.uptime_setup_way_api,
lang: "bash",
code: `curl https://api.maple.dev/v2/uptime_monitors \\
-H "Authorization: Bearer $MAPLE_API_KEY" \\
-H "Content-Type: application/json" \\
-d '{"name": "checkout-api", "kind": "http",
"config": {"type": "http", "url": "https://api.example.com/health"},
"interval_seconds": 60, "service_name": "checkout"}'`,
},
]

/** Copied from `/docs/product-events/*` and must stay runnable, so never translated. */
export const PRODUCT_EVENT_SOURCES = [
{
Expand Down Expand Up @@ -141,6 +182,24 @@ export const sectionMarkdown = (id: SectionId, site: URL | undefined): string =>
{ title: m.uptime_trace_rule_3_title, body: m.uptime_trace_rule_3_body },
]),
)
case "uptime-setup":
Comment thread
Makisuo marked this conversation as resolved.
Resolved
return section(
m.uptime_setup_title(),
m.uptime_setup_lede(),
...Arr.map(UPTIME_SETUP_WAYS, (way) => `### ${way.label()}\n\n${fence(way.lang, way.code)}`),
...rules([
{ title: m.uptime_setup_fact_1_title, body: m.uptime_setup_fact_1_body },
{ title: m.uptime_setup_fact_2_title, body: m.uptime_setup_fact_2_body },
{ title: m.uptime_setup_fact_3_title, body: m.uptime_setup_fact_3_body },
]),
Arr.join(
[
`- [${m.uptime_setup_link_checks()}](${absolute(site, "/docs/alerting/uptime-checks")})`,
`- [${m.uptime_setup_link_heartbeats()}](${absolute(site, "/docs/alerting/heartbeat-monitors")})`,
],
"\n",
),
)
case "status-page-feeds":
return section(
m.status_feeds_title(),
Expand Down
Loading