Profile prompts & reminders

3 email reminders to for new users who have not completed their
jamkazam profile
This commit is contained in:
Nuwan 2025-02-28 17:26:03 +05:30
parent dcb842035f
commit 4601dd71b6
12 changed files with 317 additions and 0 deletions

View File

@ -0,0 +1,16 @@
class AddProfileCompleteColumnsToUsers < ActiveRecord::Migration
def self.up
execute "ALTER TABLE users ADD COLUMN profile_completed_at TIMESTAMP"
execute "ALTER TABLE users ADD COLUMN profile_complete_reminder1_sent_at TIMESTAMP"
execute "ALTER TABLE users ADD COLUMN profile_complete_reminder2_sent_at TIMESTAMP"
execute "ALTER TABLE users ADD COLUMN profile_complete_reminder3_sent_at TIMESTAMP"
User.where('users.id IN (SELECT player_id FROM musicians_instruments) OR users.id IN (SELECT player_id FROM genre_players)').update_all(profile_completed_at: Time.now)
end
def self.down
execute "ALTER TABLE users DROP COLUMN profile_completed_at"
execute "ALTER TABLE users DROP COLUMN profile_complete_reminder1_sent_at"
execute "ALTER TABLE users DROP COLUMN profile_complete_reminder2_sent_at"
execute "ALTER TABLE users DROP COLUMN profile_complete_reminder3_sent_at"
end
end

View File

@ -418,6 +418,42 @@ module JamRuby
end
end
def profile_complete_reminder1(user)
@user = user
sendgrid_recipients([user.email])
sendgrid_substitute('@USERID', [user.id])
sendgrid_unique_args :type => "profile_complete_reminder1"
mail(:to => user.email, :subject => I18n.t('user_mailer.profile_complete_reminder1.subject')) do |format|
format.text
format.html { render layout: "user_mailer_beta" }
end
end
def profile_complete_reminder2(user)
@user = user
sendgrid_recipients([user.email])
sendgrid_substitute('@USERID', [user.id])
sendgrid_unique_args :type => "profile_complete_reminder2"
mail(:to => user.email, :subject => "Take 2 minutes to fill out your JamKazam profile now") do |format|
format.text
format.html { render layout: "user_mailer_beta" }
end
end
def profile_complete_reminder3(user)
@user = user
sendgrid_recipients([user.email])
sendgrid_substitute('@USERID', [user.id])
sendgrid_unique_args :type => "profile_complete_reminder3"
mail(:to => user.email, :subject => "Last reminder to update your JamKazam profile") 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

View File

@ -0,0 +1,73 @@
<p><%=I18n.t('user_mailer.profile_complete_reminder1.greeting') -%> <%= @user.first_name -%> -</p>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder1.paragraph1') -%>
</p>
<p style="text-align:center">
<a href="<%= APP_CONFIG.spa_origin_url %>/profile" style="color: #fff;
text-decoration: none;
background-color: #2c7be5;
border-color: #2c7be5;
border: 1px solid transparent;
padding: 0.3125rem 1rem;
line-height: 2.5;
font-size: 1em;
border-radius: 0.25rem;
transition: color 0.15s ease-in-out,
background-color 0.15s ease-in-out, border-color 0.15s ease-in-out,
box-shadow 0.15s ease-in-out;">
<%=I18n.t('user_mailer.profile_complete_reminder1.update_profile') -%>
</a>
</p>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder1.paragraph2') -%>
</p>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder1.paragraph3') -%>
</p>
<p style="text-align:center">
<a href="<%= APP_CONFIG.external_root_url %>/downloads" style="color: #fff;
text-decoration: none;
background-color: #2c7be5;
border-color: #2c7be5;
border: 1px solid transparent;
padding: 0.3125rem 1rem;
margin-right: 1rem;
line-height: 2.5;
font-size: 1em;
border-radius: 0.25rem;
transition: color 0.15s ease-in-out,
background-color 0.15s ease-in-out, border-color 0.15s ease-in-out,
box-shadow 0.15s ease-in-out;">
<%=I18n.t('user_mailer.profile_complete_reminder1.download_app') -%>
</a>
<a href="<%= APP_CONFIG.external_root_url %>/downloads" style="color: #fff;
text-decoration: none;
background-color: #2c7be5;
border-color: #2c7be5;
border: 1px solid transparent;
padding: 0.3125rem 1rem;
line-height: 2.5;
font-size: 1em;
border-radius: 0.25rem;
transition: color 0.15s ease-in-out,
background-color 0.15s ease-in-out, border-color 0.15s ease-in-out,
box-shadow 0.15s ease-in-out;">
<%=I18n.t('user_mailer.profile_complete_reminder1.download_legacy_app') -%>
</a>
</p>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder1.paragraph4') -%>
</p>
<div>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder1.regards') -%>
<br />
<%=I18n.t('user_mailer.profile_complete_reminder1.signature') -%>
</p>
</div>

