From 469acd8d6e4b6c24405e6db22298c3a5e1c9b2e4 Mon Sep 17 00:00:00 2001 From: insssomniac Date: Thu, 30 Nov 2023 15:02:02 +0200 Subject: [PATCH] RZ-9295 same approach for the link in the last message and final button --- package-lock.json | 4 ++-- package.json | 2 +- src/lib/chat-ui.js | 14 ++++++++++++++ 3 files changed, 17 insertions(+), 3 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/package.json b/package.json index 1aa5a3d..6107fc2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "1ff-chat-ui", - "version": "1.0.46", + "version": "1.0.47", "description": "chatbot to communicate with taught ai", "main": "src/lib/chat-ui.js", "scripts": { diff --git a/src/lib/chat-ui.js b/src/lib/chat-ui.js index a15c05a..792a1d7 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. @@ -548,6 +561,7 @@ const ChatUi = { emailInput: document.getElementById('chat-email'), errorEmail: document.querySelector('.js-error-email'), paymentFormLoader: document.querySelector('.js-payment-form-loader'), + }; }, /**