ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.88k stars 3.89k forks source link

[amp-consent] Granular consents change detection doesn't work. New selection is not saved in the amp-store local storage and the update request is not sent #38350

Open RafalOddslife opened 2 years ago

RafalOddslife commented 2 years ago

Description

There's an issue with detecting change of granular consents when user wants to update his settings. None of the following actions are triggered:

Only changing general consent alternately (accept, reject, accept, reject) triggers all these changes. It would be good to include granular consents to change detection or add some possibility to do it manually.

By manually I mean something like: tap:siteConsent.accept(isDirty/forceUpdate=true) and for consents in iframe (promptUISrc): window.parent.postMessage({ type: 'consent-response', action: 'accept', purposeConsents, isDirty/forceUpdate: true }, "*");

Reproduction Steps

Repro 1. Granular consents not saved in the amp-store in local storage Granular consents example playground

Scenario:

  1. Open example from the link above
  2. In the preview save your settings
  3. Check your local storage value. You can also decode base64 value in the console with: decodeURIComponent(atob(localStorage['amp-store:https://playground.amp.dev']))
  4. Reprompt settings dialog with "I do!" button
  5. Change your settings
  6. The list of choices (See the results of your consent choices here) doesn't reflect new selection
  7. Check again local storage value
  8. If you change the second button action tap:siteConsent.dismiss with tap:siteConsent.reject and click buttons alternately you will notice changes (to make data-block-on-consent-purposes reflect new granular consents just refresh the preview)

Repro 2. Update request is not sent

Modified granular consents example playground

It's the same example with additionaly:

Scenario:

  1. Open example from the link above
  2. Inspect outgoing requests (e.g. in chrome browser open devtools and check network tab)
  3. In the preview save any selection
  4. Update your granular consents with reprompt (click 'I do!', change something and click 'Save')
  5. You won't notice any update request until you change general consent (accept to reject or reject to accept)

Relevant Logs

No response

Browser(s) Affected

No response

OS(s) Affected

No response

Device(s) Affected

No response

AMP Version Affected

2206221455000

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.