From ce4f5e4c03231fc105bb9668bcca9be78e58a9f7 Mon Sep 17 00:00:00 2001 From: insssomniac Date: Thu, 30 Nov 2023 15:02:02 +0200 Subject: [PATCH 1/2] RZ-9295 same approach for the link in the last message and final button --- package-lock.json | 4 ++-- src/lib/chat-ui.js | 13 +++++++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index ef2b355..ee8528d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "1ff-chat-ui", - "version": "1.0.46", + "version": "1.0.47", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "1ff-chat-ui", - "version": "1.0.46", + "version": "1.0.47", "license": "ISC", "dependencies": { "socket.io-client": "^4.6.1" diff --git a/src/lib/chat-ui.js b/src/lib/chat-ui.js index a15c05a..ee0ee25 100644 --- a/src/lib/chat-ui.js +++ b/src/lib/chat-ui.js @@ -214,10 +214,12 @@ const ChatUi = { if (this.link) { this.setCtaButton(); + this.attachLinkEventListener(); if(getTerm() === experimentsPrompt.finalPage){ this.link.remove(); } } + if (content.includes(intentionType.email)) { this.setEmailVisibility(); } @@ -377,6 +379,7 @@ const ChatUi = { this.link = constructLink(this.boldedText); if (this.link) { this.setCtaButton(); + this.attachLinkEventListener(); } let strongTaggedText = this.boldedText.replace('{', '').replace('}', ''); @@ -501,6 +504,16 @@ const ChatUi = { }); }, + attachLinkEventListener() { + const links = document.querySelectorAll('.js-assistant-message a'); + const link = links[links.length - 1]; + + link.addEventListener('click', () => { + this.track(customEventTypes.linkClicked); + this.closeWidget(); + }); + }, + /** * Sets custom variables and applies them to the main container element and font family. * Theme-specific properties are handled separately. From 54773050488209b3052113fcce98bf5ad9d4be68 Mon Sep 17 00:00:00 2001 From: insssomniac Date: Wed, 20 Dec 2023 16:09:39 +0200 Subject: [PATCH 2/2] RZ-9295 fix link event listener logic --- package-lock.json | 4 ++-- src/lib/chat-ui.js | 13 +++++++------ 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index ee8528d..ef2b355 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "1ff-chat-ui", - "version": "1.0.47", + "version": "1.0.46", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "1ff-chat-ui", - "version": "1.0.47", + "version": "1.0.46", "license": "ISC", "dependencies": { "socket.io-client": "^4.6.1" diff --git a/src/lib/chat-ui.js b/src/lib/chat-ui.js index ee0ee25..6aede34 100644 --- a/src/lib/chat-ui.js +++ b/src/lib/chat-ui.js @@ -214,7 +214,6 @@ const ChatUi = { if (this.link) { this.setCtaButton(); - this.attachLinkEventListener(); if(getTerm() === experimentsPrompt.finalPage){ this.link.remove(); } @@ -379,7 +378,6 @@ const ChatUi = { this.link = constructLink(this.boldedText); if (this.link) { this.setCtaButton(); - this.attachLinkEventListener(); } let strongTaggedText = this.boldedText.replace('{', '').replace('}', ''); @@ -483,6 +481,7 @@ const ChatUi = { */ setCtaButton() { this.elements.ctaButton.classList.remove('hidden'); + this.attachLinkEventListener(); if (getTerm() === experimentsPrompt.finalPage) { this.setCtaButtonToClose(); } else { @@ -508,10 +507,12 @@ const ChatUi = { const links = document.querySelectorAll('.js-assistant-message a'); const link = links[links.length - 1]; - link.addEventListener('click', () => { - this.track(customEventTypes.linkClicked); - this.closeWidget(); - }); + if (link) { + link.addEventListener('click', () => { + this.track(customEventTypes.linkClicked); + this.closeWidget(); + }); + } }, /**