Last active
March 25, 2025 14:38
-
-
Save andresgallo/10414ac30cb8ee132e53fd2202e68492 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// We often have a cookie utility to make handling of cookies the same | |
tp = window.tp || []; | |
tp.push(["setAid", SOME ID]); | |
tp.push(["setCookieDomain", COOKIE_DOMAIN]); | |
tp.push( [ "addHandler", "startCheckout", function () { | |
window.sessionStorage.setItem("noreload", "true") | |
}]); | |
tp.push(["addHandler", "checkoutClose", function(event){ | |
switch (event.state){ | |
case 'checkoutCompleted': | |
// Deal with auth cookie, or reload if checkout implies changes in page, or use ajax|react to update page | |
break; | |
default: | |
break; | |
} | |
}]); | |
tp.push(["addHandler", "checkoutComplete", function(event){ | |
// Deal with auth cookie, or reload if checkout implies changes in page, or use ajax|react to update page | |
}]); | |
tp.push(['addHandler', 'logout', function(){ | |
if ('serviceWorker' in navigator && navigator.serviceWorker.controller) { | |
navigator.serviceWorker.controller.postMessage({ action: 'clearCache' }); | |
} | |
// Deal with cookie, | |
tp.push(["addHandler", "loginSuccess", function(data){ | |
if ('serviceWorker' in navigator && navigator.serviceWorker.controller) { | |
navigator.serviceWorker.controller.postMessage({ action: 'clearCache' }); | |
} | |
// RELOAD, or UPDATE content | |
}]); | |
// OTHER THINGS WE HAVE SETUP | |
//tp.push(['setApplePayMerchantId'... | |
// Setup what happens on start | |
tp.push(["init", function() { | |
// set consent keys tp.consent.setByPurpose('AM'... // | |
tp.pianoId.init({ | |
displayMode: 'modal', | |
containerSelector: '#login-form', | |
loggedIn: function(data) { | |
if (data.user && data.user.valid) { | |
toggleLoginOut(); | |
} | |
}, | |
loggedOut: function() { | |
toggleLoginOut(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment