/ng-pendo

Pendo.io AngularJS module

Primary LanguageJavaScriptMIT LicenseMIT

Deprecated

This is no longer the correct way to install Pendo into your application. Instructions on installation are provided upon creating a new Pendo subscription. Head over to Pendo to get started.

ng-pendo v1.1.0

Please note that the most recent installation snippet (found in your install settings) makes this integration unnecessary, but it is fine to continue using it.

Pendo.io AngularJS module

Installation

$ npm i --save ng-pendo

Use

Provide your api key:

window.pendo_options = {
    apiKey: 'replace this with your api key',
    usePendoAgentAPI: true
};

Include $pendolytics in your AngularJS modules:

angular.module('your-app', [...,'$pendolytics',...]);

When you have access to the visitor information use it to identify the visitor:

getVisitorInformationFromSomewhere().then(function (visitor) {
    $pendolytics.identify({
        visitor: {
            id: visitor.id,
            role: visitor.role,
            email: visitor.email
        },
        account: {
            id: visitor.accountId
        }
    });
});

Note that your api key needs to be set before your Angular application is bootstrapped, otherwise $pendolytics will not find the key, and will use an older version of the Pendo Agent. If you prefer to set your api key after Angular bootstraps, you can delay $pendolytics from automatically starting with a config block, for example:

angular.module('your-app').config(function ($pendolyticsProvider) {
    $pendolyticsProvider.doNotAutoStart();
});

Then you can manually start $pendolytics when you are ready:

angular.module('your-app').run(function ($pendolytics) {
    // Set your API key and identify the visitor
    $pendolytics.initialize({
        apiKey: 'your key',
        visitor: {
            id: 'visitor id'
        },
        account: {
            id: 'account id'
        }
    });
    // Load the Pendo agent and start collecting data and displaying guides
    $pendolytics.bootstrap();
});