Skip to content

notifications: emit Tapped DM Push Notification on tap#5871

Open
patosullivan wants to merge 6 commits into
developfrom
po/tlon-5728-nudge-notification-tracking
Open

notifications: emit Tapped DM Push Notification on tap#5871
patosullivan wants to merge 6 commits into
developfrom
po/tlon-5728-nudge-notification-tracking

Conversation

@patosullivan

@patosullivan patosullivan commented May 21, 2026

Copy link
Copy Markdown
Member

Summary

Adds a Tapped DM Push Notification analytics event so we can measure whether nudge notifications actually bring users back into the app. The event is emitted from the mobile notification tap handler and carries only the fields needed to join it, in PostHog, to the existing OpenClaw nudge-send event on messageId. This gives us a send-to-tap funnel for nudges.

Fixes TLON-5728

Companion PR in openclaw-tlon: tloncorp/openclaw-tlon#155

Changes

  • Added AnalyticsEvent.ActionTappedDmPushNotif = 'Tapped DM Push Notification' in packages/api/src/types/analytics.ts.
  • Added apps/tlon-mobile/src/lib/dmTapTelemetry.ts — pure helpers that read the raw notification payload, parse the activity event, and build the DM-tap telemetry (attribution-window math, sigil normalization, malformed-payload guards). The payload carries join/diagnostic fields only — ownerShip, senderShip, messageId, messageSentAtMs, delayMs, withinAttributionWindow, notificationUid, platform (no DM content).
  • Emitted the event from a dedicated effect in useNotificationListener.ts, keyed only on the notification response so it fires exactly once per tap and is fully decoupled from the routing effect (it cannot cause navigation to re-run). The owner ship is read synchronously via getCurrentUserId() — the same already-initialized client identity the rest of the API layer uses — so there is no async hydration that could race the response-clearing and drop a cold-start tap. Best-effort: wrapped so a failure can never break navigation.
  • Reuses existing single-source helpers rather than adding parallel implementations: pickPlatformPayload (now shared between the telemetry read and payloadFromNotification), preSig, and getCurrentUserId from @tloncorp/api.
  • Forwarded the notification uid from native into JS on iOS (NotificationService.swift) and Android (TalkMessagingService.kt, NotificationManager.kt). This is best-effort and diagnostic-only; notificationUid is nullable.
  • Added a dmTapTelemetry Jest suite and a vitest round-trip canary (packages/shared/src/api/__tests__/dmTapTelemetryRoundTrip.test.ts).

A paired PR in openclaw-tlon adds messageId and nudgeSentAtMs to the TlonBot Heartbeat Nudge Sent event so the two events can be joined in PostHog.

How did I test?

  • pnpm -r tsc passes.
  • Mobile Jest passes: the dmTapTelemetry suite and the existing useNotificationListener hook suite (its routing effect is unchanged by this PR).
  • vitest passes: the cross-repo round-trip canary.
  • End-to-end verified on Android and iOS against the PostHog Tlon Staging project: a nudge send followed by a DM push tap joined correctly (sends=1 / converted_sends=1).

Risks and impact

  • Safe to rollback without consulting PR author? Yes
  • Affects important code area:
    • Notifications

Rollback plan

Revert.

Screenshots / videos

N/A

@linear

linear Bot commented May 21, 2026

Copy link
Copy Markdown

TLON-5728

@patosullivan patosullivan force-pushed the po/tlon-5728-nudge-notification-tracking branch from 5f308ad to 1d0472b Compare June 1, 2026 18:44
@patosullivan patosullivan changed the title notifications: emit Tapped DM Push Notification on tap for TLON-5728 notifications: emit Tapped DM Push Notification on tap Jun 1, 2026
@patosullivan patosullivan force-pushed the po/tlon-5728-nudge-notification-tracking branch from 1d0472b to 86f8cb3 Compare June 1, 2026 18:49
@patosullivan patosullivan marked this pull request as ready for review June 1, 2026 19:12

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review and subscribe this PR to future pushes, or @claude review once for a one-time review.

Tip: disable this comment in your organization's Code Review settings.

@patosullivan

Copy link
Copy Markdown
Member Author

@claude review once

Comment thread apps/tlon-mobile/src/lib/dmTapTelemetry.ts
@patosullivan

Copy link
Copy Markdown
Member Author

@claude review once

Comment thread apps/tlon-mobile/src/lib/dmTapTelemetry.ts Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1c9debfea4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/tlon-mobile/src/hooks/useNotificationListener.ts Outdated
@patosullivan

Copy link
Copy Markdown
Member Author

@claude review once

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 38c953cbb5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread apps/tlon-mobile/src/hooks/useNotificationListener.ts Outdated
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