Skip to content
This repository was archived by the owner on Feb 22, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/botPage/bot/TradeEngine/Purchase.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ export default Engine =>
// Don't unnecessarily send a forget request for a purchased contract.
this.data.proposals = this.data.proposals.filter(p => p.id !== response.echo_req.buy);
const { buy } = response;
GTM.pushDataLayer({ event: 'bot_purchase', buy_price: proposal.ask_price });

/* eslint-disable-next-line no-unused-expressions */
GTM?.pushDataLayer?.({ event: 'bot_purchase', buy_price: proposal.ask_price });

contractStatus({
id : 'contract.purchase_recieved',
Expand Down
8 changes: 6 additions & 2 deletions src/botPage/view/View.js
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ export default class View {
this.stop();
Elevio.logoutUser();
googleDriveUtil.logout();
GTM.setVisitorId();

/* eslint-disable-next-line no-unused-expressions */
GTM?.setVisitorId?.();
removeTokens();
})
.catch(() => {});
Expand Down Expand Up @@ -688,7 +690,9 @@ export default class View {
.then(() => {
this.stop();
Elevio.logoutUser();
GTM.setVisitorId();

/* eslint-disable-next-line no-unused-expressions */
GTM?.setVisitorId?.();
const activeToken = $(e.currentTarget).attr('value');
const tokenList = getTokenList();
setStorage('tokenList', '');
Expand Down
4 changes: 3 additions & 1 deletion src/botPage/view/blockly/customBlockly.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,9 @@ Blockly.Input.prototype.attachShadowBlock = function(value, name, shadowBlockTyp
Blockly.Toolbox.TreeNode.prototype.onClick_ = function(_e) {
// eslint-disable-next-line no-underscore-dangle
const blocklyCategoryName = translateLangToLang(_e.target.innerText, getLanguage(), 'en');
GTM.pushDataLayer({ event: 'Click Block Category', blocklyCategoryName });

/* eslint-disable-next-line no-unused-expressions */
GTM?.pushDataLayer?.({ event: 'Click Block Category', blocklyCategoryName });

// Expand icon.
if (this.hasChildren() && this.isUserCollapsible_) {
Expand Down
6 changes: 4 additions & 2 deletions src/botPage/view/blockly/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ export default class _Blockly {
event.ids.forEach(id => {
const block = workspace.getBlockById(id);
if (block) {
GTM.pushDataLayer({
/* eslint-disable-next-line no-unused-expressions */
GTM?.pushDataLayer?.({
event : 'Block Event',
blockEvent: event.type,
blockType : block.type,
Expand All @@ -364,7 +365,8 @@ export default class _Blockly {
const dom = Blockly.Xml.textToDom(`<xml>${event.oldXml.outerHTML}</xml>`);
const blockNodes = dom.getElementsByTagName('block');
Array.from(blockNodes).forEach(blockNode => {
GTM.pushDataLayer({
/* eslint-disable-next-line no-unused-expressions */
GTM?.pushDataLayer?.({
event : 'Block Event',
blockEvent: event.type,
blockType : blockNode.getAttribute('type'),
Expand Down
1 change: 1 addition & 0 deletions src/botPage/view/blockly/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ export const getMandatoryBlocks = () => config.mandatoryBlocks.map(type => getBl
export const getMandatoryMainBlocks = () => config.mandatoryMainBlocks.map(type => getBlockByType(type)).filter(b => b);

export const hasChildOfType = (block, childType) =>
/* eslint-disable-next-line no-underscore-dangle */
block.childBlocks_.find(child => child.type === childType || hasChildOfType(child, childType));

export const getMissingBlocksTypes = () => {
Expand Down
4 changes: 3 additions & 1 deletion src/botPage/view/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ view.initPromise.then(() => {
$('.barspinner').hide();
window.dispatchEvent(new Event('resize'));
Elevio.init();
GTM.init();

/* eslint-disable-next-line no-unused-expressions */
GTM?.init?.();
trackJs.configure({
userId: $('.account-id')
.first()
Expand Down
3 changes: 2 additions & 1 deletion src/common/appId.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ export async function addTokenIfValid(token, tokenObjectList) {
} catch (e) {
removeToken(tokenObjectList[0].token);
Elevio.logoutUser();
GTM.setVisitorId();
/* eslint-disable-next-line no-unused-expressions */
GTM?.setVisitorId?.();
throw e;
}
return api.disconnect();
Expand Down
29 changes: 14 additions & 15 deletions src/common/elevio.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-underscore-dangle */
import { generateLiveApiInstance } from './appId';
// import { getLanguage } from '../common/lang';
import { getTokenList } from './utils/storageManager';
Expand All @@ -21,8 +22,8 @@ const Elevio = (() => {
};

const injectElevio = (isOpen = false) => {
window._elev = {}; // eslint-disable-line no-underscore-dangle
window._elev.account_id = accountId; // eslint-disable-line no-underscore-dangle
window._elev = {};
window._elev.account_id = accountId;

const script = document.createElement('script');
script.type = 'text/javascript';
Expand All @@ -31,31 +32,29 @@ const Elevio = (() => {
script.id = 'loaded-elevio-script';
document.body.appendChild(script);

window._elev.q = []; // eslint-disable-line no-underscore-dangle
window._elev.q = [];
window._elev.on = (z, y) => {
// eslint-disable-line no-underscore-dangle
window._elev.q.push([z, y]); // eslint-disable-line no-underscore-dangle
window._elev.q.push([z, y]);
};

script.onload = () => loadElevio(isOpen);
};

const loadElevio = (isOpen = false) => {
if (!window._elev) return; // eslint-disable-line no-underscore-dangle
if (!window._elev) return;

// eslint-disable-next-line no-underscore-dangle
window._elev.on('widget:opened', () => {
if (localStorage.getItem('seenWhatsBinaryBot')) {
window._elev.open(); // eslint-disable-line no-underscore-dangle
window._elev.open();
} else {
localStorage.setItem('seenWhatsBinaryBot', true);
window._elev.openArticle(90); // eslint-disable-line no-underscore-dangle
window._elev.openArticle(90);
}
});

// eslint-disable-next-line no-underscore-dangle
window._elev.on('load', elev => {
GTM.pushDataLayer({ event: 'elevio_widget_load' });
/* eslint-disable-next-line no-unused-expressions */
GTM?.pushDataLayer?.({ event: 'elevio_widget_load' });
const availableLanguages = ['en', 'es', 'id', 'pt', 'ru'];
const currentLanguage = getLanguage();
if (availableLanguages.includes(currentLanguage)) {
Expand All @@ -80,12 +79,12 @@ const Elevio = (() => {

const addEventListenerGTM = () => {
window._elev.on('widget:opened', () => {
// eslint-disable-line no-underscore-dangle
GTM.pushDataLayer({ event: 'elevio_widget_opened', is_elevio: true });
/* eslint-disable-next-line no-unused-expressions */
GTM?.pushDataLayer?.({ event: 'elevio_widget_opened', is_elevio: true });
});
window._elev.on('page:view', () => {
// eslint-disable-line no-underscore-dangle
GTM.pushDataLayer({ event: 'elevio_page_views', is_elevio: true });
/* eslint-disable-next-line no-unused-expressions */
GTM?.pushDataLayer?.({ event: 'elevio_page_views', is_elevio: true });
});
};

Expand Down
1 change: 1 addition & 0 deletions src/common/i18n.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export const translate = (input, params = []) => {
let translatedString = i18nTranslate(stringToBeTranslated);
params.forEach((replacement, index) => {
if (translatedString && typeof translatedString === 'string') {
/* eslint-disable-next-line no-useless-escape */
translatedString = translatedString.replaceAll(`\{\$${index}\}`, replacement);
}
});
Expand Down
2 changes: 2 additions & 0 deletions src/common/utils/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,7 @@ export const loadExternalScript = (src, async = true, defer = true) =>
export const errLogger = (err, msg) => {
const errStr = JSON.stringify(err);
const errMsg = `${msg} - Error: ${errStr}`;

/* eslint-disable-next-line */
console.warn(errMsg);
};
3 changes: 2 additions & 1 deletion src/indexPage/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ const loginCheck = () => {
$('.show-on-load').show();
$('.barspinner').hide();
renderElements();
GTM.init();
/* eslint-disable-next-line no-unused-expressions */
GTM?.init?.();
});
}
};
Expand Down