:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(data-warehouse): add activity history tabs to source and schema scenes (#66065)
Luke Belton623326dea9e8
diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.tsindex 656c9ef432fc..4996419d44b5 100644--- a/frontend/src/lib/api.ts+++ b/frontend/src/lib/api.ts@@ -2731,6 +2731,7 @@ const api = {ActivityScope.TICKET,ActivityScope.COHORT,ActivityScope.OAUTH_APPLICATION,+ ActivityScope.EXTERNAL_DATA_SCHEMA,].includes(scopes[0]) ||scopes.length > 1) {diff --git a/products/data_warehouse/backend/api/test/test_external_data_schema.py b/products/data_warehouse/backend/api/test/test_external_data_schema.pyindex 0bdd4d446cfe..b9f89493fc9e 100644--- a/products/data_warehouse/backend/api/test/test_external_data_schema.py+++ b/products/data_warehouse/backend/api/test/test_external_data_schema.py@@ -19,6 +19,7 @@ from temporalio.service import RPCErrorfrom posthog.api.test.test_organization import create_organizationfrom posthog.api.test.test_team import create_teamfrom posthog.api.test.test_user import create_user+from posthog.models.activity_logging.activity_log import ActivityLogfrom posthog.models.personal_api_key import PersonalAPIKey, hash_key_valuefrom posthog.models.utils import generate_random_token_personalfrom posthog.temporal.common.schedule import describe_schedule@@ -453,6 +454,48 @@ class TestExternalDataSchema(APIBaseTest):assert schema.sync_type_config.get("reset_pipeline") is Noneassert schema.sync_type == ExternalDataSchema.SyncType.FULL_REFRESH+ def test_update_schema_sync_type_is_logged_to_activity(self):+ source = ExternalDataSource.objects.create(+ team=self.team,+ source_type=ExternalDataSourceType.STRIPE,+ job_inputs={"auth_method": {"selection": "api_key", "stripe_secret_key": "123"}},+ )+ schema = ExternalDataSchema.objects.create(+ name="BalanceTransaction",+ team=self.team,+ source=source,+ should_sync=True,+ status=ExternalDataSchema.Status.COMPLETED,+ sync_type=ExternalDataSchema.SyncType.INCREMENTAL,+ )++ with (+ mock.patch("products.data_warehouse.backend.api.external_data_schema.trigger_external_data_workflow"),+ mock.patch(+ "products.data_warehouse.backend.api.external_data_schema.external_data_workflow_exists",+ return_value=False,+ ),+ ):+ response = self.client.patch(+ f"/api/environments/{self.team.pk}/external_data_schemas/{schema.id}",+ data={"sync_type": "full_refresh"},+ )+ assert response.status_code == 200++ logs = ActivityLog.objects.filter(scope="ExternalDataSchema", item_id=str(schema.id), activity="updated")+ sync_type_changes = [+ c for log in logs for c in (log.detail or {}).get("changes", []) if c["field"] == "sync_type"+ ]+ assert sync_type_changes == [+ {+ "type": "ExternalDataSchema",+ "field": "sync_type",+ "action": "changed",+ "before": "incremental",+ "after": "full_refresh",+ }+ ]+def test_update_schema_sets_and_clears_incremental_field_lookback_seconds(self):source = ExternalDataSource.objects.create(team=self.team,diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx b/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsxindex 5e8c14ea6967..ba23b10986c6 100644--- a/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx+++ b/products/data_warehouse/frontend/scenes/SchemaScene/SchemaScene.tsx@@ -4,6 +4,7 @@ import { useEffect } from 'react'import { LemonButton, LemonSkeleton } from '@posthog/lemon-ui'+import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'import { NotFound } from 'lib/components/NotFound'import { FEATURE_FLAGS } from 'lib/constants'import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'@@ -14,6 +15,7 @@ import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'import { ProductKey } from '~/queries/schema/schema-general'+import { ActivityScope } from '~/types'import { cleanSourceId } from 'products/data_warehouse/frontend/utils'@@ -137,6 +139,12 @@ function SchemaSceneContent({ sourceId, schemaId }: SchemaSceneProps): JSX.Eleme})}+ tabs.push({+ label: 'History',+ key: 'history',+ content: <ActivityLog id={schema.id} scope={ActivityScope.EXTERNAL_DATA_SCHEMA} />,+ })+const activeTab = !showMetrics && currentTab === 'metrics' ? 'configuration' : currentTabreturn (diff --git a/products/data_warehouse/frontend/scenes/SchemaScene/schemaSceneLogic.ts b/products/data_warehouse/frontend/scenes/SchemaScene/schemaSceneLogic.tsindex c0ec3c502fda..d6dd08cd2fca 100644--- a/products/data_warehouse/frontend/scenes/SchemaScene/schemaSceneLogic.ts+++ b/products/data_warehouse/frontend/scenes/SchemaScene/schemaSceneLogic.ts@@ -24,7 +24,7 @@ import { cleanSourceId } from 'products/data_warehouse/frontend/utils'import type { schemaSceneLogicType } from './schemaSceneLogicType'-export const SCHEMA_SCENE_TABS = ['configuration', 'metrics'] as const+export const SCHEMA_SCENE_TABS = ['configuration', 'metrics', 'history'] as constexport type SchemaSceneTab = (typeof SCHEMA_SCENE_TABS)[number]export const SCHEMA_CONFIGURATION_SECTIONS = [diff --git a/products/data_warehouse/frontend/scenes/SourceScene/SourceScene.tsx b/products/data_warehouse/frontend/scenes/SourceScene/SourceScene.tsxindex 08d85b14ecd2..04d16b8e8376 100644--- a/products/data_warehouse/frontend/scenes/SourceScene/SourceScene.tsx+++ b/products/data_warehouse/frontend/scenes/SourceScene/SourceScene.tsx@@ -16,6 +16,7 @@ import { useEffect } from 'react'import { LemonSkeleton } from '@posthog/lemon-ui'+import { ActivityLog } from 'lib/components/ActivityLog/ActivityLog'import { NotFound } from 'lib/components/NotFound'import { FEATURE_FLAGS } from 'lib/constants'import { LemonTab, LemonTabs } from 'lib/lemon-ui/LemonTabs'@@ -41,7 +42,7 @@ import { sourceSettingsLogic } from './tabs/sourceSettingsLogic'import { SyncsTab } from './tabs/SyncsTab'import { WebhookTab } from './tabs/WebhookTab'-const SOURCE_SCENE_TABS = ['schemas', 'syncs', 'metrics', 'configuration', 'webhook'] as const+const SOURCE_SCENE_TABS = ['schemas', 'syncs', 'metrics', 'configuration', 'webhook', 'history'] as constexport type SourceSceneTab = (typeof SOURCE_SCENE_TABS)[number]export interface SourceSceneProps {@@ -268,5 +269,11 @@ function ManagedSourceTabs({})}+ tabs.push({+ label: 'History',+ key: 'history',+ content: <ActivityLog id={sourceId} scope={ActivityScope.EXTERNAL_DATA_SOURCE} />,+ })+return <LemonTabs activeKey={currentTab} tabs={tabs} onChange={setCurrentTab} sceneInset />}