Skip to content

Commit 3154d42

Browse files
committed
feat: ✨ Add logging for aircall tags in ConversationsStream post_process method
1 parent 2b072af commit 3154d42

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

tap_intercom/streams.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,34 @@ class ConversationsStream(IntercomStream):
3333
schema = conversations_schema
3434
is_sorted = False
3535

36+
def post_process(self, row: dict, context: dict | None = None) -> dict | None:
37+
"""Log id-tags combinations if they contain "aircall" to help diagnose tap vs target issues.
38+
39+
Args:
40+
row: Individual record in the stream.
41+
context: Stream partition or context dictionary.
42+
43+
Returns:
44+
The record dict, or `None` if the record should be excluded.
45+
"""
46+
row = super().post_process(row, context)
47+
if row is None:
48+
return None
49+
aircall_tags = [
50+
tag for tag in (row.get("tags") or {}).get("tags") or []
51+
if "aircall" in (tag.get("name") or "").lower()
52+
]
53+
if aircall_tags:
54+
# Log only minimal tag information at DEBUG level to avoid high-volume,
55+
# potentially sensitive per-record logging at INFO.
56+
tag_names = [tag.get("name") for tag in aircall_tags if tag.get("name")]
57+
self.logger.debug(
58+
"CONVERSATION_TAGS: id=%s tag_names=%s",
59+
row.get("id"),
60+
tag_names,
61+
)
62+
return row
63+
3664
def get_child_context(self, record: dict, context: dict | None) -> dict: # noqa: ARG002
3765
"""Return a context dictionary for child streams."""
3866
return {"conversation_id": record["id"]}

0 commit comments

Comments
 (0)