View File

@ -0,0 +1,17 @@
<%=I18n.t('user_mailer.profile_complete_reminder1.greeting') -%> <%= @user.first_name -%> -
<%=I18n.t('user_mailer.profile_complete_reminder1.paragraph1') -%>
<%= APP_CONFIG.spa_origin_url %>/profile
<%=I18n.t('user_mailer.profile_complete_reminder1.paragraph2') -%>
<%=I18n.t('user_mailer.profile_complete_reminder1.paragraph3') -%>
<%= APP_CONFIG.external_root_url %>/downloads
<%=I18n.t('user_mailer.profile_complete_reminder1.paragraph4') -%>
<%=I18n.t('user_mailer.profile_complete_reminder1.regards') -%>
<%=I18n.t('user_mailer.profile_complete_reminder1.signature') -%>

View File

@ -0,0 +1,34 @@
<p><%=I18n.t('user_mailer.profile_complete_reminder2.greeting') -%>&nbsp;<%= @user.first_name -%> -</p>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder2.paragraph1') -%>
</p>
<p style="text-align:center">
<a href="<%= APP_CONFIG.spa_origin_url %>/profile" style="color: #fff;
text-decoration: none;
background-color: #2c7be5;
border-color: #2c7be5;
border: 1px solid transparent;
padding: 0.3125rem 1rem;
line-height: 2.5;
font-size: 1em;
border-radius: 0.25rem;
transition: color 0.15s ease-in-out,
background-color 0.15s ease-in-out, border-color 0.15s ease-in-out,
box-shadow 0.15s ease-in-out;">
<%=I18n.t('user_mailer.profile_complete_reminder2.update_profile') -%>
</a>
</p>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder2.paragraph2') -%>
</p>
<div>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder2.regards') -%>
<br />
<%=I18n.t('user_mailer.profile_complete_reminder2.signature') -%>
</p>
</div>

View File

@ -0,0 +1,11 @@
<%=I18n.t('user_mailer.profile_complete_reminder2.greeting') -%> <%= @user.first_name -%> -
<%=I18n.t('user_mailer.profile_complete_reminder2.paragraph1') -%>
<%= APP_CONFIG.spa_origin_url %>/profile
<%=I18n.t('user_mailer.profile_complete_reminder2.paragraph2') -%>
<%=I18n.t('user_mailer.profile_complete_reminder2.regards') -%>
<%=I18n.t('user_mailer.profile_complete_reminder2.signature') -%>

View File

@ -0,0 +1,29 @@
<p><%=I18n.t('user_mailer.profile_complete_reminder3.greeting') -%>&nbsp;<%= @user.first_name -%> -</p>
<p><%=I18n.t('user_mailer.profile_complete_reminder3.paragraph1') -%>
</p>
<p style="text-align:center">
<a href="<%= APP_CONFIG.spa_origin_url %>/profile" style="color: #fff;
text-decoration: none;
background-color: #2c7be5;
border-color: #2c7be5;
border: 1px solid transparent;
padding: 0.3125rem 1rem;
line-height: 2.5;
font-size: 1em;
border-radius: 0.25rem;
transition: color 0.15s ease-in-out,
background-color 0.15s ease-in-out, border-color 0.15s ease-in-out,
box-shadow 0.15s ease-in-out;">
<%=I18n.t('user_mailer.profile_complete_reminder3.update_profile') -%>
</a>
</p>
<div>
<p>
<%=I18n.t('user_mailer.profile_complete_reminder3.regards') -%>
<br />
<%=I18n.t('user_mailer.profile_complete_reminder3.signature') -%>
</p>
</div>

View File

@ -0,0 +1,9 @@
<%=I18n.t('user_mailer.profile_complete_reminder3.greeting') -%><%= @user.first_name -%> -
<%=I18n.t('user_mailer.profile_complete_reminder3.paragraph1') -%>
<%= APP_CONFIG.spa_origin_url %>/profile
<%=I18n.t('user_mailer.profile_complete_reminder3.regards') -%>
<%=I18n.t('user_mailer.profile_complete_reminder3.signature') -%>

View File

