Skip to content

Commit

Permalink
RZ-9295 same approach for the link in the last message and final butt…
Browse files Browse the repository at this point in the history
…on (#59)

* RZ-9295 same approach for the link in the last message and final button

* RZ-9295 fix link event listener logic
  • Loading branch information
insssomniac authored Dec 21, 2023
1 parent e57d130 commit a030156
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/lib/chat-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ const ChatUi = {
this.link.remove();
}
}

if (content.includes(intentionType.email)) {
this.setEmailVisibility();
}
Expand Down Expand Up @@ -480,6 +481,7 @@ const ChatUi = {
*/
setCtaButton() {
this.elements.ctaButton.classList.remove('hidden');
this.attachLinkEventListener();
if (getTerm() === experimentsPrompt.finalPage) {
this.setCtaButtonToClose();
} else {
Expand All @@ -501,6 +503,18 @@ const ChatUi = {
});
},

attachLinkEventListener() {
const links = document.querySelectorAll('.js-assistant-message a');
const link = links[links.length - 1];

if (link) {
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.
Expand Down

0 comments on commit a030156

Please sign in to comment.