1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-23 07:09:43 +02:00

fixed audit.js to initialize Intercom correctly

This commit is contained in:
Harvey Kandola 2016-07-21 14:17:04 -07:00
parent c80c7430ec
commit 481b6ac057

View file

@ -14,7 +14,8 @@ import netUtil from '../utils/net';
import config from '../config/environment'; import config from '../config/environment';
export default Ember.Service.extend({ export default Ember.Service.extend({
sessionService: Ember.inject.service('session'), session: Ember.inject.service('session'),
appMeta: Ember.inject.service(),
ready: false, ready: false,
enabled: config.APP.auditEnabled, enabled: config.APP.auditEnabled,
appId: config.APP.intercomKey, appId: config.APP.intercomKey,
@ -45,9 +46,10 @@ export default Ember.Service.extend({
}, },
start() { start() {
let session = this.get('sessionService'); let self = this;
let user = this.get('session.user');
if (this.get('appId') === "" || !this.get('enabled') || !session.authenticated || this.get('ready')) { if (is.undefined(user) || this.get('appId') === "" || !this.get('enabled') || !this.get('session.authenticated') || this.get('ready')) {
return; return;
} }
@ -55,19 +57,19 @@ export default Ember.Service.extend({
window.intercomSettings = { window.intercomSettings = {
app_id: this.get('appId'), app_id: this.get('appId'),
name: session.user.firstname + " " + session.user.lastname, name: user.fullname,
email: session.user.email, email: user.email,
user_id: session.user.id, user_id: user.id,
"administrator": session.user.admin, "administrator": user.admin,
company: { company: {
id: session.get('appMeta.orgId'), id: self.get('appMeta.orgId'),
name: session.get('appMeta.title').string, name: self.get('appMeta.title').string,
"domain": netUtil.getSubdomain(), "domain": netUtil.getSubdomain(),
"version": session.get('appMeta.version') "version": self.get('appMeta.version')
} }
}; };
if (!session.get('isMobile')) { if (!this.get('session.isMobile')) {
window.intercomSettings.widget = { window.intercomSettings.widget = {
activator: "#IntercomDefaultWidget" activator: "#IntercomDefaultWidget"
}; };
@ -75,4 +77,4 @@ export default Ember.Service.extend({
window.Intercom('boot', window.intercomSettings); window.Intercom('boot', window.intercomSettings);
}, },
}); });