fix: cookie retrieve
This commit is contained in:
		@@ -7,12 +7,20 @@ import TelemetryDeck from '@telemetrydeck/sdk';
 | 
			
		||||
 | 
			
		||||
// Telemetry Deck only collects fully anonymized data!
 | 
			
		||||
 | 
			
		||||
const getCookieValueOrNull = (name) => {
 | 
			
		||||
    const cookie = document.cookie
 | 
			
		||||
        .split(";")
 | 
			
		||||
        .map(c => c.trim())
 | 
			
		||||
        .find(c => c.startsWith(name + "="));
 | 
			
		||||
    return cookie ? cookie.split("=")[1] : null;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
function getOrCreateUUID() {
 | 
			
		||||
    let cookie = document.cookie.split(";").some((item) => item.trim().startsWith("id="));
 | 
			
		||||
    let cookie_val = getCookieValueOrNull("id");
 | 
			
		||||
    if (
 | 
			
		||||
        cookie
 | 
			
		||||
        cookie_val
 | 
			
		||||
    ) {
 | 
			
		||||
        return cookie.split("=")[1];
 | 
			
		||||
        return cookie_val;
 | 
			
		||||
    } else {
 | 
			
		||||
        let uuid =crypto.randomUUID();
 | 
			
		||||
        const days = 365;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user