Merge pull request #3468 from jaredevantabor/pendoUpdate

Update Pendo service for 3.0 changes to retreiving the config endpoint
This commit is contained in:
Jared Tabor
2016-09-08 11:13:50 -07:00
committed by GitHub

View File

@@ -92,58 +92,21 @@ export default
return deferred.promise; return deferred.promise;
}, },
getConfig: function () {
var config = ConfigService.get(),
deferred = $q.defer();
if(_.isEmpty(config)){
var url = GetBasePath('config');
Rest.setUrl(url);
var promise = Rest.get();
promise.then(function (response) {
config = response.data.license_info;
config.analytics_status = response.data.analytics_status;
config.version = response.data.version;
config.ansible_version = response.data.ansible_version;
if(config.analytics_status === 'detailed' || config.analytics_status === 'anonymous'){
$pendolytics.bootstrap();
deferred.resolve(config);
}
else {
deferred.reject('Pendo is turned off.');
}
});
promise.catch(function (response) {
ProcessErrors($rootScope, response.data, response.status, null, {
hdr: 'Error!',
msg: 'Failed to get inventory name. GET returned status: ' +
response.status });
deferred.reject('Could not resolve pendo config.');
});
}
else if(config.analytics_status === 'detailed' || config.analytics_status === 'anonymous'){
$pendolytics.bootstrap();
deferred.resolve(config);
}
else {
deferred.reject('Pendo is turned off.');
}
return deferred.promise;
},
issuePendoIdentity: function () { issuePendoIdentity: function () {
var that = this; var config,
this.getConfig().then(function(config){ options,
var options = that.setPendoOptions(config); c = ConfigService.get(),
that.setRole(options).then(function(options){ config = c.license_info;
$log.debug('Pendo status is '+ config.analytics_status + '. Object below:'); config.analytics_status = c.analytics_status;
$log.debug(options); config.version = c.version;
$pendolytics.identify(options); config.ansible_version = c.ansible_version;
}, function(reason){ options = this.setPendoOptions(config);
// reject function for setRole this.setRole(options).then(function(options){
$log.debug(reason); $log.debug('Pendo status is '+ config.analytics_status + '. Object below:');
}); $log.debug(options);
$pendolytics.identify(options);
}, function(reason){ }, function(reason){
// reject function for getConfig // reject function for setRole
$log.debug(reason); $log.debug(reason);
}); });
} }