@blotoutio/edgetag-sdk-js
Advanced tools
Comparing version 0.10.4-beta.1 to 0.10.4
@@ -295,2 +295,3 @@ var api = /*#__PURE__*/Object.freeze({ | ||
const keyPrefix = `_worker`; | ||
const cookieKey = 'tag_user_id'; | ||
@@ -474,3 +475,3 @@ const initKey = `${keyPrefix}Store`; | ||
} | ||
return getCookieValue('tag_user_id'); | ||
return getCookieValue(cookieKey); | ||
}; | ||
@@ -481,7 +482,2 @@ const setUserId = (userId) => { | ||
const getHeaders = () => ({ | ||
'Content-type': 'application/json; charset=utf-8', | ||
Accept: 'application/json; charset=utf-8', | ||
EdgeTagUserId: handleGetUserId(), | ||
}); | ||
const beacon = (url, payload) => { | ||
@@ -499,48 +495,10 @@ try { | ||
}; | ||
const fallbackAjax = (method, url, payload) => __awaiter(void 0, void 0, void 0, function* () { | ||
const https = yield import('https'); | ||
const options = { | ||
method, | ||
headers: getHeaders(), | ||
}; | ||
return new Promise((resolve, reject) => { | ||
const req = https.request(url, options, (res) => { | ||
res.on('data', (data) => { | ||
try { | ||
data = JSON.parse(data); | ||
} | ||
catch (_a) { | ||
// do nothing | ||
} | ||
resolve({ | ||
body: data, | ||
status: res.statusCode || 500, | ||
}); | ||
}); | ||
}); | ||
req.on('error', (e) => { | ||
reject(new Error(e.message)); | ||
}); | ||
if (payload && method !== 'GET') { | ||
req.write(JSON.stringify(payload)); | ||
} | ||
req.end(); | ||
}); | ||
}); | ||
const ajax = (method, url, payload) => __awaiter(void 0, void 0, void 0, function* () { | ||
if (typeof fetch === 'undefined') { | ||
return yield fallbackAjax(method, url, payload) | ||
.then((data) => { | ||
if (data.status < 200 || data.status >= 300) { | ||
return Promise.reject(new Error(`Request failed with code ${data.status} occurred: ${JSON.stringify(data.body)}`)); | ||
} | ||
return Promise.resolve(data.body); | ||
}) | ||
.catch((error) => { | ||
return Promise.reject(new Error(error)); | ||
}); | ||
} | ||
return yield fetch(url, { | ||
method, | ||
headers: getHeaders(), | ||
headers: { | ||
'Content-type': 'application/json; charset=utf-8', | ||
Accept: 'application/json; charset=utf-8', | ||
EdgeTagUserId: handleGetUserId(), | ||
}, | ||
body: JSON.stringify(payload), | ||
@@ -561,3 +519,3 @@ credentials: 'include', | ||
const getStandardPayload = (payload) => { | ||
const data = Object.assign({ pageUrl: getPageUrl(), pageTitle: getPageTitle(), userAgent: getUserAgent(), referrer: getReferrer(), search: getSearch(), sdkVersion: "0.10.3" }, (payload || {})); | ||
const data = Object.assign({ pageUrl: getPageUrl(), pageTitle: getPageTitle(), userAgent: getUserAgent(), referrer: getReferrer(), search: getSearch(), sdkVersion: "0.10.4" }, (payload || {})); | ||
let storage = {}; | ||
@@ -564,0 +522,0 @@ const session = getData$1('session'); |
{ | ||
"name": "@blotoutio/edgetag-sdk-js", | ||
"version": "0.10.4-beta.1", | ||
"version": "0.10.4", | ||
"description": "JS SDK for EdgeTag", | ||
@@ -16,2 +16,5 @@ "author": "Blotout", | ||
}, | ||
"engines": { | ||
"node": ">=17.5.0" | ||
}, | ||
"files": [ | ||
@@ -18,0 +21,0 @@ "index.cjs", |
Sorry, the diff of this file is not supported yet
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
2
54406
1898