diff --git a/plugins/intercom/hooks.js b/plugins/intercom/hooks.js index 981b83d38a..9f0d99085a 100644 --- a/plugins/intercom/hooks.js +++ b/plugins/intercom/hooks.js @@ -80,8 +80,7 @@ module.exports = { global.Intercom("boot", { app_id: this.configuration.appId, email: user.email, - name: user.name, - user_id: user.uid + name: AuthStore.getUserLabel() }); IntercomStore.addChangeListener( diff --git a/plugins/intercom/stores/IntercomStore.js b/plugins/intercom/stores/IntercomStore.js index 211b409935..0a5a9c3998 100644 --- a/plugins/intercom/stores/IntercomStore.js +++ b/plugins/intercom/stores/IntercomStore.js @@ -7,6 +7,7 @@ import { HEALTH_NODES_CHANGE, CLUSTER_CCID_SUCCESS } from "#SRC/js/constants/EventTypes"; +import AuthStore from "#SRC/js/stores/AuthStore"; import ConfigStore from "#SRC/js/stores/ConfigStore"; import MetadataStore from "#SRC/js/stores/MetadataStore"; import NodeHealthStore from "../../nodes/src/js/stores/NodeHealthStore"; @@ -123,8 +124,13 @@ class IntercomStore extends GetSetBaseStore { } onClusterCCIDSuccess() { + const user = AuthStore.getUser(); const ccid = ConfigStore.get("ccid"); - this.set({ crypto_cluster_uuid: ccid.zbase32_public_key }); + + this.set({ + crypto_cluster_uuid: ccid.zbase32_public_key, + user_id: `${user.uid}+${ccid.zbase32_public_key}` + }); this.emit(INTERCOM_CHANGE); } diff --git a/plugins/intercom/stores/__tests__/IntercomStore-test.js b/plugins/intercom/stores/__tests__/IntercomStore-test.js index cc23ee482f..cbc4d4cf0e 100644 --- a/plugins/intercom/stores/__tests__/IntercomStore-test.js +++ b/plugins/intercom/stores/__tests__/IntercomStore-test.js @@ -1,5 +1,6 @@ const MetadataStore = require("#SRC/js/stores/MetadataStore"); const ConfigStore = require("#SRC/js/stores/ConfigStore"); +const AuthStore = require("#SRC/js/stores/AuthStore"); const EventTypes = require("#SRC/js/constants/EventTypes"); const NodeHealthStore = require("../../../nodes/src/js/stores/NodeHealthStore"); @@ -7,6 +8,8 @@ const NodeHealthStore = require("../../../nodes/src/js/stores/NodeHealthStore"); const { INTERCOM_CHANGE } = require("../../constants/EventTypes"); const IntercomStore = require("../IntercomStore"); +jest.mock("#SRC/js/stores/AuthStore"); + describe("IntercomStore", function() { it("adds attribute", function() { IntercomStore.addAttribute("foo", "bar"); @@ -59,6 +62,8 @@ describe("IntercomStore", function() { const mockedFn = jest.genMockFunction(); IntercomStore.onClusterCCIDSuccess = mockedFn; + AuthStore.getUser.mockResolvedValue({ uid: "user_uid" }); + addIntercomChangeListener(); ConfigStore.emit(EventTypes.CLUSTER_CCID_SUCCESS);