Skip to content

Commit

Permalink
Merge pull request #124 from diggyk/fullstory
Browse files Browse the repository at this point in the history
Make FullStory integration configurable
  • Loading branch information
jathanism committed Feb 2, 2016
2 parents f56b0a0 + be5ab38 commit 92e3145
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 4 deletions.
3 changes: 3 additions & 0 deletions config/dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ auth_token_expiry: 600

# Additional plugin directory (full path)
# plugin_dir:

# Specify the org identifier for FullStory integration
# fullstory_id:
3 changes: 2 additions & 1 deletion hermes/handlers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -2558,7 +2558,8 @@ def get(self):
}
"""
result_json = {
"domain": settings.domain
"domain": settings.domain,
"fullstoryId": settings.fullstory_id
}

self.success(result_json)
1 change: 1 addition & 0 deletions hermes/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,5 @@ def __getattr__(self, name):
"plugin_dir": "plugins ",
"environment": "dev",
"dev_email_recipient": "",
"fullstory_id": None,
})
2 changes: 1 addition & 1 deletion hermes/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.7.6"
__version__ = "0.7.9"
1 change: 0 additions & 1 deletion hermes/webapp/src/js/controllers/questStatusCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@

// get the host tags just in case the user wants to display them
hermesService.getHostTags(vm.hostnames).then(function(data) {
console.log(data);
vm.hostTags = data;
}).catch(function(error){
vm.errorMessage = "Could not load host tags: " + error.statusText;
Expand Down
32 changes: 31 additions & 1 deletion hermes/webapp/src/js/services/hermesService.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
var fates = null;
var fatesGraph = null;
var serverConfig = null;
var currentUser = null;
var service = {
getFates: getFates,
getFatesGraph: getFatesGraph,
Expand All @@ -26,6 +27,23 @@
getServerConfig: getServerConfig
};

getServerConfig().then(function(config) {
if (config['fullstoryId']) {
window['_fs_debug'] = false;
window['_fs_host'] = 'www.fullstory.com';
window['_fs_org'] = config['fullstoryId'];
(function(m,n,e,t,l,o,g,y){
g=m[e]=function(a,b){g.q?g.q.push([a,b]):g._api(a,b);};g.q=[];
o=n.createElement(t);o.async=1;o.src='https://'+_fs_host+'/s/fs.js';
y=n.getElementsByTagName(t)[0];y.parentNode.insertBefore(o,y);
g.identify=function(i,v){g(l,{uid:i});if(v)g(l,v)};g.setUserVars=function(v){FS(l,v)};
g.identifyAccount=function(i,v){o='account';v=v||{};v.acctId=i;FS(o,v)};
g.clearUserCookie=function(d,i){d=n.domain;while(1){n.cookie='fs_uid=;domain='+d+
';path=/;expires='+new Date(0);i=d.indexOf('.');if(i<0)break;d=d.slice(i+1)}}
})(window,document,'FS','script','user');
}
});

return service;

/////////////////////////
Expand Down Expand Up @@ -89,12 +107,24 @@
* Get the current authenticated user
*/
function getCurrentUser() {
return $http.get("/api/v1/currentUser")
if (currentUser != null) {
return currentUser;
} else {
currentUser = $http.get("/api/v1/currentUser")
.then(getCurrentUserComplete)
.catch(getCurrentUserFailed);

return currentUser;
}

function getCurrentUserComplete(response) {
if (response.data['user']) {
serverConfig.then(function(config) {
if (config['fullstoryId']) {
FS.identify(response.data['user'], {});
}
});

return response.data['user'];
} else {
return null;
Expand Down

0 comments on commit 92e3145

Please sign in to comment.