bedrock icon indicating copy to clipboard operation
bedrock copied to clipboard

[Epic] Move interaction with basket to client side where possible

Open pmac opened this issue 3 years ago • 14 comments

Description

Currently newsletter signups and the email preferences center all interact with basket via bedrock's backend servers. There isn't a good reason for this for the most part. We should update our newsletter subscription forms and the email prefs center to interact directly with basket via JS rather than submit to bedrock which then just redirects the data to basket. This would reduce the load on bedrock's servers and allow for better caching by the CDN.


Success Criteria

  • [x] https://github.com/mozilla/bedrock/issues/11944
  • [x] https://github.com/mozilla/bedrock/issues/11945
  • [x] https://github.com/mozilla/bedrock/issues/11963
  • [ ] https://github.com/mozilla/bedrock/issues/11946

pmac avatar Jan 20 '22 20:01 pmac

Depending on how far we want to take it, the outcome of https://github.com/mozilla/bedrock/issues/10566 might be a good candidate for the email preference center.

alexgibson avatar Jan 21 '22 09:01 alexgibson

@pmac As https://github.com/mozilla/bedrock/issues/11120 is p2 and this is p3, I think work on #11120 should start sooner. Agreed?

stevejalim avatar Jan 21 '22 13:01 stevejalim

Yes. For sure. Agreed. I just wanted to get this into the backlog so we don't forget it.

pmac avatar Jan 22 '22 04:01 pmac

Follow up to https://github.com/mozilla/bedrock/pull/11234#pullrequestreview-896323896

Front-end note: might need to hide or provide better error feedback for users trying to submit forms without JS

maureenlholland avatar Mar 01 '22 18:03 maureenlholland

@pmac if we're going to move the preference centre to use JS, we'll first need an API we can query that can return someone's preference data. Is that something that already exists somewhere, or should we file a dependency issue to create one?

alexgibson avatar Jul 19 '22 13:07 alexgibson

It does. Same one the backend currently uses to fetch it from basket.

pmac avatar Jul 19 '22 13:07 pmac

It does. Same one the backend currently uses to fetch it from basket.

Is this endpoint documented anywhere?

alexgibson avatar Jul 19 '22 13:07 alexgibson

Found the basket docs: https://basket.readthedocs.io/newsletter_api.html

alexgibson avatar Jul 19 '22 14:07 alexgibson

Yeah, the docs aren't great, but these are they https://basket.readthedocs.io/newsletter_api.html#news-user

pmac avatar Jul 19 '22 14:07 pmac

The way it works is that once you have the user's token from the URL, you can use it in a URL like the one below to get a JSON response with their info:

https://basket.mozilla.org/news/user/4a3bd4e1-fc01-490d-98e3-0a7305ff6a33/

That token is one I just created as an example. You are welcome to mess with it to see how the data works.

pmac avatar Jul 19 '22 14:07 pmac

Thanks! I think turning this into an epic and then filing smaller issues for the individual parts you mention in the description above makes sense.

Digging into the "where possible" part a little, are there any other things we should cover here? Or can't cover? I notice there's the email recovery page too. Is that something that requires an API key?

alexgibson avatar Jul 19 '22 14:07 alexgibson

The recovery page does not require an API key, so we can include that as well.

pmac avatar Jul 21 '22 18:07 pmac

Another aspect is that this presents us with an opportunity to rethink even more of the user experience and what data we store and request. For example:

We currently only store the user's language preference as a single data point. We could in theory store a language preference for the user per newsletter since each newsletter is available in a potentially different list of languages and a user might be okay with receiving English for one but would prefer to receive French for another for which that is available. This would require work on the CTMS side as well, and potentially in Acoustic, but I believe it is possible now that we have CTMS and not our old contact storage system.

This would be a sizable expansion of scope, so we may not want to pursue this now, but it might be a good time to explore the UX of the email prefs center page with possibilities like this in mind.

pmac avatar Jul 21 '22 18:07 pmac

This would be a sizable expansion of scope, so we may not want to pursue this now, but it might be a good time to explore the UX of the email prefs center page with possibilities like this in mind.

Yeah, let's see how it goes. But my gut says this might be a good post-migration improvement.

alexgibson avatar Jul 22 '22 07:07 alexgibson