Skip to content

Commit

Permalink
πŸ› fix: update key for read amp-store from localstorage
Browse files Browse the repository at this point in the history
This commit update the cookie consent UI to read the stored consent
states from the LocalStorage using the key `amp-store:{{ site.url }}`
instead of the previously used `amp-store:http://127.0.0.1:4000`.

This change provides a more accurate and reliable way of retrieving
consent states, as it is now tied to the specific site domain rather
than a local host address. This will improve the overall functionality
of the cookie consent feature and enhance the user experience.

See: #44
  • Loading branch information
chriskyfung committed Mar 8, 2024
1 parent 1918a2b commit 2fe11bd
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion _includes/consent/granular-user-consent.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<amp-script script="get-stored-consentStates" nodom data-ampdevmode>
</amp-script>
<script id="get-stored-consentStates" type="text/plain" target="amp-script">
const str = atob(localStorage.getItem('amp-store:http://127.0.0.1:4000'));
const str = atob(localStorage.getItem('amp-store:{{ site.url }}'));
const json = JSON.parse(str);
const v = json.vv['amp-consent:site-consent']?.v;
if (v.s === 1) {
Expand Down

0 comments on commit 2fe11bd

Please sign in to comment.