/*
* (c) 2020 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.
* Note: this property is deprecated and 'activityStatus' is always 'active' now
*
* @deprecated It will be removed in future versions, as Analytics library is now included in BlackBerry Dynamics SDK version 8.0+
*
* @classdesc The Analytics object provides API to work with Analytics SDK
*/
var Analytics = function() {
var activityStatus = 'active';
Object.defineProperties(this, {
'toString': {
value: function() {
return '[object Analytics]'
}
},
'activityStatus': {
get: function() {
console.warn(
'"activityStatus" is deprecated and always "active" now.\n' +
'It will be removed in future versions, as Analytics library is now included in BlackBerry Dynamics SDK version 8.0+'
);
return activityStatus;
}
}
});
};
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.
* Note: this function is deprecated now and returns a string containing BlackBerry Dynamics SDK version instead
*
* @deprecated It will be removed in future versions, as Analytics library is now included in BlackBerry Dynamics SDK version 8.0+
*
* @param {function} onSuccess Callback function to invoke when the function returns successfully.
*
* @return {string} always
*
* @example
* function success(result) {
* console.log('Retrieved Blackberry Dynamics SDK version: ' + result);
* };
*
* function getAnalyticsSDKVersion() {
* window.analytics.getAnalyticsVersion(success);
* };
*
*/
Analytics.prototype.getAnalyticsVersion = function(onSuccess) {
if (typeof onSuccess !== 'function') {
throw new Error('ERROR in Analytics.getAnalyticsVersion: onSuccess parameter is not a function.');
}
console.warn(
'"getAnalyticsVersion" is deprecated now and returns a string containing BlackBerry Dynamics SDK version instead.\n' +
'It will be removed in future versions, as Analytics library is now included in BlackBerry Dynamics SDK version 8.0+'
);
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.