: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(replay-vision): add replay vision credits usage type (#70428)
Arno Hillen05ae31e8bd63
diff --git a/ee/hogai/tools/read_billing_tool/tool.py b/ee/hogai/tools/read_billing_tool/tool.pyindex 4cfd144d4091..95960497cf9f 100644--- a/ee/hogai/tools/read_billing_tool/tool.py+++ b/ee/hogai/tools/read_billing_tool/tool.py@@ -35,6 +35,7 @@ USAGE_TYPES = [{"label": "Rows exported", "value": "rows_exported_in_period"},{"label": "PostHog AI", "value": "ai_credits_used_in_period"},{"label": "Inbox credits", "value": "signals_credits_used_in_period"},+ {"label": "Replay vision credits", "value": "replay_vision_credits_used_in_period"},{"label": "Workflow emails", "value": "workflow_emails_sent_in_period"},{"label": "Workflow push notifications", "value": "workflow_push_sent_in_period"},{"label": "Workflow destinations", "value": "workflow_billable_invocations_in_period"},diff --git a/frontend/src/scenes/billing/BillingSpendView.tsx b/frontend/src/scenes/billing/BillingSpendView.tsxindex ae61e4907fac..e0e6fe741928 100644--- a/frontend/src/scenes/billing/BillingSpendView.tsx+++ b/frontend/src/scenes/billing/BillingSpendView.tsx@@ -12,11 +12,12 @@ import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArimport { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect/LemonInputSelect'import { LemonLabel } from 'lib/lemon-ui/LemonLabel/LemonLabel'import { Tooltip } from 'lib/lemon-ui/Tooltip'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'import { AccessControlLevel, AccessControlResourceType, ExporterFormat } from '~/types'-import { buildBillingCsv, currencyFormatter } from './billing-utils'+import { buildBillingCsv, currencyFormatter, getUsageTypeOptions } from './billing-utils'import { BillingDataTable } from './BillingDataTable'import { BillingEarlyAccessBanner } from './BillingEarlyAccessBanner'import { BillingEmptyState } from './BillingEmptyState'@@ -24,7 +25,6 @@ import { BillingLineGraph } from './BillingLineGraph'import { billingLogic } from './billingLogic'import { BillingNoAccess } from './BillingNoAccess'import { billingSpendLogic } from './billingSpendLogic'-import { USAGE_TYPES } from './constants'export function BillingSpendView(): JSX.Element {const { minimumBillingAccessLevel } = useValues(billingLogic)@@ -51,6 +51,7 @@ export function BillingSpendView(): JSX.Element {billingPeriodMarkers,} = useValues(logic)const { startExport } = useActions(exportsLogic)+ const { featureFlags } = useValues(featureFlagLogic)const {setFilters,setDateRange,@@ -104,7 +105,7 @@ export function BillingSpendView(): JSX.Element {value={filters.usage_types || []}onChange={(value: string[]) => setFilters({ usage_types: value })}placeholder="All products"- options={USAGE_TYPES.map((opt) => ({ key: opt.value, label: opt.label }))}+ options={getUsageTypeOptions(featureFlags)}allowCustomValues={false}/></div>diff --git a/frontend/src/scenes/billing/BillingUsage.tsx b/frontend/src/scenes/billing/BillingUsage.tsxindex 7a4fff9a8c7e..f1cf50418c09 100644--- a/frontend/src/scenes/billing/BillingUsage.tsx+++ b/frontend/src/scenes/billing/BillingUsage.tsx@@ -11,11 +11,12 @@ import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArimport { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect/LemonInputSelect'import { LemonLabel } from 'lib/lemon-ui/LemonLabel/LemonLabel'import { Tooltip } from 'lib/lemon-ui/Tooltip'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'import { AccessControlLevel, AccessControlResourceType, ExporterFormat } from '~/types'-import { buildBillingCsv } from './billing-utils'+import { buildBillingCsv, getUsageTypeOptions } from './billing-utils'import { BillingDataTable } from './BillingDataTable'import { BillingEarlyAccessBanner } from './BillingEarlyAccessBanner'import { BillingEmptyState } from './BillingEmptyState'@@ -23,7 +24,6 @@ import { BillingLineGraph } from './BillingLineGraph'import { billingLogic } from './billingLogic'import { BillingNoAccess } from './BillingNoAccess'import { billingUsageLogic } from './billingUsageLogic'-import { USAGE_TYPES } from './constants'export function BillingUsage(): JSX.Element {const { minimumBillingAccessLevel } = useValues(billingLogic)@@ -50,6 +50,7 @@ export function BillingUsage(): JSX.Element {billingPeriodMarkers,} = useValues(logic)const { startExport } = useActions(exportsLogic)+ const { featureFlags } = useValues(featureFlagLogic)const {setFilters,setDateRange,@@ -102,7 +103,7 @@ export function BillingUsage(): JSX.Element {value={filters.usage_types || []}onChange={(value) => setFilters({ usage_types: value })}placeholder="All products"- options={USAGE_TYPES.map((opt) => ({ key: opt.value, label: opt.label }))}+ options={getUsageTypeOptions(featureFlags)}allowCustomValues={false}/></div>diff --git a/frontend/src/scenes/billing/billing-utils.test.ts b/frontend/src/scenes/billing/billing-utils.test.tsnew file mode 100644index 000000000000..ab7d8b5c8f9d--- /dev/null+++ b/frontend/src/scenes/billing/billing-utils.test.ts@@ -0,0 +1,20 @@+import { FEATURE_FLAGS } from 'lib/constants'+import type { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'++import { getUsageTypeOptions } from './billing-utils'++describe('getUsageTypeOptions', () => {+ it.each<[string, FeatureFlagsSet, boolean]>([+ ['on', { [FEATURE_FLAGS.REPLAY_VISION]: true }, true],+ ['off', { [FEATURE_FLAGS.REPLAY_VISION]: false }, false],+ ['missing', {}, false],+ ])(+ 'shows replay vision credits only when the replay-vision flag is on (flag %s)',+ (_name, featureFlags, visible) => {+ const options = getUsageTypeOptions(featureFlags)+ expect(options.some((opt) => opt.key === 'replay_vision_credits_used_in_period')).toBe(visible)+ // the gate never affects other usage types+ expect(options.some((opt) => opt.key === 'event_count_in_period')).toBe(true)+ }+ )+})diff --git a/frontend/src/scenes/billing/billing-utils.ts b/frontend/src/scenes/billing/billing-utils.tsindex b02ac58838c7..ad206272ebf4 100644--- a/frontend/src/scenes/billing/billing-utils.ts+++ b/frontend/src/scenes/billing/billing-utils.ts@@ -5,6 +5,7 @@ import Papa from 'papaparse'import { FEATURE_FLAGS, OrganizationMembershipLevel } from 'lib/constants'import { dayjs } from 'lib/dayjs'+import type { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'import { dateStringToDayJs } from 'lib/utils/dateFilters'import { compactNumber } from 'lib/utils/numbers'import { membershipLevelToName } from 'lib/utils/permissioning'@@ -499,6 +500,12 @@ export function buildTrackingProperties(}}+// The Replay vision entry stays hidden until the replay-vision flag rolls out with the pricing launch+export const getUsageTypeOptions = (featureFlags: FeatureFlagsSet): { key: string; label: string }[] =>+ USAGE_TYPES.filter(+ (opt) => opt.value !== 'replay_vision_credits_used_in_period' || featureFlags[FEATURE_FLAGS.REPLAY_VISION]+ ).map((opt) => ({ key: opt.value, label: opt.label }))+export const isAddonVisible = (product: BillingProductV2Type,addon: BillingProductV2AddonType,diff --git a/frontend/src/scenes/billing/constants.ts b/frontend/src/scenes/billing/constants.tsindex 58ac312d2b16..3d83e4d3809c 100644--- a/frontend/src/scenes/billing/constants.ts+++ b/frontend/src/scenes/billing/constants.ts@@ -17,6 +17,7 @@ export const USAGE_TYPES = [{ label: 'Rows exported', value: 'rows_exported_in_period' },{ label: 'PostHog AI', value: 'ai_credits_used_in_period' },{ label: 'Inbox credits', value: 'signals_credits_used_in_period' },+ { label: 'Replay vision credits', value: 'replay_vision_credits_used_in_period' },{ label: 'Workflow emails', value: 'workflow_emails_sent_in_period' },{ label: 'Workflow push notifications', value: 'workflow_push_sent_in_period' },{ label: 'Workflow destinations', value: 'workflow_billable_invocations_in_period' },