Files
zeekay 1b367e2b62 chore: rebase the tree onto upstream master
The tree was a debranded snapshot of upstream taken around 2026-02-20, and
upstream has moved about five months since. This replaces it with upstream
master, mechanically re-derived: bin/debrand does the rename, and the
pipeline and squashed migrations are restored from the shipped tree.

Not a merge. The previous import replaced the tree wholesale in a single
commit, so there is no shared content history to merge against. Reproducing
the rename on the new tree is what actually converges.

What survives: .hanzo/workflows, the Dockerfiles and bin/docker* entrypoints,
compose files, LLM.md, and insights/migrations. The squashed initial
migration is load-bearing — the live database records it by name, so
upstream's ~918 individual migrations cannot come back.

Nine products are dropped as unreferenced. Twenty-one more that we do not run
are kept anyway because the core app still imports them; unpicking those is a
refactor and does not belong in a rebase.

This base does not build yet, and the reasons are not in the rename:
upstream now wants Python 3.13.13 against our 3.12.12 and Django 5.2 against
our 4.2, and the dependency manifests still name upstream packages that we
republish under our own names. Those are decisions, not renames.
2026-08-01 15:44:40 -07:00

110 lines
4.4 KiB
TypeScript

import { useActions, useMountedLogic, useValues } from 'kea'
import { Banner, Tabs } from '@hanzo/elements'
import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'
import { sceneConfigurations } from 'scenes/scenes'
import { Scene, SceneExport } from 'scenes/sceneTypes'
import { FeaturePreviewSceneGate } from '~/layout/scenes/components/FeaturePreviewSceneGate'
import { SceneContent } from '~/layout/scenes/components/SceneContent'
import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'
import { ProductKey } from '~/queries/schema/schema-general'
import { AccessControlLevel, AccessControlResourceType } from '~/types'
import { MetricsSetupPrompt } from './components/MetricsSetupPrompt'
import { MetricsSqlEditor } from './components/MetricsSqlEditor'
import { metricsUsageTrackingLogic } from './components/metricsUsageTrackingLogic'
import { MetricsViewer } from './components/MetricsViewer'
import { metricsFeaturePreviewGate } from './featurePreviewGate'
import { metricsIngestionLogic } from './metricsIngestionLogic'
import { MetricsSceneActiveTab, metricsSceneLogic } from './metricsSceneLogic'
export const METRICS_LOGIC_KEY = 'metrics'
const TABS: { key: MetricsSceneActiveTab; label: string; 'data-attr': string }[] = [
{ key: 'viewer', label: 'Viewer', 'data-attr': 'metrics-scene-tab-viewer' },
{ key: 'sql', label: 'SQL', 'data-attr': 'metrics-scene-tab-sql' },
]
export const scene: SceneExport = {
component: MetricsScene,
logic: metricsSceneLogic,
productKey: ProductKey.METRICS,
}
export function MetricsScene(): JSX.Element {
return (
<FeaturePreviewSceneGate config={metricsFeaturePreviewGate}>
<SceneContent className="h-[calc(var(--scene-layout-rect-height,_100vh)_-_1rem)]">
<MetricsSceneContent />
</SceneContent>
</FeaturePreviewSceneGate>
)
}
const MetricsSceneContent = (): JSX.Element => {
const { activeTab } = useValues(metricsSceneLogic)
const { setActiveTab } = useActions(metricsSceneLogic)
const { teamHasMetricsCheckFailed } = useValues(metricsIngestionLogic)
const metricsViewerDisabledReason = getAccessControlDisabledReason(
AccessControlResourceType.Metrics,
AccessControlLevel.Viewer
)
const metricsSqlDisabledReason = getAccessControlDisabledReason(
AccessControlResourceType.WarehouseObjects,
AccessControlLevel.Viewer
)
const tabDisabledReasons: Record<MetricsSceneActiveTab, string | null> = {
viewer: metricsViewerDisabledReason,
sql: metricsSqlDisabledReason,
}
// Scene-level so tab switches in both directions are captured; keeps the viewer
// and samples logics (its connect targets) mounted across tab flips as a side effect.
useMountedLogic(metricsUsageTrackingLogic)
return (
<>
<SceneTitleSection
name={sceneConfigurations[Scene.Metrics].name}
description={sceneConfigurations[Scene.Metrics].description}
resourceType={{
type: sceneConfigurations[Scene.Metrics].iconType || 'default_icon_type',
}}
/>
{teamHasMetricsCheckFailed && (
<Banner
type="info"
dismissKey="metrics-setup-hint-banner"
action={{
to: 'https://hanzo.ai/docs/metrics',
targetBlank: true,
children: 'Setup guide',
}}
>
Unable to verify metrics setup. If you haven't configured metrics yet, check out our setup guide.
</Banner>
)}
<Tabs<MetricsSceneActiveTab>
activeKey={activeTab}
onChange={(tab) => {
if (!tabDisabledReasons[tab]) {
setActiveTab(tab)
}
}}
tabs={TABS.map((tab) => ({
...tab,
disabledReason: tabDisabledReasons[tab.key] ?? undefined,
}))}
sceneInset
/>
<MetricsSetupPrompt>
<div className="flex flex-col gap-2 py-2 flex-1 min-h-0">
{activeTab === 'viewer' && <MetricsViewer />}
{activeTab === 'sql' && <MetricsSqlEditor />}
</div>
</MetricsSetupPrompt>
</>
)
}