Skip to content

feat(inbox): Capture "Signal source connected" analytics event#2380

Merged
charlesvien merged 1 commit into
mainfrom
posthog-code/signal-source-connected-analytics
May 27, 2026
Merged

feat(inbox): Capture "Signal source connected" analytics event#2380
charlesvien merged 1 commit into
mainfrom
posthog-code/signal-source-connected-analytics

Conversation

@Twixes
Copy link
Copy Markdown
Member

@Twixes Twixes commented May 26, 2026

Summary

  • Adds a new Signal source connected analytics event, fired from both signal-source connection paths in useSignalSourceManager: the direct toggle (non-warehouse sources) and the post-DataSourceSetup-wizard completion (warehouse sources).
  • Event carries source_product, is_first_connection (brand-new config vs. re-enable of an existing one), and via_setup_wizard (warehouse OAuth path vs. plain toggle).
  • Closes a gap surfaced when trying to measure inbox onboarding — there was no event firing on the actual source-connected moment. Now we can build a first-time-for-user trend (e.g. "inbox users onboarded") and subscribe a team channel to a daily snapshot.

Test plan

  • Toggle on error_tracking from the Inbox sources settings → confirm Signal source connected fires once with source_product: "error_tracking", is_first_connection: true, via_setup_wizard: false. Toggle off then on again → second firing has is_first_connection: false.
  • Toggle on session_replay → same flow as above (non-warehouse path).
  • Connect github (or any warehouse source) via the DataSourceSetup wizard end-to-end → confirm one firing on completion with via_setup_wizard: true and is_first_connection: true.
  • Disable a previously enabled source → confirm no event fires (we only track connections, not disconnections).
  • If the API call inside handleSetupComplete fails → confirm the event does not fire (it lives inside the try block, before the catch).

Fires when a user enables a signal source for the Inbox, either by toggling a non-warehouse source on directly or by completing the DataSourceSetup wizard for a warehouse source. `is_first_connection` distinguishes a brand-new config from a re-enable; `via_setup_wizard` distinguishes the OAuth path from a plain toggle. Lets us measure inbox onboarding (e.g. first-time-for-user trend of new users connecting their first source).

Generated-By: PostHog Code
Task-Id: 55527856-9edd-4907-a389-98ac880f806d
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented May 26, 2026

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/code/src/renderer/features/inbox/hooks/useSignalSourceManager.ts:431-435
The `track` call fires unconditionally inside the `try` block — even when `existing` is already truthy **and** `existing.enabled` is already `true`. In that case neither `createSignalSourceConfig` nor `updateSignalSourceConfig` is invoked, so no actual connection happened, yet a `Signal source connected` event is emitted. A concrete path to this state: a warehouse source's external-data-source row is deleted externally while the signal-source config stays enabled; the next toggle attempt opens the wizard, and completing it fires a spurious analytics event.

```suggestion
        if (!existing || !existing.enabled) {
          track(ANALYTICS_EVENTS.SIGNAL_SOURCE_CONNECTED, {
            source_product: completedSource,
            is_first_connection: !existing,
            via_setup_wizard: true,
          });
        }
```

Reviews (1): Last reviewed commit: "feat(inbox): Capture "Signal source conn..." | Re-trigger Greptile

@charlesvien charlesvien merged commit cc30041 into main May 27, 2026
15 checks passed
@charlesvien charlesvien deleted the posthog-code/signal-source-connected-analytics branch May 27, 2026 02:54
Gilbert09 added a commit that referenced this pull request May 28, 2026
Mirror desktop's inbox event names + property shapes on the mobile app so
both clients are comparable in PostHog dashboards.

Events wired:
- `Inbox viewed` — fired once per inbox-tab focus, with priority/actionability
  breakdown counts (per #2295).
- `Inbox report opened` / `closed` / `scrolled` — fired from the report
  detail screen via a new `useInboxEngagementTracker` hook, with priority +
  actionability snapshotted at open time.
- `Inbox report action` — fired for:
  - Dismiss / snooze via the dismiss sheet (with `dismissal_reason` and
    `dismissal_note`, truncated to 1000 chars per #2287).
  - "Start task" on the detail screen → `create_pr`, surface `detail_pane`.
  - Tinder swipe-right (accept) → `create_pr`, surface `list_row`.
  - Tinder swipe-left (dismiss) → `dismiss`, surface `list_row`.
  - Expanding the Signals list on the detail screen → `expand_signal`.

For #2369 (tagging discuss-launched task events with `signal_report_id`):
the task detail screen registers a `signal_report_id` PostHog super-property
for the duration of the screen when the task carries one, matching the
desktop super-property behaviour.

#2380 (`Signal source connected`) is intentionally skipped: there is no
signal-source connect / data-source-setup flow in the mobile app. We do not
fire any "Task created" event on mobile yet, so the desktop-side `Task
created` tagging in #2369 also doesn't apply here — only the super-property
half does, and that's what we wired.

Architecture: analytics types and the `useAnalytics()` / `useActiveTaskAnalyticsContext()`
hooks live in `apps/mobile/src/lib/analytics.ts`. Event names and property
shapes are literal mirrors of `apps/code/src/shared/types/analytics.ts` —
no shared package extraction since the desktop types live inside `apps/code`,
not in a shared workspace.

Tests:
- `apps/mobile/src/lib/analytics.test.ts` — `computeReportAgeHours` and
  the `useActiveTaskAnalyticsContext` super-property lifecycle.
- `apps/mobile/src/features/inbox/utils.test.ts` —
  `buildInboxViewedProperties` (priority/actionability counts,
  has_active_filters detection).
- `apps/mobile/src/features/inbox/hooks/useInboxEngagementTracker.test.ts`
  — OPENED/CLOSED/SCROLLED lifecycle, scroll-once semantics, and
  signalAction inheritance vs. overrides.

`pnpm --filter @posthog/mobile test` → 119 passed (14 new). `pnpm lint`
clean. No new TypeScript errors.

Generated-By: PostHog Code
Task-Id: 2e652fec-af01-4476-b6cf-ab9b4de015db
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.

2 participants