Controller
createUpwell(), UpwellOptions, UpwellState and the UpwellController methods.
import { createUpwell, UpwellController, type UpwellOptions, type UpwellState } from 'upwell';The controller runs Upwell end to end. It reads the device, fetches the policy, asks the store and the
OTA tool, runs decide(), and performs the resulting update. It doesn't depend on React;
UpwellProvider wraps it.
const upwell = createUpwell({ policy: 'https://cdn.example.com/upwell/policy.json' });UpwellOptions
Prop
Type
Events
const upwell = createUpwell({
policy: url,
onEvent: (event) => posthog.capture(`upwell_${event.type}`, event),
});The controller emits the events, so they're the same with the UI kit, your own UI, or no UI.
event.type is one of check, prompt_shown, prompt_action, store_flow, ota_downloaded,
ota_applied, updated_seen and error; every event also carries the app version, build,
runtime, running update, install source, SDK version, timestamp and the random per-install
installationId. See Send update events to your analytics for
when each one fires, and the UpwellEvent type.
Methods
| Method | |
|---|---|
check(opts?) | Re-evaluates everything. Concurrent calls share one run. Without { force: true }, a check within minCheckIntervalMs of the last one returns the current decision |
startUpdate() | Does what the current decision calls for: the store flow, installing a downloaded update, or restarting into an OTA update |
startStoreUpdate(flow?) | Starts a store flow (default: the decision's flow). Falls back to the store link if a Play flow fails |
completeStoreUpdate() | Installs a downloaded flexible update. The app restarts |
applyOta() | Restarts into the downloaded OTA update |
dismiss() | "Later" for the current decision. Reported as a prompt_action event for store prompts |
markUpdateSeen() | Clears justUpdated. Reported as an updated_seen event |
explain() | { decision, trace } for the current decision |
handleAppStateChange(next) | Call with AppState changes when you don't use the provider. 'active' checks; 'background' installs a postponed flexible update |
simulate(scenario, options?) | Jumps to a simulated state. null returns to the real device |
getState() | The current UpwellState |
subscribe(listener) | Calls listener(state) on every change. Returns an unsubscribe function |
dispose() | Stops listening to the store and drops all listeners |
UpwellState
Prop
Type