: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 7 missing tables to the Front source (#119105)
Tom Owers6f87208fc32a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex b3b9bd46c8af..0495a9b12aa1 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -5002,9 +5002,9 @@ Diffed against: <https://raw.githubusercontent.com/frontapp/front-api-specs/main- [x] `conversations/{id}/messages` — the email/SMS message bodies themselves; conversations without messages is metadata only (high)- [x] `conversations/{id}/comments` — internal team discussion on each conversation, the collaboration signal (high)- [x] `company/statuses (ticket statuses)` — lookup that resolves the ticket status ID already carried on synced conversations (high)-- [ ] `conversations/{id}/followers` — membership table linking teammates to the conversations they watch (medium)-- [ ] `teammate_groups (+ /teammates, /teams, /inboxes members)` — org structure and membership joins for the teammates and teams already synced (medium)-- [ ] `contact_lists (+ contacts in list)` — customer segmentation lists and their membership rows (medium)+- [x] `conversations/{id}/followers` — membership table linking teammates to the conversations they watch (medium)+- [x] `teammate_groups (+ /teammates, /teams, /inboxes members)` — org structure and membership joins for the teammates and teams already synced (medium)+- [x] `contact_lists (+ contacts in list)` — customer segmentation lists and their membership rows (medium)- [ ] `contact_groups (+ contacts in group)` — the other contact grouping dimension, needed to break conversations down by contact segment (medium)- [x] `custom_fields (accounts, contacts, conversations, inboxes, teammates, links)` — lookup describing the custom field definitions whose values ride on synced records (medium)- [ ] `links (+ links/{id}/conversations)` — external resource links attached to conversations — the join to CRM/issue trackers (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/front/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/front/canonical_descriptions.pyindex a7bcc0939493..7dfa278f309f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/front/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/front/canonical_descriptions.py@@ -243,4 +243,75 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"values": "Possible values, for a custom field of type `enum`.",},},+ "conversation_followers": {+ "description": "A teammate who follows a conversation. One row per conversation and follower.",+ "docs_url": "https://dev.frontapp.com/reference/list-conversation-followers",+ "columns": {+ "id": "Unique identifier of the following teammate.",+ "conversation_id": "Identifier of the followed conversation.",+ "email": "The teammate's email address.",+ "username": "The teammate's username.",+ "first_name": "The teammate's first name.",+ "last_name": "The teammate's last name.",+ },+ },+ "teammate_groups": {+ "description": "A group of teammates in the Front workspace, linked to teams and inboxes.",+ "docs_url": "https://dev.frontapp.com/reference/list-company-teammate-groups",+ "columns": {+ "id": "Unique identifier of the teammate group.",+ "name": "Name of the teammate group.",+ "description": "Description of the teammate group.",+ "is_managed_by_scim": "Whether the group is managed by SCIM provisioning.",+ "permissions": "Permissions granted to the members of the group.",+ },+ },+ "teammate_group_teammates": {+ "description": "A teammate who is a member of a teammate group. One row per group and teammate.",+ "docs_url": "https://dev.frontapp.com/reference/list-company-teammate-group-teammates",+ "columns": {+ "id": "Unique identifier of the teammate.",+ "teammate_group_id": "Identifier of the teammate group.",+ "email": "The teammate's email address.",+ "username": "The teammate's username.",+ },+ },+ "teammate_group_teams": {+ "description": "A team added to a teammate group. One row per group and team.",+ "docs_url": "https://dev.frontapp.com/reference/list-company-teammate-group-teams",+ "columns": {+ "id": "Unique identifier of the team.",+ "teammate_group_id": "Identifier of the teammate group.",+ "name": "Name of the team.",+ },+ },+ "teammate_group_inboxes": {+ "description": "An inbox that a teammate group can access through its teams. One row per group and inbox.",+ "docs_url": "https://dev.frontapp.com/reference/list-company-teammate-group-team-inboxes",+ "columns": {+ "id": "Unique identifier of the inbox.",+ "teammate_group_id": "Identifier of the teammate group.",+ "name": "Name of the inbox.",+ "is_private": "Whether the inbox is private.",+ },+ },+ "contact_lists": {+ "description": "A list of contacts, used to segment contacts.",+ "docs_url": "https://dev.frontapp.com/reference/list-contact-lists",+ "columns": {+ "id": "Unique identifier of the contact list.",+ "name": "Name of the contact list.",+ "is_private": "Whether the list is private to its owner.",+ },+ },+ "contact_list_contacts": {+ "description": "A contact that belongs to a contact list. One row per list and contact.",+ "docs_url": "https://dev.frontapp.com/reference/list-contacts-in-contact-list",+ "columns": {+ "id": "Unique identifier of the contact.",+ "contact_list_id": "Identifier of the contact list.",+ "name": "The contact's name.",+ "handles": "Handles (email addresses, phone numbers, etc.) used to reach the contact.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/front/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/front/settings.pyindex fa7357fbc4c0..9836afa67410 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/front/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/front/settings.py@@ -57,6 +57,22 @@ _CONVERSATION_FANOUT = DependentEndpointConfig(parent_field_renames={"id": "conversation_id"},)+_TEAMMATE_GROUP_FANOUT = DependentEndpointConfig(+ parent_name="teammate_groups",+ resolve_param="teammate_group_id",+ resolve_field="id",+ include_from_parent=["id"],+ parent_field_renames={"id": "teammate_group_id"},+)++_CONTACT_LIST_FANOUT = DependentEndpointConfig(+ parent_name="contact_lists",+ resolve_param="contact_list_id",+ resolve_field="id",+ include_from_parent=["id"],+ parent_field_renames={"id": "contact_list_id"},+)+def _datetime_incremental_field(field_name: str) -> IncrementalField:# Front timestamps are Unix epoch seconds, surfaced to users as a datetime cursor but@@ -141,6 +157,13 @@ FRONT_ENDPOINTS: dict[str, FrontEndpointConfig] = {sort_mode="desc",fanout=_CONVERSATION_FANOUT,),+ # Rows are teammates, so a teammate following many conversations repeats its id: key on the pair.+ "conversation_followers": FrontEndpointConfig(+ name="conversation_followers",+ path="/conversations/{conversation_id}/followers",+ primary_keys=["conversation_id", "id"],+ fanout=_CONVERSATION_FANOUT,+ ),# Resolves the ticket status id carried on each synced conversation."ticket_statuses": FrontEndpointConfig(name="ticket_statuses", path="/company/statuses", partition_key="created_at"@@ -159,6 +182,35 @@ FRONT_ENDPOINTS: dict[str, FrontEndpointConfig] = {"inboxes": FrontEndpointConfig(name="inboxes", path="/inboxes"),"channels": FrontEndpointConfig(name="channels", path="/channels"),"teams": FrontEndpointConfig(name="teams", path="/teams"),+ "teammate_groups": FrontEndpointConfig(name="teammate_groups", path="/teammate_groups"),+ # Membership joins: the same teammate, team or inbox can sit in many groups.+ "teammate_group_teammates": FrontEndpointConfig(+ name="teammate_group_teammates",+ path="/teammate_groups/{teammate_group_id}/teammates",+ primary_keys=["teammate_group_id", "id"],+ fanout=_TEAMMATE_GROUP_FANOUT,+ ),+ "teammate_group_teams": FrontEndpointConfig(+ name="teammate_group_teams",+ path="/teammate_groups/{teammate_group_id}/teams",+ primary_keys=["teammate_group_id", "id"],+ fanout=_TEAMMATE_GROUP_FANOUT,+ ),+ "teammate_group_inboxes": FrontEndpointConfig(+ name="teammate_group_inboxes",+ path="/teammate_groups/{teammate_group_id}/inboxes",+ primary_keys=["teammate_group_id", "id"],+ fanout=_TEAMMATE_GROUP_FANOUT,+ ),+ # Contact lists replace the deprecated contact groups, which are not synced.+ "contact_lists": FrontEndpointConfig(name="contact_lists", path="/contact_lists"),+ "contact_list_contacts": FrontEndpointConfig(+ name="contact_list_contacts",+ path="/contact_lists/{contact_list_id}/contacts",+ primary_keys=["contact_list_id", "id"],+ limit=100,+ fanout=_CONTACT_LIST_FANOUT,+ ),}ENDPOINTS = tuple(FRONT_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/front/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/front/source.pyindex ac807ed5d87e..3faa9cde6c8b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/front/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/front/source.py@@ -108,6 +108,8 @@ Grant read scopes for the resources you want to sync (e.g. `shared_resources:rea"events": "Only syncs the last 365 days on initial sync","conversation_messages": "Fetched one conversation at a time, so a sync takes longer the more conversations you have","conversation_comments": "Fetched one conversation at a time, so a sync takes longer the more conversations you have",+ "conversation_followers": "Fetched one conversation at a time, so a sync takes longer the more conversations you have",+ "contact_list_contacts": "Fetched one contact list at a time, so a sync takes longer the more contact lists you have",},)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/front/tests/test_front.py b/products/warehouse_sources/backend/temporal/data_imports/sources/front/tests/test_front.pyindex fd80c452c281..411fc09bd0b0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/front/tests/test_front.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/front/tests/test_front.py@@ -122,6 +122,53 @@ class TestFanout:assert [row["id"] for row in result.rows] == ["msg_2"]assert result.paths[1:] == ["/conversations/cnv_2/messages"]+ @parameterized.expand(+ [+ ("conversation_followers", "cnv", "conversation_id", "/conversations/{}/followers", None),+ ("teammate_group_teammates", "cir", "teammate_group_id", "/teammate_groups/{}/teammates", None),+ ("teammate_group_teams", "cir", "teammate_group_id", "/teammate_groups/{}/teams", None),+ ("teammate_group_inboxes", "cir", "teammate_group_id", "/teammate_groups/{}/inboxes", None),+ ("contact_list_contacts", "grp", "contact_list_id", "/contact_lists/{}/contacts", "100"),+ ]+ )+ def test_membership_rows_carry_parent_id(+ self, endpoint: str, parent_prefix: str, parent_column: str, child_path: str, limit: str | None+ ) -> None:+ # The same member sits under many parents, so each row must carry its parent id to keep+ # the composite primary key unique.+ parent_1, parent_2 = f"{parent_prefix}_1", f"{parent_prefix}_2"+ result = _driver().run(+ endpoint,+ [+ _page([{"id": parent_1}, {"id": parent_2}]),+ _page([{"id": "member_1"}]),+ _page([{"id": "member_1"}]),+ ],+ )++ assert result.raised is None+ assert result.response is not None+ primary_keys = result.response.primary_keys+ assert primary_keys is not None+ assert result.paths[1:] == [child_path.format(parent_1), child_path.format(parent_2)]+ assert result.params("limit")[1:] == [limit, limit]+ keys = [tuple(row[key] for key in primary_keys) for row in result.rows]+ assert keys == [(parent_1, "member_1"), (parent_2, "member_1")]++ def test_contact_list_contacts_follows_next_page_within_list(self) -> None:+ next_url = "https://api2.frontapp.com/contact_lists/grp_1/contacts?page_token=p2&limit=100"+ result = _driver().run(+ "contact_list_contacts",+ [+ _page([{"id": "grp_1"}]),+ _page([{"id": "crd_1"}], next_url),+ _page([{"id": "crd_2"}]),+ ],+ )++ assert [(row["contact_list_id"], row["id"]) for row in result.rows] == [("grp_1", "crd_1"), ("grp_1", "crd_2")]+ assert result.urls[2] == next_url+class TestFrontSourceResponse:@parameterized.expand(