Install — Mobile
Install AnyReplay in a Cordova App
Record Cordova app sessions with the @anyreplay/cordova plugin: the browser SDK as a global, with the app id, durable storage and the app's own styles.
A Cordova app's screens are a web page, so AnyReplay records them with the browser SDK — its masking and every one of its options — bundled into a plugin that adds the app id, the app version and device model, storage that survives the web view clearing its own, a flush on Cordova's pause event, and the app's own styles, fonts and images in the replay. It is the same core as the Capacitor plugin.
Requirements
- cordova-android 10 or later, cordova-ios 6 or later.
Tested with cordova-ios 8.1. Android is supported and not yet tested on a device; tell us through the contact page if anything is off there.
Install
cordova plugin add @anyreplay/cordovaStart recording
// The app id (bundle id / package name) is read from the app itself.
document.addEventListener('deviceready', function () {
AnyReplay.init({
projectKey: 'YOUR_PROJECT_KEY',
ingestUrl: 'https://in.anyreplay.com',
// Stop recording after this many sessions in a calendar month.
// maxSessionsPerMonth: 10000,
// Form fields are masked: what visitors type replays as asterisks.
// Passwords, one-time codes and card fields are masked either way.
// Uncomment the first line to record what visitors type, or the
// second to hide rich-text editors too.
// maskAllInputs: false,
// maskAllTyping: true
});
});The plugin installs a global AnyReplay. init waits for deviceready by itself, so calling it earlier is safe; a second call is ignored. AnyReplay.consent, identify, track, flush and stop work as in the browser SDK and may be called before init has finished. For TypeScript, add @anyreplay/cordova to compilerOptions.types for the global's types.
Allowed apps
A Cordova app has no web origin to list: iOS sends app://localhost and Android https://localhost. The plugin sends the bundle id or package name as appId, read from the app. If the project lists allowed domains or apps, add that id under Allowed apps.
Styles, fonts and images
As in the Capacitor plugin: stylesheets are copied into the recording, images the app ships (PNG, JPEG, GIF, WebP, up to 3 MB) are uploaded once per project by content hash, and fonts (up to 160 KB) and SVGs (up to 48 KB) travel inside the recording, up to 1 MB per page. Files from the device (/__cdvfile_…) are never read.
Native code
Two small classes, one per platform, read the app id, version and device model and keep one string of storage: a copy of the recorder's visitor and session keys, so a returning user stays recognised when the web view clears its storage and a relaunch within 30 minutes continues the session. They ask for no permissions and make no network requests. Pause and resume come from Cordova's own document events.
Known limits
- On iOS the pause flush has no background task, so the last seconds before the app is suspended can be lost. The Capacitor plugin holds one.
- Unsent events are kept in memory while the device is offline; if the app is killed before it reconnects they are lost.
Every option is in the browser SDK reference.