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): add survey tools as self-driving inbox sources (#121345)

Tom Owersc37394a79de3
diff --git a/products/signals/backend/contracts.py b/products/signals/backend/contracts.py
index ecc069724e0d..14f0da695a9c 100644
--- a/products/signals/backend/contracts.py
+++ b/products/signals/backend/contracts.py
@@ -997,6 +997,92 @@ class RetentlyFeedbackSignalInput(SignalInputBase):
extra: RetentlyFeedbackSignalExtra
+class UsersnapFeedbackSignalExtra(SignalExtraBase):
+ feedback_number: str | None
+ public_link: str | None
+ status_type: str | None
+ priority: str | None
+ created_at: str | None
+ labels: list
+
+
+class UsersnapFeedbackSignalInput(SignalInputBase):
+ source_type: Literal[SignalSourceType.FEEDBACK]
+ source_product: Literal[SignalSourceProduct.USERSNAP]
+ extra: UsersnapFeedbackSignalExtra
+
+
+class TypeformFeedbackSignalExtra(SignalExtraBase):
+ form_id: str | None
+ submitted_at: str | None
+
+
+class TypeformFeedbackSignalInput(SignalInputBase):
+ source_type: Literal[SignalSourceType.FEEDBACK]
+ source_product: Literal[SignalSourceProduct.TYPEFORM]
+ extra: TypeformFeedbackSignalExtra
+
+
+class QualtricsFeedbackSignalExtra(SignalExtraBase):
+ survey_id: str | None
+ recorded_date: str | None
+ finished: str | None
+
+
+class QualtricsFeedbackSignalInput(SignalInputBase):
+ source_type: Literal[SignalSourceType.FEEDBACK]
+ source_product: Literal[SignalSourceProduct.QUALTRICS]
+ extra: QualtricsFeedbackSignalExtra
+
+
+class SurveymonkeyFeedbackSignalExtra(SignalExtraBase):
+ survey_id: str | None
+ date_created: str | None
+ response_status: str | None
+
+
+class SurveymonkeyFeedbackSignalInput(SignalInputBase):
+ source_type: Literal[SignalSourceType.FEEDBACK]
+ source_product: Literal[SignalSourceProduct.SURVEYMONKEY]
+ extra: SurveymonkeyFeedbackSignalExtra
+
+
+class FormbricksFeedbackSignalExtra(SignalExtraBase):
+ survey_id: str | None
+ finished: str | None
+ created_at: str | None
+
+
+class FormbricksFeedbackSignalInput(SignalInputBase):
+ source_type: Literal[SignalSourceType.FEEDBACK]
+ source_product: Literal[SignalSourceProduct.FORMBRICKS]
+ extra: FormbricksFeedbackSignalExtra
+
+
+class SurvicateFeedbackSignalExtra(SignalExtraBase):
+ survey_id: str | None
+ collected_at: str | None
+ url: str | None
+
+
+class SurvicateFeedbackSignalInput(SignalInputBase):
+ source_type: Literal[SignalSourceType.FEEDBACK]
+ source_product: Literal[SignalSourceProduct.SURVICATE]
+ extra: SurvicateFeedbackSignalExtra
+
+
+class SurveysparrowFeedbackSignalExtra(SignalExtraBase):
+ survey_id: str | None
+ completed: str | None
+ completed_time: str | None
+
+
+class SurveysparrowFeedbackSignalInput(SignalInputBase):
+ source_type: Literal[SignalSourceType.FEEDBACK]
+ source_product: Literal[SignalSourceProduct.SURVEYSPARROW]
+ extra: SurveysparrowFeedbackSignalExtra
+
+
class AppfiguresReviewSignalExtra(SignalExtraBase):
stars: str | None
version: str | None
@@ -1599,6 +1685,13 @@ SignalInput = Annotated[
| CannyFeedbackSignalInput
| AsknicelyFeedbackSignalInput
| RetentlyFeedbackSignalInput
+ | UsersnapFeedbackSignalInput
+ | TypeformFeedbackSignalInput
+ | QualtricsFeedbackSignalInput
+ | SurveymonkeyFeedbackSignalInput
+ | FormbricksFeedbackSignalInput
+ | SurvicateFeedbackSignalInput
+ | SurveysparrowFeedbackSignalInput
| AppfiguresReviewSignalInput
| AppfollowReviewSignalInput
| JudgemeReviewsReviewSignalInput
@@ -1689,6 +1782,13 @@ SIGNAL_INPUT_VARIANTS: tuple[type[SignalInputBase], ...] = (
CannyFeedbackSignalInput,
AsknicelyFeedbackSignalInput,
RetentlyFeedbackSignalInput,
+ UsersnapFeedbackSignalInput,
+ TypeformFeedbackSignalInput,
+ QualtricsFeedbackSignalInput,
+ SurveymonkeyFeedbackSignalInput,
+ FormbricksFeedbackSignalInput,
+ SurvicateFeedbackSignalInput,
+ SurveysparrowFeedbackSignalInput,
AppfiguresReviewSignalInput,
AppfollowReviewSignalInput,
JudgemeReviewsReviewSignalInput,
diff --git a/products/signals/backend/emission/_survey.py b/products/signals/backend/emission/_survey.py
new file mode 100644
index 000000000000..802e4e03335d
--- /dev/null
+++ b/products/signals/backend/emission/_survey.py
@@ -0,0 +1,150 @@
+"""Shared helpers for survey tools that store answers in a JSON column.
+
+Each source module passes an extractor that turns its own JSON shape into `SurveyAnswer`
+items. `make_survey_emitter` keeps only free-text answers and returns `None` (skip) for a
+response that has none. Choice, rating, email, phone, contact and file answers never reach
+the description, and the helpers never read respondent identity.
+"""
+
+import re
+import json
+from collections.abc import Callable, Iterable
+from typing import Any
+
+from structlog import get_logger
+
+from posthog.dataclasses import frozen
+
+from products.signals.backend.emission._common import build_extra
+from products.signals.backend.emission.registry import SignalEmitterOutput
+
+logger = get_logger(__name__)
+
+MAX_DESCRIPTION_CHARS = 4000
+
+# Answer kinds, lowercased with punctuation removed, that hold typed-in prose.
+FREE_TEXT_KINDS = frozenset(
+ {
+ "text",
+ "shorttext",
+ "longtext",
+ "openended",
+ "opentext",
+ "essay",
+ "comment",
+ "comments",
+ "textarea",
+ "textinput",
+ "multilinetext",
+ "multilineinput",
+ "freetext",
+ "paragraph",
+ }
+)
+
+# Delimiter-exclusive classes keep the match linear-time on long answers full of "@" and ".".
+_EMAIL_RE = re.compile(r"^[^\s@]+@[^\s@.]+(?:\.[^\s@.]+)+$")
+_PHONE_RE = re.compile(r"^[+\d][\d\s().-]{6,}$")
+_FALSE_FLAGS = (False, 0, "0", "false", "False")
+# Keys or labels of fields that collect respondent identity rather than feedback.
+_CONTACT_KEY_RE = re.compile(r"e-?mail|phone|name|contact|address|^ip$", re.IGNORECASE)
+
+
+@frozen
+class SurveyAnswer:
+ kind: str | None
+ text: Any
+ label: str | None = None
+
+
+def parse_json(raw: Any) -> Any:
+ """Warehouse JSON columns arrive as either a native value or a JSON-encoded string."""
+ if isinstance(raw, str):
+ try:
+ return json.loads(raw)
+ except (json.JSONDecodeError, TypeError):
+ return None
+ return raw
+
+
+def is_free_text_kind(kind: Any) -> bool:
+ if not isinstance(kind, str):
+ return False
+ return re.sub(r"[^a-z]", "", kind.lower()) in FREE_TEXT_KINDS
+
+
+def is_explicitly_false(value: Any) -> bool:
+ """True only for a known false flag, so a missing or odd-typed column keeps the record."""
+ return value in _FALSE_FLAGS
+
+
+def looks_like_contact_key(key: Any) -> bool:
+ return isinstance(key, str) and bool(_CONTACT_KEY_RE.search(key))
+
+
+def looks_like_contact(text: str) -> bool:
+ return bool(_EMAIL_RE.match(text) or _PHONE_RE.match(text))
+
+
+def free_text_description(answers: Iterable[SurveyAnswer]) -> str | None:
+ lines: list[str] = []
+ for answer in answers:
+ if not is_free_text_kind(answer.kind) or not isinstance(answer.text, str):
+ continue
+ text = answer.text.strip()
+ if not text or looks_like_contact(text):
+ continue
+ lines.append(f"{answer.label}: {text}" if answer.label else text)
+ if not lines:
+ return None
+ return "\n".join(lines)[:MAX_DESCRIPTION_CHARS]
+
+
+def make_survey_emitter(
+ *,
+ source_product: str,
+ source_type: str,
+ build_source_id: Callable[[dict[str, Any]], Any],
+ extract_answers: Callable[[dict[str, Any]], Iterable[SurveyAnswer]],
+ extra_fields: tuple[str, ...] = (),
+ json_list_fields: tuple[str, ...] = (),
+ is_eligible: Callable[[dict[str, Any]], bool] | None = None,
+ transform_extra: Callable[[dict[str, Any]], dict[str, Any]] | None = None,
+) -> Callable[[int, dict[str, Any]], SignalEmitterOutput | None]:
+ """Build an emitter for a survey response table.
+
+ `build_source_id` may raise `KeyError` when a required column is absent from the row, which
+ surfaces as a `ValueError` (a query/schema mismatch). An empty id, an ineligible response or a
+ response without free text returns `None`.
+ """
+
+ def emitter(team_id: int, record: dict[str, Any]) -> SignalEmitterOutput | None:
+ try:
+ source_id = build_source_id(record)
+ except KeyError as e:
+ msg = f"{source_product} record missing required field {e}"
+ logger.exception(msg, record_keys=list(record), team_id=team_id, signals_type="data-import-signals")
+ raise ValueError(msg) from e
+ if not source_id:
+ return None
+ if is_eligible is not None and not is_eligible(record):
+ return None
+ description = free_text_description(extract_answers(record))
+ if description is None:
+ logger.info(
+ f"Ignoring {source_product} response without free-text answers",
+ team_id=team_id,
+ signals_type="data-import-signals",
+ )
+ return None
+ extra = build_extra(record, extra_fields, json_list_fields)
+ return SignalEmitterOutput(
+ source_product=source_product,
+ source_type=source_type,
+ source_id=str(source_id),
+ description=description,
+ weight=1.0,
+ extra=transform_extra(extra) if transform_extra else extra,
+ )
+
+ return emitter
diff --git a/products/signals/backend/emission/formbricks_responses.py b/products/signals/backend/emission/formbricks_responses.py
new file mode 100644
index 000000000000..79970c7779a5
--- /dev/null
+++ b/products/signals/backend/emission/formbricks_responses.py
@@ -0,0 +1,63 @@
+"""Signal emitter for formbricks `responses` (record kind: feedback).
+
+`data` is a JSON map of question id to answer, with no question types. Heuristic: keep a string
+answer only when it is at least `MIN_FREE_TEXT_CHARS` long and has whitespace, which drops
+short choices, ids, emails and urls. Keys that look like contact fields are skipped because
+hidden field values also live in `data`. The contact, contact attribute and meta columns are never
+selected.
+"""
+
+import re
+from collections.abc import Iterable
+from typing import Any
+
+from products.signals.backend.emission._prompts import FEEDBACK_ACTIONABILITY_PROMPT, FEEDBACK_SUMMARIZATION_PROMPT
+from products.signals.backend.emission._survey import (
+ SurveyAnswer,
+ looks_like_contact_key,
+ make_survey_emitter,
+ parse_json,
+)
+from products.signals.backend.emission.fetchers.data_warehouse import data_warehouse_record_fetcher
+from products.signals.backend.emission.registry import SignalSourceTableConfig
+
+FORMBRICKS_FIELDS = ("id", "survey_id", "finished", "data", "created_at")
+
+MIN_FREE_TEXT_CHARS = 15
+_URL_RE = re.compile(r"^https?://\S+$")
+
+
+def _extract_answers(record: dict[str, Any]) -> Iterable[SurveyAnswer]:
+ data = parse_json(record.get("data"))
+ if not isinstance(data, dict):
+ return
+ for key, value in data.items():
+ if not isinstance(value, str) or looks_like_contact_key(key) or "user" in str(key).lower():
+ continue
+ text = value.strip()
+ if len(text) < MIN_FREE_TEXT_CHARS or not re.search(r"\s", text) or _URL_RE.match(text):
+ continue
+ yield SurveyAnswer(kind="text", text=text)
+
+
+FORMBRICKS_CONFIG = SignalSourceTableConfig(
+ source_product="formbricks",
+ source_type="feedback",
+ emitter=make_survey_emitter(
+ source_product="formbricks",
+ source_type="feedback",
+ build_source_id=lambda record: record["id"],
+ extract_answers=_extract_answers,
+ extra_fields=("survey_id", "finished", "created_at"),
+ ),
+ unloggable_fields=("data",),
+ record_fetcher=data_warehouse_record_fetcher,
+ partition_field="created_at",
+ partition_field_is_datetime_string=True,
+ fields=FORMBRICKS_FIELDS,
+ max_records=200,
+ first_sync_lookback_days=1,
+ actionability_prompt=FEEDBACK_ACTIONABILITY_PROMPT,
+ summarization_prompt=FEEDBACK_SUMMARIZATION_PROMPT,
+ description_summarization_threshold_chars=2000,
+)
diff --git a/products/signals/backend/emission/qualtrics_survey_responses.py b/products/signals/backend/emission/qualtrics_survey_responses.py
new file mode 100644
index 000000000000..d16a25a34423
--- /dev/null
+++ b/products/signals/backend/emission/qualtrics_survey_responses.py
@@ -0,0 +1,57 @@
+"""Signal emitter for qualtrics `survey_responses` (record kind: feedback).
+
+`values` is a JSON map of question id to raw answer, mixed with embedded data. Only keys that end
+in `_TEXT` (text entry questions and "other" text boxes) are read, so choice codes and embedded
+data such as recipient details never reach the description. Embedded data keys that look like
+contact fields (e.g. `shipping_address_TEXT`) are skipped too. Unfinished responses are skipped in
+Python because the stored type of `finished` (bool or 0/1) is not certain.
+"""
+
+from collections.abc import Iterable
+from typing import Any
+
+from products.signals.backend.emission._prompts import FEEDBACK_ACTIONABILITY_PROMPT, FEEDBACK_SUMMARIZATION_PROMPT
+from products.signals.backend.emission._survey import (
+ SurveyAnswer,
+ is_explicitly_false,
+ looks_like_contact_key,
+ make_survey_emitter,
+ parse_json,
+)
+from products.signals.backend.emission.fetchers.data_warehouse import data_warehouse_record_fetcher
+from products.signals.backend.emission.registry import SignalSourceTableConfig
+
+QUALTRICS_FIELDS = ("response_id", "survey_id", "recorded_date", "finished", "values")
+
+
+def _extract_answers(record: dict[str, Any]) -> Iterable[SurveyAnswer]:
+ values = parse_json(record.get("values"))
+ if not isinstance(values, dict):
+ return
+ for key, value in values.items():
+ if isinstance(key, str) and key.endswith("_TEXT") and not looks_like_contact_key(key):
+ yield SurveyAnswer(kind="text", text=value)
+
+
+QUALTRICS_CONFIG = SignalSourceTableConfig(
+ source_product="qualtrics",
+ source_type="feedback",
+ emitter=make_survey_emitter(
+ source_product="qualtrics",
+ source_type="feedback",
+ build_source_id=lambda record: record["response_id"],
+ extract_answers=_extract_answers,
+ extra_fields=("survey_id", "recorded_date", "finished"),
+ is_eligible=lambda record: not is_explicitly_false(record.get("finished")),
+ ),
+ unloggable_fields=("values",),
+ record_fetcher=data_warehouse_record_fetcher,
+ partition_field="recorded_date",
+ partition_field_is_datetime_string=True,
+ fields=QUALTRICS_FIELDS,
+ max_records=200,
+ first_sync_lookback_days=1,
+ actionability_prompt=FEEDBACK_ACTIONABILITY_PROMPT,
+ summarization_prompt=FEEDBACK_SUMMARIZATION_PROMPT,
+ description_summarization_threshold_chars=2000,
+)
diff --git a/products/signals/backend/emission/registry.py b/products/signals/backend/emission/registry.py
index 3ff2e281b613..ad7d292a30a1 100644
--- a/products/signals/backend/emission/registry.py
+++ b/products/signals/backend/emission/registry.py
@@ -173,6 +173,7 @@ def _register_all_emitters() -> None:
from products.signals.backend.emission.dynamics365_cases import DYNAMICS365_CONFIG
from products.signals.backend.emission.featurebase_posts import FEATUREBASE_CONFIG
from products.signals.backend.emission.firehydrant_incidents import FIREHYDRANT_CONFIG
+ from products.signals.backend.emission.formbricks_responses import FORMBRICKS_CONFIG
from products.signals.backend.emission.freshdesk_tickets import FRESHDESK_CONFIG
from products.signals.backend.emission.freshservice_tickets import FRESHSERVICE_CONFIG
from products.signals.backend.emission.frill_ideas import FRILL_CONFIG
@@ -205,6 +206,7 @@ def _register_all_emitters() -> None:
from products.signals.backend.emission.plain_threads import PLAIN_CONFIG
from products.signals.backend.emission.plane_work_items import PLANE_CONFIG
from products.signals.backend.emission.productboard_notes import PRODUCTBOARD_CONFIG
+ from products.signals.backend.emission.qualtrics_survey_responses import QUALTRICS_CONFIG
# Tier-2 security scanners
from products.signals.backend.emission.rapid7_insightvm_vulnerabilities import RAPID7_INSIGHTVM_CONFIG
@@ -222,11 +224,16 @@ def _register_all_emitters() -> None:
from products.signals.backend.emission.sonarqube_issues import SONARQUBE_CONFIG
from products.signals.backend.emission.sprig_responses import SPRIG_CONFIG
from products.signals.backend.emission.squadcast_incidents import SQUADCAST_CONFIG
+ from products.signals.backend.emission.surveymonkey_survey_responses import SURVEYMONKEY_CONFIG
+ from products.signals.backend.emission.surveysparrow_responses import SURVEYSPARROW_CONFIG
+ from products.signals.backend.emission.survicate_responses import SURVICATE_CONFIG
from products.signals.backend.emission.tenable_vulnerability_management_vulnerabilities import (
TENABLE_VULNERABILITY_MANAGEMENT_CONFIG,
)
from products.signals.backend.emission.trigger_dev_errors import TRIGGER_DEV_CONFIG
from products.signals.backend.emission.trustpilot_service_reviews import TRUSTPILOT_CONFIG
+ from products.signals.backend.emission.typeform_responses import TYPEFORM_CONFIG
+ from products.signals.backend.emission.usersnap_feedbacks import USERSNAP_CONFIG
from products.signals.backend.emission.uservoice_suggestions import USERVOICE_CONFIG
from products.signals.backend.emission.xmatters_incidents import XMATTERS_CONFIG
from products.signals.backend.emission.zendesk_tickets import ZENDESK_TICKETS_CONFIG
@@ -328,6 +335,14 @@ def _register_all_emitters() -> None:
register_signal_source(ExternalDataSourceType.LANGSMITH, "feedback", LANGSMITH_CONFIG)
register_signal_source(ExternalDataSourceType.SPRIG, "Responses", SPRIG_CONFIG)
register_signal_source(ExternalDataSourceType.GAINSIGHTPX, "survey_responses", GAINSIGHT_PX_CONFIG)
+ # Tier-2 surveys (record kind: feedback)
+ register_signal_source(ExternalDataSourceType.USERSNAP, "feedbacks", USERSNAP_CONFIG)
+ register_signal_source(ExternalDataSourceType.TYPEFORM, "responses", TYPEFORM_CONFIG)
+ register_signal_source(ExternalDataSourceType.QUALTRICS, "survey_responses", QUALTRICS_CONFIG)
+ register_signal_source(ExternalDataSourceType.SURVEYMONKEY, "survey_responses", SURVEYMONKEY_CONFIG)
+ register_signal_source(ExternalDataSourceType.FORMBRICKS, "responses", FORMBRICKS_CONFIG)
+ register_signal_source(ExternalDataSourceType.SURVICATE, "responses", SURVICATE_CONFIG)
+ register_signal_source(ExternalDataSourceType.SURVEYSPARROW, "responses", SURVEYSPARROW_CONFIG)
# Business and product reviews (record kind: review)
register_signal_source(ExternalDataSourceType.TRUSTPILOT, "service_reviews", TRUSTPILOT_CONFIG)
register_signal_source(ExternalDataSourceType.OKENDO, "reviews", OKENDO_CONFIG)
diff --git a/products/signals/backend/emission/surveymonkey_survey_responses.py b/products/signals/backend/emission/surveymonkey_survey_responses.py
new file mode 100644
index 000000000000..a4b522f08dfb
--- /dev/null
+++ b/products/signals/backend/emission/surveymonkey_survey_responses.py
@@ -0,0 +1,57 @@
+"""Signal emitter for surveymonkey `survey_responses` (record kind: feedback).
+
+`pages` is JSON: pages[].questions[].answers[]. A free-text answer is an item with a `text` and no
+choice, row or column id (open-ended questions, and the text box of an "other" choice). Only
+`response_status = 'completed'` rows are fetched. The `ip_address` and `recipient_id` columns are
+never selected.
+"""
+
+from collections.abc import Iterable
+from typing import Any
+
+from products.signals.backend.emission._prompts import FEEDBACK_ACTIONABILITY_PROMPT, FEEDBACK_SUMMARIZATION_PROMPT
+from products.signals.backend.emission._survey import SurveyAnswer, make_survey_emitter, parse_json
+from products.signals.backend.emission.fetchers.data_warehouse import data_warehouse_record_fetcher
+from products.signals.backend.emission.registry import SignalSourceTableConfig
+
+SURVEYMONKEY_FIELDS = ("id", "survey_id", "date_created", "response_status", "pages")
+
+_STRUCTURED_ANSWER_KEYS = ("choice_id", "row_id", "col_id", "col_choice_id", "tag_data")
+
+
+def _extract_answers(record: dict[str, Any]) -> Iterable[SurveyAnswer]:
+ pages = parse_json(record.get("pages"))
+ if not isinstance(pages, list):
+ return
+ for page in pages:
+ for question in (page.get("questions") if isinstance(page, dict) else None) or []:
+ for answer in (question.get("answers") if isinstance(question, dict) else None) or []:
+ if not isinstance(answer, dict):
+ continue
+ if any(answer.get(key) for key in _STRUCTURED_ANSWER_KEYS) and not answer.get("other_id"):
+ continue
+ yield SurveyAnswer(kind="text", text=answer.get("text"))
+
+
+SURVEYMONKEY_CONFIG = SignalSourceTableConfig(
+ source_product="surveymonkey",
+ source_type="feedback",
+ emitter=make_survey_emitter(
+ source_product="surveymonkey",
+ source_type="feedback",
+ build_source_id=lambda record: record["id"],
+ extract_answers=_extract_answers,
+ extra_fields=("survey_id", "date_created", "response_status"),
+ ),
+ unloggable_fields=("pages",),
+ record_fetcher=data_warehouse_record_fetcher,
+ partition_field="date_created",
+ partition_field_is_datetime_string=True,
+ fields=SURVEYMONKEY_FIELDS,
+ where_clause="response_status = 'completed'",
+ max_records=200,
+ first_sync_lookback_days=1,
+ actionability_prompt=FEEDBACK_ACTIONABILITY_PROMPT,
+ summarization_prompt=FEEDBACK_SUMMARIZATION_PROMPT,
+ description_summarization_threshold_chars=2000,
+)
diff --git a/products/signals/backend/emission/surveysparrow_responses.py b/products/signals/backend/emission/surveysparrow_responses.py
new file mode 100644
index 000000000000..9032ef9f1087
--- /dev/null
+++ b/products/signals/backend/emission/surveysparrow_responses.py
@@ -0,0 +1,61 @@
+"""Signal emitter for surveysparrow `responses` (record kind: feedback).
+
+`answers` is a JSON list. An item counts only when it embeds a question type naming a free-text
+question and its answer is a string. Unknown answer shapes fail closed rather than treating string
+choice labels as feedback. The source syncs completed responses only. The contact column is never
+selected. Response ids are unique per survey, so the source id carries the survey id.
+"""
+
+from collections.abc import Iterable
+from typing import Any
+
+from products.signals.backend.emission._prompts import FEEDBACK_ACTIONABILITY_PROMPT, FEEDBACK_SUMMARIZATION_PROMPT
+from products.signals.backend.emission._survey import SurveyAnswer, make_survey_emitter, parse_json
+from products.signals.backend.emission.fetchers.data_warehouse import data_warehouse_record_fetcher
+from products.signals.backend.emission.registry import SignalSourceTableConfig
+
+SURVEYSPARROW_FIELDS = ("id", "survey_id", "completed", "completed_time", "answers")
+
+
+def _extract_answers(record: dict[str, Any]) -> Iterable[SurveyAnswer]:
+ answers = parse_json(record.get("answers"))
+ if not isinstance(answers, list):
+ return
+ for item in answers:
+ if not isinstance(item, dict):
+ continue
+ kind = item.get("question_type") or item.get("questionType") or item.get("type")
+ value = item.get("answer", item.get("value"))
+ if isinstance(value, dict):
+ value = value.get("value", value.get("text"))
+ yield SurveyAnswer(kind=kind, text=value)
+
+
+def _source_id(record: dict[str, Any]) -> str | None:
+ response_id, survey_id = record["id"], record["survey_id"]
+ if response_id in (None, "") or survey_id in (None, ""):
+ return None
+ return f"{survey_id}:{response_id}"
+
+
+SURVEYSPARROW_CONFIG = SignalSourceTableConfig(
+ source_product="surveysparrow",
+ source_type="feedback",
+ emitter=make_survey_emitter(
+ source_product="surveysparrow",
+ source_type="feedback",
+ build_source_id=_source_id,
+ extract_answers=_extract_answers,
+ extra_fields=("survey_id", "completed", "completed_time"),
+ ),
+ unloggable_fields=("answers",),
+ record_fetcher=data_warehouse_record_fetcher,
+ partition_field="completed_time",
+ partition_field_is_datetime_string=True,
+ fields=SURVEYSPARROW_FIELDS,
+ max_records=200,
+ first_sync_lookback_days=1,
+ actionability_prompt=FEEDBACK_ACTIONABILITY_PROMPT,
+ summarization_prompt=FEEDBACK_SUMMARIZATION_PROMPT,
+ description_summarization_threshold_chars=2000,
+)
diff --git a/products/signals/backend/emission/survicate_responses.py b/products/signals/backend/emission/survicate_responses.py
new file mode 100644
index 000000000000..63d715ece53f
--- /dev/null
+++ b/products/signals/backend/emission/survicate_responses.py
@@ -0,0 +1,75 @@
+"""Signal emitter for survicate `responses` (record kind: feedback).
+
+`answers` is a JSON list of answered questions. An item counts only when its type names a free-text
+question and its value is a string. The respondent and attribute columns are never selected, and
+the page url loses its credentials, query string and fragment.
+"""
+
+from collections.abc import Iterable
+from typing import Any
+from urllib.parse import urlsplit
+
+from products.signals.backend.emission._prompts import FEEDBACK_ACTIONABILITY_PROMPT, FEEDBACK_SUMMARIZATION_PROMPT
+from products.signals.backend.emission._survey import SurveyAnswer, make_survey_emitter, parse_json
+from products.signals.backend.emission.fetchers.data_warehouse import data_warehouse_record_fetcher
+from products.signals.backend.emission.registry import SignalSourceTableConfig
+
+SURVICATE_FIELDS = ("uuid", "survey_id", "collected_at", "answers", "url")
+
+
+def _extract_answers(record: dict[str, Any]) -> Iterable[SurveyAnswer]:
+ answers = parse_json(record.get("answers"))
+ if not isinstance(answers, list):
+ return
+ for item in answers:
+ if not isinstance(item, dict):
+ continue
+ value = item.get("answer", item.get("value"))
+ kind = item.get("type") or item.get("question_type") or item.get("answer_type")
+ if isinstance(value, dict):
+ kind = kind or value.get("type")
+ value = value.get("value", value.get("text"))
+ yield SurveyAnswer(kind=kind, text=value)
+
+
+def _strip_url_query(extra: dict[str, Any]) -> dict[str, Any]:
+ """Keep scheme, host, port and path. Drop userinfo, query string and fragment."""
+ url = extra.get("url")
+ if url:
+ try:
+ parts = urlsplit(url)
+ port = parts.port
+ except ValueError:
+ extra["url"] = None
+ return extra
+ if parts.hostname:
+ authority = f"{parts.hostname}:{port}" if port else parts.hostname
+ extra["url"] = f"{parts.scheme}://{authority}{parts.path}"
+ else:
+ # A relative page path carries no host, so keep the path alone.
+ extra["url"] = parts.path or None
+ return extra
+
+
+SURVICATE_CONFIG = SignalSourceTableConfig(
+ source_product="survicate",
+ source_type="feedback",
+ emitter=make_survey_emitter(
+ source_product="survicate",
+ source_type="feedback",
+ build_source_id=lambda record: record["uuid"],
+ extract_answers=_extract_answers,
+ extra_fields=("survey_id", "collected_at", "url"),
+ transform_extra=_strip_url_query,
+ ),
+ unloggable_fields=("answers", "url"),
+ record_fetcher=data_warehouse_record_fetcher,
+ partition_field="collected_at",
+ partition_field_is_datetime_string=True,
+ fields=SURVICATE_FIELDS,
+ max_records=200,
+ first_sync_lookback_days=1,
+ actionability_prompt=FEEDBACK_ACTIONABILITY_PROMPT,
+ summarization_prompt=FEEDBACK_SUMMARIZATION_PROMPT,
+ description_summarization_threshold_chars=2000,
+)
diff --git a/products/signals/backend/emission/tests/test_survey_sources.py b/products/signals/backend/emission/tests/test_survey_sources.py
new file mode 100644
index 000000000000..67c15027a1fd
--- /dev/null
+++ b/products/signals/backend/emission/tests/test_survey_sources.py
@@ -0,0 +1,277 @@
+import json
+from typing import Any
+
+import pytest
+
+from products.signals.backend.emission._survey import SurveyAnswer, free_text_description, is_free_text_kind
+from products.signals.backend.emission.formbricks_responses import FORMBRICKS_CONFIG
+from products.signals.backend.emission.qualtrics_survey_responses import QUALTRICS_CONFIG
+from products.signals.backend.emission.surveymonkey_survey_responses import SURVEYMONKEY_CONFIG
+from products.signals.backend.emission.surveysparrow_responses import SURVEYSPARROW_CONFIG
+from products.signals.backend.emission.survicate_responses import SURVICATE_CONFIG
+from products.signals.backend.emission.typeform_responses import TYPEFORM_CONFIG
+from products.signals.backend.emission.usersnap_feedbacks import USERSNAP_CONFIG
+
+TEXT = "The export button crashes whenever a board has more than fifty cards"
+OTHER = "Dark mode would help a lot when working late at night"
+
+
+def _run(config, record: dict[str, Any]):
+ return config.emitter(1, record)
+
+
+# (config, base record, answers column, answers value with free text and non-text answers)
+CASES = [
+ pytest.param(
+ USERSNAP_CONFIG,
+ {
+ "feedback_id": "f1",
+ "feedback_number": 7,
+ "public_link": "https://app.usersnap.com/f1",
+ "status_type": "open",
+ },
+ "ordered_inputs",
+ [
+ {"label": "Comment", "text_value": TEXT},
+ {"label": "Rating", "value": "4", "boolean_value": None},
+ {"label": "Your email", "text_value": "[email protected]"},
+ ],
+ "Comment: " + TEXT,
+ "f1",
+ id="usersnap",
+ ),
+ pytest.param(
+ TYPEFORM_CONFIG,
+ {"response_id": "r1", "form_id": "F9", "submitted_at": "2026-01-01T00:00:00Z"},
+ "answers",
+ [
+ {"type": "text", "text": TEXT, "field": {"type": "long_text"}},
+ {"type": "text", "text": "[email protected]", "field": {"type": "email"}},
+ {"type": "choice", "choice": {"label": "Other"}, "field": {"type": "multiple_choice"}},
+ {"type": "number", "number": 5, "field": {"type": "rating"}},
+ ],
+ TEXT,
+ "F9:r1",
+ id="typeform",
+ ),
+ pytest.param(
+ QUALTRICS_CONFIG,
+ {"response_id": "R_1", "survey_id": "SV_1", "finished": True},
+ "values",
+ {"QID1": "2", "QID2_TEXT": TEXT, "recipientEmail": "[email protected]", "QID3": "pick"},
+ TEXT,
+ "R_1",
+ id="qualtrics",
+ ),
+ pytest.param(
+ SURVEYMONKEY_CONFIG,
+ {"id": "9", "survey_id": "S1", "response_status": "completed"},
+ "pages",
+ [
+ {
+ "questions": [
+ {"answers": [{"text": TEXT}]},
+ {"answers": [{"choice_id": "c1"}]},
+ {"answers": [{"choice_id": "c2", "text": "Option B"}]},
+ {"answers": [{"row_id": "r1", "col_id": "c1", "text": "Agree"}]},
+ {"answers": [{"other_id": "o1", "text": OTHER}]},
+ ]
+ }
+ ],
+ TEXT + "\n" + OTHER,
+ "9",
+ id="surveymonkey",
+ ),
+ pytest.param(
+ FORMBRICKS_CONFIG,
+ {"id": "cl1", "survey_id": "s1", "finished": True},
+ "data",
+ {
+ "q1": "yes",
+ "q2": TEXT,
+ "q4": "https://example.com/a/very/long/file/path",
+ "email": "please contact me at this address soon",
+ "q5": 5,
+ },
+ TEXT,
+ "cl1",
+ id="formbricks",
+ ),
+ pytest.param(
+ SURVICATE_CONFIG,
+ {"uuid": "u1", "survey_id": "sv", "url": "https://app.example.com/page?token=secret#frag"},
+ "answers",
+ [
+ {"question_id": 1, "type": "text", "answer": TEXT},
+ {"question_id": 2, "type": "single_choice", "answer": {"value": "Yes"}},
+ {"question_id": 3, "type": "nps", "answer": "9"},
+ ],
+ TEXT,
+ "u1",
+ id="survicate",
+ ),
+ pytest.param(
+ SURVEYSPARROW_CONFIG,
+ {"id": 5, "survey_id": 12, "completed": True},
+ "answers",
+ [
+ {"question_type": "TextInput", "answer": TEXT},
+ {"question_type": "OpinionScale", "answer": "8"},
+ {"question_type": "EmailInput", "answer": "[email protected]"},
+ ],
+ TEXT,
+ "12:5",
+ id="surveysparrow",
+ ),
+]
+
+
[email protected]("config,base,column,answers,expected,source_id", CASES)
+class TestSurveyEmitters:
+ def _record(self, base: dict[str, Any], column: str, value: Any) -> dict[str, Any]:
+ return {**base, column: value}
+
+ @pytest.mark.parametrize("encode", [json.dumps, lambda value: value], ids=["json_string", "native"])
+ def test_keeps_only_free_text(self, config, base, column, answers, expected, source_id, encode):
+ output = _run(config, self._record(base, column, encode(answers)))
+
+ assert output is not None
+ assert output.description == expected
+ assert output.source_id == source_id
+ assert "jane" not in output.description
+
+ @pytest.mark.parametrize(
+ "value",
+ [None, "", "not json", "{broken", "[]", "{}", 7, '"just a string"'],
+ ids=["none", "empty", "garbage", "truncated", "empty_list", "empty_map", "number", "json_string"],
+ )
+ def test_missing_or_malformed_answers_skip(self, config, base, column, answers, expected, source_id, value):
+ assert _run(config, self._record(base, column, value)) is None
+
+ def test_extra_never_carries_respondent_identity(self, config, base, column, answers, expected, source_id):
+ output = _run(config, self._record(base, column, answers))
+
+ assert output is not None
+ for forbidden in ("email", "ip", "name", "respondent", "contact", "hidden", "recipient"):
+ assert not any(forbidden in key for key in output.extra)
+
+ def test_no_text_answers_means_no_signal(self, config, base, column, answers, expected, source_id):
+ assert _run(config, self._record(base, column, [] if isinstance(answers, list) else {})) is None
+
+ def test_missing_id_column_raises(self, config, base, column, answers, expected, source_id):
+ record = self._record(base, column, answers)
+ record.pop(next(iter(base)))
+ with pytest.raises(ValueError):
+ _run(config, record)
+
+
+class TestSourceSpecificRules:
+ def test_unfinished_qualtrics_response_is_skipped(self):
+ record = {"response_id": "R_1", "finished": False, "values": json.dumps({"QID2_TEXT": TEXT})}
+ assert _run(QUALTRICS_CONFIG, record) is None
+
+ @pytest.mark.parametrize("finished", [True, 1, "1", "true", None])
+ def test_finished_or_unknown_qualtrics_response_is_kept(self, finished):
+ record = {"response_id": "R_1", "finished": finished, "values": json.dumps({"QID2_TEXT": TEXT})}
+ assert _run(QUALTRICS_CONFIG, record) is not None
+
+ def test_survicate_url_loses_query_and_fragment(self):
+ record = {
+ "uuid": "u1",
+ "url": "https://app.example.com/page?token=secret#frag",
+ "answers": json.dumps([{"type": "text", "answer": TEXT}]),
+ }
+ output = _run(SURVICATE_CONFIG, record)
+ assert output is not None
+ assert output.extra["url"] == "https://app.example.com/page"
+
+ @pytest.mark.parametrize(
+ "url,expected",
+ [
+ ("https://user:[email protected]:8443/page?token=x", "https://app.example.com:8443/page"),
+ ("https://[email protected]/page", "https://app.example.com/page"),
+ ("/feedback?ref=mail", "/feedback"),
+ ("https://[broken/page", None),
+ ],
+ )
+ def test_survicate_url_loses_credentials(self, url, expected):
+ record = {"uuid": "u1", "url": url, "answers": json.dumps([{"type": "text", "answer": TEXT}])}
+ output = _run(SURVICATE_CONFIG, record)
+ assert output is not None
+ assert output.extra["url"] == expected
+
+ def test_typeform_dropdown_text_answer_is_skipped(self):
+ answers = [{"type": "text", "text": "Enterprise plan with yearly billing", "field": {"type": "dropdown"}}]
+ record = {"response_id": "r1", "form_id": "F9", "answers": json.dumps(answers)}
+ assert _run(TYPEFORM_CONFIG, record) is None
+
+ def test_surveysparrow_answer_without_embedded_question_type_is_skipped(self):
+ answers = [{"question_id": 123, "answer": TEXT}]
+ record = {"id": 5, "survey_id": 12, "answers": json.dumps(answers)}
+ assert _run(SURVEYSPARROW_CONFIG, record) is None
+
+ def test_qualtrics_contact_like_text_keys_are_skipped(self):
+ values = {"shipping_address_TEXT": "123 Example Street, Sample City", "QID2_TEXT": TEXT}
+ output = _run(QUALTRICS_CONFIG, {"response_id": "R_1", "values": json.dumps(values)})
+ assert output is not None
+ assert output.description == TEXT
+
+ def test_usersnap_address_label_is_skipped(self):
+ inputs = [{"label": "Billing address", "text_value": "123 Example Street, Sample City"}]
+ assert _run(USERSNAP_CONFIG, {"feedback_id": "f1", "ordered_inputs": json.dumps(inputs)}) is None
+
+ def test_formbricks_address_key_is_skipped(self):
+ data = {"billingAddress": "123 Example Street, Sample City"}
+ assert _run(FORMBRICKS_CONFIG, {"id": "cl1", "data": json.dumps(data)}) is None
+
+ @pytest.mark.parametrize("config", [c.values[0] for c in CASES])
+ def test_raw_answer_columns_are_unloggable(self, config):
+ assert config.unloggable_fields
+
+ def test_usersnap_labels_are_a_list(self):
+ record = {
+ "feedback_id": "f1",
+ "labels": '["bug"]',
+ "ordered_inputs": json.dumps([{"label": "Comment", "text_value": TEXT}]),
+ }
+ output = _run(USERSNAP_CONFIG, record)
+ assert output is not None
+ assert output.extra["labels"] == ["bug"]
+
+ def test_surveymonkey_only_fetches_completed_responses(self):
+ assert SURVEYMONKEY_CONFIG.where_clause == "response_status = 'completed'"
+
+ def test_email_check_is_linear_on_adversarial_input(self):
+ import time
+
+ text = "a@" * 20000 + "a." * 20000 + " invalid feedback"
+ started = time.monotonic()
+ description = free_text_description([SurveyAnswer(kind="text", text=text)])
+ assert time.monotonic() - started < 1
+ assert description is not None
+
+ def test_description_is_capped(self):
+ description = free_text_description([SurveyAnswer(kind="text", text="word " * 5000)])
+ assert description is not None
+ assert len(description) == 4000
+
+
+ "kind,expected",
+ [
+ ("text", True),
+ ("long_text", True),
+ ("Long-Text", True),
+ ("TextInput", True),
+ ("open_ended", True),
+ ("choice", False),
+ ("email", False),
+ ("phone_number", False),
+ ("nps", False),
+ (None, False),
+ (3, False),
+ ],
+)
+def test_is_free_text_kind(kind, expected):
+ assert is_free_text_kind(kind) is expected
diff --git a/products/signals/backend/emission/tests/test_tier1_registry.py b/products/signals/backend/emission/tests/test_tier1_registry.py
index bb5a9e083df0..600db30a926c 100644
--- a/products/signals/backend/emission/tests/test_tier1_registry.py
+++ b/products/signals/backend/emission/tests/test_tier1_registry.py
@@ -1,3 +1,4 @@
+import json
from typing import Any
import pytest
@@ -42,6 +43,14 @@ TIER1_SOURCES = [
(ExternalDataSourceType.CANNY, "posts", "canny", "feedback"),
(ExternalDataSourceType.ASKNICELY, "responses", "asknicely", "feedback"),
(ExternalDataSourceType.RETENTLY, "feedback", "retently", "feedback"),
+ # Tier-2 survey tools (answers in a JSON column)
+ (ExternalDataSourceType.USERSNAP, "feedbacks", "usersnap", "feedback"),
+ (ExternalDataSourceType.TYPEFORM, "responses", "typeform", "feedback"),
+ (ExternalDataSourceType.QUALTRICS, "survey_responses", "qualtrics", "feedback"),
+ (ExternalDataSourceType.SURVEYMONKEY, "survey_responses", "surveymonkey", "feedback"),
+ (ExternalDataSourceType.FORMBRICKS, "responses", "formbricks", "feedback"),
+ (ExternalDataSourceType.SURVICATE, "responses", "survicate", "feedback"),
+ (ExternalDataSourceType.SURVEYSPARROW, "responses", "surveysparrow", "feedback"),
# Tier-3 reviews
(ExternalDataSourceType.APPFIGURES, "reviews", "appfigures", "review"),
(ExternalDataSourceType.APPFOLLOW, "reviews", "appfollow", "review"),
@@ -100,12 +109,28 @@ TIER1_SOURCES = [
IDS = [product for _, _, product, _ in TIER1_SOURCES]
-def _mock_record(fields: tuple[str, ...]) -> dict:
+_LONG_TEXT = "The export button crashes whenever a board has more than fifty cards"
+
+# Survey tools keep their answers in a JSON column, so a full record needs real answer JSON.
+_SURVEY_ANSWERS = {
+ "usersnap": ("ordered_inputs", json.dumps([{"label": "Comment", "text_value": _LONG_TEXT}])),
+ "typeform": ("answers", json.dumps([{"type": "text", "text": _LONG_TEXT, "field": {"type": "long_text"}}])),
+ "qualtrics": ("values", json.dumps({"QID1": "2", "QID2_TEXT": _LONG_TEXT})),
+ "surveymonkey": ("pages", json.dumps([{"questions": [{"answers": [{"text": _LONG_TEXT}]}]}])),
+ "formbricks": ("data", json.dumps({"q1": "yes", "q2": _LONG_TEXT})),
+ "survicate": ("answers", json.dumps([{"type": "text", "answer": _LONG_TEXT}])),
+ "surveysparrow": ("answers", json.dumps([{"question_type": "TextInput", "answer": _LONG_TEXT}])),
+}
+
+
+def _mock_record(fields: tuple[str, ...], product: str = "") -> dict:
"""A full record covering every SELECTed column, with plausible types."""
record: dict = {}
for field in fields:
name = field.rsplit(" AS ", 1)[-1]
- if name in ("tags", "labels", "projects"):
+ if product in _SURVEY_ANSWERS and name == _SURVEY_ANSWERS[product][0]:
+ record[name] = _SURVEY_ANSWERS[product][1]
+ elif name in ("tags", "labels", "projects"):
record[name] = '[{"name": "one"}, {"name": "two"}]' if name == "projects" else '["one", "two"]'
elif name == "column_values":
record[name] = '[{"id": "a", "type": "text", "text": "some text"}]'
@@ -129,7 +154,7 @@ def test_source_is_registered(source_type, table, product, kind):
def test_emitter_output_matches_contract(source_type, table, product, kind):
config = get_signal_config(source_type.value, table)
assert config is not None
- output = config.emitter(1, _mock_record(config.fields))
+ output = config.emitter(1, _mock_record(config.fields, product))
assert output is not None, f"{product} emitter returned None for a full record"
assert output.source_product == product
assert output.source_type == kind
diff --git a/products/signals/backend/emission/typeform_responses.py b/products/signals/backend/emission/typeform_responses.py
new file mode 100644
index 000000000000..54f83f446fec
--- /dev/null
+++ b/products/signals/backend/emission/typeform_responses.py
@@ -0,0 +1,67 @@
+"""Signal emitter for typeform `responses` (record kind: feedback).
+
+`answers` is a JSON list. An answer with `type: text` is a typed-in answer (short or long text
+field). Its `field.type` must be `short_text` or `long_text` when present, which drops dropdown
+selections that also arrive as `type: text`. Choice, number, email, phone, date, url and file
+answers are skipped. Hidden fields, metadata and variables are never selected. Response ids repeat
+across forms, so the source id carries the form id.
+"""
+
+from collections.abc import Iterable
+from typing import Any
+
+from products.signals.backend.emission._prompts import FEEDBACK_ACTIONABILITY_PROMPT, FEEDBACK_SUMMARIZATION_PROMPT
+from products.signals.backend.emission._survey import SurveyAnswer, make_survey_emitter, parse_json
+from products.signals.backend.emission.fetchers.data_warehouse import data_warehouse_record_fetcher
+from products.signals.backend.emission.registry import SignalSourceTableConfig
+
+TYPEFORM_FIELDS = ("response_id", "form_id", "submitted_at", "answers")
+
+# Typeform field types that hold typed-in prose. Other fields can still answer with `type: text`
+# (a dropdown selection, for one), so a known field type outside this set is skipped.
+_FREE_TEXT_FIELD_TYPES = frozenset({"short_text", "long_text"})
+
+
+def _extract_answers(record: dict[str, Any]) -> Iterable[SurveyAnswer]:
+ answers = parse_json(record.get("answers"))
+ if not isinstance(answers, list):
+ return
+ for answer in answers:
+ if not isinstance(answer, dict):
+ continue
+ field = answer.get("field")
+ field_type = field.get("type") if isinstance(field, dict) else None
+ if field_type is not None and field_type not in _FREE_TEXT_FIELD_TYPES:
+ continue
+ yield SurveyAnswer(kind=answer.get("type"), text=answer.get("text"))
+
+
+def _source_id(record: dict[str, Any]) -> str | None:
+ response_id = record["response_id"]
+ if not response_id:
+ return None
+ form_id = record.get("form_id")
+ return f"{form_id}:{response_id}" if form_id else str(response_id)
+
+
+TYPEFORM_CONFIG = SignalSourceTableConfig(
+ source_product="typeform",
+ source_type="feedback",
+ emitter=make_survey_emitter(
+ source_product="typeform",
+ source_type="feedback",
+ build_source_id=_source_id,
+ extract_answers=_extract_answers,
+ extra_fields=("form_id", "submitted_at"),
+ ),
+ unloggable_fields=("answers",),
+ record_fetcher=data_warehouse_record_fetcher,
+ partition_field="submitted_at",
+ partition_field_is_datetime_string=True,
+ fields=TYPEFORM_FIELDS,
+ max_records=200,
+ first_sync_lookback_days=1,
+ actionability_prompt=FEEDBACK_ACTIONABILITY_PROMPT,
+ summarization_prompt=FEEDBACK_SUMMARIZATION_PROMPT,
+ description_summarization_threshold_chars=2000,
+)
diff --git a/products/signals/backend/emission/usersnap_feedbacks.py b/products/signals/backend/emission/usersnap_feedbacks.py
new file mode 100644
index 000000000000..8a504df30267
--- /dev/null
+++ b/products/signals/backend/emission/usersnap_feedbacks.py
@@ -0,0 +1,68 @@
+"""Signal emitter for usersnap `feedbacks` (record kind: feedback).
+
+The feedback text lives in `ordered_inputs`, a JSON list of form field values. Only a field's
+`text_value` counts. Email, client, custom data and screenshot columns are never selected.
+"""
+
+from collections.abc import Iterable
+from typing import Any
+
+from products.signals.backend.emission._prompts import FEEDBACK_ACTIONABILITY_PROMPT, FEEDBACK_SUMMARIZATION_PROMPT
+from products.signals.backend.emission._survey import (
+ SurveyAnswer,
+ looks_like_contact_key,
+ make_survey_emitter,
+ parse_json,
+)
+from products.signals.backend.emission.fetchers.data_warehouse import data_warehouse_record_fetcher
+from products.signals.backend.emission.registry import SignalSourceTableConfig
+
+USERSNAP_FIELDS = (
+ "feedback_id",
+ "feedback_number",
+ "public_link",
+ "created_at",
+ "status_type",
+ "priority",
+ "labels",
+ "ordered_inputs",
+)
+
+
+def _extract_answers(record: dict[str, Any]) -> Iterable[SurveyAnswer]:
+ inputs = parse_json(record.get("ordered_inputs"))
+ if not isinstance(inputs, list):
+ return
+ for item in inputs:
+ if not isinstance(item, dict):
+ continue
+ label = item.get("label")
+ label = label.strip() if isinstance(label, str) else None
+ # A custom form field can collect contact details as text; skip those by label.
+ if label and looks_like_contact_key(label):
+ continue
+ yield SurveyAnswer(kind="text", text=item.get("text_value"), label=label or None)
+
+
+USERSNAP_CONFIG = SignalSourceTableConfig(
+ source_product="usersnap",
+ source_type="feedback",
+ emitter=make_survey_emitter(
+ source_product="usersnap",
+ source_type="feedback",
+ build_source_id=lambda record: record["feedback_id"],
+ extract_answers=_extract_answers,
+ extra_fields=("feedback_number", "public_link", "status_type", "priority", "labels", "created_at"),
+ json_list_fields=("labels",),
+ ),
+ unloggable_fields=("ordered_inputs",),
+ record_fetcher=data_warehouse_record_fetcher,
+ partition_field="created_at",
+ partition_field_is_datetime_string=True,
+ fields=USERSNAP_FIELDS,
+ max_records=200,
+ first_sync_lookback_days=1,
+ actionability_prompt=FEEDBACK_ACTIONABILITY_PROMPT,
+ summarization_prompt=FEEDBACK_SUMMARIZATION_PROMPT,
+ description_summarization_threshold_chars=2000,
+)
diff --git a/products/signals/frontend/generated/api.schemas.ts b/products/signals/frontend/generated/api.schemas.ts
index 84a20c55e4ee..518967bc6fc8 100644
--- a/products/signals/frontend/generated/api.schemas.ts
+++ b/products/signals/frontend/generated/api.schemas.ts
@@ -3411,6 +3411,50 @@ export interface RetentlyFeedbackSignalExtraApi {
created_date: string | null
}
+export interface UsersnapFeedbackSignalExtraApi {
+ feedback_number: string | null
+ public_link: string | null
+ status_type: string | null
+ priority: string | null
+ created_at: string | null
+ labels: unknown[]
+}
+
+export interface TypeformFeedbackSignalExtraApi {
+ form_id: string | null
+ submitted_at: string | null
+}
+
+export interface QualtricsFeedbackSignalExtraApi {
+ survey_id: string | null
+ recorded_date: string | null
+ finished: string | null
+}
+
+export interface SurveymonkeyFeedbackSignalExtraApi {
+ survey_id: string | null
+ date_created: string | null
+ response_status: string | null
+}
+
+export interface FormbricksFeedbackSignalExtraApi {
+ survey_id: string | null
+ finished: string | null
+ created_at: string | null
+}
+
+export interface SurvicateFeedbackSignalExtraApi {
+ survey_id: string | null
+ collected_at: string | null
+ url: string | null
+}
+
+export interface SurveysparrowFeedbackSignalExtraApi {
+ survey_id: string | null
+ completed: string | null
+ completed_time: string | null
+}
+
export interface AppfiguresReviewSignalExtraApi {
stars: string | null
version: string | null
@@ -3759,6 +3803,13 @@ export type SignalExtraApi =
| CannyFeedbackSignalExtraApi
| AsknicelyFeedbackSignalExtraApi
| RetentlyFeedbackSignalExtraApi
+ | UsersnapFeedbackSignalExtraApi
+ | TypeformFeedbackSignalExtraApi
+ | QualtricsFeedbackSignalExtraApi
+ | SurveymonkeyFeedbackSignalExtraApi
+ | FormbricksFeedbackSignalExtraApi
+ | SurvicateFeedbackSignalExtraApi
+ | SurveysparrowFeedbackSignalExtraApi
| AppfiguresReviewSignalExtraApi
| AppfollowReviewSignalExtraApi
| JudgemeReviewsReviewSignalExtraApi
diff --git a/products/signals/frontend/inbox/externalSignalSources.ts b/products/signals/frontend/inbox/externalSignalSources.ts
index 84c2daf49edf..571aa800a35c 100644
--- a/products/signals/frontend/inbox/externalSignalSources.ts
+++ b/products/signals/frontend/inbox/externalSignalSources.ts
@@ -487,6 +487,69 @@ export const EXTERNAL_SIGNAL_SOURCES = [
requiredTables: ['Responses'],
sourceType: 'feedback',
},
+ {
+ source: 'usersnap',
+ label: 'Usersnap',
+ category: 'Product feedback',
+ watches: 'Turn product feedback submissions into inputs',
+ dwSourceType: 'Usersnap',
+ requiredTables: ['feedbacks'],
+ sourceType: 'feedback',
+ },
+ {
+ source: 'typeform',
+ label: 'Typeform',
+ category: 'Product feedback',
+ watches: 'Turn open-ended survey answers into inputs',
+ dwSourceType: 'Typeform',
+ requiredTables: ['responses'],
+ sourceType: 'feedback',
+ },
+ {
+ source: 'qualtrics',
+ label: 'Qualtrics',
+ category: 'Product feedback',
+ watches: 'Turn open-ended survey answers into inputs',
+ dwSourceType: 'Qualtrics',
+ requiredTables: ['survey_responses'],
+ sourceType: 'feedback',
+ },
+ {
+ source: 'surveymonkey',
+ label: 'SurveyMonkey',
+ category: 'Product feedback',
+ watches: 'Turn open-ended survey answers into inputs',
+ dwSourceType: 'SurveyMonkey',
+ requiredTables: ['survey_responses'],
+ sourceType: 'feedback',
+ },
+ {
+ source: 'formbricks',
+ label: 'Formbricks',
+ category: 'Product feedback',
+ watches: 'Turn open-ended survey answers into inputs',
+ dwSourceType: 'Formbricks',
+ requiredTables: ['responses'],
+ sourceType: 'feedback',
+ },
+ {
+ source: 'survicate',
+ label: 'Survicate',
+ category: 'Product feedback',
+ watches: 'Turn open-ended survey answers into inputs',
+ dwSourceType: 'Survicate',
+ requiredTables: ['responses'],
+ sourceType: 'feedback',
+ },
+ {
+ source: 'surveysparrow',
+ label: 'SurveySparrow',
+ category: 'Product feedback',
+ watches: 'Turn open-ended survey answers into inputs',
+ dwSourceType: 'SurveySparrow',
+ requiredTables: ['responses'],
+ sourceType: 'feedback',
+ },
{
source: 'uservoice',
label: 'UserVoice',
diff --git a/products/signals/frontend/inbox/signalSourcesLogic.ts b/products/signals/frontend/inbox/signalSourcesLogic.ts
index 692ba114ea1d..53589b4bbf22 100644
--- a/products/signals/frontend/inbox/signalSourcesLogic.ts
+++ b/products/signals/frontend/inbox/signalSourcesLogic.ts
@@ -630,6 +630,7 @@ export interface signalSourcesLogicMeta {
| 'dynamics365'
| 'featurebase'
| 'firehydrant'
+ | 'formbricks'
| 'freshdesk'
| 'freshservice'
| 'frill'
@@ -662,6 +663,7 @@ export interface signalSourcesLogicMeta {
| 'plain'
| 'plane'
| 'productboard'
+ | 'qualtrics'
| 'rapid7_insightvm'
| 'raygun'
| 'retently'
@@ -677,9 +679,14 @@ export interface signalSourcesLogicMeta {
| 'sonarqube'
| 'sprig'
| 'squadcast'
+ | 'surveymonkey'
+ | 'surveysparrow'
+ | 'survicate'
| 'tenable_vulnerability_management'
| 'trigger_dev'
| 'trustpilot'
+ | 'typeform'
+ | 'usersnap'
| 'uservoice'
| 'xmatters'
| 'zendesk'
@@ -717,6 +724,7 @@ export interface signalSourcesLogicMeta {
| 'dynamics365'
| 'featurebase'
| 'firehydrant'
+ | 'formbricks'
| 'freshdesk'
| 'freshservice'
| 'frill'
@@ -749,6 +757,7 @@ export interface signalSourcesLogicMeta {
| 'plain'
| 'plane'
| 'productboard'
+ | 'qualtrics'
| 'rapid7_insightvm'
| 'raygun'
| 'retently'
@@ -764,9 +773,14 @@ export interface signalSourcesLogicMeta {
| 'sonarqube'
| 'sprig'
| 'squadcast'
+ | 'surveymonkey'
+ | 'surveysparrow'
+ | 'survicate'
| 'tenable_vulnerability_management'
| 'trigger_dev'
| 'trustpilot'
+ | 'typeform'
+ | 'usersnap'
| 'uservoice'
| 'xmatters'
| 'zendesk'
@@ -795,6 +809,7 @@ export interface signalSourcesLogicMeta {
| 'dynamics365'
| 'featurebase'
| 'firehydrant'
+ | 'formbricks'
| 'freshdesk'
| 'freshservice'
| 'frill'
@@ -827,6 +842,7 @@ export interface signalSourcesLogicMeta {
| 'plain'
| 'plane'
| 'productboard'
+ | 'qualtrics'
| 'rapid7_insightvm'
| 'raygun'
| 'retently'
@@ -842,9 +858,14 @@ export interface signalSourcesLogicMeta {
| 'sonarqube'
| 'sprig'
| 'squadcast'
+ | 'surveymonkey'
+ | 'surveysparrow'
+ | 'survicate'
| 'tenable_vulnerability_management'
| 'trigger_dev'
| 'trustpilot'
+ | 'typeform'
+ | 'usersnap'
| 'uservoice'
| 'xmatters'
| 'zendesk'
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index ab90571e17e7..5b046cb74b2d 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -54233,6 +54233,12 @@ export namespace Schemas {
Mobile: 'mobile',
} as const;
+ export interface FormbricksFeedbackSignalExtra {
+ survey_id: string | null;
+ finished: string | null;
+ created_at: string | null;
+ }
+
/**
* * `allowed` - allowed
* * `blocked` - blocked
@@ -94753,6 +94759,12 @@ export namespace Schemas {
pins: PulsePin[];
}
+ export interface QualtricsFeedbackSignalExtra {
+ survey_id: string | null;
+ recorded_date: string | null;
+ finished: string | null;
+ }
+
/**
* * `run` - Run
* * `skip` - Skip
@@ -99373,6 +99385,38 @@ export namespace Schemas {
created_date: string | null;
}
+ export interface UsersnapFeedbackSignalExtra {
+ feedback_number: string | null;
+ public_link: string | null;
+ status_type: string | null;
+ priority: string | null;
+ created_at: string | null;
+ labels: unknown[];
+ }
+
+ export interface TypeformFeedbackSignalExtra {
+ form_id: string | null;
+ submitted_at: string | null;
+ }
+
+ export interface SurveymonkeyFeedbackSignalExtra {
+ survey_id: string | null;
+ date_created: string | null;
+ response_status: string | null;
+ }
+
+ export interface SurvicateFeedbackSignalExtra {
+ survey_id: string | null;
+ collected_at: string | null;
+ url: string | null;
+ }
+
+ export interface SurveysparrowFeedbackSignalExtra {
+ survey_id: string | null;
+ completed: string | null;
+ completed_time: string | null;
+ }
+
export interface ZohoCrmTicketSignalExtra {
case_number: string | null;
status: string | null;
@@ -99462,7 +99506,7 @@ export namespace Schemas {
created_at: string | null;
}
- export type SignalExtra = SessionProblemSignalExtra | LlmEvalSignalExtra | LlmEvalReportSignalExtra | ZendeskTicketSignalExtra | GithubIssueSignalExtra | LinearIssueSignalExtra | JiraIssueSignalExtra | ConversationsTicketSignalExtra | ErrorTrackingSignalExtra | PgAnalyzeIssueSignalExtra | EndpointExecutionFailedSignalExtra | EndpointBreakdownLimitExceededSignalExtra | SignalsScoutSignalExtra | CheckFailedSignalExtra | LogsAlertStateChangeSignalExtra | ReplayVisionScannerFindingSignalExtra | AnalyticsAnomalyInvestigationSignalExtra | HealthCheckSignalExtra | EngineeringAnalyticsCIFlakyCheckSignalExtra | EngineeringAnalyticsCIBrokenDefaultBranchSignalExtra | EngineeringAnalyticsCIDurationRegressionSignalExtra | FreshdeskTicketSignalExtra | FreshserviceTicketSignalExtra | FrontConversationSignalExtra | GorgiasTicketSignalExtra | KustomerConversationSignalExtra | DixaConversationSignalExtra | PlainThreadSignalExtra | GitlabIssueSignalExtra | GiteaIssueSignalExtra | ShortcutStorySignalExtra | SentryIssueSignalExtra | RollbarItemSignalExtra | BugsnagErrorSignalExtra | HoneybadgerFaultSignalExtra | RaygunErrorGroupSignalExtra | DatadogSignalExtra | SnykScannerFindingSignalExtra | SonarqubeScannerFindingSignalExtra | SemgrepScannerFindingSignalExtra | Rapid7InsightvmScannerFindingSignalExtra | FeaturebaseFeedbackSignalExtra | FrillFeedbackSignalExtra | AhaFeedbackSignalExtra | UservoiceFeedbackSignalExtra | ProductboardFeedbackSignalExtra | CannyFeedbackSignalExtra | AsknicelyFeedbackSignalExtra | RetentlyFeedbackSignalExtra | AppfiguresReviewSignalExtra | AppfollowReviewSignalExtra | JudgemeReviewsReviewSignalExtra | IntercomTicketSignalExtra | HubspotTicketSignalExtra | Dynamics365TicketSignalExtra | ZohoCrmTicketSignalExtra | GoogleSearchConsoleSearchOpportunitySignalExtra | PagerdutyIncidentSignalExtra | OpsgenieAlertSignalExtra | IncidentIoIncidentSignalExtra | FirehydrantIncidentSignalExtra | SquadcastIncidentSignalExtra | ServicenowIncidentSignalExtra | SolarwindsServiceDeskIncidentSignalExtra | GrafanaIrmIncidentSignalExtra | XmattersIncidentSignalExtra | LaceworkScannerFindingSignalExtra | OrcaSecurityScannerFindingSignalExtra | TenableVulnerabilityManagementScannerFindingSignalExtra | BetterstackIncidentSignalExtra | AsanaIssueSignalExtra | MondayIssueSignalExtra | PlaneIssueSignalExtra | AzureDevopsIssueSignalExtra | MonteCarloAlertSignalExtra | BigeyeIssueSignalExtra | TriggerDevErrorSignalExtra | ChecklyErrorGroupSignalExtra | RoarkIssueSignalExtra | SleekplanFeedbackSignalExtra | BettermodeFeedbackSignalExtra | DiscourseFeedbackSignalExtra | MintlifyFeedbackSignalExtra | LangsmithFeedbackSignalExtra | SprigFeedbackSignalExtra | GainsightPxFeedbackSignalExtra | TrustpilotReviewSignalExtra | OkendoReviewSignalExtra;
+ export type SignalExtra = SessionProblemSignalExtra | LlmEvalSignalExtra | LlmEvalReportSignalExtra | ZendeskTicketSignalExtra | GithubIssueSignalExtra | LinearIssueSignalExtra | JiraIssueSignalExtra | ConversationsTicketSignalExtra | ErrorTrackingSignalExtra | PgAnalyzeIssueSignalExtra | EndpointExecutionFailedSignalExtra | EndpointBreakdownLimitExceededSignalExtra | SignalsScoutSignalExtra | CheckFailedSignalExtra | LogsAlertStateChangeSignalExtra | ReplayVisionScannerFindingSignalExtra | AnalyticsAnomalyInvestigationSignalExtra | HealthCheckSignalExtra | EngineeringAnalyticsCIFlakyCheckSignalExtra | EngineeringAnalyticsCIBrokenDefaultBranchSignalExtra | EngineeringAnalyticsCIDurationRegressionSignalExtra | FreshdeskTicketSignalExtra | FreshserviceTicketSignalExtra | FrontConversationSignalExtra | GorgiasTicketSignalExtra | KustomerConversationSignalExtra | DixaConversationSignalExtra | PlainThreadSignalExtra | GitlabIssueSignalExtra | GiteaIssueSignalExtra | ShortcutStorySignalExtra | SentryIssueSignalExtra | RollbarItemSignalExtra | BugsnagErrorSignalExtra | HoneybadgerFaultSignalExtra | RaygunErrorGroupSignalExtra | DatadogSignalExtra | SnykScannerFindingSignalExtra | SonarqubeScannerFindingSignalExtra | SemgrepScannerFindingSignalExtra | Rapid7InsightvmScannerFindingSignalExtra | FeaturebaseFeedbackSignalExtra | FrillFeedbackSignalExtra | AhaFeedbackSignalExtra | UservoiceFeedbackSignalExtra | ProductboardFeedbackSignalExtra | CannyFeedbackSignalExtra | AsknicelyFeedbackSignalExtra | RetentlyFeedbackSignalExtra | UsersnapFeedbackSignalExtra | TypeformFeedbackSignalExtra | QualtricsFeedbackSignalExtra | SurveymonkeyFeedbackSignalExtra | FormbricksFeedbackSignalExtra | SurvicateFeedbackSignalExtra | SurveysparrowFeedbackSignalExtra | AppfiguresReviewSignalExtra | AppfollowReviewSignalExtra | JudgemeReviewsReviewSignalExtra | IntercomTicketSignalExtra | HubspotTicketSignalExtra | Dynamics365TicketSignalExtra | ZohoCrmTicketSignalExtra | GoogleSearchConsoleSearchOpportunitySignalExtra | PagerdutyIncidentSignalExtra | OpsgenieAlertSignalExtra | IncidentIoIncidentSignalExtra | FirehydrantIncidentSignalExtra | SquadcastIncidentSignalExtra | ServicenowIncidentSignalExtra | SolarwindsServiceDeskIncidentSignalExtra | GrafanaIrmIncidentSignalExtra | XmattersIncidentSignalExtra | LaceworkScannerFindingSignalExtra | OrcaSecurityScannerFindingSignalExtra | TenableVulnerabilityManagementScannerFindingSignalExtra | BetterstackIncidentSignalExtra | AsanaIssueSignalExtra | MondayIssueSignalExtra | PlaneIssueSignalExtra | AzureDevopsIssueSignalExtra | MonteCarloAlertSignalExtra | BigeyeIssueSignalExtra | TriggerDevErrorSignalExtra | ChecklyErrorGroupSignalExtra | RoarkIssueSignalExtra | SleekplanFeedbackSignalExtra | BettermodeFeedbackSignalExtra | DiscourseFeedbackSignalExtra | MintlifyFeedbackSignalExtra | LangsmithFeedbackSignalExtra | SprigFeedbackSignalExtra | GainsightPxFeedbackSignalExtra | TrustpilotReviewSignalExtra | OkendoReviewSignalExtra;
export type SignalMatchMetadata = MatchedMetadata | NoMatchMetadata;