Skip to content

Fix Intercom types for conversation_part.tag.* events#20

Merged
Macil merged 3 commits into
masterfrom
chris/betterIntercom
Apr 1, 2026
Merged

Fix Intercom types for conversation_part.tag.* events#20
Macil merged 3 commits into
masterfrom
chris/betterIntercom

Conversation

@Macil
Copy link
Copy Markdown
Contributor

@Macil Macil commented Apr 1, 2026

No description provided.

@greptile-apps
Copy link
Copy Markdown

greptile-apps Bot commented Apr 1, 2026

Greptile Summary

This PR fixes TypeScript type inference for Intercom webhook events whose topics have two dots (e.g. conversation_part.tag.added, conversation_part.tag.removed). Previously the topic-to-payload mapping only handled single-prefix topics (<type>.<action>), causing these three-part topics to resolve to unknown. The fix introduces a IntercomWebhookSubtopicTypeMap keyed on two-part prefixes ("conversation_part.tag"), reworks IntercomWebhookPrefix<T> to try the longer two-part match first, and adds IntercomWebhookPayload<TMap, TPrefix> to safely narrow the type field. A new public IntercomConversationPartTag interface describes the payload shape (wrapping Conversation + Tag objects), and a companion type-test file verifies both the single-topic and mixed-topic narrowing paths.

Confidence Score: 5/5

  • Safe to merge — pure TypeScript type change with no runtime behaviour affected and comprehensive type-level tests.
  • All changes are compile-time only. The type inference logic is correct: IntercomWebhookPrefix correctly matches the longest valid prefix (two-part before one-part), IntercomWebhookPayload safely narrows the type field without breaking existing, more-specific types, and the new IntercomConversationPartTag interface is well-formed with the correct literal type. Tests cover the four key paths (single new-topic, single old-topic, mixed new+old, IntercomEvent direct usage). No P0/P1 findings.
  • No files require special attention.

Important Files Changed

Filename Overview
integrations/intercom/runtime.ts Adds IntercomConversationPartTag interface and reworks the webhook item type inference to support 3-part topics (e.g. conversation_part.tag.added) via a new IntercomWebhookSubtopicTypeMap and helper types IntercomWebhookPrefix, IntercomWebhookPayload, and IntercomWebhookItem.
integrations/intercom/runtime.types.test.ts Adds type-level tests for conversation_part.tag.added (single and mixed-event listener), verifies type narrowing for existing event types like contact, conversation, job, and ticket.
mod.ts Exports the new IntercomConversationPartTag type from the public API surface.

Reviews (1): Last reviewed commit: "update intercom docs link" | Re-trigger Greptile

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request improves the type inference for Intercom webhook events by introducing a more sophisticated mapping system. It adds support for subtopics (e.g., 'conversation_part.tag'), ensures the 'type' property on event payloads is correctly narrowed, and includes the new IntercomConversationPartTag interface. The changes are accompanied by updated type tests and exports. I have no feedback to provide.

@Macil Macil merged commit 6106f10 into master Apr 1, 2026
1 check passed
@Macil Macil deleted the chris/betterIntercom branch April 1, 2026 23:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant