: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
import json
import pytest
MOCK_GITHUB_ISSUE_RECORD: dict = {
"id": 12345,
"number": 87,
"title": "Charts fail to render when filter contains special characters",
"body": (
"When I add a filter with special characters like `&` or `<` in the value, "
"the chart component throws a rendering error and shows a blank white area. "
"Reproducible on both Chrome and Firefox. Expected: chart renders normally with escaped values."
),
"state": "open",
"html_url": "https://github.com/acme/analytics/issues/87",
"labels": '[{"id": 1, "name": "bug"}, {"id": 2, "name": "frontend"}]',
"created_at": "2025-06-10T14:30:00Z",
"updated_at": "2025-06-11T09:15:00Z",
"comments": 3,
"locked": False,
"author_association": "CONTRIBUTOR",
# The warehouse stores GitHub's nested user object as a JSON string. Trimmed to the key the
# emitter reads plus ones it must leave behind.
"user": '{"login": "octocat", "id": 583231, "type": "User", "avatar_url": "https://example.com/a.png"}',
}
@pytest.fixture
def github_issue_record() -> dict:
return {**MOCK_GITHUB_ISSUE_RECORD}
MOCK_ZENDESK_TICKET_RECORD: dict = {
"id": 42,
"url": "https://testcorp.zendesk.com/api/v2/tickets/42.json",
"via": '{"channel":"api","source":{"from":{},"rel":null,"to":{}}}',
"tags": '["ack_email_sent","escalated","medium"]',
"type": None,
"fields": "[]",
"status": "open",
"subject": "Dashboard charts not loading after latest update",
"brand_id": 1001,
"group_id": 2001,
"priority": "high",
"is_public": True,
"recipient": None,
"created_at": "2025-01-15 10:30:00-05:00",
"updated_at": "2025-01-16 08:15:00-05:00",
"assignee_id": 3001,
"description": (
"After updating to v2.5, all dashboard charts show a loading spinner indefinitely. "
"Clearing cache and hard refresh don't help. Console shows 403 errors on the analytics API. "
"This affects all users in our organization."
),
"external_id": None,
"raw_subject": "Dashboard charts not loading after latest update",
"email_cc_ids": [],
"follower_ids": [],
"followup_ids": [],
"requester_id": 4001,
"submitter_id": 4001,
"custom_fields": "[]",
"has_incidents": False,
"organization_id": 5001,
"collaborator_ids": [],
"custom_status_id": 6001,
"allow_attachments": True,
"allow_channelback": False,
"generated_timestamp": 1705500600,
"sharing_agreement_ids": [],
"from_messaging_channel": False,
}
@pytest.fixture
def zendesk_ticket_record() -> dict:
return {**MOCK_ZENDESK_TICKET_RECORD}
MOCK_LINEAR_ISSUE_RECORD: dict = {
"id": "abc-123-def",
"identifier": "ENG-42",
"title": "Dashboard widgets fail to load when timezone is set to UTC+13",
"description": (
"When the user's timezone is set to UTC+13 (e.g. Samoa), dashboard widgets "
"throw a parsing error and display 'Failed to load data'. The date range picker "
"also shows incorrect dates. Reproducible in both Chrome and Safari."
),
"priority": 2,
"priority_label": "High",
"number": 42,
"url": "https://linear.app/acme/issue/ENG-42",
"state": '{"id": "state-1", "name": "In Progress", "type": "started", "color": "#f2c94c"}',
"team": '{"id": "team-1", "name": "Engineering", "key": "ENG"}',
"labels": '{"nodes": [{"id": "label-1", "name": "bug", "color": "#eb5757"}]}',
"assignee": '{"id": "user-1", "name": "Jane Doe", "email": "[email protected]"}',
"created_at": "2025-06-10T14:30:00.000Z",
"updated_at": "2025-06-11T09:15:00.000Z",
"estimate": 3,
"completed_at": None,
"canceled_at": None,
}
@pytest.fixture
def linear_issue_record() -> dict:
return {**MOCK_LINEAR_ISSUE_RECORD}
# Shaped like a row returned by the Jira signals SELECT (jira_issues.FIELDS): `id`/`key`/`self_url`/
# `created`/`updated` are top-level columns; `summary`/`status`/`priority`/`assignee` are already
# JSON-extracted to plain strings; `labels` arrives as a raw JSON-array string; `description` is a
# raw Atlassian Document Format (ADF) JSON string.
MOCK_JIRA_ISSUE_RECORD: dict = {
"id": "10042",
"key": "ENG-42",
"self_url": "https://acme.atlassian.net/rest/api/3/issue/10042",
"created": "2025-06-10T14:30:00.000+0000",
"updated": "2025-06-11T09:15:00.000+0000",
"summary": "Dashboard widgets fail to load when timezone is set to UTC+13",
"status": "In Progress",
"priority": "High",
"assignee": "Jane Doe",
"labels": '["bug", "frontend"]',
"description": json.dumps(
{
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{
"type": "text",
"text": (
"When the user's timezone is set to UTC+13, dashboard widgets throw a "
"parsing error and display 'Failed to load data'."
),
}
],
}
],
}
),
}
@pytest.fixture
def jira_issue_record() -> dict:
return {**MOCK_JIRA_ISSUE_RECORD}
MOCK_PGANALYZE_ISSUE_RECORD: dict = {
"id": "issue_abc123",
"database_id": "db_xyz789",
"description": (
"Index 'users_email_idx' on table 'users' is unused over the last 14 days "
"(0 scans, 240KB storage). Consider dropping it to reduce write overhead."
),
"severity": "warning",
"references": (
'[{"kind": "Index", "name": "users_email_idx", '
'"url": "https://app.pganalyze.com/servers/prod-1/databases/main/indexes/users_email_idx"}]'
),
"server_human_id": "prod-1",
"server_name": "production-primary",
"synced_at": "2026-04-20T12:00:00+00:00",
}
@pytest.fixture
def pganalyze_issue_record() -> dict:
return {**MOCK_PGANALYZE_ISSUE_RECORD}
MOCK_CONVERSATIONS_TICKET_RECORD: dict = {
"id": "550e8400-e29b-41d4-a716-446655440000",
"ticket_number": 17,
"channel_source": "widget",
"channel_detail": "widget_embedded",
"status": "open",
"priority": "high",
"created_at": "2025-06-10T14:30:00Z",
"email_subject": None,
"messages": [
(
"customer",
"Hi, I'm trying to create a funnel but it keeps showing 0 results even though I know there are events.",
),
("team", "Could you share a screenshot of your funnel setup? Also, which date range are you using?"),
(
"customer",
"Sure, here's a screenshot. I'm using the last 7 days. The events show up in the activity feed but the funnel is empty.",
),
],
}
@pytest.fixture
def conversations_ticket_record() -> dict:
return {**MOCK_CONVERSATIONS_TICKET_RECORD}
MOCK_GOOGLE_SEARCH_CONSOLE_RECORD: dict = {
"date": "2026-07-15",
"query": "posthog pricing",
"page": "https://example.com/pricing",
"clicks": 8,
"impressions": 1200,
"ctr": 0.0067,
"position": 6.4,
}
@pytest.fixture
def google_search_console_record() -> dict:
return {**MOCK_GOOGLE_SEARCH_CONSOLE_RECORD}