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.

feat(subscriptions): report why the export nudge skipped a healthy check (#89853)

posthog[bot]0a05c0cc4155
diff --git a/products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.test.tsx b/products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.test.tsx
index f60b80a68727..915814c7c2bf 100644
--- a/products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.test.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.test.tsx
@@ -137,12 +137,15 @@ describe('exportNudgeLogic', () => {
})
it.each([
- ['dashboard', DASHBOARD],
- ['insight', INSIGHT],
- ])('does not nudge a %s that already has a subscription', async (_kind, subject) => {
+ ['dashboard', DASHBOARD, { kind: 'dashboard', dashboard_id: DASHBOARD_ID }],
+ ['insight', INSIGHT, { kind: 'insight', insight_short_id: INSIGHT_SHORT_ID }],
+ ])('does not nudge a %s that already has a subscription', async (_kind, subject, eventProperties) => {
mockSubscriptionCounts({ subjectCount: 1 })
expect(await considerNudge(subject)).toBe(false)
+ expect(capturesOf('export nudge not eligible')).toEqual([
+ ['export nudge not eligible', { reason: 'already_subscribed', ...eventProperties }],
+ ])
})
it('asks again once the subscription that retired the offer is gone', async () => {
@@ -192,9 +195,25 @@ describe('exportNudgeLogic', () => {
sceneLogic.actions.loadSubscriptionsSuccess([{ id: 1 } as any])
expect(lookUpExportNudge(DASHBOARD)).toEqual({ status: 'ineligible' })
+ expect(capturesOf('export nudge not eligible')).toEqual([
+ [
+ 'export nudge not eligible',
+ { reason: 'already_subscribed', kind: 'dashboard', dashboard_id: DASHBOARD_ID },
+ ],
+ ])
sceneLogic.unmount()
})
+
+ it('is ineligible over the free-tier subscription limit', () => {
+ userLogic.actions.loadUserSuccess(MOCK_DEFAULT_USER) // no available features -> free tier
+ logic.actions.loadFreeTierSubscriptionCountSuccess(SubscriptionFreeTierLimit.COUNT)
+
+ expect(lookUpExportNudge(DASHBOARD)).toEqual({ status: 'ineligible' })
+ expect(capturesOf('export nudge not eligible')).toEqual([
+ ['export nudge not eligible', { reason: 'over_limit', kind: 'dashboard', dashboard_id: DASHBOARD_ID }],
+ ])
+ })
})
describe('free-tier subscription limit', () => {
@@ -210,6 +229,16 @@ describe('exportNudgeLogic', () => {
mockSubscriptionCounts({ subjectCount: 0, teamCount })
expect(await considerNudge()).toBe(nudges)
+ expect(capturesOf('export nudge not eligible')).toEqual(
+ nudges
+ ? []
+ : [
+ [
+ 'export nudge not eligible',
+ { reason: 'over_limit', kind: 'dashboard', dashboard_id: DASHBOARD_ID },
+ ],
+ ]
+ )
})
})
diff --git a/products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.ts b/products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.ts
index fb2230029e45..36aeb5cde587 100644
--- a/products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.ts
+++ b/products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.ts
@@ -146,6 +146,15 @@ export function captureExportNudgeCheckFailed(
posthog.capture('export nudge check failed', { step, ...properties })
}
+// A healthy check that lands on "not eligible" is not a failure, so it gets its own event: without
+// this, the only visible ineligible exporters were the ones whose check broke.
+function captureExportNudgeIneligible(
+ reason: 'already_subscribed' | 'over_limit',
+ properties: Record<string, unknown> = {}
+): void {
+ posthog.capture('export nudge not eligible', { reason, ...properties })
+}
+
// Mounted on first use, so exports of anything else do not pay for it, and left mounted so the
// free-tier count survives between exports.
function mountedExportNudgeLogic(): typeof exportNudgeLogic {
@@ -203,6 +212,9 @@ async function fetchHasExistingSubscription(subject: ExportNudgeSubject): Promis
export function lookUpExportNudge(subject: ExportNudgeSubject): ExportNudgeLookup {
const limitStatus = subscriptionLimitStatus()
if (limitStatus !== 'within') {
+ if (limitStatus === 'exceeded') {
+ captureExportNudgeIneligible('over_limit', exportNudgeEventProperties(subject))
+ }
return { status: limitStatus === 'unknown' ? 'unknown' : 'ineligible' }
}
@@ -211,6 +223,7 @@ export function lookUpExportNudge(subject: ExportNudgeSubject): ExportNudgeLooku
return { status: 'unknown' }
}
if (subscriptionCount > 0) {
+ captureExportNudgeIneligible('already_subscribed', exportNudgeEventProperties(subject))
return { status: 'ineligible' }
}
return { status: 'eligible', candidate: { subject, name: supportFor(subject).name(subject) } }
@@ -231,6 +244,7 @@ export async function resolveExportNudgeEligibility(subject: ExportNudgeSubject)
return null
}
if (limitStatus !== 'within') {
+ captureExportNudgeIneligible('over_limit', exportNudgeEventProperties(subject))
return null
}
@@ -239,6 +253,7 @@ export async function resolveExportNudgeEligibility(subject: ExportNudgeSubject)
return null // fail closed on a broken check
}
if (hasExistingSubscription) {
+ captureExportNudgeIneligible('already_subscribed', exportNudgeEventProperties(subject))
return null
}