Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

fix(billing): show product name in usage limit approaching banner (#66314)

Joshua Snyder3e1427710b4b
diff --git a/frontend/src/scenes/billing/billing-utils.spec.ts b/frontend/src/scenes/billing/billing-utils.spec.ts
index 117170ac527f..df8cabf7e9c0 100644
--- a/frontend/src/scenes/billing/billing-utils.spec.ts
+++ b/frontend/src/scenes/billing/billing-utils.spec.ts
@@ -572,7 +572,7 @@ describe('buildUsageLimitApproachingMessage', () => {
{ name: 'Session replay', percentage_usage: 0.9, usage_key: 'recordings' },
])
expect(result.title).toEqual('You will soon hit your usage limit')
- expect(result.message).toEqual('You have currently used 90% of your recordings allocation.')
+ expect(result.message).toEqual('You have currently used 90% of your Session replay allocation.')
})
it('should build message for multiple products', () => {
@@ -582,13 +582,17 @@ describe('buildUsageLimitApproachingMessage', () => {
])
expect(result.title).toEqual('You will soon hit your usage limits')
expect(result.message).toEqual(
- 'You are approaching your usage limits: 90% of your recordings allocation, 87% of your feature_flag_requests allocation.'
+ 'You are approaching your usage limits: 90% of your Session replay allocation, 87% of your Feature flags & Experiments allocation.'
)
})
- it('should handle missing usage_key', () => {
- const result = buildUsageLimitApproachingMessage([{ name: 'Session replay', percentage_usage: 0.9 }])
- expect(result.message).toContain('usage allocation')
+ it.each([
+ { name: 'Session replay', usage_key: undefined, expected: 'Session replay allocation' },
+ { name: '', usage_key: 'signals_credits', expected: 'signals_credits allocation' },
+ { name: '', usage_key: undefined, expected: 'usage allocation' },
+ ])('should resolve label to "$expected" (name="$name", usage_key=$usage_key)', ({ name, usage_key, expected }) => {
+ const result = buildUsageLimitApproachingMessage([{ name, percentage_usage: 0.9, usage_key }])
+ expect(result.message).toContain(expected)
})
it('should format percentage with up to 2 decimal places', () => {
diff --git a/frontend/src/scenes/billing/billing-utils.ts b/frontend/src/scenes/billing/billing-utils.ts
index ac9b4892cfdf..34bccc92b361 100644
--- a/frontend/src/scenes/billing/billing-utils.ts
+++ b/frontend/src/scenes/billing/billing-utils.ts
@@ -696,8 +696,8 @@ export function buildUsageLimitApproachingMessage(
const usageDetails = products.map((p) => {
const percentage = parseFloat((p.percentage_usage * 100).toFixed(2))
- const usageKey = p.usage_key?.toLowerCase() || 'usage'
- return `${percentage}% of your ${usageKey} allocation`
+ const productName = p.name || p.usage_key?.toLowerCase() || 'usage'
+ return `${percentage}% of your ${productName} allocation`
})
const roleName = membershipLevelToName.get(minimumBillingAccessLevel)