Skip to content

Commit

Permalink
feat(crisp): open chatbox for better visibility on first visit (#2584)
Browse files Browse the repository at this point in the history
* feat(crisp): open chatbox for better visibility on first visit
* apply Amines review
  • Loading branch information
Holist authored Jan 23, 2025
1 parent a29bd9e commit 1e7d96d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions app/javascript/controllers/crisp_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class extends Controller {
};

this.initCrisp(user);
this.handleFirstVisit();
}

initCrisp(user) {
Expand All @@ -49,6 +50,16 @@ export default class extends Controller {
}
}

handleFirstVisit() {
const firstVisit = localStorage.getItem("crispFirstVisit");
if (!firstVisit) {
window.$crisp.push(["on", "session:loaded", () => {
window.$crisp.push(["do", "chat:open"]);
localStorage.setItem("crispFirstVisit", "true");
}]);
}
}

logout() {
if (window.$crisp) {
window.CRISP_TOKEN_ID = null;
Expand Down

0 comments on commit 1e7d96d

Please sign in to comment.