Documentation

Capacitor SDK.

Screens, taps, opens, links, pushes and errors from your Capacitor or Ionic app, linked to the same people as your site.

Capacitor

Install

One package for Capacitor and Ionic apps (Angular, React and Vue) on iOS, Android and the web.

shell
echo "@gotmode:registry=https://gotmode.com/sdk/npm/" >> .npmrc
npm install @gotmode/metrics-capacitor @capacitor/app @capacitor/device @capacitor/preferences

The .npmrc line sends every @gotmode package to Mode, so commit it with the project. pnpm, Yarn 1 and Bun read it too.

Mode serves its SDKs itself, not from a public package registry. A published version never changes, and every file and its SHA-256 is listed in SHA256SUMS.

FileVersionSHA-256
gotmode-metrics-capacitor-0.1.0.tgz0.1.07c3c7e2d1711951e29427f444b5e4e1e524103d5b675dee93a8b785fe66c4176
gotmode-metrics-core-0.1.0.tgz0.1.0fac754c0bb498c57505735897073c09b2860044af54376c1a4611c095b9203c3
Capacitor

Start

Call init once, at the top of your app's entry file, with your public key and your tracking hostname.

javascript
import mode from '@gotmode/metrics-capacitor';

mode.init('YOUR_INGEST_KEY', { api_host: 'https://m.example.com' });

The SDK finds the app, device, preferences and push notification plugins your app has installed on its own, and never takes from the app a tap, a token or a launch link the plugin keeps for the app's first listener. Every plugin is optional. Without App the SDK follows the page's visibility, without Preferences it keeps its state in the web view's storage, without Device device facts come from the web view.

Capacitor

Events and people

Capture what matters in your app, and name the person once they sign in.

javascript
mode.capture('added_to_cart', { sku: 'tee-black-m', price: 24 });
mode.identify('user_42', { plan: 'pro' });
mode.group('company', 'acme', { seats: 25 });
mode.register({ app_theme: 'dark' });
mode.reset(); // on logout

A different user than the one stored starts a new person. Person properties set before identify wait for it. An empty id, one over 200 bytes, or a placeholder such as null or guest is never sent. alias, set_person_properties, unset_person_properties, register_once, register_for_session, unregister, flags (flag, flag_enabled, flag_payload) and capture_exception work as on the web.

Capacitor

What is captured automatically

Every event below arrives with no code beyond init.

EventWhen
$app_installed, $app_updated, $app_opened, $app_backgroundedLaunches, new versions, the foreground and the background
$screenEvery route your router moves to, by path or hash route, never the query
$deep_link_openedThe launch link and every link the app is opened with
$click, $rage_clickTaps on buttons, links and fields
$push_received, $push_opened, $push_registeredWith the push notifications plugin installed. The message id, campaign, iOS category and thread, never the title or the body. The tap that opened the app marks that open. capture_push: false turns it off
$exceptionUncaught errors and unhandled rejections

The platform is iOS, Android or the web, as Capacitor reports it, and the web view's own user agent names the device. A link loses its secret parameters and emails before anything is kept, and its campaign parameters, ad click ids and Mode click id become the person's touch.

Capacitor

Taps and privacy

A tapped control is described by its tag, id, role, label and visible text, never by a field's value.

Password, card, one time code and hidden fields produce nothing. data-mode-ignore keeps part of a page out, data-mode-mask hides its text, data-mode-track names a control.

Capacitor

Session recordings

The app's web view recorded like a page, played in Recordings.

Coming in the next release. The published package doesn't record sessions yet. The recording option and its masking attributes will be listed here once they are published.

Recordings will mask every text, image, and field value until you turn it on in the source's recording settings, never send a password, and record nothing before consent where it is required or after an opt out.

Capacitor

Delivery

Events wait on the device and are sent in batches, so nothing is lost offline and nothing is counted twice.

SettingValue
BatchesA second after an event, at once at 50 events, and when the app goes to the background
QueueUp to 1,000 events stored on the device
RetriesFrom 1 second to 5 minutes, with the same event ids
Shutdownmode.shutdown() sends what is queued and removes every listener

Let AI run your marketing.

Mode Agent does the daily work. You approve the spend.

Get early access