@ -0,0 +1,43 @@
module JamRuby
class EmailProfileReminder
def self.send_reminders
#If the user has not updated their profile 1 day after signup, then send reminder email1
reminder1_users.each do |user|
UserMailer.profile_complete_reminder1(user).deliver_now
user.update(profile_complete_reminder1_sent_at: Time.now)
end
#If the user has not updated their profile 3 days after signup, then send reminder email2
reminder2_users.each do |user|
UserMailer.profile_complete_reminder2(user).deliver_now
user.update(profile_complete_reminder2_sent_at: Time.now)
end
#If the user has not updated their profile 5 days after signup, then send reminder email3
reminder3_users.each do |user|
UserMailer.profile_complete_reminder3(user).deliver_now
user.update(profile_complete_reminder3_sent_at: Time.now)
end
end
def self.prospect_users
User.where("users.profile_completed_at IS NULL AND users.subscribe_email = ?", true)
end
def self.reminder1_users
EmailProfileReminder.prospect_users.where("users.created_at > ? AND users.profile_complete_reminder1_sent_at IS NULL", 1.day.ago)
end
def self.reminder2_users
EmailProfileReminder.prospect_users.where("users.created_at > ? AND users.profile_complete_reminder1_sent_at IS NOT NULL AND users.profile_complete_reminder2_sent_at IS NULL", 3.days.ago)
end
def self.reminder3_users
EmailProfileReminder.prospect_users.where("users.created_at > ? AND users.profile_complete_reminder2_sent_at IS NOT NULL AND users.profile_complete_reminder3_sent_at IS NULL", 5.days.ago)
end
end
end

View File

@ -0,0 +1,15 @@
module JamRuby
class ProfileReminderEmailer
extend Resque::Plugins::JamLonelyJob
@queue = :scheduled_profile_reminder_emailer
@@log = Logging.logger[ProfileReminderEmailer]
def self.perform
@@log.debug("waking up")
EmailProfileReminder.send_reminders
@@log.debug("done")
end
end
end

View File

@ -71,3 +71,32 @@ en:
paragraph2: "Your account was imported for you, so you'll need to set a password. Click the button below to set a password for your JamKazam account."
paragraph3: "Thanks for joining JamKazam!"
signature: "The JamKazam Team"
profile_complete_reminder1:
subject: "Update your JamKazam profile now & get connected to other musicians"
greeting: "Hello"
paragraph1: "If you may be interested in playing music live online with other musicians, the first thing you should do is fill out your JamKazam profile. The information in your profile lets other musicians with similar interests find, message, and connect with you, and also lets JamKazams matchmaking features give you recommendations for great musical connections. Click the button below to update your profile now. It only takes 2 minutes to complete your profile."
update_profile: "Update Profile"
paragraph2: "After you have updated your profile, the next thing you should do is download, install, and run the JamKazam app. Youll need this app to play online with others, and the app also gives you access to more advanced JamTracks features if you signed up to use our huge catalog of backing tracks. After you download and install the app, we recommend you open the app and then leave the app running for about 10-15 minutes on your computer. The app will use this time to quietly collect Internet data that we use to figure out which other musicians on JamKazam youll have the best connections with i.e. the lowest latency (or lag) when playing together"
paragraph3: "Click a button below to go to the JamKazam app download page. (Most users should click the Download App button, but if youre on a Mac that cant run MacOS 10.15 or later, click the Download Legacy App button, as that version of the app supports older MacOS versions back to 10.7.) After you download it, double click the downloaded installer, and follow the on-screen instructions to install the app, then start the app and leave it running for about 15 minutes."
download_app: "Download App"
download_legacy_app: "Download Legacy App"
paragraph4: "For next steps, dont forget you can always refer back to the Welcome email we sent you when you signed up. And if you run into any problems or get stuck, please send us email at support@jamkazam.com. Were always happy to help"
regards: "Best Regards,"
signature: "JamKazam Team"
profile_complete_reminder2:
subject: "Complete your JamKazam profile"
greeting: "Hello"
paragraph1: "We share your profile with JamKazam members who may be a good fit to play music with you during your first week on the platform via an automated email feature. Dont miss this opportunity to connect. Click the button below to update your profile now, before its shared with others!"
update_profile: "Update Profile"
paragraph2: "For next steps after your profile, dont forget you can always refer back to the Welcome email we sent you when you signed up. And if you run into any problems or get stuck, please send us email at support@jamkazam.com. Were always happy to help!"
regards: "Best Regards,"
signature: "JamKazam Team"
profile_complete_reminder3:
subject: "Complete your JamKazam profile"
greeting: "Hello"
paragraph1: "Your profile is your key to connecting with other musicians on JamKazam. It lets others know what instruments you play at what level of proficiency and what kinds of music you like to play. This lets our existing community find and reach out to you to connect and play, and this information also powers our automated matchmaking features that make recommendations to you. If you think you might want to play music live online on JamKazam, please click the button below now to fill out your profile!"
update_profile: "Update Profile"
regards: "Best Regards,"
signature: "JamKazam Team"

View File

@ -70,6 +70,11 @@ NewMusicianMatchEmailer:
class: "JamRuby::NewMusicianMatchEmailer"
description: "Sends weekly emails of new users with good latency - (User latency data from neo4j)"
ProfileReminderEmailer:
cron: "0 23 * * *" # 11pm
class: "JamRuby::ProfileReminderEmailer"
description: "Sends emails reminding users to complete their profile"
MusicSessionScheduler:
cron: "0 * * * *"
class: "JamRuby::MusicSessionScheduler"