From 31f7ae58d5466089f4953d88515b23f65cd5c698 Mon Sep 17 00:00:00 2001 From: negar Date: Wed, 12 Jun 2019 10:36:23 +0800 Subject: [PATCH] send userId --- src/javascript/app/Stores/client-store.js | 1 + src/javascript/app/Stores/gtm-store.js | 16 ++++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/javascript/app/Stores/client-store.js b/src/javascript/app/Stores/client-store.js index f8750685aef9..e8aa491e283c 100644 --- a/src/javascript/app/Stores/client-store.js +++ b/src/javascript/app/Stores/client-store.js @@ -199,6 +199,7 @@ export default class ClientStore extends BaseStore { this.accounts[this.loginid].landing_company_shortcode = response.authorize.landing_company_name; this.updateAccountList(response.authorize.account_list); this.upgrade_info = this.getBasicUpgradeInfo(); + this.user_id = response.authorize.user_id; } @action.bound diff --git a/src/javascript/app/Stores/gtm-store.js b/src/javascript/app/Stores/gtm-store.js index 749c107d97ef..a10c3836d575 100644 --- a/src/javascript/app/Stores/gtm-store.js +++ b/src/javascript/app/Stores/gtm-store.js @@ -2,9 +2,10 @@ import { action, computed, observable } from 'mobx'; +import BinarySocket from '_common/base/socket_base'; +import { isLoginPages } from '_common/base/login'; +import { get as getLanguage } from '_common/language'; import BaseStore from './base-store'; -import { isLoginPages } from '../../_common/base/login'; -import { get as getLanguage } from '../../_common/language'; import { getAppId } from '../../config'; export default class GTMStore extends BaseStore { @@ -38,6 +39,7 @@ export default class GTMStore extends BaseStore { ...this.root_store.client.is_logged_in && { visitorId: this.visitorId, currency : this.currency, + userId : this.root_store.client.user_id, }, ...this.root_store.ui.is_dark_mode_on && { theme: this.root_store.ui.is_dark_mode_on ? 'dark' : 'light', @@ -56,11 +58,13 @@ export default class GTMStore extends BaseStore { * @param {object} data */ @action.bound - pushDataLayer(data) { + async pushDataLayer(data) { if (this.is_gtm_applicable && !isLoginPages()) { - dataLayer.push({ - ...this.common_variables, - ...data, + BinarySocket.wait('authorize').then(() => { + dataLayer.push({ + ...this.common_variables, + ...data, + }); }); } }