Skip to content

✨ [amp-consent] Sync and store purposeConsents in localStorage#32721

Merged
micajuine-ho merged 4 commits intoampproject:masterfrom
micajuine-ho:granularConsentStore
Feb 26, 2021
Merged

✨ [amp-consent] Sync and store purposeConsents in localStorage#32721
micajuine-ho merged 4 commits intoampproject:masterfrom
micajuine-ho:granularConsentStore

Conversation

@micajuine-ho
Copy link
Copy Markdown
Contributor

@micajuine-ho micajuine-ho commented Feb 17, 2021

Partial for #31607

Alter what it means to have a stored value; we now must have consent decisions for every purpose consent listed in the purposeConsentRequired field (either inline or from remote response).

In the case of an already stored consent decision, sync new consent discussions (purposeConsents) via checkConsentHref, which will be reflected on next page visit.

Store the purposeConsents in local storage under the same namespace as the existing consent information under the key pc:

"vv": {
    "amp-consent:_ping_": {
      "v": {
        "s": 1,
        "r": "accept-string",
        "pc": {
          "purpose-ads": 1,
          "purpose-analyltics": 1,
          "purpose-analytics-vendor-a": 2
        }
      },
      "t": 1613518078945
    }
  }

Also did some cleaning up of tests (function* to preferred async/await pattern).

@micajuine-ho micajuine-ho requested a review from dmanek February 17, 2021 23:15
/** @private {?Object<string, PURPOSE_CONSENT_STATE>} */
this.purposeConsents_ = null;
/** @private {Object<string, PURPOSE_CONSENT_STATE>|undefined} */
this.purposeConsents_ = undefined;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove this assignment. If nothing is assigned, it is implied as undefined.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@micajuine-ho might have made this change due to the type issue i mentioned above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants