Skip to content

feat(mobile): stamp inbox_client=mobile on inbox analytics events (port #3059)#3086

Merged
Gilbert09 merged 2 commits into
mainfrom
posthog-code/mobile-inbox-client-analytics
Jul 2, 2026
Merged

feat(mobile): stamp inbox_client=mobile on inbox analytics events (port #3059)#3086
Gilbert09 merged 2 commits into
mainfrom
posthog-code/mobile-inbox-client-analytics

Conversation

@Gilbert09

Copy link
Copy Markdown
Member

What

Ports desktop PR #3059 (feat(inbox): stamp inbox_client=code on inbox analytics events) to the mobile app.

Desktop added a client discriminator property, inbox_client, to every inbox-family analytics event so the shared PostHog project can be sliced by surface. The plan is: desktop stamps "code", mobile stamps "mobile", and the PostHog web frontend stamps "cloud". This PR implements the mobile side.

Changes

  • apps/mobile/src/lib/analytics.ts: the useAnalytics().track wrapper now stamps { inbox_client: "mobile", ...properties } on the mobile inbox-family events (Inbox viewed, Inbox report opened, Inbox report closed, Inbox report scrolled, Inbox report action). The client value is spread first so an explicit caller override wins, matching the desktop shape. Non-inbox events are untouched.
  • Membership is determined via a small module-local INBOX_ANALYTICS_EVENT_NAMES set built from mobile's own ANALYTICS_EVENTS values — mobile already owns its own event map, so it keeps a mobile-local set rather than importing the shared helper. Mobile has no SIGNAL_SOURCE_CONNECTED event, so only the inbox events that exist in mobile are included.
  • apps/mobile/src/lib/analytics.test.ts: added tests covering that inbox events get inbox_client="mobile" (parameterized across all inbox event names), that non-inbox events do not, and that a caller-provided inbox_client wins over the default.

Testing

  • pnpm --filter mobile test src/lib/analytics.test.ts — 12 passing
  • Biome check clean on the changed files

#3059)

Ports desktop PR #3059 to the mobile app: stamp a client discriminator
`inbox_client="mobile"` on the inbox-family analytics events so the shared
PostHog project can be sliced by surface.

The mobile analytics wrapper (`useAnalytics().track`) now spreads
`{ inbox_client: "mobile", ...properties }` for events in the mobile inbox
set (Inbox viewed / report opened / closed / scrolled / action), with the
client value first so an explicit override wins. Non-inbox events are
unchanged.

Mobile keeps its own event set rather than importing the shared helper,
mirroring how it already owns its `ANALYTICS_EVENTS` map.

Generated-By: PostHog Code
Task-Id: 03d5200d-e698-4abe-8980-4bfe2290a9c7
@Gilbert09 Gilbert09 requested a review from a team July 2, 2026 10:43
@github-actions

github-actions Bot commented Jul 2, 2026

Copy link
Copy Markdown

React Doctor found no issues in the changed files. 🎉

Reviewed by React Doctor for commit 8270a6e.

@greptile-apps

greptile-apps Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(mobile): stamp inbox_client=mobile ..." | Re-trigger Greptile

Comment thread apps/mobile/src/lib/analytics.ts Outdated
// "cloud"). Mirrors packages/ui/src/shell/posthogAnalyticsImpl.ts.
const INBOX_CLIENT = "mobile" as const;

const INBOX_ANALYTICS_EVENT_NAMES: ReadonlySet<string> = new Set([

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 INBOX_ANALYTICS_EVENT_NAMES is module-private, so the test file has to maintain an identical parallel list in INBOX_EVENTS. If a new inbox event is added to ANALYTICS_EVENTS but forgotten in either place the two drift silently. Exporting the set lets the test iterate it directly, eliminating the duplicate list.

Suggested change
const INBOX_ANALYTICS_EVENT_NAMES: ReadonlySet<string> = new Set([
export const INBOX_ANALYTICS_EVENT_NAMES: ReadonlySet<string> = new Set([

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Export INBOX_ANALYTICS_EVENT_NAMES and iterate it in the analytics test
instead of maintaining a parallel INBOX_EVENTS list, so the two can no
longer drift silently when an inbox event is added. Addresses Greptile
review feedback on #3086.

Generated-By: PostHog Code
Task-Id: 03d5200d-e698-4abe-8980-4bfe2290a9c7
@Gilbert09 Gilbert09 merged commit aeacc26 into main Jul 2, 2026
23 checks passed
@Gilbert09 Gilbert09 deleted the posthog-code/mobile-inbox-client-analytics branch July 2, 2026 15:45
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