Skip to content

Conversation

@sampoder
Copy link
Member

Closes #11708 by factoring this email to only go out when a user is "onboarded" which we define as the user having a full name.

@sampoder sampoder requested review from a team as code owners September 29, 2025 20:58
sampoder and others added 2 commits September 29, 2025 16:05
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Copy link
Member

@garyhtou garyhtou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Almost there. Do you have a plan on how to handle users who don't finish onboarding? See #11708


after_update :update_stripe_cardholder, if: -> { phone_number_previously_changed? || email_previously_changed? }

after_update_commit :send_onboarded_email, if: -> { full_name_previously_changed? && full_name_before_last_save.blank? && full_name.present? }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a bit brittle in the case that we change what it means to be onboarded.

Can we abstract some of this logic out into a method that plays well with our existing onboarding? method?

hcb/app/models/user.rb

Lines 315 to 318 in ab1d1c4

def onboarding?
# in_database to prevent a blank name update attempt from triggering onboarding.
full_name_in_database.blank?
end

if user.user_sessions.size == 1
UserSessionMailer.first_login(user:).deliver_later
elsif fingerprint.present? && user.user_sessions.excluding(self).where(fingerprint:).none?
if user.user_sessions.size > 1 && fingerprint.present? && user.user_sessions.excluding(self).where(fingerprint:).none?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is not directly related to this PR. However, maybe we should explicitly wrap this in a !impersonated?.

This isn't completely necessary since impersonated sessions do not have fingerprints. However, I do still believe it's good to have this condition explicitly documented in the code.

@sampoder
Copy link
Member Author

sampoder commented Oct 2, 2025

Do you have a plan on how to handle users who don't finish onboarding?

No, honestly, it doesn't make sense to me why we'd email them this email. We can have a job that does that every 10 minutes but just feels weird to send someone an email they don't seem to want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[User] First login email is sent without the user's actual name

3 participants