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

Update unsubscribeAll to POST directly to basket #18249

Open
robhudson opened this issue Jan 17, 2025 · 0 comments
Open

Update unsubscribeAll to POST directly to basket #18249

robhudson opened this issue Jan 17, 2025 · 0 comments

Comments

@robhudson
Copy link
Member

robhudson commented Jan 17, 2025

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:

  1. The preference center itself forwards the request to Basket, making this an indirect method.
  2. The preference center recently adopted a js-only implementation for handling this request, which may cause unsubscribeAll to 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

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

No branches or pull requests

1 participant