diff --git a/apps/api/autumn.config.ts b/apps/api/autumn.config.ts index c8874f01a3..ea627c0269 100644 --- a/apps/api/autumn.config.ts +++ b/apps/api/autumn.config.ts @@ -30,6 +30,15 @@ export const traces = feature({ consumable: true, }) +// Continuous CPU profiles, in GB of decoded OTLP profiles. Metered by the ingest gateway +// (`PROFILES_FEATURE_ID` in apps/ingest/src/main.rs). +export const profiles = feature({ + id: "profiles", + name: "Profiles", + type: "metered", + consumable: true, +}) + export const browserSessions = feature({ id: "browser_sessions", name: "Browser Sessions", @@ -141,6 +150,17 @@ export const startup = plan({ interval: "month", }, }, + { + // Priced above the other byte signals: a profile stores about 28 times its wire size. + featureId: "profiles", + included: 10, + price: { + amount: 0.6, + billingUnits: 1, + billingMethod: "usage_based", + interval: "month", + }, + }, { featureId: "browser_sessions", included: 5000, diff --git a/apps/api/src/routes/internal/billing.http.test.ts b/apps/api/src/routes/internal/billing.http.test.ts index afb12968c7..f8b0994076 100644 --- a/apps/api/src/routes/internal/billing.http.test.ts +++ b/apps/api/src/routes/internal/billing.http.test.ts @@ -402,7 +402,7 @@ describe("decodeInvoices", () => { }) describe("sumDailySpend", () => { - const day = (date: string, logsGB: number, productEvents?: number) => + const day = (date: string, logsGB: number, productEvents?: number, profilesGB?: number) => new DailyVolume({ date, logsGB, @@ -410,19 +410,27 @@ describe("sumDailySpend", () => { metricsGB: 0, browserSessions: 2, ...(productEvents === undefined ? undefined : { productEvents }), + ...(profilesGB === undefined ? undefined : { profilesGB }), }) const series = (days: ReadonlyArray) => new DailySpendResponse({ cycleStart: 10, cycleEnd: 20, days }) it("adds a billing org's members into its series, day by day", () => { - const total = sumDailySpend(series([day("2026-10-01", 1, 3), day("2026-10-02", 2)]), [ - series([day("2026-10-01", 0.5), day("2026-10-02", 4, 1)]), + const total = sumDailySpend(series([day("2026-10-01", 1, 3, 0.25), day("2026-10-02", 2)]), [ + series([day("2026-10-01", 0.5, undefined, 0.5), day("2026-10-02", 4, 1)]), ]) assert.deepStrictEqual( - Arr.map(total.days, (d) => [d.date, d.logsGB, d.tracesGB, d.browserSessions, d.productEvents]), + Arr.map(total.days, (d) => [ + d.date, + d.logsGB, + d.tracesGB, + d.browserSessions, + d.productEvents, + d.profilesGB, + ]), [ - ["2026-10-01", 1.5, 2, 4, 3], - ["2026-10-02", 6, 2, 4, 1], + ["2026-10-01", 1.5, 2, 4, 3, 0.75], + ["2026-10-02", 6, 2, 4, 1, 0], ], ) assert.strictEqual(total.cycleStart, 10) diff --git a/apps/api/src/routes/internal/billing.http.ts b/apps/api/src/routes/internal/billing.http.ts index b955541b9a..883f4d3e4c 100644 --- a/apps/api/src/routes/internal/billing.http.ts +++ b/apps/api/src/routes/internal/billing.http.ts @@ -118,6 +118,7 @@ export const sumDailySpend = ( logsGB: sum.logsGB + next.logsGB, tracesGB: sum.tracesGB + next.tracesGB, metricsGB: sum.metricsGB + next.metricsGB, + profilesGB: (sum.profilesGB ?? 0) + (next.profilesGB ?? 0), browserSessions: sum.browserSessions + next.browserSessions, productEvents: (sum.productEvents ?? 0) + (next.productEvents ?? 0), }) @@ -131,6 +132,7 @@ const orgUsageTotals = (orgId: OrgId, spend: DailySpendResponse) => logsGB: Arr.reduce(spend.days, 0, (sum, day) => sum + day.logsGB), tracesGB: Arr.reduce(spend.days, 0, (sum, day) => sum + day.tracesGB), metricsGB: Arr.reduce(spend.days, 0, (sum, day) => sum + day.metricsGB), + profilesGB: Arr.reduce(spend.days, 0, (sum, day) => sum + (day.profilesGB ?? 0)), browserSessions: Arr.reduce(spend.days, 0, (sum, day) => sum + day.browserSessions), productEvents: Arr.reduce(spend.days, 0, (sum, day) => sum + (day.productEvents ?? 0)), }) diff --git a/apps/ingest/src/main.rs b/apps/ingest/src/main.rs index 064625ebff..f9b12ddff7 100644 --- a/apps/ingest/src/main.rs +++ b/apps/ingest/src/main.rs @@ -1500,6 +1500,9 @@ const BROWSER_SESSIONS_FEATURE_ID: &str = "browser_sessions"; /// server-side one; only the transport differs). const PRODUCT_EVENTS_FEATURE_ID: &str = "product_events"; +/// The Autumn feature profiles bill as, in GB of decoded OTLP profiles like the byte signals. +const PROFILES_FEATURE_ID: &str = "profiles"; + /// What a DENIED Autumn entitlement means for the batch in flight. #[derive(Clone, Copy, PartialEq, Eq)] enum OnDenied { @@ -5640,7 +5643,7 @@ fn profile_resource_stamps( /// `POST /v1development/profiles`, and `/v1/profiles` where the spec moves it: an /// OTLP profiles export, flattened to rows of `profiles` by `maple_ingest::profiles`. -/// Metered per org but neither gated nor billed: profiles have no plan feature yet. +/// Gated on the org's `profiles` plan feature and billed per GB decoded, like the byte signals. async fn handle_profiles_inner( state: &AppState, headers: &HeaderMap, @@ -5684,6 +5687,12 @@ async fn handle_profiles_inner( } let pipeline = native_rows_pipeline_for(state, destination, "Profile storage is not configured")?; + // Before the body is read: an org without the feature, or past its cap, gets a 402. + if org_id != SENTINEL_ORG_ID { + if let Some(error) = entitlement_rejection(state, &org_id, PROFILES_FEATURE_ID).await { + return Err(error); + } + } let (payload_format, gzip) = profiles_body_encoding(headers)?; let rules = profile_redaction_rules(state, &org_id).await?; @@ -5748,11 +5757,18 @@ async fn handle_profiles_inner( } commit_profile_rows(state, pipeline, &org_id, rows, destination).await?; - // The usage counters only: nothing is reported to Autumn until profiles are priced. + // Recorded once the rows are durable, as the byte signals are. An export refused part way + // (only a WAL write failing, since the whole export is reserved first) bills nothing: its + // resend bills the whole export, so billing the stored part too would count it twice. if let Some(usage) = &state.usage_metrics { let signal = TelemetrySignal::Profiles.as_str(); usage.record(&org_id, signal, decoded_bytes as u64, count as u64); } + if org_id != SENTINEL_ORG_ID && decoded_bytes > 0 { + if let Some(tracker) = &state.autumn_tracker { + tracker.track(&org_id, PROFILES_FEATURE_ID, billable_gb(decoded_bytes as u64)); + } + } state.resolver.note_source_use(&resolved_key, false); Ok(accepted) } @@ -15166,6 +15182,88 @@ mod tests { base } + // Profiles are a plan feature: checked before the body is read, billed in GB once stored. + #[tokio::test] + async fn profiles_are_gated_and_billed_on_the_profiles_feature() { + let queue_dir = unique_main_test_dir("profiles-billing"); + let key = "maple_sk_test_profiles_billing"; + let store = private_key_store(key, "org_profiles_billing", false); + let (state, mut imports) = profiles_test_state(store, queue_dir.clone()).await; + let (state, mut rx) = with_fake_autumn(state).await; + + assert_eq!( + send_sdk_profiles(&state, key).await.expect("an allowed org stores profiles"), + PROFILES_SDK_ROWS + ); + assert_eq!( + imported_profile_rows(&mut imports, PROFILES_SDK_ROWS).await.len(), + PROFILES_SDK_ROWS + ); + let calls = drain_autumn_calls(&mut rx).await; + assert!(checks(&calls) + .iter() + .any(|call| call.feature_id() == PROFILES_FEATURE_ID)); + let billed = tracked(&calls); + assert_eq!(billed.len(), 1, "{billed:?}"); + assert_eq!(billed[0].0, PROFILES_FEATURE_ID); + let expected = billable_gb(PROFILES_SDK_EXPORT.len() as u64); + assert!((billed[0].1 - expected).abs() < 1e-12, "{billed:?}"); + + // An org Autumn denies is refused before anything is decoded or stored. + let denied_dir = unique_main_test_dir("profiles-billing-denied"); + let store = private_key_store(key, "org_profiles_denied", false); + let (state, mut imports) = profiles_test_state(store, denied_dir.clone()).await; + let state = with_autumn_denying(state, "org_profiles_denied").await; + let refused = send_sdk_profiles(&state, key) + .await + .expect_err("a denied org is refused"); + assert_eq!(refused.status, StatusCode::PAYMENT_REQUIRED); + assert_eq!(state.decode_memory.reserved_bytes(), 0); + assert!(no_profiles_are_stored(&mut imports).await); + drop(std::fs::remove_dir_all(&queue_dir)); + drop(std::fs::remove_dir_all(&denied_dir)); + } + + // A refused commit bills nothing, whatever it stored before the refusal: the resend bills the + // whole export, once. Any commit error returns before usage is recorded. + #[tokio::test] + async fn a_refused_profiles_commit_bills_nothing_and_its_resend_bills_once() { + let key = "maple_sk_test_profiles_refused_billing"; + let refused_dir = unique_main_test_dir("profiles-refused-billing"); + let store = private_key_store(key, "org_profiles_refused_billing", false); + // The org's queue cannot hold the export, so the commit is refused. + let (state, mut imports) = + profiles_test_state_with_org_queue(store, refused_dir.clone(), 100 * 1024).await; + let (state, mut rx) = with_fake_autumn(state).await; + let refused = send_sdk_profiles(&state, key) + .await + .expect_err("the export is past the org's queue"); + assert_eq!(refused.status, StatusCode::PAYLOAD_TOO_LARGE); + assert!(no_profiles_are_stored(&mut imports).await); + assert!(tracked(&drain_autumn_calls(&mut rx).await).is_empty()); + + // The resend to a gateway with room is stored and billed whole, once. + let resent_dir = unique_main_test_dir("profiles-resent-billing"); + let store = private_key_store(key, "org_profiles_refused_billing", false); + let (state, mut imports) = profiles_test_state(store, resent_dir.clone()).await; + let (state, mut rx) = with_fake_autumn(state).await; + assert_eq!( + send_sdk_profiles(&state, key).await.expect("the resend is stored"), + PROFILES_SDK_ROWS + ); + assert_eq!( + imported_profile_rows(&mut imports, PROFILES_SDK_ROWS).await.len(), + PROFILES_SDK_ROWS + ); + let calls = drain_autumn_calls(&mut rx).await; + let billed = tracked(&calls); + assert_eq!(billed.len(), 1, "{billed:?}"); + let expected = billable_gb(PROFILES_SDK_EXPORT.len() as u64); + assert!((billed[0].1 - expected).abs() < 1e-12, "{billed:?}"); + drop(std::fs::remove_dir_all(&refused_dir)); + drop(std::fs::remove_dir_all(&resent_dir)); + } + // The spec's development path and the path it moves to both take an export. #[tokio::test] async fn both_profiles_routes_take_an_export() { diff --git a/apps/landing/src/lib/pricing-offer.ts b/apps/landing/src/lib/pricing-offer.ts index 32ab2bca38..4cf8e21c53 100644 --- a/apps/landing/src/lib/pricing-offer.ts +++ b/apps/landing/src/lib/pricing-offer.ts @@ -13,7 +13,7 @@ * `label: m.pricing_logs()` freezes whichever locale rendered first and every * other locale inherits it. */ -import { PRICING_CARD_FEATURE_IDS, isPricingCardFeature } from "@maple/domain/billing" +import { PRICING_CARD_FEATURE_IDS, isAdvertisedPricingFeature } from "@maple/domain/billing" import { Autumn } from "autumn-js" import * as m from "../paraglide/messages.js" import { Array as Arr } from "effect" @@ -142,7 +142,7 @@ export async function getOffer(): Promise { hasTrial: !!product.freeTrial, trialDuration: product.freeTrial?.durationLength, allotments: Arr.map( - Arr.filter(product.items, (item) => isPricingCardFeature(item.featureId)), + Arr.filter(product.items, (item) => isAdvertisedPricingFeature(item.featureId)), (item) => { const featureId = item.featureId const unit = unitFor(featureId) diff --git a/apps/web/src/lab/billing-orgs-lab.ts b/apps/web/src/lab/billing-orgs-lab.ts index b2543cbf03..18a91fff27 100644 --- a/apps/web/src/lab/billing-orgs-lab.ts +++ b/apps/web/src/lab/billing-orgs-lab.ts @@ -59,6 +59,7 @@ const plans = Schema.decodeSync(Schema.Array(CatalogPlan))([ { featureId: "logs", included: 100, price: { amount: 0.3 } }, { featureId: "traces", included: 100, price: { amount: 0.3 } }, { featureId: "metrics", included: 100, price: { amount: 0.3 } }, + { featureId: "profiles", included: 10, price: { amount: 0.6 } }, { featureId: "browser_sessions", included: 5_000, price: { amount: 0.002 } }, { featureId: "product_events", @@ -85,6 +86,7 @@ const customer = Schema.decodeSync(BillingCustomer)({ logs: { granted: 100 }, traces: { granted: 100 }, metrics: { granted: 100 }, + profiles: { granted: 10 }, browser_sessions: { granted: 5_000 }, product_events: { granted: 1_000_000 }, ai_credits: { granted: 10 }, @@ -98,6 +100,7 @@ const usage = (state: LabState) => logs: { sum: 142.6 }, traces: { sum: 61.2 }, metrics: { sum: 18.4 }, + profiles: { sum: 6.3 }, browser_sessions: { sum: 3_120 }, product_events: { sum: 0 }, ai_credits: { sum: state === "ai-credits" ? 16.11 : 0 }, @@ -168,6 +171,7 @@ const accountUsage = Schema.decodeSync(BillingAccountUsageResponse)({ logsGB: 120, tracesGB: 50, metricsGB: 15, + profilesGB: 6.3, browserSessions: 3_120, productEvents: 0, }, diff --git a/apps/web/src/lab/entries/onboarding.ts b/apps/web/src/lab/entries/onboarding.ts index 3fe5c89080..209d1b7881 100644 --- a/apps/web/src/lab/entries/onboarding.ts +++ b/apps/web/src/lab/entries/onboarding.ts @@ -48,6 +48,7 @@ export const PLANS = [ meteredItem("logs", 100, 0.3, 1, "then $0.3 per Logs"), meteredItem("traces", 100, 0.3, 1, "then $0.3 per Traces"), meteredItem("metrics", 100, 0.3, 1, "then $0.3 per Metrics"), + meteredItem("profiles", 10, 0.6, 1, "then $0.6 per Profiles"), meteredItem("browser_sessions", 5000, 0.002, 1, "then $0.002 per browser session"), meteredItem("product_events", 1_000_000, 0.005, 1000, "then $0.005 per 1,000 product events"), ], diff --git a/apps/web/src/page/onboarding/pricing-plans.test.ts b/apps/web/src/page/onboarding/pricing-plans.test.ts index 4f51aa9ff5..913ce9e169 100644 --- a/apps/web/src/page/onboarding/pricing-plans.test.ts +++ b/apps/web/src/page/onboarding/pricing-plans.test.ts @@ -27,6 +27,23 @@ describe("getFeatureRows", () => { expect(Arr.map(getFeatureRows(plan), (row) => row.featureId)).toEqual(["logs", "ai_credits"]) }) + it("leaves profiles off the plan cards until they are advertised", () => { + const plan = new CatalogPlan({ + id: "startup", + name: "Startup", + items: [ + new CatalogPlanItem({ featureId: "logs", included: 100 }), + new CatalogPlanItem({ + featureId: "profiles", + included: 10, + display: { secondaryText: "then $0.6 per 1 profiles" }, + }), + ], + }) + + expect(Arr.map(getFeatureRows(plan), (row) => row.featureId)).toEqual(["logs"]) + }) + it("quotes an overage rate in whole cents and leaves sub-cent rates alone", () => { const metered = (featureId: string, secondaryText: string) => new CatalogPlanItem({ featureId, included: 100, display: { secondaryText } }) diff --git a/apps/web/src/page/onboarding/pricing-plans.ts b/apps/web/src/page/onboarding/pricing-plans.ts index aee55e63e2..3ded9e97b6 100644 --- a/apps/web/src/page/onboarding/pricing-plans.ts +++ b/apps/web/src/page/onboarding/pricing-plans.ts @@ -1,5 +1,5 @@ import type { CatalogPlan, CatalogPlanItem } from "@maple/domain/http" -import { isPricingCardFeature } from "@maple/domain/billing" +import { isAdvertisedPricingFeature } from "@maple/domain/billing" import { formatCurrency } from "@maple/domain/format" import { formatCount, formatQuoteUnits, quoteUnits } from "../kit/billing/usage" import type { IconName } from "@maple/views/ui/icon" @@ -12,6 +12,7 @@ export const FEATURE_ICONS = new Map([ ["logs", "FileIcon"], ["traces", "PulseIcon"], ["metrics", "ChartLineIcon"], + ["profiles", "FireIcon"], ["browser_sessions", "PlayRotateClockwiseIcon"], ["product_events", "GlobePointerIcon"], ["ai_credits", "SquareSparkleIcon"], @@ -21,6 +22,7 @@ const DATA_FEATURE_LABELS = new Map([ ["logs", "Logs"], ["traces", "Traces"], ["metrics", "Metrics"], + ["profiles", "Profiles"], ["browser_sessions", "Browser sessions"], ["product_events", "Product events"], ["ai_credits", "AI usage"], @@ -72,7 +74,7 @@ const padCents = (text: string): string => replaceWith(text, /\$(\d+)\.(\d)(?!\d)/g, (_, dollars = "", tenths = "") => `$${dollars}.${tenths}0`) const normalizeDetailText = (text: string): string => - padCents(Str.replace(/\bper\s+(?:[\d,]+\s+)?(?:logs?|traces?|metrics?)\b/i, "per GB")(text)) + padCents(Str.replace(/\bper\s+(?:[\d,]+\s+)?(?:logs?|traces?|metrics?|profiles?)\b/i, "per GB")(text)) /** Autumn words the rate per billing block; events are quoted per million, in its style. */ const formatDetail = (item: CatalogPlanItem): string | undefined => { @@ -134,7 +136,7 @@ export type FeatureRow = Readonly<{ featureId: string; label: string; value: str export const getFeatureRows = (plan: CatalogPlan): ReadonlyArray => Arr.map( - Arr.filter(plan.items, (item) => isPricingCardFeature(item.featureId)), + Arr.filter(plan.items, (item) => isAdvertisedPricingFeature(item.featureId)), (item) => { const detail = formatDetail(item) return { diff --git a/apps/web/src/page/settings/billing/model.ts b/apps/web/src/page/settings/billing/model.ts index 1d389d0ee8..2c75305b06 100644 --- a/apps/web/src/page/settings/billing/model.ts +++ b/apps/web/src/page/settings/billing/model.ts @@ -31,6 +31,7 @@ export const SpendFeatureId = Schema.Literals([ "logs", "traces", "metrics", + "profiles", "browser_sessions", "product_events", "ai_credits", diff --git a/apps/web/src/page/settings/billing/spend.test.ts b/apps/web/src/page/settings/billing/spend.test.ts index 0e30dcb069..6eda6481d0 100644 --- a/apps/web/src/page/settings/billing/spend.test.ts +++ b/apps/web/src/page/settings/billing/spend.test.ts @@ -52,6 +52,7 @@ const startupPlan = startupPlanWith([ item("logs", 100, 0.3), item("traces", 100, 0.3), item("metrics", 100, 0.3), + item("profiles", 10, 0.6), item("browser_sessions", 5_000, 0.002), // Billed per 1,000 events: `amount` is the price of one billing block. item("product_events", 1_000_000, 0.005, 1_000), @@ -104,6 +105,7 @@ const buildCustomer = ( logs: { granted: 100 }, traces: { granted: 100 }, metrics: { granted: 100 }, + profiles: { granted: 10 }, browser_sessions: { granted: 5_000 }, product_events: { granted: 1_000_000 }, }, @@ -363,6 +365,7 @@ describe("buildSpendModel", () => { logs: "No overage", traces: "$0.30/GB", metrics: "Rate unavailable", + profiles: "$0.60/GB", browser_sessions: "$0.002/session", product_events: "Included", ai_credits: "$1/credit", @@ -379,6 +382,7 @@ describe("buildSpendModel", () => { logs: "$0.30/GB", traces: "$0.30/GB", metrics: "$0.30/GB", + profiles: "$0.60/GB", browser_sessions: "$0.002/session", product_events: "$5/1M events", ai_credits: "$1/credit", @@ -387,6 +391,7 @@ describe("buildSpendModel", () => { expect(featureUnit("product_events")).toBe("events") expect(featureUnit("browser_sessions")).toBe("sessions") expect(featureUnit("logs")).toBe("GB") + expect(featureUnit("profiles")).toBe("GB") }) it("falls back to the calendar month with no active subscription", () => { @@ -579,6 +584,40 @@ describe("buildCumulativeSeries", () => { expect(series[2]?.total).toBe(63) }) + it("prices profiles past their 10 GB allotment at the profiles rate", () => { + const spendModel = buildSpendModel({ + customer: buildCustomer(), + plans: [startupPlan], + usage: usageOf({ profiles: 30 }), + nowMs: NOW, + }) + if (spendModel === null) throw new Error("expected a model") + + const series = buildCumulativeSeries({ + daily: new DailySpendResponse({ + days: Arr.map( + ["2026-07-01", "2026-07-02", "2026-07-03"], + (date) => + new DailyVolume({ + date, + logsGB: 0, + tracesGB: 0, + metricsGB: 0, + profilesGB: 10, + browserSessions: 0, + }), + ), + cycleStart: CYCLE_START, + cycleEnd: CYCLE_END, + }), + model: spendModel, + }) + + // Day 1 fills the allotment, then each 10 GB day adds $6 at $0.60/GB. + expect(Arr.map(series, (point) => point.profiles)).toEqual([0, 6, 12]) + expect(Arr.map(series, (point) => point.logs)).toEqual([0, 0, 0]) + }) + it("is monotonic — a zero-ingest day holds the line flat instead of dipping", () => { const spendModel = unscaledModel(200) @@ -703,6 +742,7 @@ describe("AI credits", () => { logs: { granted: 100 }, traces: { granted: 100 }, metrics: { granted: 100 }, + profiles: { granted: 10 }, browser_sessions: { granted: 5_000 }, product_events: { granted: 1_000_000 }, } @@ -736,7 +776,14 @@ describe("AI credits", () => { }) it("leaves the maximum invoice unbounded until AI overage has a cap too", () => { - const dataCaps = { logs: 100, traces: 100, metrics: 100, browser_sessions: 1_000, product_events: 0 } + const dataCaps = { + logs: 100, + traces: 100, + metrics: 100, + profiles: 10, + browser_sessions: 1_000, + product_events: 0, + } const uncapped = withAi(0, dataCaps) expect(Arr.map(uncappedFeatures(uncapped, undefined), (feature) => feature.featureId)).toContain( "ai_credits", @@ -746,8 +793,8 @@ describe("AI credits", () => { balances: { ...dataBalances, ai_credits: { granted: 10, overageAllowed: true } }, overageCaps: { ...dataCaps, ai_credits: 25 }, }) - // $39 base, 300 GB at $0.30, 1,000 sessions at $0.002, and $25 of AI credits. - expect(maximumInvoiceCents(capped, customer)).toBe(3_900 + 9_000 + 200 + 2_500) + // $39 base, 300 GB at $0.30, 10 GB of profiles at $0.60, 1,000 sessions at $0.002, and $25 of AI credits. + expect(maximumInvoiceCents(capped, customer)).toBe(3_900 + 9_000 + 600 + 200 + 2_500) }) it("draws the AI band from the daily AI spend, accruing only past the included credits", () => { diff --git a/apps/web/src/page/settings/billing/spend.ts b/apps/web/src/page/settings/billing/spend.ts index 6e76704475..3dd30b06d4 100644 --- a/apps/web/src/page/settings/billing/spend.ts +++ b/apps/web/src/page/settings/billing/spend.ts @@ -35,6 +35,7 @@ export const SPEND_FEATURES = [ "logs", "traces", "metrics", + "profiles", "browser_sessions", "product_events", "ai_credits", @@ -45,6 +46,7 @@ export const FEATURE_LABELS: Record = { logs: "Logs", traces: "Traces", metrics: "Metrics", + profiles: "Profiles", browser_sessions: "Browser sessions", product_events: "Product events", ai_credits: "AI credits", @@ -65,6 +67,8 @@ export const FEATURE_COLORS: Record = { logs: "#3987e5", traces: "#199e70", metrics: "#9085e9", + // Rust: a flame-graph hue darker than amber and the lime of AI credits, so deutan CVD keeps them apart. + profiles: "#a3542f", browser_sessions: "#d55181", product_events: "light-dark(var(--chart-5), var(--chart-4))", // Lime: lighter than the traces green, so the two stay apart under deutan CVD. @@ -444,6 +448,7 @@ export interface CumulativePoint { readonly logs: number | null readonly traces: number | null readonly metrics: number | null + readonly profiles: number | null readonly browser_sessions: number | null readonly product_events: number | null readonly ai_credits: number | null @@ -498,6 +503,7 @@ export function buildCumulativeSeries({ logs: (day) => day.logsGB, traces: (day) => day.tracesGB, metrics: (day) => day.metricsGB, + profiles: (day) => day.profilesGB ?? 0, browser_sessions: (day) => day.browserSessions, product_events: (day) => day.productEvents ?? 0, ai_credits: (day) => aiCreditsByDate.get(day.date) ?? 0, @@ -527,6 +533,7 @@ export function buildCumulativeSeries({ logs: 0, traces: 0, metrics: 0, + profiles: 0, browser_sessions: 0, product_events: 0, ai_credits: 0, @@ -567,6 +574,7 @@ export function buildCumulativeSeries({ logs: future ? null : accrued.logs, traces: future ? null : accrued.traces, metrics: future ? null : accrued.metrics, + profiles: future ? null : accrued.profiles, browser_sessions: future ? null : accrued.browser_sessions, product_events: future ? null : accrued.product_events, ai_credits: future ? null : accrued.ai_credits, diff --git a/apps/web/src/page/settings/billing/view-account.ts b/apps/web/src/page/settings/billing/view-account.ts index 382c808b6c..95808b891e 100644 --- a/apps/web/src/page/settings/billing/view-account.ts +++ b/apps/web/src/page/settings/billing/view-account.ts @@ -82,7 +82,7 @@ export const memberSection = (h: H, model: Model, account: BillingAccount): Html const volumeLabel = (usage: BillingAccountOrgUsage): string => Arr.join( [ - formatUsage(usage.logsGB + usage.tracesGB + usage.metricsGB), + formatUsage(usage.logsGB + usage.tracesGB + usage.metricsGB + (usage.profilesGB ?? 0)), ...(usage.browserSessions > 0 ? [`${formatCount(usage.browserSessions)} sessions`] : []), ...(usage.productEvents > 0 ? [`${formatCount(usage.productEvents)} events`] : []), ], diff --git a/packages/domain/src/billing.ts b/packages/domain/src/billing.ts index 0b46a5997e..4347c886d7 100644 --- a/packages/domain/src/billing.ts +++ b/packages/domain/src/billing.ts @@ -75,6 +75,7 @@ export const PRICING_CARD_FEATURE_IDS = [ "logs", "traces", "metrics", + "profiles", "browser_sessions", "product_events", "ai_credits", @@ -85,6 +86,13 @@ const pricingCardFeatureIds: ReadonlySet = new Set(PRICING_CARD_FEATURE_ export const isPricingCardFeature = (featureId: string | null | undefined): featureId is string => featureId !== null && featureId !== undefined && pricingCardFeatureIds.has(featureId) +/** Billed features not yet advertised: kept off the public pricing page and the onboarding plan cards. */ +const UNADVERTISED_FEATURE_IDS: ReadonlySet = new Set(["profiles"]) + +/** A pricing card feature the public pricing surfaces list; the billing page lists every card feature. */ +export const isAdvertisedPricingFeature = (featureId: string | null | undefined): featureId is string => + isPricingCardFeature(featureId) && !UNADVERTISED_FEATURE_IDS.has(featureId) + /** Does a raw Autumn customer carry this boolean feature? Autumn keys granted ones under `flags`. */ export const customerHasFlag = (response: unknown, featureId: string): boolean => Predicate.isObject(response) && diff --git a/packages/domain/src/http/billing-account.ts b/packages/domain/src/http/billing-account.ts index d760a55ed7..05e78c508d 100644 --- a/packages/domain/src/http/billing-account.ts +++ b/packages/domain/src/http/billing-account.ts @@ -37,6 +37,7 @@ export class BillingAccountOrgUsage extends Schema.Class logsGB: Schema.Number, tracesGB: Schema.Number, metricsGB: Schema.Number, + profilesGB: Schema.optionalKey(Schema.Number), browserSessions: Schema.Number, productEvents: Schema.Number, }) {} diff --git a/packages/domain/src/http/billing.ts b/packages/domain/src/http/billing.ts index ae110490ae..33a079055f 100644 --- a/packages/domain/src/http/billing.ts +++ b/packages/domain/src/http/billing.ts @@ -102,6 +102,7 @@ export const BillingFeatureId = Schema.Literals([ "logs", "traces", "metrics", + "profiles", "browser_sessions", "product_events", "ai_credits", @@ -211,7 +212,7 @@ export class BillingUsageFeature extends Schema.Class("Bill }) {} export class BillingUsage extends Schema.Class("BillingUsage")({ - // Keyed by Autumn featureId (logs/traces/metrics/browser_sessions/product_events). + // Keyed by Autumn featureId (logs/traces/metrics/profiles/browser_sessions/product_events). total: Schema.optionalKey(Schema.Record(Schema.String, BillingUsageFeature)), }) {} @@ -233,6 +234,8 @@ export class DailyVolume extends Schema.Class("DailyVolume")({ logsGB: Schema.Number, tracesGB: Schema.Number, metricsGB: Schema.Number, + /** Continuous profiling GB metered that day. Absent until the warehouse records profile bytes. */ + profilesGB: Schema.optionalKey(Schema.Number), browserSessions: Schema.Number, /** Product events (browser `track()` + server events) metered that day. Absent until the API emits it. */ productEvents: Schema.optionalKey(Schema.Number),