only add account portal people to intercom

This commit is contained in:
Martin McKeaveney 2022-07-15 10:26:41 +01:00
parent 27fffe63bf
commit 346416d2ee
2 changed files with 21 additions and 20 deletions

View File

@ -52,13 +52,13 @@ export default class IntercomClient {
* @param {Object} user - user to identify * @param {Object} user - user to identify
* @returns Intercom global object * @returns Intercom global object
*/ */
show(user = {}) { show(user = {}, enabled) {
if (this.initialised && user?.admin && user?.cloud) { if (!this.initialised || !enabled) return
return window.Intercom("boot", {
app_id: this.token, return window.Intercom("boot", {
...user, app_id: this.token,
}) ...user,
} })
} }
/** /**

View File

@ -54,23 +54,24 @@ export function createAuthStore() {
}) })
if (user) { if (user) {
const adminStore = get(admin)
analytics analytics
.activate() .activate()
.then(() => { .then(() => {
analytics.identify(user._id) analytics.identify(user._id)
analytics.showChat({ analytics.showChat(
email: user.email, {
created_at: (user.createdAt || Date.now()) / 1000, email: user.email,
name: user.account?.name, created_at: (user.createdAt || Date.now()) / 1000,
user_id: user._id, name: user.account?.name,
tenant: user.tenantId, user_id: user._id,
admin: user?.admin?.global, tenant: user.tenantId,
builder: user?.builder?.global, admin: user?.admin?.global,
"Company size": user.account?.size, builder: user?.builder?.global,
"Job role": user.account?.profession, "Company size": user.account?.size,
cloud: adminStore.cloud, "Job role": user.account?.profession,
}) },
!!user?.account
)
}) })
.catch(() => { .catch(() => {
// This request may fail due to browser extensions blocking requests // This request may fail due to browser extensions blocking requests