npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@userpilot/cordova

v1.0.6

Published

Cordova Plugin for the native Userpilot SDKs on Android and iOS

Readme

Userpilot Cordova Plugin

npm License: MIT

Userpilot Cordova Plugin enables you to capture user insights and deliver personalized in-app experiences in real time. With just a one-time setup, you can immediately begin leveraging Userpilot's analytics and engagement features to understand user behaviors and guide their journeys in-app.

This document provides a step-by-step walkthrough of the installation and initialization process, as well as instructions on using the plugin's public APIs.

🚀 Getting Started

Prerequisites

Cordova - your application should use Cordova version 10+ with cordova-cli installed globally.

Android - your application's config.xml must have a android-compileSdkVersion of 35+ and android-minSdkVersion of 24+. Your project should use the Android Gradle Plugin (AGP) version 8.1 or above.

<platform name="android">
    <preference name="android-minSdkVersion" value="21" />
    <preference name="android-compileSdkVersion" value="35" />
    <preference name="android-targetSdkVersion" value="35" />
    <preference name="GradlePluginKotlinEnabled" value="true" />
</platform>

iOS - your application must target iOS 13+ to install the SDK, Update the iOS project xcodeproj to set the deployment target. Update your config.xml to set the deployment target.

<platform name="ios">
    <preference name="deployment-target" value="13.0" />
    <preference name="SwiftVersion" value="5.0" />
</platform>

Installation

Add the Userpilot Cordova Plugin to your application.

  1. In your app's root directory, install the Userpilot Cordova Plugin

    cordova plugin add @userpilot/cordova
  2. Prepare your platforms:

    cordova prepare

Initializing

To use Userpilot, initialize it once when your device is ready. This ensures the SDK is ready as soon as your app starts. Replace <APP_TOKEN> with your Application Token, which can be fetched from your Environments Page.

    API:
setup(token, options, onSuccess, onError)
    Basic Example:
document.addEventListener('deviceready', function() {
    window.userpilot.setup('<APP_TOKEN>', 
        function(success) {
            console.log('Userpilot initialized successfully');
        },
        function(error) {
            console.error('Failed to initialize Userpilot:', error);
        }
    );
}, false);
    Advanced Example with Options:
document.addEventListener('deviceready', function() {
    const options = {
        logging: true,         // Enable/disable SDK logging
        useInAppBrowser: true, // Enable/disable in-app browser for links - Works for Android       
    };
    
    window.userpilot.setup('<APP_TOKEN>', options,
        function(success) {
            console.log('Userpilot initialized successfully');
        },
        function(error) {
            console.error('Failed to initialize Userpilot:', error);
        }
    );
}, false);
SDK Configurations

| Parameter | Type | Description | | ----------------------------------------- | -------- | ------------------------------------------------------------------------------------------------------------ | | logging | Boolean | Enable or Disable logs for SDKDefault: false | | disableRequestPushNotificationsPermission | Boolean | Disable request push notifications permission by SDK.Default: false | | useInAppBrowser | Boolean | configuration to indicate when to open the URL inside CustomTabsIntent or not.Default: false |

Identifying Users

This API is used to identify unique users and companies (groups of users) and set their properties. Once identified, all subsequent tracked events and screens will be attributed to that user.

Recommended Usage:

  • On user authentication (login): Immediately call identify when a user signs in to establish their identity for all future events.
  • On app launch for authenticated users: If the user has a valid authenticated session, call identify at app launch.
  • Upon property updates: Whenever user or company properties change.
    API:
identify(userID, properties, company, onSuccess, onError)
    Example:
window.userpilot.identify(
    '<USER_ID>',
    {
        'name': 'John Doe', 
        'email': '[email protected]', 
        'created_at': '2019-10-17', 
        'role': 'Admin'
    },
    {
        'id': 'company123', 
        'name': 'Acme Labs', 
        'created_at': '2019-10-17', 
        'plan': 'Free'
    },
    function(success) {
        console.log('User identified successfully');
    },
    function(error) {
        console.error('Failed to identify user:', error);
    }
);

Properties Guidelines

  • Key id is required in company properties, to identify a unique company.
  • Userpilot supports String, Numeric, and Date types.
  • Make sure you're sending date values in ISO8601 format.
  • If you are planning to use Userpilot's localization features, make sure you are passing user property locale_code with a value that adheres to ISO 639-1 format.
  • Userpilot's reserved properties have pre-determined types and improve profiles interface in the dashboard:
    • Use key email to pass the user's email.
    • Use key name to pass the user's or company's name.
    • Use key created_at to pass the user's or company's signed up date.

Notes

  • Make sure your User ID source is consistent across all of your platform installations (Web, Android, and iOS).
  • While properties are optional, they are essential in Userpilot's segmentation capabilities. We encourage you to set the properties with the people who are responsible for Userpilot integration.

Tracking Screens (Required)

Calling screen is crucial for unlocking Userpilot's core engagement and analytics capabilities. When a user navigates to a particular screen, invoking screen records that view and triggers any eligible in-app experiences. Subsequent events are also attributed to the most recently tracked screen, providing context for richer analytical insights. For these reasons, we strongly recommend tracking all of your app's screen views.

    API:
