-
Notifications
You must be signed in to change notification settings - Fork 217
Open
Description
Description
The unsubscribeAll function currently sends a POST request to the preference center on mozilla.org to unsubscribe users from all newsletters. However, this approach has some limitations and potential issues:
- The preference center itself forwards the request to Basket, making this an indirect method.
- The preference center recently adopted a js-only implementation for handling this request, which may cause
unsubscribeAllto break or behave unpredictably in the future.
Proposed Solution
To ensure future reliability unsubscribeAll should send requests directly to Basket. This is the more direct and stable approach since Basket is the service ultimately handling the unsubscription.
The direct API call would:
- POST to
https://basket.mozilla.org/news/unsubscribe/<token>/ - Include a request body with
optout=Y, this is the signal to basket to unsubscribe from ALL newsletters and flags the user as opted out of emails.
Implementation Example
Here’s how the request could look using fetch:
await fetch(`https://basket.mozilla.org/news/unsubscribe/${userToken}/`, {
method: "POST",
body: "optout=Y",
headers: {
"Content-Type": "application/x-www-form-urlencoded",
"X-Requested-With": "XMLHttpRequest",
},
});┆Issue is synchronized with this Jira Task
Metadata
Metadata
Assignees
Labels
No labels