Skip to content

feat: onEvent, typed update events for your analytics (plan 06 session 2) - #16

Merged
ommgh merged 1 commit into
mainfrom
sdk-event-stream
Nov 14, 2026
Merged

ommgh merged 1 commit into
mainfrom
sdk-event-stream

Conversation

@ommgh

@ommgh ommgh commented Nov 13, 2026

Copy link
Copy Markdown
Member

Stacked on #11 (zero-policy-mode): it makes policy optional and touches the controller, so this branch builds on it. Merge #11 first; GitHub then retargets this PR to main.

What

A new onEvent option on createUpwell() and UpwellProvider. The controller (not the UI kit) emits typed events, so headless apps get them too. Upwell still sends nothing anywhere itself.

Event When
check Every completed check (not throttled ones): decision kind, reason, policy origin (fresh / cached / none), duration
prompt_shown The decision becomes store.recommended / store.required, once per kind + target per session
prompt_action update (store flow started from a prompt), later (dismiss()), dismiss (declined Play's own dialog)
store_flow A store flow finished: flow, result (a Play flow falling back to the store link reports both)
ota_downloaded / ota_applied OTA download finished / restart requested, with the new update id and apply mode
updated_seen markUpdateSeen() while an update is announced
error Anything passed to onError

Common fields: timestamp, SDK version, platform, app version, build, runtime, running update id, install source, the random installationId, and the simulate() scenario (null on a real device). Nothing personal. A test pins the common keys.

A handler that throws or rejects goes to onError with context onEvent and never breaks updating (and can't loop into another error event).

Other changes:

  • Event types in @upwell/core (packages/core/src/events.ts); StoreFlowResult moved there (still exported from upwell).
  • OtaAdapter.download() may return { updateId }; expoUpdatesAdapter() returns the fetched manifest id. Returning nothing still works.
  • sdkVersion comes from package.json at runtime (src/version.ts), so the version changesets writes is the one reported.
  • useAppUpdate() is unchanged; the UI kit is untouched.

Design decisions (also recorded in the plan)

  • prompt_shown fires when the decision calls for the prompt, not from a UI callback. That's when the controller already counts a prompt for maxPrompts, it works headless, and the UI kit renders its prompts for exactly those decisions. The catch: a custom UI that doesn't render the prompt still gets the event. The docs say so.
  • Prompt events cover store prompts only. OTA restart prompts show up as ota_applied with applyMode: 'prompt'.
  • nextLaunch OTA updates have no ota_applied, because the OTA tool applies them by itself. The next check carries the new updateId.

Docs

  • New guide: Send update events to your analytics (guides/analytics-events.mdx). It covers the event reference, PostHog and Firebase Analytics examples (Firebase reserves error, so names are prefixed upwell_ and fields flattened), volume notes, and dashboards: installs per build, stranded share and prompt conversion, with PostHog SQL.
  • onEvent added to the controller, React and types references, and to the OTA adapter guide (download() result). "Debugging and analytics" now points to onEvent. FAQ, how-it-works and the SDK README updated.
  • Plan 06 session 2 is ticked off, and its event table now matches what was built.

Checks

npm run lint, npm run typecheck, npm test (core 169, upwell 96, up from 71) and npm run build pass locally. The docs site builds.

Changeset: upwell and @upwell/core, minor.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RX4BmNghPADsZ6GMRb2ALH

…n 2)

The controller emits check, prompt_shown, prompt_action, store_flow,
ota_downloaded, ota_applied, updated_seen and error events through a new
onEvent option, so headless apps get them too. Each carries the app
version, build, runtime, running update, install source, SDK version,
timestamp and the random installationId; nothing personal. A throwing or
rejecting handler goes to onError with context "onEvent" and never
breaks updating.

The event types live in @upwell/core (StoreFlowResult moved there too).
OtaAdapter.download() may return { updateId }, which expoUpdatesAdapter()
does, so OTA events can name the new update.

Docs: a new guide, "Send update events to your analytics", with PostHog
and Firebase Analytics examples and the dashboards worth building;
onEvent in the controller, React and types references.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RX4BmNghPADsZ6GMRb2ALH
@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
upwell-docs Ready Ready Preview Nov 13, 2026 6:31am UTC

@ommgh
ommgh deleted the branch zero-policy-mode November 14, 2026 07:21
@ommgh ommgh closed this Nov 14, 2026
@ommgh ommgh reopened this Nov 14, 2026
@ommgh
ommgh changed the base branch from zero-policy-mode to main November 14, 2026 07:26
@ommgh
ommgh merged commit c5de442 into main Nov 14, 2026
11 checks passed
@ommgh
ommgh deleted the sdk-event-stream branch November 14, 2026 07:39
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