screen(screenName, onSuccess, onError)
    Example:
window.userpilot.screen('Profile',
    function(success) {
        console.log('Screen tracked successfully');
    },
    function(error) {
        console.error('Failed to track screen:', error);
    }
);

Tracking Events

Log any meaningful action the user performs. Events can be button clicks, form submissions, or any custom activity you want to analyze. Optionally, you can pass metadata with the event to provide specific context.

    API:
track(name, properties, onSuccess, onError)
    Example:
window.userpilot.track('Added to Cart', 
    { 
        itemId: 'sku_456', 
        price: 29.99 
    },
    function(success) {
        console.log('Event tracked successfully');
    },
    function(error) {
        console.error('Failed to track event:', error);
    }
);

Logging Out

When a user logs out, call logout() to clear the current user context. This ensures subsequent events are no longer associated with the previous user.

    API:
logout(onSuccess, onError)
    Example:
window.userpilot.logout(
    function(success) {
        console.log('User logged out successfully');
    },
    function(error) {
        console.error('Failed to logout user:', error);
    }
);

Anonymous Users

If a user is not authenticated, call anonymous() to track events without a user ID. This is useful for pre-signup flows or guest user sessions.

    API:
anonymous(onSuccess, onError)
    Example:
window.userpilot.anonymous(
    function(success) {
        console.log('Anonymous user set successfully');
    },
    function(error) {
        console.error('Failed to set anonymous user:', error);
    }
);

Notes

  • Anonymous users are counted towards your Monthly Active Users usage. You should take your account's MAU limit into consideration before applying this API.

Trigger Experience

Triggers a specific experience programmatically using its ID. This API allows you to manually initiate an experience within your application.

    API:
triggerExperience(experienceId, onSuccess, onError)
    Example:
window.userpilot.triggerExperience('<EXPERIENCE_ID>',
    function(success) {
        console.log('Experience triggered successfully');
    },
    function(error) {
        console.error('Failed to trigger experience:', error);
    }
);

End Experience

Ends the current active experience programmatically.

    API:
endExperience(onSuccess, onError)
    Example:
window.userpilot.endExperience(
    function(success) {
        console.log('Experience ended successfully');  
    },
    function(error) {
        console.error('Failed to end experience:', error);
    }
);

SDK callbacks

Userpilot SDK provides three types of callbacks:

  • Navigation Listener
  • Analytics Listener
  • Experience Listener

Navigation Listener is called when a deep link is triggered from an experience or notification. It holds the custom deep link URL to be handled by the client app.

Params:

url: string

Analytics Listener is called when an event is triggered by the client app.

Params:

analytic: string
value: string
properties: Map<string, any>

Analytics Listener Called when an analytics event is triggered by the Userpilot SDK. Use this to mirror or log SDK-level events into your analytics system.

Params:

analytic: "Identify" | "Screen" | "Event"

value: String — Event value, if any.

properties: Map<String, Any> — Additional metadata for the event.

Experience Listener Called when an experience or its step changes state. Includes two callback types:

onExperienceStateChanged Triggered when the overall state of an experience changes.

experienceId?: Int — Unique ID of the experience (optional)

experienceType: "Flow" | "Survey" | "NPS"

experienceState: "Started" | "Completed" | "Dismissed" | "Skipped" | "Submitted"

onExperienceStepStateChanged Triggered when the state of a specific step within an experience changes.

stepId: Int — Unique identifier of the step

experienceId: Int — ID of the parent experience

experienceType: "Flow" | "Survey" | "NPS"

stepState: "Started" | "Completed" | "Dismissed" | "Skipped" | "Submitted"

step?: Int — Step index (optional)

totalSteps?: Int — Total number of steps in the experience (optional)

Both callbacks are sent under the same event name: UserpilotExperienceEvent

// Register for callbacks
window.userpilot.registerCallbacks(
    function(event) {
        console.log('Callback received:', event);
    },
    function(error) {
        console.error('Failed to register callbacks:', error);
    }
);

// Set up individual event listeners
window.userpilot.onUserpilotNavigationEvent(function(data) {
    console.log('Navigation Event:', data);
    // Handle deep link navigation
    if (data.url) {
        handleDeepLink(data.url);
    }
});

window.userpilot.onUserpilotAnalyticsEvent(function(data) {
    console.log('Analytics Event:', data);
});

window.userpilot.onUserpilotExperienceEvent(function(data) {
    console.log('Experience Event:', data);
});

Push Notification

Userpilot SDK supports handling push notifications to help you deliver targeted messages and enhance user engagement. For setup instructions, and integration details, please refer to the Push Notification Guide.

📝 Documentation

Full documentation is available at Userpilot

🎬 Examples

The UserpilotSample repository contains a full example Cordova app providing references for correct installation and usage of the Userpilot Plugin APIs.

📄 License

This project is licensed under the MIT License. See LICENSE for more information.