Skip to content

Commit

Permalink
Merge pull request #130 from ushahidi/feature/intercom
Browse files Browse the repository at this point in the history
added cleaner version of domain using regex
  • Loading branch information
willdoran committed Mar 18, 2016
2 parents d7a6c1c + dc2582f commit d2746d1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/common/controllers/intercom.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,23 @@ function (
ConfigEndpoint,
$q
) {
var pattern = /^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/\n]+)/g;

$rootScope.$on('event:authentication:login:succeeded', function () {
$q.all([
ConfigEndpoint.get({ id: 'site' }).$promise,
UserEndpoint.getFresh({id: 'me'}).$promise
]).then(function (results) {
var site = results[0];
var user = results[1];
var domain = pattern.exec(window.ushahidi.apiUrl);
domain = domain[1].replace('api.', '');

window.Intercom('boot', {
app_id: window.ushahidi.intercomAppId,
email: user.email,
created_at: user.created,
user_id: window.ushahidi.apiUrl + '_' + user.id,
user_id: domain + '_' + user.id,
'company': site.name,
'deployment_url': window.ushahidi.apiUrl,
'realname' : user.realname,
Expand Down

0 comments on commit d2746d1

Please sign in to comment.