: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
chore(frontend): load integration setup modals on demand (#126844)
Paul D'Ambra0263cac96326
diff --git a/frontend/bin/layer-baseline.txt b/frontend/bin/layer-baseline.txtindex 4920450e095e..de5af16643a1 100644--- a/frontend/bin/layer-baseline.txt+++ b/frontend/bin/layer-baseline.txt@@ -200,16 +200,6 @@ frontend/src/lib/components/ChartFilter/ChartFilter.tsx -> products/product_analfrontend/src/lib/components/ChartFilter/ChartFilter.tsx -> products/product_analytics/frontend/insights/chartAlternatives/chartDisplayOptions.tsfrontend/src/lib/components/CyclotronJob/CyclotronJobInputs.tsx -> frontend/src/scenes/hog-functions/email-templater/EmailTemplater.tsxfrontend/src/lib/components/CyclotronJob/CyclotronJobInputsValidation.ts -> frontend/src/scenes/hog-functions/email-templater/types.ts-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/aws-s3/AwsS3SetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/azure-blob/AzureBlobSetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/databricks/DatabricksSetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/gitlab/GitLabSetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/google-cloud-service-account/GoogleCloudServiceAccountSetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/postgresql/PostgreSQLSetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/redshift/RedshiftSetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/s3-compatible/S3CompatibleSetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> frontend/src/scenes/integrations/snowflake/SnowflakeSetupModal.tsx-frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx -> products/workflows/frontend/Channels/ChannelSetupModal.tsxfrontend/src/lib/components/DateFilter/openJumpToTimestampModal.tsx -> frontend/src/scenes/activity/explore/defaults.tsfrontend/src/lib/components/DefinitionPopover/CohortPopoverInfo.tsx -> frontend/src/scenes/cohorts/CohortFilters/constants.tsxfrontend/src/lib/components/DefinitionPopover/CohortPopoverInfo.tsx -> frontend/src/scenes/cohorts/cohortUtils.tsxdiff --git a/frontend/src/lib/components/CyclotronJob/integrations/integrationSetupRegistry.ts b/frontend/src/lib/components/CyclotronJob/integrations/integrationSetupRegistry.tsindex 3d2192832a25..8140f3e0ddd8 100644--- a/frontend/src/lib/components/CyclotronJob/integrations/integrationSetupRegistry.ts+++ b/frontend/src/lib/components/CyclotronJob/integrations/integrationSetupRegistry.ts@@ -1,3 +1,5 @@+import { Suspense, createElement } from 'react'+import { IntegrationKind } from '~/types'export type IntegrationSetupMenuItem = {@@ -13,21 +15,33 @@ export type IntegrationSetupContext = {uploadKey: (kind: string) => void}+type IntegrationSetupModalProps = {+ isOpen: boolean+ kind: string+ integration?: any+ onComplete: (id?: number) => void+ onClose: () => void+}+export type IntegrationSetupDefinition = {kind: string | string[]menuItem: (ctx: IntegrationSetupContext) => IntegrationSetupMenuItem- SetupModal?: React.ComponentType<{- isOpen: boolean- kind: string- integration?: any- onComplete: (id?: number) => void- onClose: () => void- }>+ SetupModal?: React.ComponentType<IntegrationSetupModalProps>}const registeredSetups = new Map<string, IntegrationSetupDefinition>()-export function registerIntegrationSetup(def: IntegrationSetupDefinition): void {+// Setup modals load lazily, so each one gets its own Suspense boundary instead of suspending the form around it.+function withSuspense(+ SetupModal: React.ComponentType<IntegrationSetupModalProps>+): React.ComponentType<IntegrationSetupModalProps> {+ return function SuspendedSetupModal(props) {+ return createElement(Suspense, { fallback: null }, createElement(SetupModal, props))+ }+}++export function registerIntegrationSetup(setup: IntegrationSetupDefinition): void {+ const def = setup.SetupModal ? { ...setup, SetupModal: withSuspense(setup.SetupModal) } : setupconst kinds = Array.isArray(def.kind) ? def.kind : [def.kind]for (const k of kinds) {registeredSetups.set(k, def)diff --git a/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx b/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsxindex d777ef547c70..763fa658017d 100644--- a/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx+++ b/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx@@ -1,18 +1,53 @@-import { AwsS3SetupModal } from 'scenes/integrations/aws-s3/AwsS3SetupModal'-import { AzureBlobSetupModal } from 'scenes/integrations/azure-blob/AzureBlobSetupModal'-import { DatabricksSetupModal } from 'scenes/integrations/databricks/DatabricksSetupModal'-import { GitLabSetupModal } from 'scenes/integrations/gitlab/GitLabSetupModal'-import { GoogleCloudServiceAccountSetupModal } from 'scenes/integrations/google-cloud-service-account/GoogleCloudServiceAccountSetupModal'-import { PostgreSQLSetupModal } from 'scenes/integrations/postgresql/PostgreSQLSetupModal'-import { RedshiftSetupModal } from 'scenes/integrations/redshift/RedshiftSetupModal'-import { S3CompatibleSetupModal } from 'scenes/integrations/s3-compatible/S3CompatibleSetupModal'-import { SnowflakeSetupModal } from 'scenes/integrations/snowflake/SnowflakeSetupModal'+import { lazyWithRetry } from 'lib/utils/retryImport'import { urls } from 'scenes/urls'-import { ChannelSetupModal } from 'products/workflows/frontend/Channels/ChannelSetupModal'-import { registerIntegrationSetup } from './integrationSetupRegistry'+const AwsS3SetupModal = lazyWithRetry(() =>+ import('scenes/integrations/aws-s3/AwsS3SetupModal').then((module) => ({ default: module.AwsS3SetupModal }))+)+const AzureBlobSetupModal = lazyWithRetry(() =>+ import('scenes/integrations/azure-blob/AzureBlobSetupModal').then((module) => ({+ default: module.AzureBlobSetupModal,+ }))+)+const DatabricksSetupModal = lazyWithRetry(() =>+ import('scenes/integrations/databricks/DatabricksSetupModal').then((module) => ({+ default: module.DatabricksSetupModal,+ }))+)+const GitLabSetupModal = lazyWithRetry(() =>+ import('scenes/integrations/gitlab/GitLabSetupModal').then((module) => ({ default: module.GitLabSetupModal }))+)+const GoogleCloudServiceAccountSetupModal = lazyWithRetry(() =>+ import('scenes/integrations/google-cloud-service-account/GoogleCloudServiceAccountSetupModal').then((module) => ({+ default: module.GoogleCloudServiceAccountSetupModal,+ }))+)+const PostgreSQLSetupModal = lazyWithRetry(() =>+ import('scenes/integrations/postgresql/PostgreSQLSetupModal').then((module) => ({+ default: module.PostgreSQLSetupModal,+ }))+)+const RedshiftSetupModal = lazyWithRetry(() =>+ import('scenes/integrations/redshift/RedshiftSetupModal').then((module) => ({ default: module.RedshiftSetupModal }))+)+const S3CompatibleSetupModal = lazyWithRetry(() =>+ import('scenes/integrations/s3-compatible/S3CompatibleSetupModal').then((module) => ({+ default: module.S3CompatibleSetupModal,+ }))+)+const SnowflakeSetupModal = lazyWithRetry(() =>+ import('scenes/integrations/snowflake/SnowflakeSetupModal').then((module) => ({+ default: module.SnowflakeSetupModal,+ }))+)+const ChannelSetupModal = lazyWithRetry(() =>+ import('products/workflows/frontend/Channels/ChannelSetupModal').then((module) => ({+ default: module.ChannelSetupModal,+ }))+)+registerIntegrationSetup({kind: ['google-pubsub', 'google-cloud-storage', 'firebase'],menuItem: ({ kind, uploadKey }) => ({