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(insights): add reset button for invalid dwh settings (#59333)

Thomas Obermüller308bfc982135
diff --git a/frontend/src/queries/nodes/InsightViz/InsightVizDisplay.tsx b/frontend/src/queries/nodes/InsightViz/InsightVizDisplay.tsx
index 19512a5ebc16..8feef4de4e8d 100644
--- a/frontend/src/queries/nodes/InsightViz/InsightVizDisplay.tsx
+++ b/frontend/src/queries/nodes/InsightViz/InsightVizDisplay.tsx
@@ -1,6 +1,8 @@
import clsx from 'clsx'
import { useActions, useValues } from 'kea'
+import { LemonButton } from '@posthog/lemon-ui'
+
import { ExportButton } from 'lib/components/ExportButton/ExportButton'
import { InsightLegend } from 'lib/components/InsightLegend/InsightLegend'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
@@ -148,9 +150,10 @@ export function InsightVizDisplay({
series,
insightData,
validationError,
+ validationErrorCode,
theme,
} = useValues(insightVizDataLogic(insightProps))
- const { loadData } = useActions(insightVizDataLogic(insightProps))
+ const { loadData, updateQuerySource } = useActions(insightVizDataLogic(insightProps))
const { exportContext, queryId } = useValues(insightDataLogic(insightProps))
const { funnelsFilter, hasFunnelResults, isFunnelWithEnoughSteps, isFunnelWithIncompleteDataWarehouseStep } =
useValues(funnelDataLogic(insightProps))
@@ -190,13 +193,35 @@ export function InsightVizDisplay({
}
if (validationError) {
+ const isUnsupportedDataWarehouseSettings =
+ validationErrorCode === 'data_warehouse_series_unsupported_settings'
+ const resetCta = isUnsupportedDataWarehouseSettings ? (
+ <LemonButton
+ type="primary"
+ loading={insightDataLoading}
+ onClick={() =>
+ updateQuerySource({
+ filterTestAccounts: false,
+ properties: undefined,
+ samplingFactor: undefined,
+ })
+ }
+ >
+ Reset unsupported settings
+ </LemonButton>
+ ) : undefined
return (
<InsightValidationError
query={query}
detail={validationError}
- onRetry={() => {
- loadData(query && shouldQueryBeAsync(query) ? 'force_async' : 'force_blocking')
- }}
+ onRetry={
+ resetCta
+ ? undefined
+ : () => {
+ loadData(query && shouldQueryBeAsync(query) ? 'force_async' : 'force_blocking')
+ }
+ }
+ cta={resetCta}
/>
)
}
diff --git a/frontend/src/queries/nodes/InsightViz/utils.ts b/frontend/src/queries/nodes/InsightViz/utils.ts
index 06b9ccaacdfb..7194e5f617d9 100644
--- a/frontend/src/queries/nodes/InsightViz/utils.ts
+++ b/frontend/src/queries/nodes/InsightViz/utils.ts
@@ -194,6 +194,16 @@ export const extractValidationError = (error: Error | Record<string, any> | null
return null
}
+export const extractValidationErrorCode = (error: Error | Record<string, any> | null | undefined): string | null => {
+ if (error instanceof ApiError || (error && typeof error === 'object' && 'status' in error)) {
+ if (error?.status === 400 || error?.status === 512) {
+ return error.code ?? error.data?.code ?? null
+ }
+ }
+
+ return null
+}
+
export const isTimeoutError = (error: Error | Record<string, any> | null | undefined): boolean => {
if (error instanceof ApiError || (error && typeof error === 'object' && 'status' in error)) {
return error?.status === 512
diff --git a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx
index 27e1e284fb86..95ac8149d987 100644
--- a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx
+++ b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx
@@ -490,10 +490,12 @@ export function InsightValidationError({
detail,
query,
onRetry,
+ cta,
}: {
detail: string
query?: Record<string, any> | null
onRetry?: () => void
+ cta?: JSX.Element
}): JSX.Element {
return (
<div
@@ -516,7 +518,7 @@ export function InsightValidationError({
<p className="text-sm text-muted max-w-120 mb-2">{detail}</p>
- {onRetry ? <RetryButton onRetry={onRetry} query={query} /> : <QueryDebuggerButton query={query} />}
+ {cta ?? (onRetry ? <RetryButton onRetry={onRetry} query={query} /> : <QueryDebuggerButton query={query} />)}
{detail.includes('Exclusion') && (
<div className="mt-4">
diff --git a/frontend/src/scenes/insights/insightVizDataLogic.ts b/frontend/src/scenes/insights/insightVizDataLogic.ts
index db3229c35ab5..24e9b6d7db8c 100644
--- a/frontend/src/scenes/insights/insightVizDataLogic.ts
+++ b/frontend/src/scenes/insights/insightVizDataLogic.ts
@@ -24,7 +24,12 @@ import { filterTestAccountsDefaultsLogic } from 'scenes/settings/environment/fil
import { BASE_MATH_DEFINITIONS } from 'scenes/trends/mathsLogic'
import { actionsModel } from '~/models/actionsModel'
-import { extractValidationError, getAllEventNames, queryFromKind } from '~/queries/nodes/InsightViz/utils'
+import {
+ extractValidationError,
+ extractValidationErrorCode,
+ getAllEventNames,
+ queryFromKind,
+} from '~/queries/nodes/InsightViz/utils'
import {
AnyDataWarehouseNode,
AnyEntityNode,
@@ -497,6 +502,10 @@ export const insightVizDataLogic = kea<insightVizDataLogicType>([
(s) => [s.insightDataError],
(insightDataError): string | null => extractValidationError(insightDataError),
],
+ validationErrorCode: [
+ (s) => [s.insightDataError],
+ (insightDataError): string | null => extractValidationErrorCode(insightDataError),
+ ],
timezone: [(s) => [s.insightData], (insightData) => insightData?.timezone || 'UTC'],