Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(sms): Add localized body text to SMS #18312

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft

feat(sms): Add localized body text to SMS #18312

wants to merge 1 commit into from

Conversation

vpomerleau
Copy link
Contributor

@vpomerleau vpomerleau commented Jan 30, 2025

Because

  • We want to include a localized message in addition to the code

This pull request

  • Add ftl strings for localized SMS messages
  • Pass strings to sms manager for inclusion in sms
  • Add missing import in integration test
  • Add tags to accounts libs projects for inclusion in CI integration tests
  • Add some more logging
  • Split email sending for recovery phone actions into separate try catch with error logging that doesn't crash the main SMS actions

Issue that this pull request solves

Closes: #FXA-11007

Checklist

Put an x in the boxes that apply

  • My commit is GPG signed.
  • If applicable, I have modified or added tests which pass locally.
  • I have added necessary documentation (if appropriate).
  • I have verified that my changes render correctly in RTL (if appropriate).

Screenshots (Optional)

Please attach the screenshots of the changes made in case of change in user interface.

Other information (Optional)

Noticed that the recovery-phone libs tests weren't running on CI and added them + updated instructions in readme to run the tests locally.

@vpomerleau vpomerleau force-pushed the FXA-11007 branch 4 times, most recently from 255780d to c82a71e Compare February 3, 2025 21:57
@@ -2181,7 +2181,7 @@ const convictConf = convict({
format: Array,
},
maxMessageLength: {
default: 60,
default: 160,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dschom I saw that 160 was the limit for a deprecated Twilio endpoint, other active endpoints seem to have a limit of 1600 (which is way too much IMO for our needs). Considering that the localized body text in English is roughly 60, setting the limit here to 160 seems fair to account for expansion in other locales.

Is there a reason for the limit being set to 60 here vs 160 in sms.manager.spec.ts?

Copy link
Contributor

@dschom dschom Feb 3, 2025

Choose a reason for hiding this comment

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

I think 60 was just seemed like a 'short' message. If 160 is needed, that's no problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've shortened the English message to be under 60 characters, but languages that use a different encoding like Russian and Japanese might require a higher number of characters. Hopefully comfortably under the 160 character limit.

Copy link
Contributor Author

@vpomerleau vpomerleau Feb 4, 2025

Choose a reason for hiding this comment

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

I read up a bit more on the encoding for SMS, and it's trickier to calculate than I thought. For now I've reverted to full length message from Figma which is about 100 characters long - this is fine for GSM encoding - and added a comment in the FTL string to check the messaging segment calculator when localizing. I've also filed a follow-up (FXA-11072) to review handling for formatted messages that exceed the max length set here.

@vpomerleau vpomerleau force-pushed the FXA-11007 branch 2 times, most recently from 87debca to 14416c8 Compare February 3, 2025 23:11
@vpomerleau vpomerleau marked this pull request as ready for review February 3, 2025 23:11
@vpomerleau vpomerleau requested review from a team as code owners February 3, 2025 23:12
public async setupPhoneNumber(
uid: string,
phoneNumber: string,
localizedMessageBody?: { part1: string; part2: string }
Copy link
Contributor

@dschom dschom Feb 3, 2025

Choose a reason for hiding this comment

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

Instead of doing part1 and part 2, another approach is a template function, e.g.

messageBody = (code:string) =>${code}`

This is a bit cleaner, because it abstracts away any assumptions about the message format.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I see what you mean! I'll have to modify our localization handling for auth-server a bit because it wasn't set up to take in variables, but should be a simple enough change to make this work.

} catch (error) {
// log email send error but don't throw
// user should be allowed to proceed
this.log.trace('account.recoveryPhone.phoneRemovedNotification.error', {
Copy link
Contributor

Choose a reason for hiding this comment

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

I feel like statsd metrics are more useful than logs for monitoring things.

Copy link
Contributor Author

@vpomerleau vpomerleau Feb 4, 2025

Choose a reason for hiding this comment

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

Will look into using that instead, but might file a follow up

Copy link
Contributor

@dschom dschom left a comment

Choose a reason for hiding this comment

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

Only thing I think should change is use of template function. Other than that looks great. r+wc

@vpomerleau vpomerleau marked this pull request as draft February 4, 2025 01:14
@vpomerleau vpomerleau force-pushed the FXA-11007 branch 2 times, most recently from f713205 to fdbdd52 Compare February 4, 2025 05:10
Copy link
Contributor

@dschom dschom left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks for the changes and improvements!

Because:

* We want to include a localized message in addition to the code

This commit:

* Add ftl strings
* Pass strings to sms manager for inclusion in sms
* Add missing import in integration test
* Add tags to accounts libs projects for inclusion in CI integration tests

Closes #FXA-11007
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.

2 participants