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.

perf(surveys): keep the surveys scene constants off the shell (#127280)

Paul D'Ambra4ca76d40c070
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjs
index 52ef06d7330f..ca607b16349e 100644
--- a/frontend/bin/check-eager-graph.mjs
+++ b/frontend/bin/check-eager-graph.mjs
@@ -156,6 +156,8 @@ const ROOTS = [
// The login scene's logics. Shell code reads the login redirect from lib/utils/loginRedirect.
'src/scenes/authentication/auth/loginLogic.ts',
'src/scenes/authentication/shared/passkeyLogic.ts',
+ // The surveys scene constants hold the question type tables. lib/api reads its page size from lib/constants.
+ 'src/scenes/surveys/constants.tsx',
// The rich text editor stack is for the scenes that edit text. Rendered markdown needs none of it.
'node_modules/@tiptap/',
'node_modules/prosemirror-',
diff --git a/frontend/bin/layer-baseline.txt b/frontend/bin/layer-baseline.txt
index 79543cdfc792..350806c891fc 100644
--- a/frontend/bin/layer-baseline.txt
+++ b/frontend/bin/layer-baseline.txt
@@ -92,7 +92,6 @@ frontend/src/layout/today/todayWorkItems.ts -> products/tasks/frontend/spaces/ta
frontend/src/lib/api.ts -> frontend/src/exporter/exporterViewLogic.ts
frontend/src/lib/api.ts -> frontend/src/lib/apiRequestTiming.ts
frontend/src/lib/api.ts -> frontend/src/lib/logic/apiStatusLogic.ts
-frontend/src/lib/api.ts -> frontend/src/scenes/surveys/constants.tsx
frontend/src/lib/components/Account/ProjectFreshnessIndicator.tsx -> frontend/src/scenes/onboarding/shared/utils.tsx
frontend/src/lib/components/ActivityLog/ActivityLogSubscribeMenu.tsx -> frontend/src/scenes/hog-functions/sub-templates/sub-templates.ts
frontend/src/lib/components/AddToDashboard/addToDashboardModalLogic.ts -> frontend/src/scenes/dashboard/liveDashboardIds.ts
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts
index 9c606734f1a6..2c24f00d5d94 100644
--- a/frontend/src/lib/api.ts
+++ b/frontend/src/lib/api.ts
@@ -18,6 +18,7 @@ import {
import { ApiRequestTiming, ApiRequestTimingRecorder } from 'lib/apiRequestTiming'
import { ActivityLogProps } from 'lib/components/ActivityLog/ActivityLog'
import { ActivityLogItem } from 'lib/components/ActivityLog/humanizeActivity'
+import { SURVEY_PAGE_SIZE } from 'lib/constants'
import { apiStatusLogic, awaitReauthentication, isUserActionInProgress } from 'lib/logic/apiStatusLogic'
import { HogQLQueryString } from 'lib/utils/hogql'
import { getBackendHost, getStoredSession, isOAuthMode, refreshAccessToken } from 'lib/utils/oauthClient'
@@ -29,7 +30,6 @@ import { SchemaPropertyGroup } from 'scenes/data-management/schema/schemaManagem
import type { MaxBillingContext } from 'scenes/max/maxBillingContextLogic'
import { NotebookListItemType, NotebookNodeResource, NotebookType } from 'scenes/notebooks/types'
import { RecordingComment } from 'scenes/session-recordings/player/inspector/playerInspectorLogic'
-import { SURVEY_PAGE_SIZE } from 'scenes/surveys/constants'
import { getCurrentExporterData, isSharedView } from '~/exporter/exporterViewLogic'
import { OrganizationOAuthApplicationApi, ProjectSecretAPIKeyApi } from '~/generated/core/api.schemas'
diff --git a/frontend/src/lib/constants.tsx b/frontend/src/lib/constants.tsx
index 8747b538c44e..9e7d0a6bb537 100644
--- a/frontend/src/lib/constants.tsx
+++ b/frontend/src/lib/constants.tsx
@@ -706,6 +706,7 @@ export const GENERATED_DASHBOARD_PREFIX = 'Generated Dashboard'
export const ACTIVITY_PAGE_SIZE = 20
export const ADVANCED_ACTIVITY_PAGE_SIZE = 100
+export const SURVEY_PAGE_SIZE = 100
export const EVENT_DEFINITIONS_PER_PAGE = 50
export const PROPERTY_DEFINITIONS_PER_EVENT = 5
export const EVENT_PROPERTY_DEFINITIONS_PER_PAGE = 50
diff --git a/frontend/src/scenes/experiments/ExperimentView/experimentFeedbackTabLogic.ts b/frontend/src/scenes/experiments/ExperimentView/experimentFeedbackTabLogic.ts
index dc63acc3fcc6..263730821bfa 100644
--- a/frontend/src/scenes/experiments/ExperimentView/experimentFeedbackTabLogic.ts
+++ b/frontend/src/scenes/experiments/ExperimentView/experimentFeedbackTabLogic.ts
@@ -1,7 +1,7 @@
import { MakeLogicType, afterMount, connect, kea, key, listeners, path, props, reducers } from 'kea'
import { loaders } from 'kea-loaders'
-import { SURVEY_PAGE_SIZE } from 'scenes/surveys/constants'
+import { SURVEY_PAGE_SIZE } from 'lib/constants'
import { surveysLogic } from 'scenes/surveys/surveysLogic'
import { teamLogic } from 'scenes/teamLogic'
diff --git a/frontend/src/scenes/surveys/constants.tsx b/frontend/src/scenes/surveys/constants.tsx
index 884c59a3a2a3..8c0856b1af73 100644
--- a/frontend/src/scenes/surveys/constants.tsx
+++ b/frontend/src/scenes/surveys/constants.tsx
@@ -19,8 +19,6 @@ import {
import { QuickSurveyContext, QuickSurveyType } from './quick-create/types'
-export const SURVEY_PAGE_SIZE = 100
-
// Max recurring-survey iterations. Mirrors MAX_ITERATION_COUNT in products/surveys/backend/models.py,
// which caps the generated iteration windows (and the API enforces the same limit).
export const MAX_ITERATION_COUNT = 500
diff --git a/frontend/src/scenes/surveys/surveysLogic.tsx b/frontend/src/scenes/surveys/surveysLogic.tsx
index dbb29b58d1e0..51a2972b4fc1 100644
--- a/frontend/src/scenes/surveys/surveysLogic.tsx
+++ b/frontend/src/scenes/surveys/surveysLogic.tsx
@@ -6,12 +6,11 @@ import { lemonToast } from '@posthog/lemon-ui'
import api, { CountedPaginatedResponse } from 'lib/api'
import { SetupTaskId, globalSetupLogic } from 'lib/components/ProductSetup'
-import { FEATURE_FLAGS } from 'lib/constants'
+import { FEATURE_FLAGS, SURVEY_PAGE_SIZE } from 'lib/constants'
import { featureFlagLogic as enabledFlagLogic } from 'lib/logic/featureFlagLogic'
import { pluralize } from 'lib/utils/strings'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene } from 'scenes/sceneTypes'
-import { SURVEY_PAGE_SIZE } from 'scenes/surveys/constants'
import { duplicateExistingSurvey, sanitizeSurvey } from 'scenes/surveys/utils'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'