Skip to content

Commit

Permalink
Merge 22883c6 into 3a93d78
Browse files Browse the repository at this point in the history
  • Loading branch information
akinsola-guardian authored Feb 11, 2025
2 parents 3a93d78 + 22883c6 commit c77ec3c
Show file tree
Hide file tree
Showing 17 changed files with 756 additions and 169 deletions.
9 changes: 9 additions & 0 deletions .changeset/breezy-drinks-live.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
'@guardian/libs': major
---

- Add the ability for consent or pay by adding two new params, useNonAdvertisingList and isUsedSignedIn to cmp.init
- Using Sourcepoint Subdomain property if useNonAdvertisedList is true
- Merging user consent from Advertising to Non-Advertising vendor list
- Redirecting user to Support when clicking Reject for Consent or Pay users
- Extending \_\_tcfapi to postCustomConsent as part of merging user consent process.
65 changes: 59 additions & 6 deletions apps/github-pages/src/components/CmpTest.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
<script>
// this maps to the version in libs/@guardian/libs
import { cmp, onConsentChange, log } from '@guardian/libs';
import { cmp, onConsentChange, log, setCookie } from '@guardian/libs';
import { onMount } from 'svelte';
let useNonAdvertisedList = window.location.search.includes('NON_ADV');
let isUserSignedIn = window.location.search.includes('SIGNED_IN');
switch (window.location.hash) {
case '#tcfv2':
localStorage.setItem('framework', JSON.stringify('tcfv2'));
Expand Down Expand Up @@ -37,6 +40,13 @@
log('cmp', event);
}
let setABTest = () => {
setCookie({
name: 'X-GU-Experiment-0perc-E',
value: 'true',
})
}
let clearPreferences = () => {
// clear local storage
// https://documentation.sourcepoint.com/web-implementation/general/cookies-and-local-storage#cmp-local-storage
Expand All @@ -49,9 +59,35 @@
.replace(/^ +/, '')
.replace(/=.*/, `=;expires=${new Date().toUTCString()};path=/`);
});
setABTest();
window.location.reload();
};
const toggleQueryParams = (param) => {
let queryParams = new URLSearchParams(window.location.search);
queryParams.has(param)
? queryParams.delete(param)
: queryParams.append(param, '');
window.location.search = queryParams.toString();
};
const toggleIsFeatureFlagEnabled = () => {
isFeatureFlagEnabled = !isFeatureFlagEnabled;
toggleQueryParams('CMP_COP');
};
const toggleIsUserSignedIn = () => {
isUserSignedIn = !isUserSignedIn;
toggleQueryParams('SIGNED_IN');
};
const toggleUseNonAdvertisedList = () => {
useNonAdvertisedList = !useNonAdvertisedList;
toggleQueryParams('NON_ADV');
};
let framework = JSON.parse(localStorage.getItem('framework'));
let setLocation = () => {
Expand Down Expand Up @@ -90,11 +126,11 @@
break;
}
// do this loads to make sure that doesn't break things
cmp.init({ country });
cmp.init({ country });
cmp.init({ country });
cmp.init({ country });
cmp.init({
country,
isUserSignedIn: isUserSignedIn,
useNonAdvertisedList: useNonAdvertisedList,
});
});
</script>

Expand All @@ -104,6 +140,7 @@
>open privacy manager</button
>
<button on:click={clearPreferences}>clear preferences</button>
<button on:click={setABTest}>set ab test</button>
<label class={framework == 'tcfv2' ? 'selected' : 'none'}>
<input
type="radio"
Expand Down Expand Up @@ -133,6 +170,22 @@
in Australia:
<strong>CCPA-like</strong>
</label>
<label class={useNonAdvertisedList ? 'selected' : 'none'}>
<input
type="checkbox"
on:change={toggleUseNonAdvertisedList}
checked={useNonAdvertisedList}
/>
<strong>useNonAdvertisedList?</strong>
</label>
<label class={isUserSignedIn ? 'selected' : 'none'}>
<input
type="checkbox"
on:change={toggleIsUserSignedIn}
checked={isUserSignedIn}
/>
<strong>isUserSignedIn?</strong>
</label>
</nav>

<div id="consent-state">
Expand Down
Loading

0 comments on commit c77ec3c

Please sign in to comment.