@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 = {
La: function (e, o = !1) {
let t = !1;
try {
if (localStorage && localStorage.getItem)
try {
localStorage.setItem(s.ct.ec, "true"),
localStorage.getItem(s.ct.ec) &&
(localStorage.removeItem(s.ct.ec), (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.oc(),
a = new ee.tc(e, r && !o, t);
let n;
return (n = t ? new ee.rc(e) : new ee.ac()), new ee(a, n);
},
oc: function () {
return (
navigator.cookieEnabled ||
("cookie" in document &&
(document.cookie.length > 0 ||
(document.cookie = "test").indexOf.call(document.cookie, "test") >
-1))
);
},
};
export default Gt;