From 55372bf83d0853857bfceca9f9735db7d9ef43c4 Mon Sep 17 00:00:00 2001 From: Nuwan Chaturanga Date: Fri, 13 Jun 2025 12:02:21 +0000 Subject: [PATCH] Merged in 5631-signup-survey (pull request #61) signup survey email sending * signup survey email sending Send new user survey email 24 hours after signup to all new users * add config parameters add config.signup_survey_url, config.signup_survey_cutoff_date --- ...92511_add_signup_survey_sent_at_to_users.rb | 8 ++++++++ ruby/lib/jam_ruby/app/mailers/user_mailer.rb | 10 ++++++++++ .../user_mailer/signup_survey.html.erb | 18 ++++++++++++++++++ .../user_mailer/signup_survey.text.erb | 11 +++++++++++ ruby/lib/jam_ruby/lib/email_signup_survey.rb | 16 ++++++++++++++++ .../jam_ruby/resque/scheduled/hourly_job.rb | 1 + web/config/application.rb | 2 ++ web/config/environments/development.rb | 2 ++ web/config/locales/en.yml | 8 ++++++++ 9 files changed, 76 insertions(+) create mode 100644 ruby/db/migrate/20250605092511_add_signup_survey_sent_at_to_users.rb create mode 100644 ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/signup_survey.html.erb create mode 100644 ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/signup_survey.text.erb create mode 100644 ruby/lib/jam_ruby/lib/email_signup_survey.rb diff --git a/ruby/db/migrate/20250605092511_add_signup_survey_sent_at_to_users.rb b/ruby/db/migrate/20250605092511_add_signup_survey_sent_at_to_users.rb new file mode 100644 index 000000000..879bda4a2 --- /dev/null +++ b/ruby/db/migrate/20250605092511_add_signup_survey_sent_at_to_users.rb @@ -0,0 +1,8 @@ + class AddSignupSurveySentAtToUsers < ActiveRecord::Migration + def self.up + execute "ALTER TABLE users ADD COLUMN signup_survey_sent_at TIMESTAMP" + end + def self.down + execute "ALTER TABLE users DROP COLUMN signup_survey_sent_at" + end + end diff --git a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb index 9dec8cfe6..0f2020854 100644 --- a/ruby/lib/jam_ruby/app/mailers/user_mailer.rb +++ b/ruby/lib/jam_ruby/app/mailers/user_mailer.rb @@ -480,6 +480,16 @@ module JamRuby end end + def signup_survey(user) + @user = user + @subject = I18n.t('user_mailer.signup_survey.subject') + @survey_url = Rails.application.config.signup_survey_url + mail(:to => user.email, :subject => @subject) do |format| + format.text + format.html { render layout: "user_mailer_beta" } + end + end + #################################### NOTIFICATION EMAILS #################################### def friend_request(user, msg, friend_request_id) return if !user.subscribe_email diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/signup_survey.html.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/signup_survey.html.erb new file mode 100644 index 000000000..b3e216fa9 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/signup_survey.html.erb @@ -0,0 +1,18 @@ +

<%= I18n.t 'user_mailer.signup_survey.greeting' -%> <%= @user.first_name -%> -

+ +

+ <%= I18n.t 'user_mailer.signup_survey.paragraph1' -%> +

+ +

+ <%= @survey_url %> +

+

+ <%= I18n.t 'user_mailer.signup_survey.ps' -%> + <%= I18n.t 'user_mailer.signup_survey.ps_text' -%> +

+ + +

<%= I18n.t 'user_mailer.signup_survey.regards' -%>
+ <%= I18n.t 'user_mailer.signup_survey.signature' -%> +

\ No newline at end of file diff --git a/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/signup_survey.text.erb b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/signup_survey.text.erb new file mode 100644 index 000000000..4834ebde6 --- /dev/null +++ b/ruby/lib/jam_ruby/app/views/jam_ruby/user_mailer/signup_survey.text.erb @@ -0,0 +1,11 @@ +<%= I18n.t 'user_mailer.signup_survey.greeting' -%> <%= @user.first_name -%> - + +<%= I18n.t 'user_mailer.signup_survey.paragraph1' -%> + +<%= @survey_url %> + +<%= I18n.t 'user_mailer.signup_survey.ps' -%> +<%= I18n.t 'user_mailer.signup_survey.ps_text' -%> + +<%= I18n.t 'user_mailer.signup_survey.regards' -%>, +<%= I18n.t 'user_mailer.signup_survey.signature' -%> diff --git a/ruby/lib/jam_ruby/lib/email_signup_survey.rb b/ruby/lib/jam_ruby/lib/email_signup_survey.rb new file mode 100644 index 000000000..400513abe --- /dev/null +++ b/ruby/lib/jam_ruby/lib/email_signup_survey.rb @@ -0,0 +1,16 @@ +module JamRuby + class EmailSignupSurvey + def self.send_survey + # if signup survey email has not been sent to this user, then send it + survey_users.each do |user| + UserMailer.signup_survey(user).deliver_now + user.update(signup_survey_sent_at: Time.now) + end + end + + def self.survey_users + cutoff_date = Date.parse(Rails.application.config.signup_survey_cutoff_date) # Define a cutoff date for the survey + User.where("users.signup_survey_sent_at IS NULL AND users.created_at < ? AND users.created_at > ?", 1.days.ago, cutoff_date) + end + end +end \ No newline at end of file diff --git a/ruby/lib/jam_ruby/resque/scheduled/hourly_job.rb b/ruby/lib/jam_ruby/resque/scheduled/hourly_job.rb index a73b813b9..420909a28 100644 --- a/ruby/lib/jam_ruby/resque/scheduled/hourly_job.rb +++ b/ruby/lib/jam_ruby/resque/scheduled/hourly_job.rb @@ -14,6 +14,7 @@ module JamRuby User.hourly_check AffiliatePartner.tally_up(Date.today) EmailProfileReminder.send_reminders + EmailSignupSurvey.send_survey ConnectionManager.new.cleanup_dangling @@log.info("done") diff --git a/web/config/application.rb b/web/config/application.rb index 6de2590b1..3ca4f1cf5 100644 --- a/web/config/application.rb +++ b/web/config/application.rb @@ -520,6 +520,8 @@ if defined?(Bundler) config.spa_origin_url = "http://beta.jamkazam.local:4000" config.user_match_monitoring_email = "user_match_monitoring_email@jamkazam.com" config.send_user_match_mail_only_to_jamkazam_team = true + config.signup_survey_url = "https://www.surveymonkey.com/r/WVBKLYL" + config.signup_survey_cutoff_date = "2025-06-10" config.action_mailer.asset_host = config.action_controller.asset_host end end diff --git a/web/config/environments/development.rb b/web/config/environments/development.rb index efd1faf54..858e677b1 100644 --- a/web/config/environments/development.rb +++ b/web/config/environments/development.rb @@ -126,4 +126,6 @@ SampleApp::Application.configure do config.action_controller.asset_host = 'http://www.jamkazam.local:3000' config.send_user_match_mail_only_to_jamkazam_team = false + config.signup_survey_url = "https://www.surveymonkey.com/r/WVBKLYL" + config.signup_survey_cutoff_date = "2025-06-10" end diff --git a/web/config/locales/en.yml b/web/config/locales/en.yml index 5f841d9b4..82453cdb5 100644 --- a/web/config/locales/en.yml +++ b/web/config/locales/en.yml @@ -142,4 +142,12 @@ en: paragraph5: | If you have any trouble or feel confused about gear setup, you can email us for help at support@jamkazam.com. You can also visit with a JamKazam support team member in our weekly Zoom office hours, which is offered every Wednesday from 11am to 12pm US Central Time. regards: "Best Regards," + signature: "JamKazam Team" + signup_survey: + subject: "Let us help you to be successful on JamKazam" + greeting: "Hi" + paragraph1: "Thanks for signing up to join our community of musicians! Please click the link below and take 2 minutes to let us know a little more about your goals. Our support team will use this information to provide tailored, individual help to you to make it faster and easier for you to be successful." + ps: "p.s." + ps_text: "If we can help in any way, please always feel free to contact us at" + regards: "Best Regards," signature: "JamKazam Team" \ No newline at end of file