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.

1.6 KB
Raw Blame
"""Signal emitter for front `conversations` (record kind: ticket).

Front returns `created_at` as a Unix epoch (seconds); the conversation body lives in the messages table, so the subject is the only text here.
"""

from products.signals.backend.emission._common import make_flat_emitter
from products.signals.backend.emission._prompts import TICKET_ACTIONABILITY_PROMPT, TICKET_SUMMARIZATION_PROMPT
from products.signals.backend.emission.fetchers.data_warehouse import data_warehouse_record_fetcher
from products.signals.backend.emission.registry import SignalSourceTableConfig

FRONT_FIELDS = ("id", "subject", "status", "tags", "created_at")

FRONT_CONFIG = SignalSourceTableConfig(
    source_product="front",
    source_type="ticket",
    emitter=make_flat_emitter(
        source_product="front",
        source_type="ticket",
        id_field="id",
        title_field="subject",
        extra_fields=("status", "tags", "created_at"),
        json_list_fields=("tags",),
    ),
    record_fetcher=data_warehouse_record_fetcher,
    # Front sends fractional epoch seconds (for example 1453770984.123). toInt prints as an
    # accurate cast, which returns NULL for a fractional value, so truncate before the cast.
    # Without floor, every conversation resolves to NULL and drops out of the time filter.
    partition_field="fromUnixTimestamp(toInt(floor(created_at)))",
    fields=FRONT_FIELDS,
    where_clause="status NOT IN ('archived', 'deleted')",
    max_records=200,
    first_sync_lookback_days=1,
    actionability_prompt=TICKET_ACTIONABILITY_PROMPT,
    summarization_prompt=TICKET_SUMMARIZATION_PROMPT,
    description_summarization_threshold_chars=2000,
)