: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(error-tracking): show the new wizard command behind a flag (#100838)
Aleksander Błaszkiewicz692af78c81f1
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 3ddfe56a0a5b..b0b07a0c1498 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -1864,6 +1864,10 @@ snapshots:hash: v1.k794b7964.c0cd3727394a11388389774d7880c2a28aeb059a308d75feeb1341b13673a104.SetdbHN--yP6YcrM12BpBzA0_aqJVqwxQM3Uc2Wchmgcomponents-product-empty-state--error-tracking-needs-setup--light:hash: v1.k794b7964.7f40a4a9bc119d95d61ef68b1ed144de44a460d8015a7196100e9048c6b57ce5.cKeg20m9AJX9GmwJ0XKpX1qaZB5sopbADXCeE9ZsHL0+ components-product-empty-state--error-tracking-needs-setup-new-wizard--dark:+ hash: v1.k794b7964.97078a8193b2f01f0cdfdcfa57bdbd57634fa1a823b6b7edd6094761ffd1ca51.wy1tp5DHhvEP4pAy3q0YnUBLk6gXKtnPAAobLnuOqoI+ components-product-empty-state--error-tracking-needs-setup-new-wizard--light:+ hash: v1.k794b7964.26df8e4c1300ed356335f5a0e341c4f871153a643362f6d91b92e39af677e421.ZLuBcDzu_KP3gTng_eMJM1rl3L6vY_MFfIypyY9rUHkcomponents-product-empty-state--error-tracking-waiting-for-data--dark:hash: v1.k794b7964.80bdd04e414ed36e173f1dcac8e4ccf407375157fdd5b9497e7209bdb623564b.RbOoZt9BkTBAV3sXCR0IHWu0wvAh9JNPIdFcZJ7axOUcomponents-product-empty-state--error-tracking-waiting-for-data--light:diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsxindex 92104276cf7d..9b477f5ace31 100644--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.stories.tsx@@ -2,6 +2,8 @@ import { Meta } from '@storybook/react'import { screen, within } from '@testing-library/dom'import userEvent from '@testing-library/user-event'+import { FEATURE_FLAGS } from 'lib/constants'+import type { Mocks } from '~/mocks/utils'import { actionsEmptyState } from 'products/actions/frontend/emptyState/actionsEmptyState'@@ -338,6 +340,19 @@ export const ErrorTrackingWaitingForData: ProductEmptyStateStory = productEmptyS{ mocks: errorTrackingMocks })+// The `error-tracking` wizard subcommand is flag-gated: with the flag on the terminal card+// is the only call to action and the autocapture opt-in leaves the screen.+const errorTrackingNeedsSetupNewWizard = productEmptyStateStory(errorTrackingEmptyState, 'needs-setup', {+ mocks: errorTrackingMocks,+})+export const ErrorTrackingNeedsSetupNewWizard: ProductEmptyStateStory = {+ ...errorTrackingNeedsSetupNewWizard,+ parameters: {+ ...errorTrackingNeedsSetupNewWizard.parameters,+ featureFlags: [FEATURE_FLAGS.ERROR_TRACKING_NEW_WIZARD],+ },+}+// Logs detection asks the has-logs API on mount - answer "none yet".export const LogsNeedsSetup: ProductEmptyStateStory = productEmptyStateStory(logsEmptyState, 'needs-setup', {// nosemgrep: no-environments-api-urls-frontend -- api.logs is env-scoped, so the msw mock must match /api/environments to intercept itdiff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.test.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.test.tsxindex 731e4a780efb..84b2201841e2 100644--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.test.tsx+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.test.tsx@@ -1,6 +1,8 @@import { cleanup, render, screen } from '@testing-library/react'import { expectLogic } from 'kea-test-utils'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'import { useMocks } from '~/mocks/jest'@@ -122,4 +124,41 @@ describe('ProductEmptyState', () => {}expect(!!screen.queryByText('Hint')).toBe(expected)})++ // Overrides keyed by a flag let a config roll out a new call to action without a second+ // config: they must apply only while the flag is on, `primaryAction: undefined` must drop+ // the action, and a text field left out of the override must keep its base value.+ it.each([+ [false, false],+ [true, true],+ ])('with its flag on=%s applies the feature flag overrides: %s', async (flagOn, applied) => {+ useMocks({ get: { '/_preflight/': { cloud: true } } })+ preflightLogic.actions.loadPreflight()+ await expectLogic(preflightLogic).toDispatchActions(['loadPreflightSuccess'])+ featureFlagLogic.mount()+ featureFlagLogic.actions.setFeatureFlags([], flagOn ? { [FEATURE_FLAGS.ERROR_TRACKING_NEW_WIZARD]: true } : {})+ const overriddenConfig: ProductEmptyStateConfig = {+ ...config,+ text: { 'needs-setup': { headline: 'Headline', lead: 'Lead', hint: 'Base hint' } },+ featureFlagOverrides: {+ [FEATURE_FLAGS.ERROR_TRACKING_NEW_WIZARD]: {+ text: { 'needs-setup': { hint: 'Override hint' } },+ wizard: { slug: 'experiments' },+ primaryAction: undefined,+ },+ },+ }++ render(<ProductEmptyState config={overriddenConfig} mode="needs-setup" />)++ if (applied) {+ expect(await screen.findByLabelText(/Copy command/)).toBeTruthy()+ } else {+ expect(screen.queryByLabelText(/Copy command/)).toBeNull()+ }+ expect(!!screen.queryByTestId('create-experiment')).toBe(!applied)+ expect(!!screen.queryByText('Override hint')).toBe(applied)+ expect(!!screen.queryByText('Base hint')).toBe(!applied)+ expect(screen.getByText('Headline')).toBeTruthy()+ })})diff --git a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsxindex 070f3cf8bfee..36da8cb98096 100644--- a/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx+++ b/frontend/src/lib/components/ProductEmptyState/ProductEmptyState.tsx@@ -6,8 +6,9 @@ import { IconBook, IconGear } from '@posthog/icons'import { AccessControlAction } from 'lib/components/AccessControlAction'import { TerminalCard } from 'lib/components/CommandBlock/TerminalCard'import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'-import { TeamMembershipLevel } from 'lib/constants'+import { type FeatureFlagKey, TeamMembershipLevel } from 'lib/constants'import { LemonButton } from 'lib/lemon-ui/LemonButton'+import { type FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'import { cn } from 'lib/utils/css-classes'import { useWizardCommand } from 'scenes/onboarding/shared/useWizardCommand'import { teamLogic } from 'scenes/teamLogic'@@ -18,6 +19,8 @@ import type {ProductEmptyStateMode,ProductEmptyStatePrimaryAction,ProductEmptyStateText,+ ProductEmptyStateTextByMode,+ ProductEmptyStateTextOverride,ProductEmptyStateWizard,} from './types'@@ -51,13 +54,45 @@ function resolveWizard(return 'slug' in wizard ? wizard : wizard[mode]}+function mergeText(+ base: ProductEmptyStateTextByMode,+ override: ProductEmptyStateTextOverride+): ProductEmptyStateTextByMode {+ const merged: ProductEmptyStateTextByMode = {+ ...base,+ 'needs-setup': { ...base['needs-setup'], ...override['needs-setup'] },+ }+ if (override['waiting-for-data']) {+ merged['waiting-for-data'] = { ...base['waiting-for-data'], ...override['waiting-for-data'] }+ }+ return merged+}++/** Applies the overrides of every flag that is on, in declaration order, so later entries win. */+function resolveConfig(config: ProductEmptyStateConfig, featureFlags: FeatureFlagsSet): ProductEmptyStateConfig {+ const resolved: ProductEmptyStateConfig = { ...config }+ for (const [flag, override] of Object.entries(config.featureFlagOverrides ?? {})) {+ if (!override || !featureFlags[flag as FeatureFlagKey]) {+ continue+ }+ const { text, ...rest } = override+ Object.assign(resolved, rest)+ if (text) {+ resolved.text = mergeText(resolved.text, text)+ }+ }+ return resolved+}+/*** The product setup empty state: pitch + install command on the left, an animated* preview of the product filled with example data on the right. Shown before* a product has been set up — gate it with `ProductEmptyStateGate` (or declare* `emptyState` on the scene's `SceneExport` and the app shell gates for you).*/-export function ProductEmptyState({ config, mode, preview = false }: ProductEmptyStateProps): JSX.Element {+export function ProductEmptyState({ config: baseConfig, mode, preview = false }: ProductEmptyStateProps): JSX.Element {+ const { featureFlags } = useValues(featureFlagLogic)+ const config = resolveConfig(baseConfig, featureFlags)const wizard = resolveWizard(config.wizard, mode)const { wizardCommand, isCloudOrDev } = useWizardCommand(wizard?.slug, {pinProjectId: wizard?.pinProjectId,diff --git a/frontend/src/lib/components/ProductEmptyState/types.ts b/frontend/src/lib/components/ProductEmptyState/types.tsindex d046d27c0e0a..42255f919b38 100644--- a/frontend/src/lib/components/ProductEmptyState/types.ts+++ b/frontend/src/lib/components/ProductEmptyState/types.ts@@ -158,6 +158,23 @@ export interface ProductEmptyStateConfig {* has nothing to reveal and the primary action is the only next step.*/skippable?: boolean+ /**+ * Overrides applied while a feature flag is on, to roll out a change to this screen (a new+ * wizard subcommand, a different call to action) without a second config. Each field+ * replaces the base value, so `primaryAction: undefined` removes the action. `text` merges+ * per mode, so a field left out keeps its base value. When several flags are on, later+ * entries win.+ */+ featureFlagOverrides?: Partial<Record<FeatureFlagKey, ProductEmptyStateOverride>>+}++/** Per-mode text fields to replace; fields left out keep the base value. */+export type ProductEmptyStateTextOverride = Partial<Record<ProductEmptyStateMode, Partial<ProductEmptyStateText>>>++export type ProductEmptyStateOverride = Partial<+ Omit<ProductEmptyStateConfig, 'productKey' | 'text' | 'featureFlagOverrides'>+> & {+ text?: ProductEmptyStateTextOverride}/**diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsxindex a2899cb597e4..cc7db5c55149 100644--- a/frontend/src/lib/constants.tsx+++ b/frontend/src/lib/constants.tsx@@ -312,6 +312,7 @@ export const FEATURE_FLAGS = {ERROR_TRACKING_ISSUE_CORRELATION: 'error-tracking-issue-correlation', // owner: @david #team-error-trackingERROR_TRACKING_ISSUE_RELEASES: 'error-tracking-issue-releases', // owner: #team-error-trackingERROR_TRACKING_ISSUE_SPLITTING: 'error-tracking-issue-splitting', // owner: @david #team-error-tracking+ ERROR_TRACKING_NEW_WIZARD: 'error-tracking-new-wizard', // owner: @ablaszkiewicz #team-error-trackingERROR_TRACKING_RATE_LIMITING: 'error-tracking-rate-limiting', // owner: @ablaszkiewicz #team-error-trackingERROR_TRACKING_RATE_LIMITING_BYPASS: 'error-tracking-rate-limiting-bypass', // owner: @ablaszkiewicz #team-error-trackingERROR_TRACKING_RATE_LIMITING_PER_ISSUE: 'error-tracking-rate-limiting-per-issue', // owner: @ablaszkiewicz #team-error-trackingdiff --git a/products/error_tracking/frontend/emptyState/errorTrackingEmptyState.tsx b/products/error_tracking/frontend/emptyState/errorTrackingEmptyState.tsxindex 688b0308094d..382a588aa1f4 100644--- a/products/error_tracking/frontend/emptyState/errorTrackingEmptyState.tsx+++ b/products/error_tracking/frontend/emptyState/errorTrackingEmptyState.tsx@@ -2,6 +2,7 @@ import { IconWarning } from '@posthog/icons'import { WarningHog } from 'lib/components/hedgehogs'import type { SceneProductEmptyState } from 'lib/components/ProductEmptyState/types'+import { FEATURE_FLAGS } from 'lib/constants'import { teamLogic } from 'scenes/teamLogic'import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'@@ -52,5 +53,19 @@ export const errorTrackingEmptyState: SceneProductEmptyState = {manualSetupUrl: 'https://posthog.com/docs/error-tracking/installation',previewLabel: 'Issues, once exceptions arrive',Preview: ErrorTrackingPreview,+ // The `error-tracking` wizard subcommand is still rolling out. While its flag is on the terminal+ // card is the only call to action, so the one-click opt-in and its lead-in leave the setup screen.+ // The wizard is keyed to setup: once autocapture is on the screen only waits for an exception.+ featureFlagOverrides: {+ [FEATURE_FLAGS.ERROR_TRACKING_NEW_WIZARD]: {+ text: {+ 'needs-setup': {+ hint: 'Run Wizard in your project. The setup agent installs the SDK if needed, then adds exception capture and source map upload:',+ },+ },+ wizard: { 'needs-setup': { slug: 'error-tracking', pinProjectId: true } },+ primaryAction: undefined,+ },+ },},}diff --git a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsFixWizardLogic.ts b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsFixWizardLogic.tsindex 6019ef8361e4..7c1896d42f99 100644--- a/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsFixWizardLogic.ts+++ b/products/error_tracking/frontend/scenes/ErrorTrackingScene/tabs/recommendations/sourceMapsFixWizardLogic.ts@@ -1,10 +1,14 @@-import { MakeLogicType, actions, kea, listeners, path, reducers, selectors } from 'kea'+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'import posthog from 'posthog-js'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { getSurveyIdBasedResponseKey, getSurveyResponseKey } from 'scenes/surveys/utils'import { SurveyEventName, SurveyEventProperties } from '~/types'+import type { FeatureFlagsSet } from '../../../../../../../frontend/src/lib/logic/featureFlagLogic'+export type WizardRating = 'good' | 'bad'export type WizardOpenSource = 'issues_list' | 'recommendations'@@ -26,6 +30,7 @@ const FEEDBACK_QUESTION_ID = '03e1255c-6daf-46a2-9629-2354bcd230ff'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface sourceMapsFixWizardLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogicfeedbackRevealed: booleanfeedbackSubmitted: booleanfeedbackText: string@@ -63,9 +68,18 @@ export interface sourceMapsFixWizardLogicActions {}}+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface sourceMapsFixWizardLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ wizardCommand: (featureFlags: FeatureFlagsSet) => string+ }+}+export type sourceMapsFixWizardLogicType = MakeLogicType<sourceMapsFixWizardLogicValues,- sourceMapsFixWizardLogicActions+ sourceMapsFixWizardLogicActions,+ Record<string, any>,+ sourceMapsFixWizardLogicMeta>export const sourceMapsFixWizardLogic = kea<sourceMapsFixWizardLogicType>([@@ -79,6 +93,10 @@ export const sourceMapsFixWizardLogic = kea<sourceMapsFixWizardLogicType>(['sourceMapsFixWizardLogic',]),+ connect(() => ({+ values: [featureFlagLogic, ['featureFlags']],+ })),+actions({openModal: (source: WizardOpenSource) => ({ source }),closeModal: true,@@ -148,7 +166,15 @@ export const sourceMapsFixWizardLogic = kea<sourceMapsFixWizardLogicType>([}),selectors({- wizardCommand: [() => [], (): string => 'npx -y @posthog/wizard@latest upload-source-maps'],+ // The dedicated `error-tracking` command also sets up source map upload; it replaces the+ // narrower `upload-source-maps` command as it rolls out behind the flag.+ wizardCommand: [+ (s) => [s.featureFlags],+ (featureFlags: FeatureFlagsSet): string =>+ featureFlags[FEATURE_FLAGS.ERROR_TRACKING_NEW_WIZARD]+ ? 'npx -y @posthog/wizard@latest error-tracking'+ : 'npx -y @posthog/wizard@latest upload-source-maps',+ ],}),listeners(({ actions, values, cache }) => ({