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(data-warehouse): implement float_app import source (#67819)

Tom Owers76cee96e46e2
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
index 504c92f5ee70..7aaba208cc36 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
@@ -156,6 +156,7 @@ the row lists both.
| finnworlds | HTTP | requests | ✅ |
| fleetio | HTTP | requests | ✅ |
| firehydrant | HTTP | requests | ✅ |
+| float_app | HTTP | requests | ✅ |
| front | HTTP | requests | ✅ |
| fulcrum | HTTP | requests | ✅ |
| fullstory | HTTP | requests | ✅ |
@@ -443,7 +444,6 @@ doesn't conflict with concurrent PRs.
- firebolt
- flexmail
- flexport
-- float_app
- flowlu
- formbricks
- freeagent
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/canonical_descriptions.py
new file mode 100644
index 000000000000..14d4c4f86020
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/canonical_descriptions.py
@@ -0,0 +1,215 @@
+"""Canonical, documentation-sourced descriptions for Float endpoints and columns.
+
+Sourced from the official Float API reference (https://developer.float.com/api_reference.html).
+Keyed by the endpoint names in `settings.py` `FLOAT_ENDPOINTS`, which match the
+`ExternalDataSchema.name` of a synced Float table. Columns absent here fall back to LLM enrichment.
+"""
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+
+_DOCS_URL = "https://developer.float.com/api_reference.html"
+
+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
+ "people": {
+ "description": "A person scheduled in Float — a team member or placeholder that work is allocated to.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "people_id": "Unique identifier for the person.",
+ "name": "The person's full name.",
+ "email": "The person's email address.",
+ "job_title": "The person's job title.",
+ "department": "The department the person belongs to.",
+ "people_type_id": "Employment type: 1 = employee, 2 = contractor, 3 = placeholder.",
+ "active": "Whether the person is active (1) or archived (0).",
+ "start_date": "The person's start date.",
+ "end_date": "The person's end date, if set.",
+ "default_hourly_rate": "The person's default hourly rate.",
+ "tags": "Tags applied to the person.",
+ "created": "Time at which the person was created.",
+ "modified": "Time at which the person was last modified.",
+ },
+ },
+ "accounts": {
+ "description": "A Float login account with its access level and role in the workspace.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "account_id": "Unique identifier for the account.",
+ "name": "The account holder's name.",
+ "email": "The account's email address.",
+ "account_type": "Account role: 1 = account owner, 2 = admin, 3 = project manager, etc.",
+ "access": "Bitmask describing the account's access rights.",
+ "active": "Whether the account is active (1) or deactivated (0).",
+ "created": "Time at which the account was created.",
+ "modified": "Time at which the account was last modified.",
+ },
+ },
+ "clients": {
+ "description": "A client that projects can be associated with.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "client_id": "Unique identifier for the client.",
+ "name": "The client's name.",
+ },
+ },
+ "departments": {
+ "description": "A department used to group people in Float.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "department_id": "Unique identifier for the department.",
+ "name": "The department's name.",
+ "parent_id": "The id of the parent department, if this is a sub-department.",
+ },
+ },
+ "projects": {
+ "description": "A project that work (tasks, phases, milestones) is scheduled against.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "project_id": "Unique identifier for the project.",
+ "name": "The project's name.",
+ "client_id": "The id of the client the project belongs to.",
+ "color": "The project's display color (hex).",
+ "notes": "Free-text notes on the project.",
+ "tags": "Tags applied to the project.",
+ "budget_type": "The project's budget type (e.g. hours, fee, per-phase).",
+ "budget_total": "The project's total budget.",
+ "default_hourly_rate": "The project's default hourly rate.",
+ "non_billable": "Whether the project is non-billable (1) or billable (0).",
+ "tentative": "Whether the project is tentative (1) or confirmed (0).",
+ "active": "Whether the project is active (1) or archived (0).",
+ "created": "Time at which the project was created.",
+ "modified": "Time at which the project was last modified.",
+ },
+ },
+ "phases": {
+ "description": "A phase within a project, bounding a date range with its own budget and rate.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "phase_id": "Unique identifier for the phase.",
+ "project_id": "The id of the project the phase belongs to.",
+ "name": "The phase's name.",
+ "start_date": "The phase's start date.",
+ "end_date": "The phase's end date.",
+ "created": "Time at which the phase was created.",
+ "modified": "Time at which the phase was last modified.",
+ },
+ },
+ "tasks": {
+ "description": "An allocation (scheduled task) assigning a person to work over a date range.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "task_id": "Unique identifier for the allocation.",
+ "project_id": "The id of the project the allocation belongs to.",
+ "phase_id": "The id of the phase the allocation belongs to, if any.",
+ "people_id": "The id of the person assigned to the allocation.",
+ "name": "The allocation's task name.",
+ "start_date": "The allocation's start date.",
+ "end_date": "The allocation's end date.",
+ "hours": "Hours per day allocated.",
+ "billable": "Whether the allocation is billable (1) or not (0).",
+ "status": "The allocation's status: 1 = tentative, 2 = confirmed, 3 = complete.",
+ "created": "Time at which the allocation was created.",
+ "modified": "Time at which the allocation was last modified.",
+ },
+ },
+ "project_tasks": {
+ "description": "A named task defined on a project (the reusable task names allocations can use).",
+ "docs_url": _DOCS_URL,
+ },
+ "milestones": {
+ "description": "A milestone marking a key date on a project.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "milestone_id": "Unique identifier for the milestone.",
+ "project_id": "The id of the project the milestone belongs to.",
+ "name": "The milestone's name.",
+ "date": "The milestone's start date.",
+ "end_date": "The milestone's end date.",
+ },
+ },
+ "timeoffs": {
+ "description": "A time off entry for one or more people over a date range.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "timeoff_id": "Unique identifier for the time off entry.",
+ "timeoff_type_id": "The id of the time off type.",
+ "start_date": "The first day of the time off.",
+ "end_date": "The last day of the time off.",
+ "hours": "Hours per day of time off.",
+ "full_day": "Whether the time off is a full day (1) or partial (0).",
+ "people_ids": "The ids of the people the time off applies to.",
+ "status": "Approval status of the time off.",
+ "created": "Time at which the time off was created.",
+ "modified": "Time at which the time off was last modified.",
+ },
+ },
+ "timeoff_types": {
+ "description": "A category of time off (e.g. vacation, sick leave) configured in the workspace.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "timeoff_type_id": "Unique identifier for the time off type.",
+ "timeoff_type_name": "The name of the time off type.",
+ "color": "The type's display color (hex).",
+ "balance_type": "How the type's balance is tracked.",
+ "days_per_year": "The number of days allotted per year for this type.",
+ },
+ },
+ "logged_time": {
+ "description": "An entry of actual hours logged against a project (and optionally a task) on a date.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "logged_time_id": "Unique identifier for the logged time entry.",
+ "project_id": "The id of the project the time was logged against.",
+ "phase_id": "The id of the phase the time was logged against, if any.",
+ "people_id": "The id of the person who logged the time.",
+ "task_id": "The id of the allocation the time was logged against, if any.",
+ "date": "The date the time was logged for.",
+ "hours": "The number of hours logged.",
+ "billable": "Whether the logged time is billable (1) or not (0).",
+ "note": "Free-text note on the logged time.",
+ "created": "Time at which the logged time was created.",
+ "modified": "Time at which the logged time was last modified.",
+ },
+ },
+ "status": {
+ "description": "A status entry marking a person as available/unavailable over a date range.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "status_id": "Unique identifier for the status entry.",
+ "people_id": "The id of the person the status applies to.",
+ "start_date": "The first day the status applies.",
+ "end_date": "The last day the status applies.",
+ },
+ },
+ "roles": {
+ "description": "A role that can be assigned to people in the workspace.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "id": "Unique identifier for the role.",
+ "name": "The role's name.",
+ },
+ },
+ "holidays": {
+ "description": "A company-wide (public) holiday that blocks scheduling for everyone.",
+ "docs_url": _DOCS_URL,
+ "columns": {
+ "holiday_id": "Unique identifier for the holiday.",
+ "name": "The holiday's name.",
+ "date": "The holiday's start date.",
+ "end_date": "The holiday's end date.",
+ },
+ },
+ "deleted_tasks": {
+ "description": "Tombstone log of deleted allocations (tasks), for reconciling deletions since a cursor.",
+ "docs_url": _DOCS_URL,
+ },
+ "deleted_timeoffs": {
+ "description": "Tombstone log of deleted time off entries, for reconciling deletions since a cursor.",
+ "docs_url": _DOCS_URL,
+ },
+ "deleted_logged_time": {
+ "description": "Tombstone log of deleted logged-time entries, for reconciling deletions since a cursor.",
+ "docs_url": _DOCS_URL,
+ },
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/float_app.posthog.com.md b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/float_app.posthog.com.md
new file mode 100644
index 000000000000..f8b40026d242
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/float_app.posthog.com.md
@@ -0,0 +1,71 @@
+---
+title: Linking Float as a source
+sidebar: Docs
+showTitle: true
+availability: { free: full, selfServe: full, enterprise: full }
+sourceId: FloatApp
+beta: true
+---
+
+import SourceSetupIntro from "../\_snippets/source-setup-intro.mdx"
+import SyncModes from "../\_snippets/sync-modes.mdx"
+import TroubleshootingLink from "../\_snippets/dw-troubleshooting-link.mdx"
+import AlphaRelease from "../\_snippets/alpha-release.mdx"
+
+<AlphaRelease />
+
+[Float](https://www.float.com/) is a resource-management and team-scheduling platform for capacity
+planning. This source syncs your people, accounts, clients, departments, projects, phases,
+allocations, milestones, logged time, time off, and holidays into the PostHog data warehouse so you
+can join scheduling and capacity data with your product and revenue data.
+
+## Prerequisites
+
+- A Float account.
+- A Float **access token**, created by the account owner. The token has the same access as its
+ account owner and is sent as a `Bearer` token on every request.
+
+## Adding a data source
+
+<SourceSetupIntro />
+
+You'll need:
+
+- **Access token** – create one in Float under **Team Settings → Integrations → API**. Treat it like
+ a password; regenerating it revokes the old one.
+
+## Sync modes
+
+<SyncModes />
+
+Every Float table is **full refresh** only — Float's public API exposes no server-side
+modified-since filter on its core resources, so there is no reliable incremental cursor to sync
+against. The Delete Log tables (`deleted_tasks`, `deleted_timeoffs`, `deleted_logged_time`) are
+tombstone logs for reconciling deletions and are **not** selected by default.
+
+## Configuration
+
+<SourceParameters />
+
+## Supported tables
+
+<SourceTables />
+
+## Troubleshooting
+
+- **401 Unauthorized** – the access token is invalid or has been revoked. Create a new token in Float
+ under Team Settings → Integrations → API and reconnect.
+- **403 Forbidden** – the token's account owner does not have permission to the data you're syncing.
+ Confirm the owner's access and reconnect.
+- **429 Too Many Requests** – Float rate-limits API traffic (200 GET requests/minute). The sync backs
+ off and retries automatically; no action is needed.
+
+<TroubleshootingLink />
+
+<!--
+DRAFT — this user-facing doc belongs in the posthog.com repo at
+contents/docs/cdp/sources/float-app.md (served at /docs/cdp/sources/float-app). No posthog.com
+checkout was available when this was written, so it is committed alongside the source to travel with
+the PR. Copy it to posthog.com (dropping this comment) and run
+`python manage.py audit_source_docs --docs-dir <posthog.com>/contents/docs/cdp/sources`.
+-->
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/float_app.py b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/float_app.py
new file mode 100644
index 000000000000..d0773c53e847
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/float_app.py
@@ -0,0 +1,249 @@
+import dataclasses
+from collections.abc import Iterator
+from typing import Any
+from urllib.parse import urlencode
+
+import requests
+from structlog.types import FilteringBoundLogger
+from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter
+
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.batcher import Batcher
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.float_app.settings import (
+ DELETE_LOG_LIMIT,
+ FLOAT_ENDPOINTS,
+ PER_PAGE,
+ FloatEndpointConfig,
+)
+
+FLOAT_BASE_URL = "https://api.float.com/v3"
+# Float rejects requests without a User-Agent that identifies the app and a contact email. This is a
+# static integration identifier, not user data, so it's hardcoded rather than surfaced as a form field.
+USER_AGENT = "PostHog Data Warehouse ([email protected])"
+
+
+class FloatRetryableError(Exception):
+ pass
+
+
+class FloatAppResumeConfig:
+ # Page-number endpoints resume from `next_page` (1-indexed); Delete Log endpoints resume from the
+ # opaque `next_cursor`. Only one is set per endpoint. None means "start from the beginning".
+ next_page: int | None = None
+ next_cursor: str | None = None
+
+
+def _headers(api_key: str) -> dict[str, str]:
+ return {
+ "Authorization": f"Bearer {api_key}",
+ "Accept": "application/json",
+ "User-Agent": USER_AGENT,
+ }
+
+
+def _build_url(path: str, params: dict[str, Any]) -> str:
+ if not params:
+ return f"{FLOAT_BASE_URL}{path}"
+ return f"{FLOAT_BASE_URL}{path}?{urlencode(params)}"
+
+
+def _header_int(headers: Any, name: str) -> int | None:
+ raw = headers.get(name)
+ if raw is None:
+ return None
+ try:
+ return int(raw)
+ except (TypeError, ValueError):
+ return None
+
+
+def _extract_items(payload: Any) -> list[dict[str, Any]]:
+ """Float list endpoints return a bare JSON array. Guard against a wrapped shape defensively."""
+ if isinstance(payload, list):
+ return payload
+ if isinstance(payload, dict):
+ for key in ("data", "items"):
+ value = payload.get(key)
+ if isinstance(value, list):
+ return value
+ return []
+
+
+@retry(
+ retry=retry_if_exception_type((FloatRetryableError, requests.ReadTimeout, requests.ConnectionError)),
+ stop=stop_after_attempt(5),
+ wait=wait_exponential_jitter(initial=1, max=30),
+ reraise=True,
+)
+def _fetch_page(
+ session: requests.Session, url: str, headers: dict[str, str], logger: FilteringBoundLogger
+) -> requests.Response:
+ response = session.get(url, headers=headers, timeout=60)
+
+ # Float enforces 200 GET/min (burst 10/sec) and returns 429 with a `ratelimit-reset` header on
+ # exceed. Back off and retry rather than failing the sync; transient 5xx are retryable too.
+ if response.status_code == 429 or response.status_code >= 500:
+ raise FloatRetryableError(f"Float API error (retryable): status={response.status_code}, url={url}")
+
+ if not response.ok:
+ logger.error(f"Float API error: status={response.status_code}, body={response.text}, url={url}")
+ response.raise_for_status()
+
+ return response
+
+
+def _get_page_rows(
+ session: requests.Session,
+ config: FloatEndpointConfig,
+ headers: dict[str, str],
+ logger: FilteringBoundLogger,
+ batcher: Batcher,
+ resumable_source_manager: ResumableSourceManager[FloatAppResumeConfig],
+ resume: FloatAppResumeConfig | None,
+) -> Iterator[Any]:
+ page = resume.next_page if resume is not None and resume.next_page else 1
+ if page > 1:
+ logger.debug(f"Float: resuming {config.name} from page {page}")
+
+ while True:
+ response = _fetch_page(session, _build_url(config.path, {"per-page": PER_PAGE, "page": page}), headers, logger)
+ items = _extract_items(response.json())
+ if not items:
+ break
+
+ # Prefer Float's `X-Pagination-Pages` header; fall back to a full-page heuristic if it's absent.
+ total_pages = _header_int(response.headers, "X-Pagination-Pages")
+ has_more = page < total_pages if total_pages is not None else len(items) >= PER_PAGE
+
+ for item in items:
+ batcher.batch(item)
+
+ # Yield and save state only after the whole page is batched, so the resume pointer never
+ # advances past a page whose items are still buffered — a mid-page save could skip the
+ # remaining items of the current page on a crash-resume. Save AFTER yielding so a crash
+ # re-yields rather than skips (merge dedupes on the primary key).
+ if batcher.should_yield():
+ yield batcher.get_table()
+ if has_more:
+ resumable_source_manager.save_state(FloatAppResumeConfig(next_page=page + 1))
+
+ if not has_more:
+ break
+ page += 1
+
+
+def _get_cursor_rows(
+ session: requests.Session,
+ config: FloatEndpointConfig,
+ headers: dict[str, str],
+ logger: FilteringBoundLogger,
+ batcher: Batcher,
+ resumable_source_manager: ResumableSourceManager[FloatAppResumeConfig],
+ resume: FloatAppResumeConfig | None,
+) -> Iterator[Any]:
+ """Walk the cursor-paginated Delete Log endpoints.
+
+ Termination is defensive: we stop on a missing/blank/repeated `X-Pagination-Next-Cursor`, an explicit
+ `X-Pagination-Has-More=false`, or a short page. That guarantees the loop ends even if the delete-log
+ pagination header names differ from the documented ones (they can't be verified without a live token).
+ """
+ cursor = resume.next_cursor if resume is not None else None
+
+ while True:
+ params: dict[str, Any] = {"limit": DELETE_LOG_LIMIT}
+ if cursor:
+ params["cursor"] = cursor
+ response = _fetch_page(session, _build_url(config.path, params), headers, logger)
+ items = _extract_items(response.json())
+
+ next_cursor = response.headers.get("X-Pagination-Next-Cursor") or None
+ has_more_header = response.headers.get("X-Pagination-Has-More")
+ has_more_false = has_more_header is not None and str(has_more_header).strip().lower() in ("false", "0", "no")
+
+ page_full = len(items) >= DELETE_LOG_LIMIT
+ advances = bool(next_cursor) and next_cursor != cursor
+ keep_going = page_full and advances and not has_more_false
+
+ if page_full and not advances:
+ logger.warning(
+ f"Float: {config.name} returned a full page with no advancing cursor; stopping to avoid a loop"
+ )
+
+ for item in items:
+ batcher.batch(item)
+
+ # Same page-boundary discipline as the page paginator: only advance the saved cursor after
+ # the whole page has been batched, so a crash-resume can't skip the current page's tail.
+ if batcher.should_yield():
+ yield batcher.get_table()
+ if keep_going:
+ resumable_source_manager.save_state(FloatAppResumeConfig(next_cursor=next_cursor))
+
+ if not keep_going:
+ break
+ cursor = next_cursor
+
+
+def get_rows(
+ api_key: str,
+ endpoint: str,
+ logger: FilteringBoundLogger,
+ resumable_source_manager: ResumableSourceManager[FloatAppResumeConfig],
+) -> Iterator[Any]:
+ config = FLOAT_ENDPOINTS[endpoint]
+ headers = _headers(api_key)
+ batcher = Batcher(logger=logger, chunk_size=2000, chunk_size_bytes=100 * 1024 * 1024)
+ # One session reused across every page so urllib3 keeps the connection alive.
+ session = make_tracked_session()
+
+ resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
+
+ if config.pagination == "cursor":
+ yield from _get_cursor_rows(session, config, headers, logger, batcher, resumable_source_manager, resume)
+ else:
+ yield from _get_page_rows(session, config, headers, logger, batcher, resumable_source_manager, resume)
+
+ if batcher.should_yield(include_incomplete_chunk=True):
+ yield batcher.get_table()
+
+
+def float_app_source(
+ api_key: str,
+ endpoint: str,
+ logger: FilteringBoundLogger,
+ resumable_source_manager: ResumableSourceManager[FloatAppResumeConfig],
+) -> SourceResponse:
+ config = FLOAT_ENDPOINTS[endpoint]
+
+ return SourceResponse(
+ name=endpoint,
+ items=lambda: get_rows(
+ api_key=api_key,
+ endpoint=endpoint,
+ logger=logger,
+ resumable_source_manager=resumable_source_manager,
+ ),
+ primary_keys=config.primary_keys,
+ partition_count=1,
+ partition_size=1,
+ partition_mode="datetime" if config.partition_key else None,
+ partition_format="month" if config.partition_key else None,
+ partition_keys=[config.partition_key] if config.partition_key else None,
+ )
+
+
+def validate_credentials(api_key: str) -> tuple[bool, int | None]:
+ """Probe Float's `/accounts` endpoint to confirm the token is genuine.
+
+ Returns ``(ok, status_code)``. ``status_code`` is ``None`` on a transport error. Float uses a single
+ account-owner token with full access, so a 200 means the whole API is reachable.
+ """
+ url = _build_url("/accounts", {"per-page": 1})
+ try:
+ response = make_tracked_session().get(url, headers=_headers(api_key), timeout=10)
+ except Exception:
+ return False, None
+ return response.status_code == 200, response.status_code
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/settings.py
new file mode 100644
index 000000000000..43cc3dacfae9
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/settings.py
@@ -0,0 +1,87 @@
+from dataclasses import dataclass
+from typing import Literal
+
+from products.warehouse_sources.backend.types import IncrementalField
+
+# Float caps `per-page` at 200 (default 50). Always request the max to minimise round trips.
+PER_PAGE = 200
+# The Delete Log endpoints use cursor pagination and accept a `limit` of up to 500.
+DELETE_LOG_LIMIT = 500
+
+PaginationMode = Literal["page", "cursor"]
+
+
+@dataclass
+class FloatEndpointConfig:
+ name: str
+ # Path under the `/v3` base, e.g. "/people". Verified to exist against the live API (401 behind
+ # auth vs 404 for unknown paths). Note the hyphenated resources: `/project-tasks`, `/timeoff-types`,
+ # `/logged-time`.
+ path: str
+ # Float ids follow the `<resource>_id` convention (e.g. `people_id`, `project_id`). These are the
+ # table's declared primary keys; sourced from Float's documented object shapes. Because every stream
+ # is full-refresh (replace), a mismatch here is metadata-only and cannot accumulate duplicate rows.
+ primary_keys: list[str]
+ # Stable creation-time field to partition by. Only set where Float is known to return a `created`
+ # timestamp on every row — an absent partition column would fail the write. None disables partitioning.
+ partition_key: str | None = None
+ # Core resources use page-number pagination (`page`/`per-page` + `X-Pagination-*` headers). Only the
+ # Delete Log endpoints use cursor pagination (`cursor`/`limit` + `X-Pagination-Next-Cursor`).
+ pagination: PaginationMode = "page"
+ should_sync_default: bool = True
+
+
+# Float's public API exposes no general modified-since filter on its core resources, so every stream is
+# full refresh. The Delete Log and logged-time streams are documented incremental candidates, but Float
+# offers no server-side timestamp filter we could verify without a live token, so they ship full refresh
+# too (see the source docstring). Keep this in mind before flipping any `supports_incremental` on.
+FLOAT_ENDPOINTS: dict[str, FloatEndpointConfig] = {
+ "people": FloatEndpointConfig(name="people", path="/people", primary_keys=["people_id"], partition_key="created"),
+ "accounts": FloatEndpointConfig(name="accounts", path="/accounts", primary_keys=["account_id"]),
+ "departments": FloatEndpointConfig(name="departments", path="/departments", primary_keys=["department_id"]),
+ "clients": FloatEndpointConfig(name="clients", path="/clients", primary_keys=["client_id"]),
+ "projects": FloatEndpointConfig(
+ name="projects", path="/projects", primary_keys=["project_id"], partition_key="created"
+ ),
+ "phases": FloatEndpointConfig(name="phases", path="/phases", primary_keys=["phase_id"]),
+ "tasks": FloatEndpointConfig(name="tasks", path="/tasks", primary_keys=["task_id"], partition_key="created"),
+ "project_tasks": FloatEndpointConfig(name="project_tasks", path="/project-tasks", primary_keys=["task_meta_id"]),
+ "milestones": FloatEndpointConfig(name="milestones", path="/milestones", primary_keys=["milestone_id"]),
+ "timeoffs": FloatEndpointConfig(
+ name="timeoffs", path="/timeoffs", primary_keys=["timeoff_id"], partition_key="created"
+ ),
+ "timeoff_types": FloatEndpointConfig(name="timeoff_types", path="/timeoff-types", primary_keys=["timeoff_type_id"]),
+ "logged_time": FloatEndpointConfig(
+ name="logged_time", path="/logged-time", primary_keys=["logged_time_id"], partition_key="created"
+ ),
+ "status": FloatEndpointConfig(name="status", path="/status", primary_keys=["status_id"]),
+ "roles": FloatEndpointConfig(name="roles", path="/roles", primary_keys=["id"]),
+ "holidays": FloatEndpointConfig(name="holidays", path="/holidays", primary_keys=["holiday_id"]),
+ # Delete Log endpoints — cursor pagination, append-only tombstones. Niche, so off by default.
+ "deleted_tasks": FloatEndpointConfig(
+ name="deleted_tasks",
+ path="/deleted/tasks",
+ primary_keys=["task_id"],
+ pagination="cursor",
+ should_sync_default=False,
+ ),
+ "deleted_timeoffs": FloatEndpointConfig(
+ name="deleted_timeoffs",
+ path="/deleted/timeoffs",
+ primary_keys=["timeoff_id"],
+ pagination="cursor",
+ should_sync_default=False,
+ ),
+ "deleted_logged_time": FloatEndpointConfig(
+ name="deleted_logged_time",
+ path="/deleted/logged-time",
+ primary_keys=["logged_time_id"],
+ pagination="cursor",
+ should_sync_default=False,
+ ),
+}
+
+ENDPOINTS = tuple(FLOAT_ENDPOINTS.keys())
+
+# Every stream is full refresh — no endpoint advertises a server-side incremental cursor today.
+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {name: [] for name in FLOAT_ENDPOINTS}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/source.py
index 5643bd5d5c8d..be71d2279a8d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/source.py
@@ -1,19 +1,43 @@
-from typing import cast
+from typing import Optional, cast
from posthog.schema import (
DataWarehouseSourceCategory,
ExternalDataSourceType as SchemaExternalDataSourceType,
+ ReleaseStatus,
SourceConfig,
+ SourceFieldInputConfig,
+ SourceFieldInputConfigType,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import (
+ SourceInputs,
+ SourceResponse,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import SourceSchema
+from products.warehouse_sources.backend.temporal.data_imports.sources.float_app.float_app import (
+ FloatAppResumeConfig,
+ float_app_source,
+ validate_credentials as validate_float_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.float_app.settings import (
+ ENDPOINTS,
+ FLOAT_ENDPOINTS,
+ INCREMENTAL_FIELDS,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import FloatAppSourceConfig
from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
-class FloatAppSource(SimpleSource[FloatAppSourceConfig]):
+class FloatAppSource(ResumableSource[FloatAppSourceConfig, FloatAppResumeConfig]):
+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
+
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.FLOATAPP
@@ -24,7 +48,95 @@ class FloatAppSource(SimpleSource[FloatAppSourceConfig]):
name=SchemaExternalDataSourceType.FLOAT_APP,
category=DataWarehouseSourceCategory.PRODUCTIVITY,
label="Float",
- iconPath="/static/services/float_app.png",
- fields=cast(list[FieldType], []),
+ releaseStatus=ReleaseStatus.ALPHA,
unreleasedSource=True,
+ caption="""Enter your Float access token to automatically pull your Float resource-management data into the PostHog Data warehouse.
+
+You can create an access token in Float under **Team Settings → Integrations → API**. The token has the same access as its account owner.
+
+All streams sync via full refresh — Float's API exposes no server-side modified-since filter on its core resources.""",
+ keywords=["resource management", "scheduling", "capacity planning"],
+ iconPath="/static/services/float_app.png",
+ docsUrl="https://posthog.com/docs/cdp/sources/float-app",
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldInputConfig(
+ name="api_key",
+ label="Access token",
+ type=SourceFieldInputConfigType.PASSWORD,
+ required=True,
+ placeholder="",
+ secret=True,
+ ),
+ ],
+ ),
+ )
+
+ def get_canonical_descriptions(self) -> CanonicalDescriptions:
+ from products.warehouse_sources.backend.temporal.data_imports.sources.float_app.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+ )
+
+ return CANONICAL_DESCRIPTIONS
+
+ def get_non_retryable_errors(self) -> dict[str, str | None]:
+ return {
+ # An invalid or revoked Float token surfaces as an HTTPError when `_fetch_page` calls
+ # `raise_for_status()`. Retrying can never satisfy a credential problem, so stop the sync.
+ # Match the stable status text and base host, not the per-request path/query.
+ "401 Client Error: Unauthorized for url: https://api.float.com": "Your Float access token is invalid or has been revoked. Create a new token in Float under Team Settings → Integrations → API, then reconnect.",
+ "403 Client Error: Forbidden for url: https://api.float.com": "Your Float access token does not have permission to sync this data. Confirm the token's account owner has access, then reconnect.",
+ }
+
+ def get_schemas(
+ self,
+ config: FloatAppSourceConfig,
+ team_id: int,
+ with_counts: bool = False,
+ names: list[str] | None = None,
+ force_refresh: bool = False,
+ ) -> list[SourceSchema]:
+ def _build_schema(endpoint: str) -> SourceSchema:
+ endpoint_config = FLOAT_ENDPOINTS[endpoint]
+ return SourceSchema(
+ name=endpoint,
+ # Float has no server-side incremental filter today, so every stream is full refresh.
+ supports_incremental=False,
+ supports_append=False,
+ incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),
+ should_sync_default=endpoint_config.should_sync_default,
+ detected_primary_keys=endpoint_config.primary_keys,
+ )
+
+ schemas = [_build_schema(endpoint) for endpoint in ENDPOINTS]
+ if names is not None:
+ names_set = set(names)
+ schemas = [s for s in schemas if s.name in names_set]
+ return schemas
+
+ def validate_credentials(
+ self, config: FloatAppSourceConfig, team_id: int, schema_name: Optional[str] = None
+ ) -> tuple[bool, str | None]:
+ ok, status_code = validate_float_credentials(config.api_key)
+ if ok:
+ return True, None
+ if status_code == 401:
+ return False, "Invalid Float access token"
+ return False, "Could not connect to Float with the provided access token"
+
+ def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[FloatAppResumeConfig]:
+ return ResumableSourceManager[FloatAppResumeConfig](inputs, FloatAppResumeConfig)
+
+ def source_for_pipeline(
+ self,
+ config: FloatAppSourceConfig,
+ resumable_source_manager: ResumableSourceManager[FloatAppResumeConfig],
+ inputs: SourceInputs,
+ ) -> SourceResponse:
+ return float_app_source(
+ api_key=config.api_key,
+ endpoint=inputs.schema_name,
+ logger=inputs.logger,
+ resumable_source_manager=resumable_source_manager,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/tests/test_float_app.py b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/tests/test_float_app.py
new file mode 100644
index 000000000000..9b403c235c24
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/tests/test_float_app.py
@@ -0,0 +1,294 @@
+from typing import Any
+
+import pytest
+from unittest.mock import MagicMock
+
+from parameterized import parameterized
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.float_app import float_app
+from products.warehouse_sources.backend.temporal.data_imports.sources.float_app.float_app import (
+ DELETE_LOG_LIMIT,
+ PER_PAGE,
+ FloatAppResumeConfig,
+ _build_url,
+ _extract_items,
+ _header_int,
+ get_rows,
+ validate_credentials,
+)
+
+
+class TestExtractItems:
+ @parameterized.expand(
+ [
+ ("bare_list", [{"people_id": 1}], [{"people_id": 1}]),
+ ("wrapped_data", {"data": [{"a": 1}]}, [{"a": 1}]),
+ ("wrapped_items", {"items": [{"b": 2}]}, [{"b": 2}]),
+ ("unexpected_dict", {"x": 1}, []),
+ ("empty_list", [], []),
+ ]
+ )
+ def test_extract_items(self, _name: str, payload: Any, expected: list) -> None:
+ assert _extract_items(payload) == expected
+
+
+class TestHeaderInt:
+ @parameterized.expand(
+ [
+ ("valid", {"X-Pagination-Pages": "5"}, 5),
+ ("missing", {}, None),
+ ("non_numeric", {"X-Pagination-Pages": "abc"}, None),
+ ]
+ )
+ def test_header_int(self, _name: str, headers: dict, expected: int | None) -> None:
+ assert _header_int(headers, "X-Pagination-Pages") == expected
+
+
+class TestBuildUrl:
+ def test_no_params(self) -> None:
+ assert _build_url("/people", {}) == "https://api.float.com/v3/people"
+
+ def test_encodes_params(self) -> None:
+ assert (
+ _build_url("/people", {"per-page": 200, "page": 2}) == "https://api.float.com/v3/people?per-page=200&page=2"
+ )
+
+
+class _FakeResponse:
+ def __init__(self, items: Any, headers: dict[str, str]) -> None:
+ self._items = items
+ self.headers = headers
+ self.status_code = 200
+ self.ok = True
+
+ def json(self) -> Any:
+ return self._items
+
+
+class _FakeResumableManager:
+ def __init__(self, state: FloatAppResumeConfig | None = None) -> None:
+ self._state = state
+ self.saved: list[FloatAppResumeConfig] = []
+
+ def can_resume(self) -> bool:
+ return self._state is not None
+
+ def load_state(self) -> FloatAppResumeConfig | None:
+ return self._state
+
+ def save_state(self, data: FloatAppResumeConfig) -> None:
+ self.saved.append(data)
+
+
+class _FakeBatcher:
+ """Accumulates rows and only yields once a full chunk is buffered, like the real Batcher.
+
+ ``chunk_size`` defaults to 1 (yield per item) so most tests observe save-after-yield behavior
+ without thousands of rows. A larger ``chunk_size`` lets a chunk fill partway through a page, which
+ exercises the mid-page-save scenario: the yield/save happens after the page is fully batched, so the
+ resume pointer must still advance exactly once per page boundary — never mid-page.
+ """
+
+ def __init__(self, *args: Any, chunk_size: int = 1, **kwargs: Any) -> None:
+ self._rows: list[dict] = []
+ self._chunk_size = chunk_size
+
+ def batch(self, row: dict) -> None:
+ self._rows.append(row)
+
+ def should_yield(self, include_incomplete_chunk: bool = False) -> bool:
+ if include_incomplete_chunk:
+ return len(self._rows) > 0
+ return len(self._rows) >= self._chunk_size
+
+ def get_table(self) -> list[dict]:
+ rows = self._rows
+ self._rows = []
+ return rows
+
+
+def _patch_fetch(monkeypatch: Any, pages: dict[str, _FakeResponse]) -> list[str]:
+ fetched: list[str] = []
+
+ def fake_fetch(session: Any, url: str, headers: dict[str, str], logger: Any) -> _FakeResponse:
+ fetched.append(url)
+ return pages[url]
+
+ monkeypatch.setattr(float_app, "_fetch_page", fake_fetch)
+ return fetched
+
+
+def _collect(monkeypatch: Any, manager: _FakeResumableManager, endpoint: str, chunk_size: int = 1) -> list[dict]:
+ # Ignore the real chunk_size get_rows passes; drive it from the test so a chunk can span a page.
+ monkeypatch.setattr(float_app, "Batcher", lambda *a, **k: _FakeBatcher(chunk_size=chunk_size))
+ rows: list[dict] = []
+ for batch in get_rows(api_key="tok", endpoint=endpoint, logger=MagicMock(), resumable_source_manager=manager): # type: ignore[arg-type]
+ rows.extend(batch)
+ return rows
+
+
+class TestGetRowsPagePagination:
+ def test_paginates_until_last_page_via_header(self, monkeypatch: Any) -> None:
+ pages = {
+ "https://api.float.com/v3/people?per-page=200&page=1": _FakeResponse(
+ [{"people_id": "1"}, {"people_id": "2"}], {"X-Pagination-Pages": "2"}
+ ),
+ "https://api.float.com/v3/people?per-page=200&page=2": _FakeResponse(
+ [{"people_id": "3"}], {"X-Pagination-Pages": "2"}
+ ),
+ }
+ fetched = _patch_fetch(monkeypatch, pages)
+ rows = _collect(monkeypatch, _FakeResumableManager(), "people")
+
+ assert [r["people_id"] for r in rows] == ["1", "2", "3"]
+ assert fetched == list(pages)
+
+ def test_falls_back_to_full_page_heuristic_when_header_absent(self, monkeypatch: Any) -> None:
+ # No X-Pagination-Pages header: a full page (== PER_PAGE) implies another page may follow;
+ # a short page ends the walk. Without this fallback a header-less response truncates at page 1.
+ pages = {
+ "https://api.float.com/v3/roles?per-page=200&page=1": _FakeResponse(
+ [{"id": str(i)} for i in range(PER_PAGE)], {}
+ ),
+ "https://api.float.com/v3/roles?per-page=200&page=2": _FakeResponse([{"id": "last"}], {}),
+ }
+ fetched = _patch_fetch(monkeypatch, pages)
+ rows = _collect(monkeypatch, _FakeResumableManager(), "roles")
+
+ assert len(rows) == PER_PAGE + 1
+ assert fetched == list(pages)
+
+ def test_saves_resume_state_after_each_page_except_last(self, monkeypatch: Any) -> None:
+ pages = {
+ "https://api.float.com/v3/people?per-page=200&page=1": _FakeResponse(
+ [{"people_id": "1"}], {"X-Pagination-Pages": "2"}
+ ),
+ "https://api.float.com/v3/people?per-page=200&page=2": _FakeResponse(
+ [{"people_id": "2"}], {"X-Pagination-Pages": "2"}
+ ),
+ }
+ _patch_fetch(monkeypatch, pages)
+ manager = _FakeResumableManager()
+ _collect(monkeypatch, manager, "people")
+
+ assert manager.saved == [FloatAppResumeConfig(next_page=2)]
+
+ def test_saves_state_once_per_page_when_chunk_spans_page(self, monkeypatch: Any) -> None:
+ # The resume pointer must advance exactly once per page boundary. Page 1 has four items against
+ # chunk_size=2, so the buffer crosses a chunk boundary twice within the page. If the save were
+ # mid-page (inside the item loop) it would fire on each crossing, writing next_page=2 twice;
+ # done once after the page is fully batched, it writes next_page=2 exactly once.
+ pages = {
+ "https://api.float.com/v3/people?per-page=200&page=1": _FakeResponse(
+ [{"people_id": str(i)} for i in range(4)], {"X-Pagination-Pages": "2"}
+ ),
+ "https://api.float.com/v3/people?per-page=200&page=2": _FakeResponse(
+ [{"people_id": "4"}], {"X-Pagination-Pages": "2"}
+ ),
+ }
+ _patch_fetch(monkeypatch, pages)
+ manager = _FakeResumableManager()
+ _collect(monkeypatch, manager, "people", chunk_size=2)
+
+ assert manager.saved == [FloatAppResumeConfig(next_page=2)]
+
+ def test_resumes_from_saved_page(self, monkeypatch: Any) -> None:
+ pages = {
+ "https://api.float.com/v3/people?per-page=200&page=2": _FakeResponse(
+ [{"people_id": "2"}], {"X-Pagination-Pages": "2"}
+ ),
+ }
+ fetched = _patch_fetch(monkeypatch, pages)
+ rows = _collect(monkeypatch, _FakeResumableManager(FloatAppResumeConfig(next_page=2)), "people")
+
+ assert [r["people_id"] for r in rows] == ["2"]
+ assert fetched == ["https://api.float.com/v3/people?per-page=200&page=2"]
+
+ def test_stops_on_empty_page(self, monkeypatch: Any) -> None:
+ pages = {
+ "https://api.float.com/v3/projects?per-page=200&page=1": _FakeResponse([], {"X-Pagination-Pages": "1"}),
+ }
+ _patch_fetch(monkeypatch, pages)
+ assert _collect(monkeypatch, _FakeResumableManager(), "projects") == []
+
+
+class TestGetRowsCursorPagination:
+ def test_advances_via_cursor_and_stops_on_short_page(self, monkeypatch: Any) -> None:
+ pages = {
+ "https://api.float.com/v3/deleted/tasks?limit=500": _FakeResponse(
+ [{"task_id": i} for i in range(DELETE_LOG_LIMIT)],
+ {"X-Pagination-Next-Cursor": "c2", "X-Pagination-Has-More": "true"},
+ ),
+ "https://api.float.com/v3/deleted/tasks?limit=500&cursor=c2": _FakeResponse(
+ [{"task_id": 999}], {"X-Pagination-Next-Cursor": "", "X-Pagination-Has-More": "false"}
+ ),
+ }
+ fetched = _patch_fetch(monkeypatch, pages)
+ rows = _collect(monkeypatch, _FakeResumableManager(), "deleted_tasks")
+
+ assert len(rows) == DELETE_LOG_LIMIT + 1
+ assert fetched == list(pages)
+
+ def test_terminates_when_full_page_has_no_advancing_cursor(self, monkeypatch: Any) -> None:
+ # A full page whose cursor header is missing (or unchanged) must NOT loop forever — the
+ # defensive guard stops after one page rather than re-requesting the same cursor endlessly.
+ pages = {
+ "https://api.float.com/v3/deleted/tasks?limit=500": _FakeResponse(
+ [{"task_id": i} for i in range(DELETE_LOG_LIMIT)], {}
+ ),
+ }
+ fetched = _patch_fetch(monkeypatch, pages)
+ rows = _collect(monkeypatch, _FakeResumableManager(), "deleted_tasks")
+
+ assert len(rows) == DELETE_LOG_LIMIT
+ assert fetched == list(pages)
+
+ def test_saves_next_cursor_after_yield(self, monkeypatch: Any) -> None:
+ pages = {
+ "https://api.float.com/v3/deleted/tasks?limit=500": _FakeResponse(
+ [{"task_id": i} for i in range(DELETE_LOG_LIMIT)],
+ {"X-Pagination-Next-Cursor": "c2", "X-Pagination-Has-More": "true"},
+ ),
+ "https://api.float.com/v3/deleted/tasks?limit=500&cursor=c2": _FakeResponse([{"task_id": 999}], {}),
+ }
+ _patch_fetch(monkeypatch, pages)
+ manager = _FakeResumableManager()
+ _collect(monkeypatch, manager, "deleted_tasks")
+
+ assert FloatAppResumeConfig(next_cursor="c2") in manager.saved
+
+ def test_resumes_from_saved_cursor(self, monkeypatch: Any) -> None:
+ pages = {
+ "https://api.float.com/v3/deleted/tasks?limit=500&cursor=c2": _FakeResponse([{"task_id": 999}], {}),
+ }
+ fetched = _patch_fetch(monkeypatch, pages)
+ rows = _collect(monkeypatch, _FakeResumableManager(FloatAppResumeConfig(next_cursor="c2")), "deleted_tasks")
+
+ assert [r["task_id"] for r in rows] == [999]
+ assert fetched == ["https://api.float.com/v3/deleted/tasks?limit=500&cursor=c2"]
+
+
+class TestValidateCredentials:
+ @pytest.mark.parametrize(
+ "status_code, expected",
+ [
+ (200, (True, 200)),
+ (401, (False, 401)),
+ (403, (False, 403)),
+ ],
+ )
+ def test_maps_status_code(self, status_code: int, expected: tuple, monkeypatch: Any) -> None:
+ response = MagicMock()
+ response.status_code = status_code
+ session = MagicMock()
+ session.get.return_value = response
+ monkeypatch.setattr(float_app, "make_tracked_session", lambda *a, **k: session)
+
+ assert validate_credentials("tok") == expected
+
+ def test_transport_error_returns_none_status(self, monkeypatch: Any) -> None:
+ session = MagicMock()
+ session.get.side_effect = Exception("connection reset")
+ monkeypatch.setattr(float_app, "make_tracked_session", lambda *a, **k: session)
+
+ assert validate_credentials("tok") == (False, None)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/tests/test_float_app_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/tests/test_float_app_source.py
new file mode 100644
index 000000000000..cd7e55433043
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/float_app/tests/test_float_app_source.py
@@ -0,0 +1,145 @@
+import pytest
+from unittest import mock
+
+from posthog.schema import (
+ DataWarehouseSourceCategory,
+ ReleaseStatus,
+ SourceFieldInputConfig,
+ SourceFieldInputConfigType,
+)
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.float_app.float_app import FloatAppResumeConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.float_app.settings import (
+ ENDPOINTS,
+ FLOAT_ENDPOINTS,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.float_app.source import FloatAppSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import FloatAppSourceConfig
+from products.warehouse_sources.backend.types import ExternalDataSourceType
+
+_CURSOR_ENDPOINTS = {"deleted_tasks", "deleted_timeoffs", "deleted_logged_time"}
+
+
+class TestFloatAppSource:
+ def setup_method(self):
+ self.source = FloatAppSource()
+ self.team_id = 123
+ self.config = FloatAppSourceConfig(api_key="key")
+
+ def test_source_type(self):
+ assert self.source.source_type == ExternalDataSourceType.FLOATAPP
+
+ def test_get_source_config(self):
+ config = self.source.get_source_config
+
+ assert config.name.value == "FloatApp"
+ assert config.label == "Float"
+ assert config.category == DataWarehouseSourceCategory.PRODUCTIVITY
+ assert config.releaseStatus == ReleaseStatus.ALPHA
+ assert config.unreleasedSource is True
+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/float-app"
+
+ field_names = [f.name for f in config.fields if isinstance(f, SourceFieldInputConfig)]
+ assert field_names == ["api_key"]
+
+ def test_api_key_field_is_secret_password(self):
+ config = self.source.get_source_config
+ api_key_field = next(f for f in config.fields if isinstance(f, SourceFieldInputConfig) and f.name == "api_key")
+ assert api_key_field.type == SourceFieldInputConfigType.PASSWORD
+ assert api_key_field.secret is True
+ assert api_key_field.required is True
+
+ @pytest.mark.parametrize(
+ "observed_error",
+ [
+ "401 Client Error: Unauthorized for url: https://api.float.com/v3/people?per-page=200&page=1",
+ "403 Client Error: Forbidden for url: https://api.float.com/v3/logged-time?per-page=200&page=1",
+ ],
+ )
+ def test_non_retryable_errors_match_auth_failures(self, observed_error):
+ assert any(key in observed_error for key in self.source.get_non_retryable_errors())
+
+ @pytest.mark.parametrize(
+ "other_error",
+ [
+ "429 Client Error: Too Many Requests for url: https://api.float.com/v3/people",
+ "500 Server Error: Internal Server Error for url: https://api.float.com/v3/people",
+ "HTTPSConnectionPool(host='api.float.com', port=443): Read timed out.",
+ ],
+ )
+ def test_non_retryable_errors_do_not_match_transient(self, other_error):
+ assert not any(key in other_error for key in self.source.get_non_retryable_errors())
+
+ def test_get_schemas_are_all_full_refresh_with_mapped_primary_keys(self):
+ schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}
+
+ assert set(schemas) == set(ENDPOINTS)
+ for name, schema in schemas.items():
+ # Float exposes no server-side incremental filter, so every stream is full refresh.
+ assert schema.supports_incremental is False
+ assert schema.supports_append is False
+ assert schema.incremental_fields == []
+ assert schema.detected_primary_keys == FLOAT_ENDPOINTS[name].primary_keys
+
+ def test_delete_log_endpoints_are_off_by_default(self):
+ schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}
+ for name in _CURSOR_ENDPOINTS:
+ assert schemas[name].should_sync_default is False
+ assert schemas["people"].should_sync_default is True
+
+ def test_get_schemas_filtered_by_names(self):
+ schemas = self.source.get_schemas(self.config, self.team_id, names=["people"])
+ assert [s.name for s in schemas] == ["people"]
+
+ def test_get_schemas_filtered_unknown_name_returns_empty(self):
+ assert self.source.get_schemas(self.config, self.team_id, names=["nope"]) == []
+
+ def test_lists_tables_without_credentials_publishes_catalog(self):
+ assert self.source.lists_tables_without_credentials is True
+ documented = self.source.get_documented_tables()
+ assert {table["name"] for table in documented} == set(ENDPOINTS)
+ # Full refresh is the only advertised sync method.
+ assert all(table["sync_methods"] == ["Full refresh"] for table in documented)
+
+ def test_canonical_descriptions_cover_every_endpoint(self):
+ canonical = self.source.get_canonical_descriptions()
+ assert set(canonical) == set(FLOAT_ENDPOINTS)
+
+ @pytest.mark.parametrize(
+ "mock_return, expected_valid, expected_message",
+ [
+ ((True, 200), True, None),
+ ((False, 401), False, "Invalid Float access token"),
+ ((False, 403), False, "Could not connect to Float with the provided access token"),
+ ((False, None), False, "Could not connect to Float with the provided access token"),
+ ],
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.float_app.source.validate_float_credentials"
+ )
+ def test_validate_credentials(self, mock_validate, mock_return, expected_valid, expected_message):
+ mock_validate.return_value = mock_return
+
+ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)
+
+ assert is_valid is expected_valid
+ assert error_message == expected_message
+ mock_validate.assert_called_once_with("key")
+
+ def test_get_resumable_source_manager_bound_to_resume_config(self):
+ manager = self.source.get_resumable_source_manager(mock.MagicMock())
+ assert manager._data_class is FloatAppResumeConfig
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.float_app.source.float_app_source")
+ def test_source_for_pipeline_plumbs_arguments(self, mock_float_source):
+ inputs = mock.MagicMock()
+ inputs.schema_name = "people"
+ manager = mock.MagicMock()
+
+ self.source.source_for_pipeline(self.config, manager, inputs)
+
+ mock_float_source.assert_called_once()
+ kwargs = mock_float_source.call_args.kwargs
+ assert kwargs["api_key"] == "key"
+ assert kwargs["endpoint"] == "people"
+ assert kwargs["resumable_source_manager"] is manager
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py
index b20b46707b3e..94eebe294a33 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py
@@ -1223,7 +1223,7 @@ class FlexportSourceConfig(config.Config):
@config.config
class FloatAppSourceConfig(config.Config):
- pass
+ api_key: str
@config.config