Source: cordova-plugin-bbd-analytics/assets/www/BBDAnalytics.js

/*
 * (c) 2019 BlackBerry Limited. All rights reserved.
 */

;
(function() {
    var cordovaExec = require('cordova/exec'),
        FEATURE_NAME = 'BBDAnalytics',
        METHODS = {
            getVersion: 'getAnalyticsVersion',
            getIsActive: 'getFeatureIsActive'
        };

    /**
     * @class Analytics
     *
     * @property {String} activityStatus describes the feature activity status. 'active' for the active feature and 'inactive' otherwise
     * 
     * @classdesc The Analytics object provides API to work with Analytics SDK
     */
    var Analytics = function() {
        var activityStatus = 'inactive';
        Object.defineProperties(this, {
            'toString': {
                value: function() {
                    return '[object Analytics]'
                }
            },
            'activityStatus': {
                get: function() {
                    return activityStatus;
                }
            }
        });

        function updateActivityStatus(status) {
            activityStatus = status;
        }

        cordovaExec(updateActivityStatus, null, FEATURE_NAME, METHODS.getIsActive, []);
    };

    Object.defineProperty(Analytics, 'toString', {
        value: function() {
            return 'function Analytics() { [native code] }'
        }
    });

    /**
     * @function Analytics#getAnalyticsVersion
     *
     * @description This function returns a string containing BlackBerry Analytics Framework version in major.minor.build format.
     *
     * @param {function} onSuccess Callback function to invoke when the function returns successfully.
     *
     * @return {string} always
     *
     * @example
     * <pre class="prettyprint"><code>
     *
     * function success(result) {
     *   console.log('Retrieved the Analytics SDK version: ' + result);
     * };
     *
     * function getAnalyticsSDKVersion(){
     * window.analytics.getAnalyticsVersion(success);
     * };
     * </code></pre>
     *
     *
     */
    Analytics.prototype.getAnalyticsVersion = function(onSuccess) {
        if (typeof onSuccess !== 'function') {
            throw new Error('ERROR in Analytics.getAnalyticsVersion: onSuccess parameter is not a function.');
        }

        cordovaExec(onSuccess, null, FEATURE_NAME, METHODS.getVersion, []);
    };

    Object.defineProperty(Analytics.prototype.getAnalyticsVersion, 'toString', {
        value: function() {
            return 'function getAnalyticsVersion() { [native code] }'
        }
    });

    var analytics = new Analytics();
    Object.preventExtensions(analytics);

    module.exports = analytics;
}()); // End the Module Definition.