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(warehouse_sources): support Langfuse API version v2 (#80091)

Tom Owers7808d754bfa6
diff --git a/.agents/skills/warehouse-source-new-version/SKILL.md b/.agents/skills/warehouse-source-new-version/SKILL.md
index 5cec408d1a23..31af03c42b3b 100644
--- a/.agents/skills/warehouse-source-new-version/SKILL.md
+++ b/.agents/skills/warehouse-source-new-version/SKILL.md
@@ -76,6 +76,7 @@ Add it when any of these hold:
## Common pitfalls
- Vendor version labels are opaque: `"2026-02-25.clover"`, `"v21.0"`, `"2022-06-28"`. Copy them exactly; never normalize, sort, or parse.
+- A source's per-endpoint URL versions (a hardcoded `/v2/...`, `/v3/...` in the endpoint config) are independent of the framework's source-level version label. A source may already call the vendor's newest per-resource routes while still carrying the `UNVERSIONED_API_VERSION` default — so a version-add can be correct as declaration-only even when the vendor's own version numbers look far apart. Diff what the source actually requests, not the vendor's headline version.
- A change the vendor calls "breaking" (e.g. resource ids migrating int→string) still needs no per-version branch when the source only passes the affected values through opaquely — a primary key whose _column name_ is stable (type auto-inferred), cursors forwarded verbatim. The version still has to exist (the gate passed on a real divergence), but branch the request path only where the change hits a surface you hardcode: column hints, a parsed cursor, a typed primary key.
- A version bump often changes **webhook payloads** too — if the source is a `WebhookSource`, check whether webhook-created clients (created at source-setup time, not sync time) also need the version and whether existing webhook subscriptions must be updated.
- Credential-validation paths (`validate_credentials`, permission probes) run at creation time with no row pin; they may use the default/legacy version. Changing them is optional per version bump — verify the vendor accepts the validation calls under the new version before switching them.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py
index 05e6b424ab1b..54ad3f6b3276 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/settings.py
@@ -2,8 +2,20 @@ from dataclasses import dataclass, field
from datetime import timedelta
from typing import Literal, Optional
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import UNVERSIONED_API_VERSION
from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
+# Source-level vendor API version labels. Distinct from the per-endpoint URL versions baked into
+# LANGFUSE_ENDPOINTS below (Langfuse versions each resource route independently). The source already
+# reads Langfuse's current route for every resource that has one (`/v2/observations`, `/v3/scores`,
+# `/v2/prompts`, `/v2/datasets`), so both labels resolve to the same wire — the bump is a declaration
+# plus deprecation with no request-layer branching. v1 keeps the pre-versioning UNVERSIONED default
+# so already-pinned rows resolve unchanged.
+LANGFUSE_API_VERSION_V1 = UNVERSIONED_API_VERSION
+LANGFUSE_API_VERSION_V2 = "v2"
+SUPPORTED_VERSIONS = (LANGFUSE_API_VERSION_V1, LANGFUSE_API_VERSION_V2)
+DEFAULT_VERSION = LANGFUSE_API_VERSION_V2
+
def _datetime_incremental_field(name: str) -> IncrementalField:
return {
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/source.py
index 1457ec968009..7da948db14fa 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/source.py
@@ -9,7 +9,11 @@ from posthog.schema import (
SourceFieldInputConfigType,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import (
+ FieldType,
+ ResumableSource,
+ VersionDeprecation,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
CanonicalDescriptions,
)
@@ -30,8 +34,11 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.langfuse.l
validate_credentials as validate_langfuse_credentials,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.langfuse.settings import (
+ DEFAULT_VERSION,
ENDPOINTS,
INCREMENTAL_FIELDS,
+ LANGFUSE_API_VERSION_V1,
+ SUPPORTED_VERSIONS,
)
from products.warehouse_sources.backend.types import ExternalDataSourceType
@@ -41,6 +48,15 @@ class LangfuseSource(ResumableSource[LangfuseSourceConfig, LangfuseResumeConfig]
lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
api_docs_url = "https://langfuse.com/docs/api-and-data-platform/features/public-api"
+ supported_versions = SUPPORTED_VERSIONS
+ default_version = DEFAULT_VERSION
+ # Langfuse is retiring its v1 public read endpoints at the (undated) v4 cutover. The source
+ # already reads Langfuse's current route for every resource that has one, so both labels share
+ # one wire and v1-pinned rows keep working — v1 is deprecated advisory-only (no vendor sunset
+ # date). `traces`/`sessions` have no lossless v2 replacement (v2 returns observation rows, not
+ # trace/session objects), so their cutover is a documented manual migration, not an auto repin.
+ deprecated_versions = (VersionDeprecation(version=LANGFUSE_API_VERSION_V1),)
+
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.LANGFUSE
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse_source.py
index 8f6991e40ee2..02667b1d2256 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/langfuse/tests/test_langfuse_source.py
@@ -25,6 +25,18 @@ class TestLangfuseSource:
def test_source_type(self):
assert self.source.source_type == ExternalDataSourceType.LANGFUSE
+ def test_v1_is_deprecated_advisory_and_default_is_v2(self):
+ # New sources start on v2; v1 stays supported so already-pinned rows keep resolving to the
+ # unchanged wire. Langfuse announced no sunset date, so the deprecation is advisory
+ # (sunset_at is None) — the generic in-product warning fires but no repin migration ships.
+ assert self.source.default_version == "v2"
+ assert set(self.source.supported_versions) == {"v1", "v2"}
+
+ deprecation = self.source.get_version_deprecation("v1")
+ assert deprecation is not None
+ assert deprecation.sunset_at is None
+ assert self.source.get_version_deprecation("v2") is None
+
def test_get_source_config(self):
config = self.source.get_source_config