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.

chore(toolbar): cut the preflight and web-analytics-achievements edges (#69128)

Rafael Audibert59f1d23ddc14
diff --git a/.agents/toolbar-migration.md b/.agents/toolbar-migration.md
index 72b9b13a2c3c..0453a0808e17 100644
--- a/.agents/toolbar-migration.md
+++ b/.agents/toolbar-migration.md
@@ -4,7 +4,7 @@ This file is the committed source of truth for the toolbar bundle modernization
## Status
-- **Current step**: Steps 1–4 and 7 implemented and in review as a Graphite stack (drafts), plus a seventh PR batching the simple Step 5/6 moves (PanelSettings, UrlMatchingHints, KeyboardShortcut, LemonMarkdown mermaid barrel — baseline 31 → 25 edges, mermaid deny retired). Next: merge the base of the stack before extending further, then the remaining Step 6 seams (Link→DraggableToNotebook, LemonColor, eventUsageLogic) and Step 8.
+- **Current step**: Steps 1–4 and 7 implemented and in review as a Graphite stack (drafts), plus a seventh PR batching the simple Step 5/6 moves (PanelSettings, UrlMatchingHints, KeyboardShortcut, LemonMarkdown mermaid barrel — baseline 31 → 25) and an eighth cutting the preflight + web-analytics-achievements edges (baseline 25 → 18). Next: merge the base of the stack before extending further, then the remaining Step 6 seams (Link→DraggableToNotebook, LemonColor→theme logics, taxonomy/PropertyKeyInfo→surveyQuestionLabelsLogic) and Step 8.
- **Last updated**: 2026-07-07
- **PRs**: Step 1 — `rafa/toolbar-migration-1-graph-guard` (#69045); Step 3 — `rafa/toolbar-migration-2-products-urls-split` (#69071); chain cuts + shim-leak fix — `rafa/toolbar-migration-3-shim-leak-and-chain-cuts` (#69088); Step 2 — `rafa/toolbar-migration-4-loader-esm-splitting` (#69093); Step 4 — `rafa/toolbar-migration-5-types-replay-shared-cut` (#69106); Step 7 — `rafa/toolbar-migration-6-lazy-menus` (#69113); Step 5/6 batch — `rafa/toolbar-migration-7-simple-edge-cuts` (#69122) (each stacked on the previous)
- **Reorder note (resolved)**: a trial Step 2 build emitted **487 dead chunks** — with `products.tsx` reachable, every product scene's dynamic import becomes a real chunk in `dist/toolbar/`. The gate was: flip the format only once `products.tsx` leaves the graph. That's now done via two moves in the third PR. First, the remaining chains all funneled through one root cause: the kea shims only matched exact alias strings (`scenes/teamLogic`), so relative imports (`dataThemeLogic` → `./teamLogic`) and `~/`-prefixed imports pulled the REAL logics and their whole app graph — fixed with relative + `~/` matching in `createToolbarModulePlugin`, disconnecting `products.tsx`, `scenes.ts`, `teamLogic`, `PersonDisplay`, and `experimentsLogic` in one move. Second, `scenes/urls` itself (imported by lib components shared with the app) is shimmed to the toolbar's parity-tested `~/toolbar/urls` duplicate from Step 3, taking the last products-manifest path out. Bundle graph 8448 → ~1000 files (99 → ~13.5 MiB source), shipped `dist/toolbar.js` 9.95 MB → ~4 MB (was just under the 10 MB CloudFront cliff). Graph budget ratcheted 110 MB → 18 MB.
@@ -110,7 +110,9 @@ Approach (revised on review): rather than restructuring the generated products m
- [x] `lib/lemon-ui/LemonMarkdown/index.ts`: the barrel no longer re-exports `LemonMarkdownWithMermaid` (the one product user imports the module directly); the `mermaid` deny in `toolbar-config.mjs` is retired, reintroduction caught by FORBIDDEN_PACKAGES
- [x] `HeatmapEventsPanel` → `PersonDisplay`: replaced with a plain span (PersonDisplay renders exactly that for a distinct_id-only person with `noPopover`); `TZLabel` → teamLogic edge now shimmed at resolve time (`~/scenes/teamLogic` matching)
- [x] `KeyboardShortcut` moved out of `layout/navigation-3000/components/` into `lib/components/KeyboardShortcut/` (25 importers repointed; cuts the 4 lemon-ui → layout edges)
-- [ ] `TZLabel` → urls (already shim-resolved to `~/toolbar/urls`; boundary-only); `eventUsageLogic` → preflight/web-analytics/product-tours edges
+- [x] `preflightLogic` moved from `scenes/PreflightCheck/` to `lib/logic/preflightLogic` (it's global app state, not scene state; its `scenes/urls` import resolves through the toolbar shim). All `src/lib/**` importers repointed; a `scenes/PreflightCheck/preflightLogic.tsx` re-export keeps the other ~100 app importers working, so a follow-up repoint is optional cleanup. Cuts 5 baseline edges (incidentStatusLogic, MCPInstallCommand, payGateMiniLogic, superpowersLogic, eventUsageLogic)
+- [x] `eventUsageLogic` → web-analytics achievements: inverted — `webAnalyticsAchievementsLogic` now owns interaction recording (a `recordInteraction` action absorbing `recordInteraction.ts`, deleted) and listens to the five `reportWebAnalytics*` action types itself. Cuts 2 edges and drops the achievements + generated web_analytics API modules (~62 KB, 8 files) from the toolbar graph. Behavior note: recording now requires the achievements logic mounted, which the web analytics scene menu bar guarantees wherever those reports fire
+- [ ] `TZLabel` → urls (already shim-resolved to `~/toolbar/urls`; boundary-only); `eventUsageLogic` → `product-tours/constants` (1 KB leaf, part of the product-tours seam family)
### Step 7 — lazy boundaries in toolbar source (in review: `rafa/toolbar-migration-6-lazy-menus`)
diff --git a/frontend/bin/toolbar-graph-baseline.json b/frontend/bin/toolbar-graph-baseline.json
index dec1eb35fb5a..81c2c8103f24 100644
--- a/frontend/bin/toolbar-graph-baseline.json
+++ b/frontend/bin/toolbar-graph-baseline.json
@@ -2,21 +2,14 @@
"//": "Toolbar -> app-zone import edges that exist today, enforced by bin/check-toolbar-graph.mjs. Do not add entries; delete them as the migration (.agents/toolbar-migration.md) cuts each edge.",
"edges": [
"src/lib/components/HedgehogMode/HedgehogMode.tsx -> src/layout/navigation-3000/themeLogic.ts",
- "src/lib/components/HelpMenu/incidentStatusLogic.tsx -> src/scenes/PreflightCheck/preflightLogic.tsx",
"src/lib/components/JSONViewer.tsx -> src/layout/navigation-3000/themeLogic.ts",
- "src/lib/components/MCPHint/MCPInstallCommand.tsx -> src/scenes/PreflightCheck/preflightLogic.tsx",
- "src/lib/components/PayGateMini/payGateMiniLogic.tsx -> src/scenes/PreflightCheck/preflightLogic.tsx",
"src/lib/components/PropertyKeyInfo.tsx -> src/scenes/surveys/surveyQuestionLabelsLogic.ts",
- "src/lib/components/Superpowers/superpowersLogic.ts -> src/scenes/PreflightCheck/preflightLogic.tsx",
"src/lib/lemon-ui/LemonColor/LemonColorButton.tsx -> src/scenes/dataThemeLogic.tsx",
"src/lib/lemon-ui/LemonColor/LemonColorGlyph.tsx -> src/layout/navigation-3000/themeLogic.ts",
"src/lib/lemon-ui/LemonColor/LemonColorGlyph.tsx -> src/scenes/dataThemeLogic.tsx",
"src/lib/lemon-ui/LemonColor/LemonColorPicker.tsx -> src/scenes/dataThemeLogic.tsx",
"src/lib/lemon-ui/Link/Link.tsx -> src/scenes/notebooks/AddToNotebook/DraggableToNotebook.tsx",
- "src/lib/utils/eventUsageLogic.ts -> ../products/web_analytics/frontend/generated/api.schemas.ts",
- "src/lib/utils/eventUsageLogic.ts -> src/scenes/PreflightCheck/preflightLogic.tsx",
"src/lib/utils/eventUsageLogic.ts -> src/scenes/product-tours/constants.ts",
- "src/lib/utils/eventUsageLogic.ts -> src/scenes/web-analytics/achievements/recordInteraction.ts",
"src/taxonomy/helpers.ts -> src/scenes/surveys/surveyQuestionLabelsLogic.ts",
"src/taxonomy/taxonomy.tsx -> src/scenes/web-analytics/tabs/marketing-analytics/utils.ts",
"src/toolbar/experiments/experimentsTabLogic.tsx -> src/scenes/experiments/experimentStatus.ts",
diff --git a/frontend/src/lib/components/Account/AccountMenu.tsx b/frontend/src/lib/components/Account/AccountMenu.tsx
index 60dc4483b322..7eab5eb48f19 100644
--- a/frontend/src/lib/components/Account/AccountMenu.tsx
+++ b/frontend/src/lib/components/Account/AccountMenu.tsx
@@ -30,6 +30,7 @@ import { Link } from 'lib/lemon-ui/Link/Link'
import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture/ProfilePicture'
import { UploadedLogo } from 'lib/lemon-ui/UploadedLogo/UploadedLogo'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import {
DropdownMenu,
@@ -48,7 +49,6 @@ import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { billingLogic } from 'scenes/billing/billingLogic'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { inviteLogic } from 'scenes/settings/organization/inviteLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
diff --git a/frontend/src/lib/components/Account/NewAccountMenu.tsx b/frontend/src/lib/components/Account/NewAccountMenu.tsx
index 29f31ed4cc6b..a05c12aebc70 100644
--- a/frontend/src/lib/components/Account/NewAccountMenu.tsx
+++ b/frontend/src/lib/components/Account/NewAccountMenu.tsx
@@ -17,6 +17,7 @@ import { Link } from 'lib/lemon-ui/Link/Link'
import { ProfilePicture } from 'lib/lemon-ui/ProfilePicture/ProfilePicture'
import { UploadedLogo } from 'lib/lemon-ui/UploadedLogo/UploadedLogo'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { DropdownMenuSeparator } from 'lib/ui/DropdownMenu/DropdownMenu'
import { Label } from 'lib/ui/Label/Label'
@@ -25,7 +26,6 @@ import { cn } from 'lib/utils/css-classes'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { billingLogic } from 'scenes/billing/billingLogic'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { inviteLogic } from 'scenes/settings/organization/inviteLogic'
import { isAuthenticatedTeam, teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
diff --git a/frontend/src/lib/components/Account/OrgCombobox.tsx b/frontend/src/lib/components/Account/OrgCombobox.tsx
index f713e3e537fa..9d01339745af 100644
--- a/frontend/src/lib/components/Account/OrgCombobox.tsx
+++ b/frontend/src/lib/components/Account/OrgCombobox.tsx
@@ -4,12 +4,12 @@ import { IconCheck, IconPlusSmall } from '@posthog/icons'
import { IconBlank } from 'lib/lemon-ui/icons'
import { UploadedLogo } from 'lib/lemon-ui/UploadedLogo'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { Combobox } from 'lib/ui/Combobox/Combobox'
import { DropdownMenuSeparator } from 'lib/ui/DropdownMenu/DropdownMenu'
import { Label } from 'lib/ui/Label/Label'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { userLogic } from 'scenes/userLogic'
import { globalModalsLogic } from '~/layout/globalModalsLogic'
diff --git a/frontend/src/lib/components/Account/OrgSwitcher.tsx b/frontend/src/lib/components/Account/OrgSwitcher.tsx
index b4003314e301..c8b0ad89177d 100644
--- a/frontend/src/lib/components/Account/OrgSwitcher.tsx
+++ b/frontend/src/lib/components/Account/OrgSwitcher.tsx
@@ -8,11 +8,11 @@ import { KeyboardShortcut } from 'lib/components/KeyboardShortcut/KeyboardShortc
import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic'
import { IconBlank } from 'lib/lemon-ui/icons'
import { UploadedLogo } from 'lib/lemon-ui/UploadedLogo'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { MenuSeparator } from 'lib/ui/Menus/Menus'
import { cn } from 'lib/utils/css-classes'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { userLogic } from 'scenes/userLogic'
import { globalModalsLogic } from '~/layout/globalModalsLogic'
diff --git a/frontend/src/lib/components/Account/ProjectCombobox.tsx b/frontend/src/lib/components/Account/ProjectCombobox.tsx
index e7752ecc6252..45960b75b175 100644
--- a/frontend/src/lib/components/Account/ProjectCombobox.tsx
+++ b/frontend/src/lib/components/Account/ProjectCombobox.tsx
@@ -5,13 +5,13 @@ import { Link } from '@posthog/lemon-ui'
import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic'
import { IconBlank } from 'lib/lemon-ui/icons'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { ButtonGroupPrimitive, ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { Combobox } from 'lib/ui/Combobox/Combobox'
import { Label } from 'lib/ui/Label/Label'
import { MenuSeparator } from 'lib/ui/Menus/Menus'
import { getProjectSwitchTargetUrl } from 'lib/utils/kea-router'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { isAuthenticatedTeam, teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
diff --git a/frontend/src/lib/components/Account/ProjectSwitcher.tsx b/frontend/src/lib/components/Account/ProjectSwitcher.tsx
index ecc3b6a82805..e8f0039b1474 100644
--- a/frontend/src/lib/components/Account/ProjectSwitcher.tsx
+++ b/frontend/src/lib/components/Account/ProjectSwitcher.tsx
@@ -7,12 +7,12 @@ import { IconCheck, IconLetter, IconPlusSmall, IconSearch, IconX } from '@postho
import { KeyboardShortcut } from 'lib/components/KeyboardShortcut/KeyboardShortcut'
import { upgradeModalLogic } from 'lib/components/UpgradeModal/upgradeModalLogic'
import { IconBlank } from 'lib/lemon-ui/icons'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { MenuSeparator } from 'lib/ui/Menus/Menus'
import { cn } from 'lib/utils/css-classes'
import { getProjectSwitchTargetUrl } from 'lib/utils/kea-router'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { isAuthenticatedTeam, teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
diff --git a/frontend/src/lib/components/AllowTrainingCallout/AllowTrainingCallout.tsx b/frontend/src/lib/components/AllowTrainingCallout/AllowTrainingCallout.tsx
index 92ef2e8523d3..487292192236 100644
--- a/frontend/src/lib/components/AllowTrainingCallout/AllowTrainingCallout.tsx
+++ b/frontend/src/lib/components/AllowTrainingCallout/AllowTrainingCallout.tsx
@@ -5,8 +5,8 @@ import { LemonBanner } from '@posthog/lemon-ui'
import { useRestrictedArea } from 'lib/components/RestrictedArea'
import { OrganizationMembershipLevel } from 'lib/constants'
import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { urls } from 'scenes/urls'
export function AllowTrainingCallout({
diff --git a/frontend/src/lib/components/Errors/errorPropertiesLogic.ts b/frontend/src/lib/components/Errors/errorPropertiesLogic.ts
index 2087dd4812b0..2bffd49a619b 100644
--- a/frontend/src/lib/components/Errors/errorPropertiesLogic.ts
+++ b/frontend/src/lib/components/Errors/errorPropertiesLogic.ts
@@ -18,7 +18,7 @@ import {
getSessionId,
} from 'lib/components/Errors/utils'
import { dayjs } from 'lib/dayjs'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import type { errorPropertiesLogicType } from './errorPropertiesLogicType'
import { KeyedStackFrameRecords, stackFrameLogic } from './Frame/stackFrameLogic'
diff --git a/frontend/src/lib/components/EventPropertyTabs/eventPropertyFilteringLogic.ts b/frontend/src/lib/components/EventPropertyTabs/eventPropertyFilteringLogic.ts
index 10a26f70d199..c79328e7fcaa 100644
--- a/frontend/src/lib/components/EventPropertyTabs/eventPropertyFilteringLogic.ts
+++ b/frontend/src/lib/components/EventPropertyTabs/eventPropertyFilteringLogic.ts
@@ -1,7 +1,7 @@
import { connect, kea, path, selectors } from 'kea'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { userPreferencesLogic } from 'lib/logic/userPreferencesLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { CLOUD_INTERNAL_POSTHOG_PROPERTY_KEYS, PROPERTY_KEYS } from '~/taxonomy/taxonomy'
diff --git a/frontend/src/lib/components/FeedbackNotice.tsx b/frontend/src/lib/components/FeedbackNotice.tsx
index 65adb0cc9d76..a154adfcab7a 100644
--- a/frontend/src/lib/components/FeedbackNotice.tsx
+++ b/frontend/src/lib/components/FeedbackNotice.tsx
@@ -5,7 +5,7 @@ import { LemonBanner } from '@posthog/lemon-ui'
import { IconFeedback } from 'lib/lemon-ui/icons'
import { LemonButton } from 'lib/lemon-ui/LemonButton'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { supportLogic } from './Support/supportLogic'
diff --git a/frontend/src/lib/components/HelpMenu/HelpMenu.tsx b/frontend/src/lib/components/HelpMenu/HelpMenu.tsx
index b48546a65a9e..595ca1ead50e 100644
--- a/frontend/src/lib/components/HelpMenu/HelpMenu.tsx
+++ b/frontend/src/lib/components/HelpMenu/HelpMenu.tsx
@@ -9,13 +9,13 @@ import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'
import { IconMenu, IconWithBadge } from 'lib/lemon-ui/icons'
import { LemonBadge } from 'lib/lemon-ui/LemonBadge/LemonBadge'
import { Link } from 'lib/lemon-ui/Link/Link'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { ButtonPrimitive } from 'lib/ui/Button/ButtonPrimitives'
import { Label } from 'lib/ui/Label/Label'
import { MenuOpenIndicator } from 'lib/ui/Menus/Menus'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { billingLogic } from 'scenes/billing/billingLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
diff --git a/frontend/src/lib/components/HelpMenu/incidentStatusLogic.tsx b/frontend/src/lib/components/HelpMenu/incidentStatusLogic.tsx
index 49a256c7acbb..394f35c957c7 100644
--- a/frontend/src/lib/components/HelpMenu/incidentStatusLogic.tsx
+++ b/frontend/src/lib/components/HelpMenu/incidentStatusLogic.tsx
@@ -4,7 +4,7 @@ import posthog from 'posthog-js'
// eslint-disable-next-line import/no-cycle
import { superpowersLogic } from 'lib/components/Superpowers/superpowersLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { Region } from '~/types'
diff --git a/frontend/src/lib/components/JSSnippet.tsx b/frontend/src/lib/components/JSSnippet.tsx
index 1434db921481..210dcf6999ff 100644
--- a/frontend/src/lib/components/JSSnippet.tsx
+++ b/frontend/src/lib/components/JSSnippet.tsx
@@ -6,7 +6,7 @@ import { buildJsHtmlSnippet, SnippetOption } from '@posthog/shared-onboarding/pr
import { CodeSnippet, Language } from 'lib/components/CodeSnippet'
import { FEATURE_FLAGS } from 'lib/constants'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { domainFor, proxyLogic } from 'scenes/settings/environment/proxyLogic'
import { teamLogic } from 'scenes/teamLogic'
diff --git a/frontend/src/lib/components/MCPHint/MCPInstallCommand.tsx b/frontend/src/lib/components/MCPHint/MCPInstallCommand.tsx
index 82c1bf344b7c..7b1c80e8239d 100644
--- a/frontend/src/lib/components/MCPHint/MCPInstallCommand.tsx
+++ b/frontend/src/lib/components/MCPHint/MCPInstallCommand.tsx
@@ -1,8 +1,8 @@
import { useValues } from 'kea'
import { CommandBlock } from 'lib/components/CommandBlock/CommandBlock'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { cn } from 'lib/utils/css-classes'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { MCP_INSTALL_COMMAND } from './constants'
diff --git a/frontend/src/lib/components/Map/Map.tsx b/frontend/src/lib/components/Map/Map.tsx
index e35fee09e4c0..785449ce27a2 100644
--- a/frontend/src/lib/components/Map/Map.tsx
+++ b/frontend/src/lib/components/Map/Map.tsx
@@ -8,7 +8,7 @@ import { Protocol } from 'pmtiles'
import { useEffect, useRef } from 'react'
import useResizeObserver from 'use-resize-observer'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { themeLogic } from '~/layout/navigation-3000/themeLogic'
diff --git a/frontend/src/lib/components/MarkdownEditor/inline/inlineMarkdownSlashCommands.test.tsx b/frontend/src/lib/components/MarkdownEditor/inline/inlineMarkdownSlashCommands.test.tsx
index b10d1367c0b0..716c580f8d5c 100644
--- a/frontend/src/lib/components/MarkdownEditor/inline/inlineMarkdownSlashCommands.test.tsx
+++ b/frontend/src/lib/components/MarkdownEditor/inline/inlineMarkdownSlashCommands.test.tsx
@@ -4,7 +4,7 @@ import { act, cleanup, fireEvent, render, screen } from '@testing-library/react'
import type { Editor } from '@tiptap/core'
import { createRef, type ComponentRef } from 'react'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { initKeaTests } from '~/test/init'
import { Realm, type PreflightStatus } from '~/types'
diff --git a/frontend/src/lib/components/MarkdownEditor/inline/inlineMarkdownSlashCommands.tsx b/frontend/src/lib/components/MarkdownEditor/inline/inlineMarkdownSlashCommands.tsx
index 3a7e44394af5..1ac6d72c55f5 100644
--- a/frontend/src/lib/components/MarkdownEditor/inline/inlineMarkdownSlashCommands.tsx
+++ b/frontend/src/lib/components/MarkdownEditor/inline/inlineMarkdownSlashCommands.tsx
@@ -19,7 +19,7 @@ import { LemonButton, LemonDivider } from '@posthog/lemon-ui'
import { IconBold, IconItalic, IconLink, IconTextSize } from 'lib/lemon-ui/icons'
import { Popover } from 'lib/lemon-ui/Popover'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
/** Plugin key for {@link createInlineMarkdownSlashCommandsExtension} (use for `exitSuggestion` / debugging). */
export const INLINE_MARKDOWN_SLASH_COMMANDS_PLUGIN_KEY = new PluginKey('inlineRichMarkdownSlashCommands')
diff --git a/frontend/src/lib/components/MarkdownEditor/shared/MarkdownEditorImageEmojiControls.tsx b/frontend/src/lib/components/MarkdownEditor/shared/MarkdownEditorImageEmojiControls.tsx
index b75b75b83ef5..44da4e782cea 100644
--- a/frontend/src/lib/components/MarkdownEditor/shared/MarkdownEditorImageEmojiControls.tsx
+++ b/frontend/src/lib/components/MarkdownEditor/shared/MarkdownEditorImageEmojiControls.tsx
@@ -10,7 +10,7 @@ import { LemonFileInput } from 'lib/lemon-ui/LemonFileInput'
import { emojiUsageLogic } from 'lib/lemon-ui/LemonTextArea/emojiUsageLogic'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { useMarkdownEditorImageUpload } from './useMarkdownEditorImageUpload'
diff --git a/frontend/src/lib/components/MetabaseQueryLink.tsx b/frontend/src/lib/components/MetabaseQueryLink.tsx
index ed3911c5879a..a979e5984909 100644
--- a/frontend/src/lib/components/MetabaseQueryLink.tsx
+++ b/frontend/src/lib/components/MetabaseQueryLink.tsx
@@ -1,7 +1,7 @@
import { useValues } from 'kea'
import { Link } from 'lib/lemon-ui/Link'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { Realm, Region } from '~/types'
diff --git a/frontend/src/lib/components/NavPanelAdvertisement/NavPanelAdvertisement.tsx b/frontend/src/lib/components/NavPanelAdvertisement/NavPanelAdvertisement.tsx
index ba97fc64c77a..4c221dc0addf 100644
--- a/frontend/src/lib/components/NavPanelAdvertisement/NavPanelAdvertisement.tsx
+++ b/frontend/src/lib/components/NavPanelAdvertisement/NavPanelAdvertisement.tsx
@@ -1,7 +1,7 @@
import { useValues } from 'kea'
import { getFeatureFlagPayload } from 'lib/logic/featureFlagLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { userLogic } from 'scenes/userLogic'
import { panelLayoutLogic } from '~/layout/panel-layout/panelLayoutLogic'
diff --git a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushLogic.test.ts b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushLogic.test.ts
index 05a54505fe05..12eb3b714972 100644
--- a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushLogic.test.ts
+++ b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushLogic.test.ts
@@ -1,6 +1,6 @@
import { expectLogic } from 'kea-test-utils'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { initKeaTests } from '~/test/init'
diff --git a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushLogic.ts b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushLogic.ts
index 85731bf46e3e..1b55c22ee24d 100644
--- a/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushLogic.ts
+++ b/frontend/src/lib/components/NavPanelAdvertisement/navPanelProductPushLogic.ts
@@ -1,8 +1,8 @@
import { afterMount, connect, kea, listeners, path } from 'kea'
import { loaders } from 'kea-loaders'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'
import * as api from 'products/growth/frontend/generated/api'
diff --git a/frontend/src/lib/components/NotFound/index.tsx b/frontend/src/lib/components/NotFound/index.tsx
index 1fbfeb687ceb..5d91138e526b 100644
--- a/frontend/src/lib/components/NotFound/index.tsx
+++ b/frontend/src/lib/components/NotFound/index.tsx
@@ -11,12 +11,12 @@ import { LemonButton, LemonCheckbox, ProfilePicture, SpinnerOverlay, lemonToast
import { useOnMountEffect } from 'lib/hooks/useOnMountEffect'
import { LemonMenuOverlay } from 'lib/lemon-ui/LemonMenu/LemonMenu'
import { Link } from 'lib/lemon-ui/Link'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { cn } from 'lib/utils/css-classes'
import { getAppContext } from 'lib/utils/getAppContext'
import { capitalizeFirstLetter } from 'lib/utils/strings'
import { getDefaultEventsSceneQuery } from 'scenes/activity/explore/defaults'
import { useNotebookNode } from 'scenes/notebooks/Nodes/NotebookNodeContext'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { urls } from 'scenes/urls'
import { adminLoginAs } from '~/layout/navigation/ImpersonationNotice/adminLoginAs'
diff --git a/frontend/src/lib/components/PayGateMini/PayGateMini.tsx b/frontend/src/lib/components/PayGateMini/PayGateMini.tsx
index c9b189f2a7e4..8b9bc43e8cfd 100644
--- a/frontend/src/lib/components/PayGateMini/PayGateMini.tsx
+++ b/frontend/src/lib/components/PayGateMini/PayGateMini.tsx
@@ -6,9 +6,9 @@ import { useEffect } from 'react'
import { IconInfo, IconOpenSidebar, IconUnlock } from '@posthog/icons'
import { LemonButton, LemonSkeleton, Link, Tooltip } from '@posthog/lemon-ui'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { billingLogic } from 'scenes/billing/billingLogic'
import { getProductIcon } from 'scenes/onboarding/shared/utils'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { userLogic } from 'scenes/userLogic'
import { AvailableFeature, BillingFeatureType, BillingProductV2AddonType, BillingProductV2Type } from '~/types'
diff --git a/frontend/src/lib/components/PayGateMini/payGateMiniLogic.tsx b/frontend/src/lib/components/PayGateMini/payGateMiniLogic.tsx
index d219b2c9b482..648d28ca731d 100644
--- a/frontend/src/lib/components/PayGateMini/payGateMiniLogic.tsx
+++ b/frontend/src/lib/components/PayGateMini/payGateMiniLogic.tsx
@@ -1,7 +1,7 @@
import { actions, connect, kea, key, path, props, reducers, selectors } from 'kea'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { billingLogic } from 'scenes/billing/billingLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { userLogic } from 'scenes/userLogic'
import { AvailableFeature, BillingProductV2AddonType, BillingProductV2Type } from '~/types'
diff --git a/frontend/src/lib/components/ProductSetup/productSetupLogic.ts b/frontend/src/lib/components/ProductSetup/productSetupLogic.ts
index 69cc17cc2b0d..76a6506c6e96 100644
--- a/frontend/src/lib/components/ProductSetup/productSetupLogic.ts
+++ b/frontend/src/lib/components/ProductSetup/productSetupLogic.ts
@@ -3,8 +3,8 @@ import { router } from 'kea-router'
import posthog from 'posthog-js'
import { SetupTaskId } from 'lib/components/ProductSetup'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { inviteLogic } from 'scenes/settings/organization/inviteLogic'
import { teamLogic } from 'scenes/teamLogic'
diff --git a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
index aed82e3da0aa..a3d8ab4dbaf5 100644
--- a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
+++ b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
@@ -10,11 +10,11 @@ import { LemonCheckbox, LemonDialog, LemonInput, LemonMenu, LemonTag, Link, Tool
import { LemonButton } from 'lib/lemon-ui/LemonButton'
import { LemonTable, LemonTableColumns, LemonTableProps } from 'lib/lemon-ui/LemonTable'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { userPreferencesLogic } from 'lib/logic/userPreferencesLogic'
import { isObject, isKeyOf } from 'lib/utils/guards'
import { isURL } from 'lib/utils/url'
import { NewProperty } from 'scenes/persons/NewProperty'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { urls } from 'scenes/urls'
import { propertyDefinitionsModel } from '~/models/propertyDefinitionsModel'
diff --git a/frontend/src/lib/components/Search/searchLogic.tsx b/frontend/src/lib/components/Search/searchLogic.tsx
index 1241b991e760..d619dc745dfb 100644
--- a/frontend/src/lib/components/Search/searchLogic.tsx
+++ b/frontend/src/lib/components/Search/searchLogic.tsx
@@ -6,10 +6,10 @@ import { IconBell, IconClock, IconDownload, IconLeave, IconNotification } from '
import api from 'lib/api'
import { commandLogic } from 'lib/components/Command/commandLogic'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { getEntryAccessDisabledReason, getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'
import { GroupQueryResult, mapGroupQueryResponse } from 'lib/utils/groups'
import { toSentenceCase } from 'lib/utils/strings'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { organizationIntegrationsLogic } from 'scenes/settings/organization/organizationIntegrationsLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
diff --git a/frontend/src/lib/components/Sharing/SharingModal.tsx b/frontend/src/lib/components/Sharing/SharingModal.tsx
index c76e6114ffab..d8201c5d6c94 100644
--- a/frontend/src/lib/components/Sharing/SharingModal.tsx
+++ b/frontend/src/lib/components/Sharing/SharingModal.tsx
@@ -27,10 +27,10 @@ import { LemonLabel } from 'lib/lemon-ui/LemonLabel/LemonLabel'
import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { accessLevelSatisfied } from 'lib/utils/accessControlUtils'
import { copyToClipboard } from 'lib/utils/copyToClipboard'
import { insightVizDataLogic } from 'scenes/insights/insightVizDataLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { projectLogic } from 'scenes/projectLogic'
import { urls } from 'scenes/urls'
diff --git a/frontend/src/lib/components/Sharing/sharingLogic.ts b/frontend/src/lib/components/Sharing/sharingLogic.ts
index 9896adce5f47..c13bcab25b56 100644
--- a/frontend/src/lib/components/Sharing/sharingLogic.ts
+++ b/frontend/src/lib/components/Sharing/sharingLogic.ts
@@ -3,10 +3,10 @@ import { forms } from 'kea-forms'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { getInsightId } from 'scenes/insights/utils'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
diff --git a/frontend/src/lib/components/SocialLoginButton/SocialLoginButton.tsx b/frontend/src/lib/components/SocialLoginButton/SocialLoginButton.tsx
index ae4ec276a6e5..4fe24ef31646 100644
--- a/frontend/src/lib/components/SocialLoginButton/SocialLoginButton.tsx
+++ b/frontend/src/lib/components/SocialLoginButton/SocialLoginButton.tsx
@@ -6,8 +6,8 @@ import { SSO_PROVIDER_NAMES } from 'lib/constants'
import { LemonButton, LemonButtonWithoutSideActionProps } from 'lib/lemon-ui/LemonButton'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
import { LemonTag } from 'lib/lemon-ui/LemonTag'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { BeginPasskeyLoginParams, passkeyLogic } from 'scenes/authentication/shared/passkeyLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { LoginMethod, SSOProvider } from '~/types'
diff --git a/frontend/src/lib/components/Superpowers/Superpowers.tsx b/frontend/src/lib/components/Superpowers/Superpowers.tsx
index 48f5abeae550..782d68c02acc 100644
--- a/frontend/src/lib/components/Superpowers/Superpowers.tsx
+++ b/frontend/src/lib/components/Superpowers/Superpowers.tsx
@@ -5,9 +5,9 @@ import { LemonButton, LemonDivider, LemonSelect, LemonSwitch, LemonTag } from '@
import { SupermanHog } from 'lib/components/hedgehogs'
import { LemonModal } from 'lib/lemon-ui/LemonModal'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
diff --git a/frontend/src/lib/components/Superpowers/superpowersLogic.ts b/frontend/src/lib/components/Superpowers/superpowersLogic.ts
index 3ab8fba4422b..bb17e0c89ed9 100644
--- a/frontend/src/lib/components/Superpowers/superpowersLogic.ts
+++ b/frontend/src/lib/components/Superpowers/superpowersLogic.ts
@@ -1,7 +1,7 @@
import { actions, connect, kea, path, reducers, selectors } from 'kea'
import { mcpHintLogic } from 'lib/components/MCPHint/mcpHintLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
// eslint-disable-next-line import/no-cycle
import { userLogic } from 'scenes/userLogic'
diff --git a/frontend/src/lib/components/Support/SupportForm.tsx b/frontend/src/lib/components/Support/SupportForm.tsx
index 1f495f33383e..c2530995b427 100644
--- a/frontend/src/lib/components/Support/SupportForm.tsx
+++ b/frontend/src/lib/components/Support/SupportForm.tsx
@@ -20,7 +20,7 @@ import { LemonFileInput } from 'lib/lemon-ui/LemonFileInput/LemonFileInput'
import { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect/LemonInputSelect'
import { LemonSelect } from 'lib/lemon-ui/LemonSelect/LemonSelect'
import { LemonTextArea } from 'lib/lemon-ui/LemonTextArea/LemonTextArea'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { userLogic } from 'scenes/userLogic'
import {
diff --git a/frontend/src/lib/components/Support/SupportModal.tsx b/frontend/src/lib/components/Support/SupportModal.tsx
index 36e357c9f843..a79dc5c7d821 100644
--- a/frontend/src/lib/components/Support/SupportModal.tsx
+++ b/frontend/src/lib/components/Support/SupportModal.tsx
@@ -5,7 +5,7 @@ import { createRoot } from 'react-dom/client'
import { LemonButton } from '@posthog/lemon-ui'
import { LemonModal } from 'lib/lemon-ui/LemonModal/LemonModal'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { sidePanelStateLogic } from '~/layout/navigation-3000/sidepanel/sidePanelStateLogic'
diff --git a/frontend/src/lib/components/Support/supportLogic.ts b/frontend/src/lib/components/Support/supportLogic.ts
index 61fbb012b102..de2443180df2 100644
--- a/frontend/src/lib/components/Support/supportLogic.ts
+++ b/frontend/src/lib/components/Support/supportLogic.ts
@@ -6,10 +6,10 @@ import { LemonSelectOptions } from '@posthog/lemon-ui'
import api from 'lib/api'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { uuid } from 'lib/utils/dom'
import { billingLogic } from 'scenes/billing/billingLogic'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
diff --git a/frontend/src/lib/components/UpgradeModal/upgradeModalLogic.ts b/frontend/src/lib/components/UpgradeModal/upgradeModalLogic.ts
index 0bbc480dad2b..b46806db446a 100644
--- a/frontend/src/lib/components/UpgradeModal/upgradeModalLogic.ts
+++ b/frontend/src/lib/components/UpgradeModal/upgradeModalLogic.ts
@@ -1,8 +1,8 @@
import { actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { billingLogic } from 'scenes/billing/billingLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { userLogic } from 'scenes/userLogic'
import { AvailableFeature } from '~/types'
diff --git a/frontend/src/lib/integrations/integrationsLogic.ts b/frontend/src/lib/integrations/integrationsLogic.ts
index 0d3fa313d1d0..79ff0d158c4c 100644
--- a/frontend/src/lib/integrations/integrationsLogic.ts
+++ b/frontend/src/lib/integrations/integrationsLogic.ts
@@ -8,9 +8,9 @@ import api, { ApiError, getCookie } from 'lib/api'
import { globalSetupLogic } from 'lib/components/ProductSetup'
import { describeGithubSetupError, GITHUB_INSTALL_PENDING_MESSAGE } from 'lib/integrations/githubSetupErrors'
import { describeOAuthCallbackError } from 'lib/integrations/oauthCallbackErrors'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { isKeyOf } from 'lib/utils/guards'
import { fromParamsGivenUrl } from 'lib/utils/url'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
diff --git a/frontend/src/lib/integrations/slackIntegrationLogic.ts b/frontend/src/lib/integrations/slackIntegrationLogic.ts
index 8a9d9a3e1b97..8868a95c58f0 100644
--- a/frontend/src/lib/integrations/slackIntegrationLogic.ts
+++ b/frontend/src/lib/integrations/slackIntegrationLogic.ts
@@ -4,7 +4,7 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
import { getRecentSlackChannelIds, slackChannelId } from 'lib/integrations/slackChannel'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { SlackChannelType } from '~/types'
diff --git a/frontend/src/lib/integrations/twilioIntegrationLogic.ts b/frontend/src/lib/integrations/twilioIntegrationLogic.ts
index bcdb5b3c45d8..60c784c002a6 100644
--- a/frontend/src/lib/integrations/twilioIntegrationLogic.ts
+++ b/frontend/src/lib/integrations/twilioIntegrationLogic.ts
@@ -3,7 +3,7 @@ import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { dayjs } from 'lib/dayjs'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { TwilioPhoneNumberType } from '~/types'
diff --git a/frontend/src/lib/introductions/groupsAccessLogic.ts b/frontend/src/lib/introductions/groupsAccessLogic.ts
index f43b2e3a2070..90944fa8b431 100644
--- a/frontend/src/lib/introductions/groupsAccessLogic.ts
+++ b/frontend/src/lib/introductions/groupsAccessLogic.ts
@@ -1,6 +1,6 @@
import { connect, kea, path, selectors } from 'kea'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'
import { userLogic } from 'scenes/userLogic'
diff --git a/frontend/src/lib/lemon-ui/LemonRichContent/LemonRichContentEditor.tsx b/frontend/src/lib/lemon-ui/LemonRichContent/LemonRichContentEditor.tsx
index d8bb842cff1c..0a936c0888d2 100644
--- a/frontend/src/lib/lemon-ui/LemonRichContent/LemonRichContentEditor.tsx
+++ b/frontend/src/lib/lemon-ui/LemonRichContent/LemonRichContentEditor.tsx
@@ -25,8 +25,8 @@ import { LemonFileInput } from 'lib/lemon-ui/LemonFileInput'
import { emojiUsageLogic } from 'lib/lemon-ui/LemonTextArea/emojiUsageLogic'
import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { Spinner } from 'lib/lemon-ui/Spinner'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { cn } from 'lib/utils/css-classes'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
export type LemonRichContentEditorProps = {
logicKey?: string
diff --git a/frontend/src/lib/lemon-ui/LemonTextArea/LemonTextAreaMarkdown.tsx b/frontend/src/lib/lemon-ui/LemonTextArea/LemonTextAreaMarkdown.tsx
index 3c9945aa173a..dc9e871b6b6a 100644
--- a/frontend/src/lib/lemon-ui/LemonTextArea/LemonTextAreaMarkdown.tsx
+++ b/frontend/src/lib/lemon-ui/LemonTextArea/LemonTextAreaMarkdown.tsx
@@ -15,7 +15,7 @@ import { LemonTextArea, LemonTextAreaProps } from 'lib/lemon-ui/LemonTextArea/Le
import { lemonToast } from 'lib/lemon-ui/LemonToast'
import { Spinner } from 'lib/lemon-ui/Spinner'
import { Tooltip } from 'lib/lemon-ui/Tooltip'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+import { preflightLogic } from 'lib/logic/preflightLogic'
export const LemonTextAreaMarkdown = React.forwardRef<HTMLTextAreaElement, LemonTextAreaProps>(
function LemonTextAreaMarkdown({ value, onChange, className, ...editAreaProps }, ref): JSX.Element {
diff --git a/frontend/src/scenes/PreflightCheck/preflightLogic.test.ts b/frontend/src/lib/logic/preflightLogic.test.ts
similarity index 100%
rename from frontend/src/scenes/PreflightCheck/preflightLogic.test.ts
rename to frontend/src/lib/logic/preflightLogic.test.ts
diff --git a/frontend/src/lib/logic/preflightLogic.tsx b/frontend/src/lib/logic/preflightLogic.tsx
new file mode 100644
index 000000000000..07118062f373
--- /dev/null
+++ b/frontend/src/lib/logic/preflightLogic.tsx
@@ -0,0 +1,361 @@
+import { actions, events, kea, listeners, path, reducers, selectors } from 'kea'
+import { loaders } from 'kea-loaders'
+import { actionToUrl, router, urlToAction } from 'kea-router'
+import posthog from 'posthog-js'
+
+import api from 'lib/api'
+import { getAppContext } from 'lib/utils/getAppContext'
+import { urls } from 'scenes/urls'
+
+import { PreflightStatus, Realm } from '~/types'
+
+import type { preflightLogicType } from './preflightLogicType'
+
+export type PreflightMode = 'experimentation' | 'live'
+
+export type PreflightCheckStatus = 'validated' | 'error' | 'warning' | 'optional'
+
+export interface PreflightItem {
+ name: string
+ status: PreflightCheckStatus
+ caption?: string
+ id: string
+}
+
+export interface PreflightCheckSummary {
+ summaryString: string
+ summaryStatus: PreflightCheckStatus
+}
+
+export interface EnvironmentConfigOption {
+ key: string
+ metric: string
+ value: string | undefined
+}
+
+export const preflightLogic = kea<preflightLogicType>([
+ path(['scenes', 'PreflightCheck', 'preflightLogic']),
+ loaders({
+ preflight: [
+ null as PreflightStatus | null,
+ {
+ loadPreflight: async () => {
+ const response = await api.get<PreflightStatus>('_preflight/')
+ return response
+ },
+ },
+ ],
+ }),
+ actions({
+ registerInstrumentationProps: true,
+ setPreflightMode: (mode: PreflightMode | null, noReload?: boolean) => ({ mode, noReload }),
+ handlePreflightFinished: true,
+ setChecksManuallyExpanded: (expanded: boolean | null) => ({ expanded }),
+ revalidatePreflight: true,
+ }),
+ reducers({
+ preflightMode: [
+ null as PreflightMode | null,
+ {
+ setPreflightMode: (_, { mode }) => mode,
+ },
+ ],
+ areChecksManuallyExpanded: [
+ null as boolean | null,
+ {
+ setChecksManuallyExpanded: (_, { expanded }) => expanded,
+ },
+ ],
+ }),
+ selectors({
+ checks: [
+ (s) => [s.preflight, s.preflightMode],
+ (preflight, preflightMode) => {
+ const preflightItems = [
+ {
+ id: 'database',
+ name: 'Application database · Postgres',
+ status: preflight?.db ? 'validated' : 'error',
+ },
+ {
+ id: 'clickhouse',
+ name: 'Analytics database · ClickHouse',
+ status: preflight?.clickhouse ? 'validated' : 'error',
+ },
+ {
+ id: 'kafka',
+ name: 'Queue · Kafka',
+ status: preflight?.kafka ? 'validated' : 'error',
+ },
+ {
+ id: 'backend',
+ name: 'Backend server · Django',
+ status: preflight?.django ? 'validated' : 'error',
+ },
+ {
+ id: 'redis',
+ name: 'Cache · Redis',
+ status: preflight?.redis
+ ? 'validated'
+ : preflightMode === 'experimentation'
+ ? 'warning'
+ : 'error',
+ caption:
+ !preflight?.redis && preflightMode === 'experimentation'
+ ? 'Required in production environments'
+ : undefined,
+ },
+ {
+ id: 'celery',
+ name: 'Background jobs · Celery',
+ status: preflight?.celery
+ ? 'validated'
+ : preflightMode === 'experimentation'
+ ? 'warning'
+ : 'error',
+ caption:
+ !preflight?.celery && preflightMode === 'experimentation'
+ ? 'Required in production environments'
+ : undefined,
+ },
+ {
+ id: 'plugins',
+ name: 'Plugin server · Node',
+ status: preflight?.plugins
+ ? 'validated'
+ : preflightMode === 'experimentation'
+ ? 'warning'
+ : 'error',
+ caption:
+ !preflight?.plugins && preflightMode === 'experimentation'
+ ? 'Required in production environments'
+ : undefined,
+ },
+ {
+ id: 'frontend',
+ name: 'Frontend build · Vite',
+ status: 'validated', // Always validated if we're showing the preflight check
+ },
+ {
+ id: 'tls',
+ name: 'SSL/TLS certificate',
+ status:
+ window.location.protocol === 'https:'
+ ? 'validated'
+ : preflightMode === 'experimentation'
+ ? 'optional'
+ : 'warning',
+ caption:
+ !(window.location.protocol === 'https:') && preflightMode === 'experimentation'
+ ? 'Not required for experimentation mode'
+ : 'Set up before ingesting real user data',
+ },
+ ]
+
+ if (preflight?.object_storage || preflight?.is_debug) {
+ /** __for now__, only prompt debug users if object storage is unhealthy **/
+ preflightItems.push({
+ id: 'object_storage',
+ name: 'Object Storage',
+ status: preflight?.object_storage ? 'validated' : 'warning',
+ caption: preflight?.object_storage
+ ? undefined
+ : 'Some features will not work without object storage',
+ })
+ }
+
+ return preflightItems as PreflightItem[]
+ },
+ ],
+ checksSummary: [
+ (s) => [s.checks],
+ (checks): PreflightCheckSummary => {
+ const statusCounts = {} as Record<PreflightCheckStatus, number>
+ if (checks.length > 0) {
+ for (const check of checks) {
+ statusCounts[check.status] = (statusCounts[check.status] || 0) + 1
+ }
+ }
+
+ let summaryString = ''
+ let summaryStatus: PreflightCheckStatus = 'validated'
+
+ if (statusCounts.validated) {
+ summaryString += `${statusCounts.validated} successful, `
+ }
+ if (statusCounts.warning) {
+ summaryString += `${statusCounts.warning} warning${statusCounts.warning > 1 ? 's' : ''}, `
+ summaryStatus = 'warning'
+ }
+ if (statusCounts.error) {
+ summaryString += `${statusCounts.error} error${statusCounts.error > 1 ? 's' : ''}, `
+ summaryStatus = 'error'
+ }
+ if (statusCounts.optional) {
+ summaryString += `${statusCounts.optional} optional, `
+ }
+
+ return { summaryString: summaryString.slice(0, -2), summaryStatus: summaryStatus }
+ },
+ ],
+ areChecksExpanded: [
+ (s) => [s.checksSummary, s.areChecksManuallyExpanded],
+ (checksSummary, areChecksManuallyExpanded) => {
+ return areChecksManuallyExpanded ?? checksSummary?.summaryStatus !== 'validated'
+ },
+ ],
+ socialAuthAvailable: [
+ (s) => [s.preflight],
+ (preflight): boolean =>
+ Boolean(preflight && Object.values(preflight.available_social_auth_providers).filter((i) => i).length),
+ ],
+ objectStorageAvailable: [
+ (s) => [s.preflight],
+ (preflight): boolean => Boolean(preflight && preflight.object_storage),
+ ],
+ realm: [
+ (s) => [s.preflight],
+ (preflight): Realm | null => {
+ if (!preflight) {
+ return null
+ }
+ return preflight.realm
+ },
+ ],
+ siteUrlMisconfigured: [
+ (s) => [s.preflight],
+ (preflight): boolean => {
+ if (process?.env.STORYBOOK) {
+ // Disable the "site URL misconfigured" warning in Storybook. This is for consistent snapshots
+ // - when opening Storybook in the browser or when updating the snapshots in CI, the origin is
+ // http://localhost:6006, but in the local dockerized setup http://host.docker.internal:6006
+ return false
+ }
+ const isMismatchPresent =
+ !!preflight && (!preflight.site_url || preflight.site_url != window.location.origin)
+ if (
+ isMismatchPresent &&
+ preflight.site_url === 'http://localhost:8010' &&
+ window.location.origin === 'http://localhost:8000'
+ ) {
+ // Local development setup using the old port - we have a warning in DebugNotice for this
+ return false
+ }
+ return isMismatchPresent
+ },
+ ],
+ configOptions: [
+ (s) => [s.preflight],
+ (preflight): EnvironmentConfigOption[] => {
+ // Returns the preflight config options to display in the /instance/status page
+
+ const RELEVANT_CONFIGS = [
+ {
+ key: 'site_url',
+ label: 'Site URL',
+ },
+ ] as const
+
+ if (!preflight) {
+ return []
+ }
+ return RELEVANT_CONFIGS.map((config) => ({
+ key: config.key,
+ metric: config.label,
+ value: preflight[config.key],
+ }))
+ },
+ ],
+ isCloudOrDev: [
+ (s) => [s.preflight],
+ (preflight): boolean | undefined => {
+ return preflight?.cloud || preflight?.is_debug
+ },
+ ],
+ isTest: [(s) => [s.preflight], (preflight) => !!preflight?.is_test],
+ isHobby: [(s) => [s.isCloudOrDev, s.isTest], (isCloudOrDev, isTest) => !isCloudOrDev && !isTest],
+ isCloud: [
+ (s) => [s.preflight],
+ (preflight): boolean | undefined => {
+ return preflight?.cloud
+ },
+ ],
+ isDev: [
+ (s) => [s.preflight],
+ (preflight): boolean | undefined => {
+ return preflight?.is_debug
+ },
+ ],
+ disableNavigationHooks: [
+ (s) => [s.preflight],
+ (preflight): boolean | undefined => {
+ return preflight?.dev_disable_navigation_hooks
+ },
+ ],
+ }),
+ listeners(({ values, actions }) => ({
+ handlePreflightFinished: () => {
+ router.actions.push(urls.signup())
+ },
+ loadPreflightSuccess: () => {
+ actions.registerInstrumentationProps()
+ actions.setChecksManuallyExpanded(values.areChecksManuallyExpanded || null)
+ },
+ registerInstrumentationProps: async (_, breakpoint) => {
+ await breakpoint(100)
+ if (posthog && values.preflight) {
+ const appContext = getAppContext()
+
+ posthog.register({
+ realm: values.realm,
+ email_service_available: values.preflight.email_service_available,
+ slack_service_available: values.preflight.slack_service?.available,
+ commit_sha: appContext?.commit_sha,
+ })
+
+ if (values.preflight.site_url) {
+ posthog.group('instance', values.preflight.site_url, {
+ site_url: values.preflight.site_url,
+ })
+ }
+ }
+ },
+ setPreflightMode: async ({ mode, noReload }) => {
+ if (mode && !noReload) {
+ actions.loadPreflight()
+ }
+ },
+ revalidatePreflight: () => {
+ // The TLS check MUST be in the array returned by the `checks` selector
+ const tlsCheckResult = values.checks.find((check) => check.id === 'tls') as PreflightItem
+ if (tlsCheckResult.status === 'warning') {
+ // Full page reload is needed to revalidate whether the page is served over HTTPS
+ window.location.reload()
+ } else {
+ // Otherwise, just fetch from the preflight endpoint within the logic
+ actions.loadPreflight()
+ }
+ },
+ })),
+ events(({ actions, values }) => ({
+ afterMount: () => {
+ const appContext = getAppContext()
+ const preflight = appContext?.preflight
+ if (preflight) {
+ actions.loadPreflightSuccess(preflight)
+ } else if (!values.preflight) {
+ actions.loadPreflight()
+ }
+ },
+ })),
+ actionToUrl(({ values }) => ({
+ setPreflightMode: () => ['/preflight', { mode: values.preflightMode }],
+ })),
+ urlToAction(({ actions, values }) => ({
+ '/preflight': (_, { mode }) => {
+ if (values.preflightMode !== mode) {
+ actions.setPreflightMode(mode ?? (null as PreflightMode | null), true)
+ }
+ },
+ })),
+])
diff --git a/frontend/src/lib/utils/eventUsageLogic.ts b/frontend/src/lib/utils/eventUsageLogic.ts
index 8a33cdfb9f1e..2ddcdba1ee2a 100644
--- a/frontend/src/lib/utils/eventUsageLogic.ts
+++ b/frontend/src/lib/utils/eventUsageLogic.ts
@@ -5,15 +5,14 @@ import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import type { Dayjs } from 'lib/dayjs'
import { now } from 'lib/dayjs'
import { TimeToSeeDataPayload } from 'lib/internalMetrics'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { objectClean } from 'lib/utils/objects'
import { BillingUsageInteractionProps } from 'scenes/billing/types'
import type { DashboardAddTileType } from 'scenes/dashboard/dashboardAddTileTypes'
import { SharedMetric } from 'scenes/experiments/SharedMetrics/sharedMetricLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { ProductTourEvent } from 'scenes/product-tours/constants'
import { NewSurvey, SURVEY_CREATED_SOURCE, SurveyTemplateType } from 'scenes/surveys/constants'
import { userLogic } from 'scenes/userLogic'
-import { recordWebAnalyticsInteraction } from 'scenes/web-analytics/achievements/recordInteraction'
import {
Breakdown,
@@ -75,8 +74,6 @@ import {
SurveyQuestionType,
} from '~/types'
-import { InteractionKindEnumApi } from 'products/web_analytics/frontend/generated/api.schemas'
-
import type { eventUsageLogicType } from './eventUsageLogicType'
export enum DashboardEventSource {
@@ -2508,19 +2505,15 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
},
reportWebAnalyticsFilterApplied: ({ props }) => {
posthog.capture('web analytics filter applied', props)
- recordWebAnalyticsInteraction(InteractionKindEnumApi.Data)
},
reportWebAnalyticsFilterRemoved: ({ props }) => {
posthog.capture('web analytics filter removed', props)
- recordWebAnalyticsInteraction(InteractionKindEnumApi.Data)
},
reportWebAnalyticsDateRangeChanged: ({ props }) => {
posthog.capture('web analytics date range changed', props)
- recordWebAnalyticsInteraction(InteractionKindEnumApi.Data)
},
reportWebAnalyticsCompareToggled: ({ props }) => {
posthog.capture('web analytics compare toggled', props)
- recordWebAnalyticsInteraction(InteractionKindEnumApi.Data)
},
reportWebAnalyticsConversionGoalSet: ({ props }) => {
posthog.capture('web analytics conversion goal set', props)
@@ -2539,7 +2532,6 @@ export const eventUsageLogic = kea<eventUsageLogicType>([
},
reportWebAnalyticsPathCleaningToggled: ({ props }) => {
posthog.capture('web analytics path cleaning toggled', props)
- recordWebAnalyticsInteraction(InteractionKindEnumApi.Data)
},
// Customer Analytics
reportCustomerAnalyticsDashboardBusinessModeChanged: async ({ business_mode }) => {
diff --git a/frontend/src/scenes/PreflightCheck/preflightLogic.tsx b/frontend/src/scenes/PreflightCheck/preflightLogic.tsx
index 07118062f373..8228705f5340 100644
--- a/frontend/src/scenes/PreflightCheck/preflightLogic.tsx
+++ b/frontend/src/scenes/PreflightCheck/preflightLogic.tsx
@@ -1,361 +1 @@
-import { actions, events, kea, listeners, path, reducers, selectors } from 'kea'
-import { loaders } from 'kea-loaders'
-import { actionToUrl, router, urlToAction } from 'kea-router'
-import posthog from 'posthog-js'
-
-import api from 'lib/api'
-import { getAppContext } from 'lib/utils/getAppContext'
-import { urls } from 'scenes/urls'
-
-import { PreflightStatus, Realm } from '~/types'
-
-import type { preflightLogicType } from './preflightLogicType'
-
-export type PreflightMode = 'experimentation' | 'live'
-
-export type PreflightCheckStatus = 'validated' | 'error' | 'warning' | 'optional'
-
-export interface PreflightItem {
- name: string
- status: PreflightCheckStatus
- caption?: string
- id: string
-}
-
-export interface PreflightCheckSummary {
- summaryString: string
- summaryStatus: PreflightCheckStatus
-}
-
-export interface EnvironmentConfigOption {
- key: string
- metric: string
- value: string | undefined
-}
-
-export const preflightLogic = kea<preflightLogicType>([
- path(['scenes', 'PreflightCheck', 'preflightLogic']),
- loaders({
- preflight: [
- null as PreflightStatus | null,
- {
- loadPreflight: async () => {
- const response = await api.get<PreflightStatus>('_preflight/')
- return response
- },
- },
- ],
- }),
- actions({
- registerInstrumentationProps: true,
- setPreflightMode: (mode: PreflightMode | null, noReload?: boolean) => ({ mode, noReload }),
- handlePreflightFinished: true,
- setChecksManuallyExpanded: (expanded: boolean | null) => ({ expanded }),
- revalidatePreflight: true,
- }),
- reducers({
- preflightMode: [
- null as PreflightMode | null,
- {
- setPreflightMode: (_, { mode }) => mode,
- },
- ],
- areChecksManuallyExpanded: [
- null as boolean | null,
- {
- setChecksManuallyExpanded: (_, { expanded }) => expanded,
- },
- ],
- }),
- selectors({
- checks: [
- (s) => [s.preflight, s.preflightMode],
- (preflight, preflightMode) => {
- const preflightItems = [
- {
- id: 'database',
- name: 'Application database · Postgres',
- status: preflight?.db ? 'validated' : 'error',
- },
- {
- id: 'clickhouse',
- name: 'Analytics database · ClickHouse',
- status: preflight?.clickhouse ? 'validated' : 'error',
- },
- {
- id: 'kafka',
- name: 'Queue · Kafka',
- status: preflight?.kafka ? 'validated' : 'error',
- },
- {
- id: 'backend',
- name: 'Backend server · Django',
- status: preflight?.django ? 'validated' : 'error',
- },
- {
- id: 'redis',
- name: 'Cache · Redis',
- status: preflight?.redis
- ? 'validated'
- : preflightMode === 'experimentation'
- ? 'warning'
- : 'error',
- caption:
- !preflight?.redis && preflightMode === 'experimentation'
- ? 'Required in production environments'
- : undefined,
- },
- {
- id: 'celery',
- name: 'Background jobs · Celery',
- status: preflight?.celery
- ? 'validated'
- : preflightMode === 'experimentation'
- ? 'warning'
- : 'error',
- caption:
- !preflight?.celery && preflightMode === 'experimentation'
- ? 'Required in production environments'
- : undefined,
- },
- {
- id: 'plugins',
- name: 'Plugin server · Node',
- status: preflight?.plugins
- ? 'validated'
- : preflightMode === 'experimentation'
- ? 'warning'
- : 'error',
- caption:
- !preflight?.plugins && preflightMode === 'experimentation'
- ? 'Required in production environments'
- : undefined,
- },
- {
- id: 'frontend',
- name: 'Frontend build · Vite',
- status: 'validated', // Always validated if we're showing the preflight check
- },
- {
- id: 'tls',
- name: 'SSL/TLS certificate',
- status:
- window.location.protocol === 'https:'
- ? 'validated'
- : preflightMode === 'experimentation'
- ? 'optional'
- : 'warning',
- caption:
- !(window.location.protocol === 'https:') && preflightMode === 'experimentation'
- ? 'Not required for experimentation mode'
- : 'Set up before ingesting real user data',
- },
- ]
-
- if (preflight?.object_storage || preflight?.is_debug) {
- /** __for now__, only prompt debug users if object storage is unhealthy **/
- preflightItems.push({
- id: 'object_storage',
- name: 'Object Storage',
- status: preflight?.object_storage ? 'validated' : 'warning',
- caption: preflight?.object_storage
- ? undefined
- : 'Some features will not work without object storage',
- })
- }
-
- return preflightItems as PreflightItem[]
- },
- ],
- checksSummary: [
- (s) => [s.checks],
- (checks): PreflightCheckSummary => {
- const statusCounts = {} as Record<PreflightCheckStatus, number>
- if (checks.length > 0) {
- for (const check of checks) {
- statusCounts[check.status] = (statusCounts[check.status] || 0) + 1
- }
- }
-
- let summaryString = ''
- let summaryStatus: PreflightCheckStatus = 'validated'
-
- if (statusCounts.validated) {
- summaryString += `${statusCounts.validated} successful, `
- }
- if (statusCounts.warning) {
- summaryString += `${statusCounts.warning} warning${statusCounts.warning > 1 ? 's' : ''}, `
- summaryStatus = 'warning'
- }
- if (statusCounts.error) {
- summaryString += `${statusCounts.error} error${statusCounts.error > 1 ? 's' : ''}, `
- summaryStatus = 'error'
- }
- if (statusCounts.optional) {
- summaryString += `${statusCounts.optional} optional, `
- }
-
- return { summaryString: summaryString.slice(0, -2), summaryStatus: summaryStatus }
- },
- ],
- areChecksExpanded: [
- (s) => [s.checksSummary, s.areChecksManuallyExpanded],
- (checksSummary, areChecksManuallyExpanded) => {
- return areChecksManuallyExpanded ?? checksSummary?.summaryStatus !== 'validated'
- },
- ],
- socialAuthAvailable: [
- (s) => [s.preflight],
- (preflight): boolean =>
- Boolean(preflight && Object.values(preflight.available_social_auth_providers).filter((i) => i).length),
- ],
- objectStorageAvailable: [
- (s) => [s.preflight],
- (preflight): boolean => Boolean(preflight && preflight.object_storage),
- ],
- realm: [
- (s) => [s.preflight],
- (preflight): Realm | null => {
- if (!preflight) {
- return null
- }
- return preflight.realm
- },
- ],
- siteUrlMisconfigured: [
- (s) => [s.preflight],
- (preflight): boolean => {
- if (process?.env.STORYBOOK) {
- // Disable the "site URL misconfigured" warning in Storybook. This is for consistent snapshots
- // - when opening Storybook in the browser or when updating the snapshots in CI, the origin is
- // http://localhost:6006, but in the local dockerized setup http://host.docker.internal:6006
- return false
- }
- const isMismatchPresent =
- !!preflight && (!preflight.site_url || preflight.site_url != window.location.origin)
- if (
- isMismatchPresent &&
- preflight.site_url === 'http://localhost:8010' &&
- window.location.origin === 'http://localhost:8000'
- ) {
- // Local development setup using the old port - we have a warning in DebugNotice for this
- return false
- }
- return isMismatchPresent
- },
- ],
- configOptions: [
- (s) => [s.preflight],
- (preflight): EnvironmentConfigOption[] => {
- // Returns the preflight config options to display in the /instance/status page
-
- const RELEVANT_CONFIGS = [
- {
- key: 'site_url',
- label: 'Site URL',
- },
- ] as const
-
- if (!preflight) {
- return []
- }
- return RELEVANT_CONFIGS.map((config) => ({
- key: config.key,
- metric: config.label,
- value: preflight[config.key],
- }))
- },
- ],
- isCloudOrDev: [
- (s) => [s.preflight],
- (preflight): boolean | undefined => {
- return preflight?.cloud || preflight?.is_debug
- },
- ],
- isTest: [(s) => [s.preflight], (preflight) => !!preflight?.is_test],
- isHobby: [(s) => [s.isCloudOrDev, s.isTest], (isCloudOrDev, isTest) => !isCloudOrDev && !isTest],
- isCloud: [
- (s) => [s.preflight],
- (preflight): boolean | undefined => {
- return preflight?.cloud
- },
- ],
- isDev: [
- (s) => [s.preflight],
- (preflight): boolean | undefined => {
- return preflight?.is_debug
- },
- ],
- disableNavigationHooks: [
- (s) => [s.preflight],
- (preflight): boolean | undefined => {
- return preflight?.dev_disable_navigation_hooks
- },
- ],
- }),
- listeners(({ values, actions }) => ({
- handlePreflightFinished: () => {
- router.actions.push(urls.signup())
- },
- loadPreflightSuccess: () => {
- actions.registerInstrumentationProps()
- actions.setChecksManuallyExpanded(values.areChecksManuallyExpanded || null)
- },
- registerInstrumentationProps: async (_, breakpoint) => {
- await breakpoint(100)
- if (posthog && values.preflight) {
- const appContext = getAppContext()
-
- posthog.register({
- realm: values.realm,
- email_service_available: values.preflight.email_service_available,
- slack_service_available: values.preflight.slack_service?.available,
- commit_sha: appContext?.commit_sha,
- })
-
- if (values.preflight.site_url) {
- posthog.group('instance', values.preflight.site_url, {
- site_url: values.preflight.site_url,
- })
- }
- }
- },
- setPreflightMode: async ({ mode, noReload }) => {
- if (mode && !noReload) {
- actions.loadPreflight()
- }
- },
- revalidatePreflight: () => {
- // The TLS check MUST be in the array returned by the `checks` selector
- const tlsCheckResult = values.checks.find((check) => check.id === 'tls') as PreflightItem
- if (tlsCheckResult.status === 'warning') {
- // Full page reload is needed to revalidate whether the page is served over HTTPS
- window.location.reload()
- } else {
- // Otherwise, just fetch from the preflight endpoint within the logic
- actions.loadPreflight()
- }
- },
- })),
- events(({ actions, values }) => ({
- afterMount: () => {
- const appContext = getAppContext()
- const preflight = appContext?.preflight
- if (preflight) {
- actions.loadPreflightSuccess(preflight)
- } else if (!values.preflight) {
- actions.loadPreflight()
- }
- },
- })),
- actionToUrl(({ values }) => ({
- setPreflightMode: () => ['/preflight', { mode: values.preflightMode }],
- })),
- urlToAction(({ actions, values }) => ({
- '/preflight': (_, { mode }) => {
- if (values.preflightMode !== mode) {
- actions.setPreflightMode(mode ?? (null as PreflightMode | null), true)
- }
- },
- })),
-])
+export * from 'lib/logic/preflightLogic'
diff --git a/frontend/src/scenes/web-analytics/CrossSellButtons/ReplayButton.tsx b/frontend/src/scenes/web-analytics/CrossSellButtons/ReplayButton.tsx
index 0796199e55f0..4fa4564b4823 100644
--- a/frontend/src/scenes/web-analytics/CrossSellButtons/ReplayButton.tsx
+++ b/frontend/src/scenes/web-analytics/CrossSellButtons/ReplayButton.tsx
@@ -2,7 +2,7 @@ import posthog from 'posthog-js'
import ViewRecordingsPlaylistButton from 'lib/components/ViewRecordingButton/ViewRecordingsPlaylistButton'
import { addProductIntentForCrossSell } from 'lib/utils/product-intents'
-import { recordWebAnalyticsInteraction } from 'scenes/web-analytics/achievements/recordInteraction'
+import { webAnalyticsAchievementsLogic } from 'scenes/web-analytics/achievements/webAnalyticsAchievementsLogic'
import { BREAKDOWN_NULL_DISPLAY } from 'scenes/web-analytics/common'
import {
@@ -146,7 +146,7 @@ export const ReplayButton = ({
const handleClick = (e: React.MouseEvent): void => {
e.stopPropagation()
posthog.capture('web_analytics_recording_opened', { breakdown_by: breakdownBy })
- recordWebAnalyticsInteraction(InteractionKindEnumApi.Recording)
+ webAnalyticsAchievementsLogic.findMounted()?.actions.recordInteraction(InteractionKindEnumApi.Recording)
void addProductIntentForCrossSell({
from: ProductKey.WEB_ANALYTICS,
to: ProductKey.SESSION_REPLAY,
diff --git a/frontend/src/scenes/web-analytics/achievements/recordInteraction.ts b/frontend/src/scenes/web-analytics/achievements/recordInteraction.ts
deleted file mode 100644
index f23e085841e5..000000000000
--- a/frontend/src/scenes/web-analytics/achievements/recordInteraction.ts
+++ /dev/null
@@ -1,26 +0,0 @@
-import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
-import { teamLogic } from 'scenes/teamLogic'
-
-import { webAnalyticsAchievementsRecordInteraction } from 'products/web_analytics/frontend/generated/api'
-import { InteractionKindEnumApi } from 'products/web_analytics/frontend/generated/api.schemas'
-
-import { isWebAnalyticsAchievementsEnabled } from './gating'
-import { webAnalyticsAchievementsLogic } from './webAnalyticsAchievementsLogic'
-import { webAnalyticsAchievementsPreferencesLogic } from './webAnalyticsAchievementsPreferencesLogic'
-
-export function recordWebAnalyticsInteraction(kind: InteractionKindEnumApi): void {
- const featureFlags = featureFlagLogic.findMounted()?.values.featureFlags
- const optedOut = webAnalyticsAchievementsPreferencesLogic.findMounted()?.values.achievementsOptOut
- if (!featureFlags || !isWebAnalyticsAchievementsEnabled(featureFlags, optedOut)) {
- return
- }
- const projectId = teamLogic.findMounted()?.values.currentProjectId
- if (projectId === undefined || projectId === null) {
- return
- }
- void webAnalyticsAchievementsRecordInteraction(String(projectId), { interaction_kind: kind })
- .then(() => {
- webAnalyticsAchievementsLogic.findMounted()?.actions.loadAchievements()
- })
- .catch(() => {})
-}
diff --git a/frontend/src/scenes/web-analytics/achievements/webAnalyticsAchievementsLogic.test.ts b/frontend/src/scenes/web-analytics/achievements/webAnalyticsAchievementsLogic.test.ts
index 4bfbbb145e9e..f8e2bd711748 100644
--- a/frontend/src/scenes/web-analytics/achievements/webAnalyticsAchievementsLogic.test.ts
+++ b/frontend/src/scenes/web-analytics/achievements/webAnalyticsAchievementsLogic.test.ts
@@ -1,6 +1,9 @@
import { expectLogic } from 'kea-test-utils'
+import { FEATURE_FLAGS } from 'lib/constants'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { useMocks } from '~/mocks/jest'
import { initKeaTests } from '~/test/init'
@@ -12,6 +15,7 @@ import { webAnalyticsAchievementsLogic } from './webAnalyticsAchievementsLogic'
const OVERVIEW_URL = '/api/projects/:team_id/web_analytics_achievements/overview/'
const ACKNOWLEDGE_URL = '/api/projects/:team_id/web_analytics_achievements/acknowledge_celebration/'
const PREFERENCES_URL = '/api/projects/:team_id/web_analytics_achievements/preferences/'
+const RECORD_INTERACTION_URL = '/api/projects/:team_id/web_analytics_achievements/record_interaction/'
const MOCK_OVERVIEW: AchievementsListResponseApi = {
definitions: [],
@@ -59,9 +63,11 @@ const DEFS_OVERVIEW: AchievementsListResponseApi = {
describe('webAnalyticsAchievementsLogic', () => {
let logic: ReturnType<typeof webAnalyticsAchievementsLogic.build>
let lastAck: { track_key: string; stage: number } | null
+ let lastInteraction: { interaction_kind: string } | null
beforeEach(() => {
lastAck = null
+ lastInteraction = null
jest.spyOn(lemonToast, 'success').mockReturnValue('mock-toast-id')
initKeaTests()
useMocks({
@@ -74,6 +80,10 @@ describe('webAnalyticsAchievementsLogic', () => {
lastAck = (await request.json()) as { track_key: string; stage: number }
return [200, { acknowledged: true }]
},
+ [RECORD_INTERACTION_URL]: async ({ request }) => {
+ lastInteraction = (await request.json()) as { interaction_kind: string }
+ return [200, { recorded: true }]
+ },
},
})
logic = webAnalyticsAchievementsLogic()
@@ -204,6 +214,45 @@ describe('webAnalyticsAchievementsLogic', () => {
expect(logic.values.sortedTeamTracks.map((track) => track.key)).toEqual(['traffic'])
})
+ describe('interaction recording', () => {
+ const enableAchievements = (): void => {
+ featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.WEB_ANALYTICS_ACHIEVEMENTS]: true,
+ [FEATURE_FLAGS.WEB_ANALYTICS_STREAK_CADENCE]: 'daily',
+ })
+ }
+
+ it.each([
+ 'reportWebAnalyticsFilterApplied',
+ 'reportWebAnalyticsFilterRemoved',
+ 'reportWebAnalyticsDateRangeChanged',
+ 'reportWebAnalyticsCompareToggled',
+ 'reportWebAnalyticsPathCleaningToggled',
+ ] as const)('records a data interaction when %s fires', async (report) => {
+ enableAchievements()
+ await expectLogic(logic, () => {
+ eventUsageLogic.mount()
+ eventUsageLogic.actions[report]({} as any)
+ })
+ .toDispatchActions(['recordInteraction'])
+ .toFinishAllListeners()
+ expect(lastInteraction).toEqual({ interaction_kind: 'data' })
+ })
+
+ it('does not post an interaction when achievements are disabled', async () => {
+ featureFlagLogic.actions.setFeatureFlags([], {
+ [FEATURE_FLAGS.WEB_ANALYTICS_ACHIEVEMENTS]: false,
+ })
+ await expectLogic(logic, () => {
+ eventUsageLogic.mount()
+ eventUsageLogic.actions.reportWebAnalyticsFilterApplied({} as any)
+ })
+ .toDispatchActions(['recordInteraction'])
+ .toFinishAllListeners()
+ expect(lastInteraction).toBeNull()
+ })
+ })
+
it('toggles expanded tracks and clears them when the modal closes', async () => {
await expectLogic(logic, () => {
logic.actions.toggleTrackExpanded('explorer')
diff --git a/frontend/src/scenes/web-analytics/achievements/webAnalyticsAchievementsLogic.ts b/frontend/src/scenes/web-analytics/achievements/webAnalyticsAchievementsLogic.ts
index 48440decf2f9..f25788b78545 100644
--- a/frontend/src/scenes/web-analytics/achievements/webAnalyticsAchievementsLogic.ts
+++ b/frontend/src/scenes/web-analytics/achievements/webAnalyticsAchievementsLogic.ts
@@ -4,17 +4,20 @@ import posthog from 'posthog-js'
import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'
import { featureFlagLogic } from 'lib/logic/featureFlagLogic'
+import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { teamLogic } from 'scenes/teamLogic'
import {
webAnalyticsAchievementsAcknowledgeCelebration,
webAnalyticsAchievementsOverview,
+ webAnalyticsAchievementsRecordInteraction,
} from 'products/web_analytics/frontend/generated/api'
-import type {
- AchievementDefinitionApi,
- AchievementProgressApi,
- AchievementsListResponseApi,
- PendingCelebrationApi,
+import {
+ type AchievementDefinitionApi,
+ type AchievementProgressApi,
+ type AchievementsListResponseApi,
+ InteractionKindEnumApi,
+ type PendingCelebrationApi,
} from 'products/web_analytics/frontend/generated/api.schemas'
import { deriveTrackProgress } from './achievementProgress'
@@ -55,6 +58,7 @@ export const webAnalyticsAchievementsLogic = kea<webAnalyticsAchievementsLogicTy
openModal: true,
closeModal: true,
acknowledgeCelebration: (trackKey: string, stage: number) => ({ trackKey, stage }),
+ recordInteraction: (kind: InteractionKindEnumApi) => ({ kind }),
markCelebrated: (key: string) => ({ key }),
triggerConfetti: true,
toggleTrackExpanded: (trackKey: string) => ({ trackKey }),
@@ -218,6 +222,39 @@ export const webAnalyticsAchievementsLogic = kea<webAnalyticsAchievementsLogicTy
actions.loadAchievements()
}
},
+ recordInteraction: async ({ kind }) => {
+ if (!isWebAnalyticsAchievementsEnabled(values.featureFlags, values.achievementsOptOut)) {
+ return
+ }
+ if (values.currentProjectId === undefined || values.currentProjectId === null) {
+ return
+ }
+ try {
+ await webAnalyticsAchievementsRecordInteraction(String(values.currentProjectId), {
+ interaction_kind: kind,
+ })
+ actions.loadAchievements()
+ } catch {
+ // best-effort gamification signal: never surface recording failures
+ }
+ },
+ // Dashboard interactions count toward achievements. These reports fire only from web
+ // analytics UI, where this logic is mounted via the scene menu bar.
+ [eventUsageLogic.actionTypes.reportWebAnalyticsFilterApplied]: () => {
+ actions.recordInteraction(InteractionKindEnumApi.Data)
+ },
+ [eventUsageLogic.actionTypes.reportWebAnalyticsFilterRemoved]: () => {
+ actions.recordInteraction(InteractionKindEnumApi.Data)
+ },
+ [eventUsageLogic.actionTypes.reportWebAnalyticsDateRangeChanged]: () => {
+ actions.recordInteraction(InteractionKindEnumApi.Data)
+ },
+ [eventUsageLogic.actionTypes.reportWebAnalyticsCompareToggled]: () => {
+ actions.recordInteraction(InteractionKindEnumApi.Data)
+ },
+ [eventUsageLogic.actionTypes.reportWebAnalyticsPathCleaningToggled]: () => {
+ actions.recordInteraction(InteractionKindEnumApi.Data)
+ },
})),
afterMount(({ actions, values }) => {
if (values.preferences && isWebAnalyticsAchievementsEnabled(values.featureFlags, values.achievementsOptOut)) {
diff --git a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
index 31db80da5b2c..5913d24c91f2 100644
--- a/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
+++ b/products/subscriptions/frontend/components/Subscriptions/views/EditSubscription.tsx
@@ -25,10 +25,10 @@ import { LemonSelect } from 'lib/lemon-ui/LemonSelect'
import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'
import { LemonSwitch } from 'lib/lemon-ui/LemonSwitch'
import { Spinner } from 'lib/lemon-ui/Spinner/Spinner'
+import { preflightLogic } from 'lib/logic/preflightLogic'
import { maxGlobalLogic } from 'scenes/max/maxGlobalLogic'
import { membersLogic } from 'scenes/organization/membersLogic'
import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { AIConsentPopoverWrapper } from 'scenes/settings/organization/AIConsentPopoverWrapper'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'