Skip to content

Commit

Permalink
fix(intercom): add zbase to user_id
Browse files Browse the repository at this point in the history
Closes DCOS-41283
  • Loading branch information
nLight authored and Fabs committed Sep 3, 2018
1 parent 94bea3a commit 888d1be
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
3 changes: 1 addition & 2 deletions plugins/intercom/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 7 additions & 1 deletion plugins/intercom/stores/IntercomStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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);
}
Expand Down
5 changes: 5 additions & 0 deletions plugins/intercom/stores/__tests__/IntercomStore-test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
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");

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");
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 888d1be

Please sign in to comment.