liquid
liquid copied to clipboard
Shopify Customer Privacy API suddenly stopped working
Hi, I have been using the Shopify Customer Privacy API for almost a year with no problems.
Today my consent banner suddenly started bugging out. Please pass this along to your dev team.
Here's the bug:
TypeError: Cannot read properties of undefined (reading 'loadFeatures')
TypeError: undefined is not an object (evaluating 'window.Shopify.loadFeatures')
This seems like an internal bug that Shopify needs to fix. Around the same time, I started getting
liquid error: Internal
showing up at the top of my page. When I removed my Shopify Customer Privacy Api code, the liquid error also went away. That's weird since the shopify customer privacy code is in javascript, not liquid.
Here's my code:
window.Shopify.loadFeatures(
[
{
name: 'consent-tracking-api',
version: '0.1',
},
],
(error) => {
if (error) {
console.error(error); // if you want to raise
}
if (window.Shopify.customerPrivacy.shouldShowGDPRBanner()) {
setShow(true);
}
},
)
function onAccept() {
window.Shopify.customerPrivacy.setTrackingConsent(true, () => setShow(false));
}
function onDecline() {
window.Shopify.customerPrivacy.setTrackingConsent(false, () => setShow(false));
}