@braze/web-sdk
Version:
Braze SDK for web sites and other JS platforms.
43 lines (42 loc) • 1.19 kB
JavaScript
import ee, { STORAGE_KEYS as s } from "./storage-manager.js";
import { logger as E } from "../../shared-lib/index.js";
const Gt = {
Ya: function (e, o = !1) {
let t = !1;
try {
if (localStorage && localStorage.getItem)
try {
localStorage.setItem(s.ct.lc, "true"),
localStorage.getItem(s.ct.lc) &&
(localStorage.removeItem(s.ct.lc), (t = !0));
} catch (e) {
if (
!(
e instanceof Error &&
("QuotaExceededError" === e.name ||
"NS_ERROR_DOM_QUOTA_REACHED" === e.name) &&
localStorage.length > 0
)
)
throw e;
t = !0;
}
} catch (e) {
E.info("Local Storage not supported!");
}
const r = Gt.gc(),
a = new ee.uc(e, r && !o, t);
let n;
return (n = t ? new ee.dc(e) : new ee.mc()), new ee(a, n);
},
gc: function () {
return (
navigator.cookieEnabled ||
("cookie" in document &&
(document.cookie.length > 0 ||
(document.cookie = "test").indexOf.call(document.cookie, "test") >
-1))
);
},
};
export default Gt;