bedrock
bedrock copied to clipboard
Render email preference center client side
Description
In an effort to lighten the load on bedrock we'd like to move as much of the email preference centre rendering as possible to the client side, and also make it so the form interacts directly with basket using JS.
This might be a good candidate for something like Svelte or Handlebars to render the form.
Endpoint: https://basket.mozilla.org/news/user/ Docs: https://basket.readthedocs.io/newsletter_api.html#news-user
Example: https://basket.mozilla.org/news/user/4a3bd4e1-fc01-490d-98e3-0a7305ff6a33/
Success Criteria
- [ ] Email preference centre is rendered using JS, with data fetched directly from basket using the above endpoint.
- [ ] User can update their preferences, subscribe, unsubscribe (all existing functionality is retained)
Issue worth flagging:
- Depending on which newsletters someone has signed up to, there's a chance they might have subscribed to a private newsletter (e.g. VPN wait list). As such, when they try and update their preferences it would error because the client side code would not include the required API key.
Possible solutions:
- The preference centre continues to POST to bedrock. We only hit Basket to query data on page load and then render.
- We update basket to not require an API key when unsubscribing from a private newsletter. In theory, unsubscribing is all someone should be able to do from the preferences page.
Depends on https://github.com/mozmeao/basket/issues/918