Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(wizard): add warehouse_destination_type to the tool catalog (#128056)

Tom Owers55832a0872c6
diff --git a/products/wizard/backend/facade/api.py b/products/wizard/backend/facade/api.py
index 2a764844f6a2..2fdb9d45f461 100644
--- a/products/wizard/backend/facade/api.py
+++ b/products/wizard/backend/facade/api.py
@@ -50,6 +50,7 @@ from products.wizard.backend.logic.installs import service as installs
from products.wizard.backend.logic.runs import pubsub as run_pubsub
from products.wizard.backend.logic.sessions import pubsub
from products.wizard.backend.tool_catalog.catalog import tool_catalog_json
+from products.wizard.backend.tool_catalog.warehouse_destinations import CATALOG_DESTINATION_CHOICES
def upsert(params: UpsertWizardSessionInput) -> tuple[WizardSessionDTO, bool]:
@@ -66,6 +67,9 @@ def organization_has_detected_tool(*, organization_id: str, kinds: Collection[st
return scans.organization_has_detected_tool(organization_id=organization_id, kinds=kinds)
+TOOL_CATALOG_DESTINATION_CHOICES: list[tuple[str, str]] = CATALOG_DESTINATION_CHOICES
+
+
def get_tool_catalog_json() -> bytes:
return tool_catalog_json()
diff --git a/products/wizard/backend/presentation/tool_catalog/serializers.py b/products/wizard/backend/presentation/tool_catalog/serializers.py
index 84079e774548..d6419d31119f 100644
--- a/products/wizard/backend/presentation/tool_catalog/serializers.py
+++ b/products/wizard/backend/presentation/tool_catalog/serializers.py
@@ -3,6 +3,8 @@ from django.db.models import TextChoices
from drf_spectacular.utils import extend_schema_serializer
from rest_framework import serializers
+from products.wizard.backend.facade import api as wizard_facade
+
class WizardSetupMode(TextChoices):
IN_CLI = "in-cli", "In the terminal"
@@ -31,6 +33,11 @@ class WizardCatalogToolSerializer(serializers.Serializer):
allow_null=True,
help_text="Data warehouse source type the tool imports as, or null for a tool with no warehouse source.",
)
+ warehouse_destination_type = serializers.ChoiceField(
+ choices=wizard_facade.TOOL_CATALOG_DESTINATION_CHOICES,
+ allow_null=True,
+ help_text="Warehouse destination PostHog can send data to when the tool is that warehouse, or null for any other tool.",
+ )
wizard_setup_mode = serializers.ChoiceField(
choices=WizardSetupMode.choices,
allow_null=True,
diff --git a/products/wizard/backend/tests/test_tool_catalog_presentation.py b/products/wizard/backend/tests/test_tool_catalog_presentation.py
index e8a1f0597f94..2f65697e2241 100644
--- a/products/wizard/backend/tests/test_tool_catalog_presentation.py
+++ b/products/wizard/backend/tests/test_tool_catalog_presentation.py
@@ -1,14 +1,22 @@
import json
from pathlib import Path
+import pytest
from unittest.mock import patch
from django.test import TestCase
from rest_framework import status
+from products.warehouse_sources.backend.facade.types import ExternalDataSourceType
from products.wizard.backend.presentation.tool_catalog.serializers import WizardToolCatalogSerializer
from products.wizard.backend.tool_catalog import catalog
+from products.wizard.backend.tool_catalog.posthog_alternatives import POSTHOG_ALTERNATIVES_WITHOUT_SOURCE
+from products.wizard.backend.tool_catalog.warehouse_destinations import (
+ CATALOG_DESTINATION_CHOICES,
+ WAREHOUSE_DESTINATION_BY_KIND,
+ warehouse_destination_type,
+)
class TestWizardToolCatalogViewSet(TestCase):
@@ -42,3 +50,70 @@ class TestWizardToolCatalogViewSet(TestCase):
assert serializer.is_valid(), serializer.errors
# is_valid() drops keys the serializer does not declare, so equality catches an undocumented field.
assert serializer.validated_data == document
+
+
+def rendered_tools() -> dict[str, dict]:
+ document = catalog.build_catalog_document()
+ return {tool["kind"]: tool for tool in document["tools"]}
+
+
+ "kind,expected",
+ [
+ ("Postgres", None),
+ ("BigQuery", "BigQuery"),
+ ("Snowflake", "Snowflake"),
+ ("Redshift", "Redshift"),
+ ("Databricks", "Databricks"),
+ ("AmazonS3", "S3"),
+ ("AzureBlob", "AzureBlob"),
+ ("Supabase", None),
+ ("Neon", None),
+ ("Stripe", None),
+ ("not-a-kind", None),
+ ],
+)
+def test_warehouse_destination_type_by_kind(kind: str, expected: str | None) -> None:
+ assert warehouse_destination_type(kind) == expected
+
+
+ "kind,expected",
+ [
+ ("Postgres", None),
+ ("BigQuery", "BigQuery"),
+ ("Snowflake", "Snowflake"),
+ ("Redshift", "Redshift"),
+ ("Databricks", "Databricks"),
+ ("AmazonS3", "S3"),
+ ("AzureBlob", "AzureBlob"),
+ ("Supabase", None),
+ ("Neon", None),
+ ],
+)
+def test_rendered_document_emits_destination_type(
+ rendered_tools: dict[str, dict], kind: str, expected: str | None
+) -> None:
+ if kind not in rendered_tools:
+ pytest.skip(f"{kind} has no codebase detection")
+ assert rendered_tools[kind]["warehouse_destination_type"] == expected
+
+
+def test_every_tool_emits_the_field_with_a_valid_value(rendered_tools: dict[str, dict]) -> None:
+ valid = {value for value, _ in CATALOG_DESTINATION_CHOICES}
+ assert len(valid) == 7
+ for tool in rendered_tools.values():
+ assert "warehouse_destination_type" in tool
+ assert tool["warehouse_destination_type"] is None or tool["warehouse_destination_type"] in valid
+
+
+def test_posthog_alternatives_have_no_destination_type(rendered_tools: dict[str, dict]) -> None:
+ assert POSTHOG_ALTERNATIVES_WITHOUT_SOURCE
+ for kind in POSTHOG_ALTERNATIVES_WITHOUT_SOURCE:
+ assert rendered_tools[kind]["warehouse_destination_type"] is None
+
+
+def test_mapped_kinds_are_known_source_types() -> None:
+ source_values = {source_type.value for source_type in ExternalDataSourceType}
+ assert set(WAREHOUSE_DESTINATION_BY_KIND) <= source_values
diff --git a/products/wizard/backend/tool_catalog/catalog.py b/products/wizard/backend/tool_catalog/catalog.py
index 2227405537b3..ab82aa0e2bf9 100644
--- a/products/wizard/backend/tool_catalog/catalog.py
+++ b/products/wizard/backend/tool_catalog/catalog.py
@@ -15,6 +15,7 @@ from products.warehouse_sources.backend.facade.codebase_detection import Detecti
from products.warehouse_sources.backend.facade.source_management import SourceRegistry, load_all_sources_or_raise
from products.wizard.backend.tool_catalog.posthog_alternatives import POSTHOG_ALTERNATIVES_WITHOUT_SOURCE
from products.wizard.backend.tool_catalog.types import Tool, ToolClassification
+from products.wizard.backend.tool_catalog.warehouse_destinations import warehouse_destination_type
# Bump when the JSON shape changes in a way an older wizard cannot read.
CATALOG_SCHEMA_VERSION = 1
@@ -29,13 +30,21 @@ def get_tool_catalog() -> tuple[Tool, ...]:
label=source.get_source_config.label or source_type.value,
warehouse_source_type=source_type,
detection=source.codebase_detection,
+ warehouse_destination_type=warehouse_destination_type(source_type.value),
setup_requires_ui=source.setup_requires_ui or fields_require_ui(source.get_source_config.fields),
)
for source_type, source in SourceRegistry.get_all_sources().items()
if isinstance(source.codebase_detection, Detection)
]
tools += [
- Tool(kind=kind, label=kind, warehouse_source_type=None, detection=detection, setup_requires_ui=None)
+ Tool(
+ kind=kind,
+ label=kind,
+ warehouse_source_type=None,
+ detection=detection,
+ warehouse_destination_type=None,
+ setup_requires_ui=None,
+ )
for kind, detection in POSTHOG_ALTERNATIVES_WITHOUT_SOURCE.items()
]
return tuple(sorted(tools, key=lambda tool: tool.kind))
@@ -47,6 +56,7 @@ def build_catalog_document() -> dict[str, Any]:
"kind": tool.kind,
"label": tool.label,
"warehouse_source_type": tool.warehouse_source_type.value if tool.warehouse_source_type else None,
+ "warehouse_destination_type": tool.warehouse_destination_type,
"wizard_setup_mode": None
if tool.setup_requires_ui is None
else ("deep-link" if tool.setup_requires_ui else "in-cli"),
diff --git a/products/wizard/backend/tool_catalog/types.py b/products/wizard/backend/tool_catalog/types.py
index 84773bbda386..f57065464cb5 100644
--- a/products/wizard/backend/tool_catalog/types.py
+++ b/products/wizard/backend/tool_catalog/types.py
@@ -10,6 +10,8 @@ class Tool:
label: str
warehouse_source_type: ExternalDataSourceType | None
detection: Detection
+ # The warehouse destination this tool is, when PostHog can send data to it.
+ warehouse_destination_type: str | None
# Whether the wizard sends the user to the app to create the source. None for a tool with no source.
setup_requires_ui: bool | None
diff --git a/products/wizard/backend/tool_catalog/warehouse_destinations.py b/products/wizard/backend/tool_catalog/warehouse_destinations.py
new file mode 100644
index 000000000000..3b65f08f6cfe
--- /dev/null
+++ b/products/wizard/backend/tool_catalog/warehouse_destinations.py
@@ -0,0 +1,24 @@
+from products.warehouse_sources.backend.facade.models import ExternalDataDestination
+from products.warehouse_sources.backend.facade.types import ExternalDataSourceType
+
+DestinationType = ExternalDataDestination.Type
+
+# Tools that are also an analytics warehouse PostHog can send data to, keyed by tool kind.
+# Postgres is left out: in a codebase it is almost always the app's own database.
+WAREHOUSE_DESTINATION_BY_KIND: dict[str, str] = {
+ ExternalDataSourceType.BIGQUERY.value: DestinationType.BIGQUERY.value,
+ ExternalDataSourceType.SNOWFLAKE.value: DestinationType.SNOWFLAKE.value,
+ ExternalDataSourceType.REDSHIFT.value: DestinationType.REDSHIFT.value,
+ ExternalDataSourceType.DATABRICKS.value: DestinationType.DATABRICKS.value,
+ ExternalDataSourceType.AMAZONS3.value: DestinationType.S3.value,
+ ExternalDataSourceType.AZUREBLOB.value: DestinationType.AZURE_BLOB.value,
+}
+
+# The catalog advertises every destination except PostHog's own.
+CATALOG_DESTINATION_CHOICES: list[tuple[str, str]] = [
+ (value, str(label)) for value, label in DestinationType.choices if value != DestinationType.POSTHOG_WAREHOUSE.value
+]
+
+
+def warehouse_destination_type(kind: str) -> str | None:
+ return WAREHOUSE_DESTINATION_BY_KIND.get(kind)
diff --git a/products/wizard/frontend/generated/api.schemas.ts b/products/wizard/frontend/generated/api.schemas.ts
index 1fec823fa99f..789bf993f0dd 100644
--- a/products/wizard/frontend/generated/api.schemas.ts
+++ b/products/wizard/frontend/generated/api.schemas.ts
@@ -776,6 +776,28 @@ export interface UpsertWizardSessionRequestApi {
error?: UpsertWizardSessionRequestApiError
}
+/**
+ * * `Redshift` - Redshift
+ * * `Snowflake` - Snowflake
+ * * `BigQuery` - BigQuery
+ * * `Postgres` - Postgres
+ * * `Databricks` - Databricks
+ * * `AzureBlob` - Azure Blob
+ * * `S3` - S3
+ */
+export type UserCreatableDestinationTypeEnumApi =
+ (typeof UserCreatableDestinationTypeEnumApi)[keyof typeof UserCreatableDestinationTypeEnumApi]
+
+export const UserCreatableDestinationTypeEnumApi = {
+ Redshift: 'Redshift',
+ Snowflake: 'Snowflake',
+ BigQuery: 'BigQuery',
+ Postgres: 'Postgres',
+ Databricks: 'Databricks',
+ AzureBlob: 'AzureBlob',
+ S3: 'S3',
+} as const
+
/**
* * `in-cli` - In the terminal
* * `deep-link` - In the app
@@ -811,6 +833,16 @@ export interface WizardCatalogToolApi {
* @nullable
*/
warehouse_source_type: string | null
+ /** Warehouse destination PostHog can send data to when the tool is that warehouse, or null for any other tool.
+ *
+ * * `Redshift` - Redshift
+ * * `Snowflake` - Snowflake
+ * * `BigQuery` - BigQuery
+ * * `Postgres` - Postgres
+ * * `Databricks` - Databricks
+ * * `AzureBlob` - Azure Blob
+ * * `S3` - S3 */
+ warehouse_destination_type: UserCreatableDestinationTypeEnumApi | null
/** How the wizard sets up the source: in the terminal or in the app. Null for a tool with no warehouse source.
*
* * `in-cli` - In the terminal
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 5850d9411678..afc4831347e2 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -124487,6 +124487,28 @@ export namespace Schemas {
connected_at?: string | null;
}
+ /**
+ * * `Redshift` - Redshift
+ * * `Snowflake` - Snowflake
+ * * `BigQuery` - BigQuery
+ * * `Postgres` - Postgres
+ * * `Databricks` - Databricks
+ * * `AzureBlob` - Azure Blob
+ * * `S3` - S3
+ */
+ export type UserCreatableDestinationTypeEnum = typeof UserCreatableDestinationTypeEnum[keyof typeof UserCreatableDestinationTypeEnum];
+
+
+ export const UserCreatableDestinationTypeEnum = {
+ Redshift: 'Redshift',
+ Snowflake: 'Snowflake',
+ BigQuery: 'BigQuery',
+ Postgres: 'Postgres',
+ Databricks: 'Databricks',
+ AzureBlob: 'AzureBlob',
+ S3: 'S3',
+ } as const;
+
export interface UserCustomerAnalyticsConfig {
/** Account properties pinned in sidebar display order. */
readonly pinned_properties: readonly PinnedAccountProperty[];
@@ -126368,6 +126390,16 @@ export namespace Schemas {
* @nullable
*/
warehouse_source_type: string | null;
+ /** Warehouse destination PostHog can send data to when the tool is that warehouse, or null for any other tool.
+ *
+ * * `Redshift` - Redshift
+ * * `Snowflake` - Snowflake
+ * * `BigQuery` - BigQuery
+ * * `Postgres` - Postgres
+ * * `Databricks` - Databricks
+ * * `AzureBlob` - Azure Blob
+ * * `S3` - S3 */
+ warehouse_destination_type: UserCreatableDestinationTypeEnum | null;
/** How the wizard sets up the source: in the terminal or in the app. Null for a tool with no warehouse source.
*
* * `in-cli` - In the terminal