Start the session only when user starts a conversation #8494
Replies: 9 comments 2 replies
-
I'm debating something like the following as a post-process command that I can at least script up to run nightly, but don't know enough about the database structure to know if this is safe or not yet.
From looking at the scheme it looks like it /should/ be as long as the naming convention is consistent and I'm not missing a reference to contact or contact_inboxes. EDITED to change the order of the two commands since contact_inbox_id can have references to contact_id. Otherwise, it looks like it does what I want. |
Beta Was this translation helpful? Give feedback.
-
Sorry, accidentally closed. Leaving open to see if there's plans to properly fix this so post-processing isn't needed. |
Beta Was this translation helpful? Give feedback.
-
If there's no objections, I can submit a PR to add a rake task for the Heroku scheduler: https://devcenter.heroku.com/articles/scheduler with this: desc "This task may be called by the Heroku scheduler add-on"
task :update_feed => :environment do
puts "Cleaning old contacts..."
require "sequel"
DB = Sequel.connect ENV["DATABASE_URL"]
DB["DELETE FROM contact_inboxes WHERE id NOT IN (SELECT contact_inbox_id FROM conversations)"]
DB["DELETE FROM contacts WHERE id NOT IN (SELECT contact_id FROM conversations)"]
puts "done."
puts "done."
end
task :send_reminders => :environment do
User.send_reminders
end |
Beta Was this translation helpful? Give feedback.
-
@psifertex That's associated with sessions. If you have 4k unique visitors on the website, you will have 4k session records. We initiate a session when the user first visits the webpage the first time and persist 365 days after the last visit. |
Beta Was this translation helpful? Give feedback.
-
Is it possible to disable session creation until the user actually either 1) opens the chat dialog, or 2) sends a message? |
Beta Was this translation helpful? Give feedback.
-
It can be an enhancement. I'm removing the bug as it is not a bug. I'll let @sojan-official @nithindavid evaluate the work need for the changes you mentioned. |
Beta Was this translation helpful? Give feedback.
-
Sounds good -- if it's actually tracking useful information I agree it shouldn't be a bug but configuration of it could be considered an enhancement. Let me know about that Suggested PR -- just adding that task would make cleanup easier for those who care. |
Beta Was this translation helpful? Give feedback.
-
@psifertex Please feel free to raise a PR. We are happy to take that in if that helps you. |
Beta Was this translation helpful? Give feedback.
-
Moving it to feature discussions as we won't be prioritizing it anytime soon. |
Beta Was this translation helpful? Give feedback.
-
Describe the bug
Running chatwoot with a web-integration causes a contact and conversation to be created for each visitor to a website, even if no conversation is ever initiated. This will pollute the database unnecessarily. For example, right now I have three "contacts" shown in my web UI, but when I check the database, I have 4k rows in the contacts table. This seems unnecessarily wasteful. I'd expect that either some process could easily expunge the unused records, or (even better) the rows in the database wouldn't even be created at all unless the user actually initiates some conversation!
To Reproduce
Steps to reproduce the behavior:
Expected behavior
The number of contacts actually created and the rows in the database should be the same.
Screenshots
Environment
Heroku install
Desktop (please complete the following information):
N/A
Smartphone (please complete the following information):
N/A
Beta Was this translation helpful? Give feedback.
All reactions