@blotoutio/providers-attentive-sdk
Advanced tools
Comparing version 0.44.0 to 0.44.1
116
index.cjs.js
@@ -5,6 +5,118 @@ 'use strict'; | ||
const sdkVersion = "0.44.0" ; | ||
const loaded = () => { | ||
checks().then((result) => { | ||
sessionStorage.setItem('attentiveLoaded', result); | ||
}); | ||
}; | ||
const checks = () => { | ||
const url = 'https://cdn.attn.tv/offersbytext/dtag.js'; | ||
return new Promise((internalResolve) => { | ||
const states = []; | ||
const timeout = setTimeout(() => { | ||
resolve('TIMEOUT'); | ||
}, 5000); | ||
const resolve = (value) => { | ||
clearTimeout(timeout); | ||
switch (value) { | ||
case 'ERROR': { | ||
return internalResolve('error'); | ||
} | ||
case 'BLOCKED': { | ||
if (states.includes(XMLHttpRequest.HEADERS_RECEIVED)) { | ||
return internalResolve('extension'); | ||
} | ||
return internalResolve('browser'); | ||
} | ||
case 'ALLOWED': { | ||
return internalResolve('allowed'); | ||
} | ||
case 'TIMEOUT': { | ||
return internalResolve('timeout'); | ||
} | ||
default: { | ||
return internalResolve('unknown'); | ||
} | ||
} | ||
}; | ||
const xhr = new XMLHttpRequest(); | ||
xhr.onreadystatechange = function () { | ||
states.push(xhr.readyState); | ||
if (xhr.readyState == XMLHttpRequest.DONE) { | ||
if (xhr.status === 0 || xhr.responseURL !== url) { | ||
resolve('BLOCKED'); | ||
return; | ||
} | ||
if (xhr.readyState == 4 && xhr.status == 200) { | ||
resolve('ALLOWED'); | ||
} | ||
} | ||
}; | ||
try { | ||
xhr.open('HEAD', url, true); | ||
xhr.send(null); | ||
} | ||
catch (e) { | ||
resolve('ERROR'); | ||
} | ||
}); | ||
}; | ||
const canLog = () => { | ||
try { | ||
return localStorage.getItem('edgeTagDebug') === '1'; | ||
} | ||
catch { | ||
return false; | ||
} | ||
}; | ||
const logger = { | ||
log: (...args) => { | ||
if (canLog()) { | ||
console.log(...args); | ||
} | ||
}, | ||
error: (...args) => { | ||
if (canLog()) { | ||
console.error(...args); | ||
} | ||
}, | ||
info: (...args) => { | ||
if (canLog()) { | ||
console.info(...args); | ||
} | ||
}, | ||
trace: (...args) => { | ||
if (canLog()) { | ||
console.trace(...args); | ||
} | ||
}, | ||
table: (...args) => { | ||
if (canLog()) { | ||
console.table(...args); | ||
} | ||
}, | ||
dir: (...args) => { | ||
if (canLog()) { | ||
console.dir(...args); | ||
} | ||
}, | ||
}; | ||
const init = () => { | ||
try { | ||
if (sessionStorage && !sessionStorage.getItem('attentiveLoaded')) { | ||
loaded(); | ||
} | ||
} | ||
catch (error) { | ||
logger.error(error); | ||
} | ||
}; | ||
const sdkVersion = "0.44.1" ; | ||
const tag = () => { | ||
let sdkStatus = 'none'; | ||
let sdkStatus2 = 'none'; | ||
try { | ||
sdkStatus2 = sessionStorage.getItem('attentiveLoaded') || 'none'; | ||
const tagScript = document.querySelector('script[src*="dtag.js"]'); | ||
@@ -24,2 +136,3 @@ if (tagScript) { | ||
sdkStatus, | ||
sdkStatus2, | ||
}; | ||
@@ -31,2 +144,3 @@ }; | ||
name: packageName, | ||
init, | ||
tag, | ||
@@ -33,0 +147,0 @@ }; |
116
index.js
@@ -6,6 +6,118 @@ var ProvidersAttentiveSdk = (function () { | ||
const sdkVersion = "0.44.0" ; | ||
const loaded = () => { | ||
checks().then((result) => { | ||
sessionStorage.setItem('attentiveLoaded', result); | ||
}); | ||
}; | ||
const checks = () => { | ||
const url = 'https://cdn.attn.tv/offersbytext/dtag.js'; | ||
return new Promise((internalResolve) => { | ||
const states = []; | ||
const timeout = setTimeout(() => { | ||
resolve('TIMEOUT'); | ||
}, 5000); | ||
const resolve = (value) => { | ||
clearTimeout(timeout); | ||
switch (value) { | ||
case 'ERROR': { | ||
return internalResolve('error'); | ||
} | ||
case 'BLOCKED': { | ||
if (states.includes(XMLHttpRequest.HEADERS_RECEIVED)) { | ||
return internalResolve('extension'); | ||
} | ||
return internalResolve('browser'); | ||
} | ||
case 'ALLOWED': { | ||
return internalResolve('allowed'); | ||
} | ||
case 'TIMEOUT': { | ||
return internalResolve('timeout'); | ||
} | ||
default: { | ||
return internalResolve('unknown'); | ||
} | ||
} | ||
}; | ||
const xhr = new XMLHttpRequest(); | ||
xhr.onreadystatechange = function () { | ||
states.push(xhr.readyState); | ||
if (xhr.readyState == XMLHttpRequest.DONE) { | ||
if (xhr.status === 0 || xhr.responseURL !== url) { | ||
resolve('BLOCKED'); | ||
return; | ||
} | ||
if (xhr.readyState == 4 && xhr.status == 200) { | ||
resolve('ALLOWED'); | ||
} | ||
} | ||
}; | ||
try { | ||
xhr.open('HEAD', url, true); | ||
xhr.send(null); | ||
} | ||
catch (e) { | ||
resolve('ERROR'); | ||
} | ||
}); | ||
}; | ||
const canLog = () => { | ||
try { | ||
return localStorage.getItem('edgeTagDebug') === '1'; | ||
} | ||
catch { | ||
return false; | ||
} | ||
}; | ||
const logger = { | ||
log: (...args) => { | ||
if (canLog()) { | ||
console.log(...args); | ||
} | ||
}, | ||
error: (...args) => { | ||
if (canLog()) { | ||
console.error(...args); | ||
} | ||
}, | ||
info: (...args) => { | ||
if (canLog()) { | ||
console.info(...args); | ||
} | ||
}, | ||
trace: (...args) => { | ||
if (canLog()) { | ||
console.trace(...args); | ||
} | ||
}, | ||
table: (...args) => { | ||
if (canLog()) { | ||
console.table(...args); | ||
} | ||
}, | ||
dir: (...args) => { | ||
if (canLog()) { | ||
console.dir(...args); | ||
} | ||
}, | ||
}; | ||
const init = () => { | ||
try { | ||
if (sessionStorage && !sessionStorage.getItem('attentiveLoaded')) { | ||
loaded(); | ||
} | ||
} | ||
catch (error) { | ||
logger.error(error); | ||
} | ||
}; | ||
const sdkVersion = "0.44.1" ; | ||
const tag = () => { | ||
let sdkStatus = 'none'; | ||
let sdkStatus2 = 'none'; | ||
try { | ||
sdkStatus2 = sessionStorage.getItem('attentiveLoaded') || 'none'; | ||
const tagScript = document.querySelector('script[src*="dtag.js"]'); | ||
@@ -25,2 +137,3 @@ if (tagScript) { | ||
sdkStatus, | ||
sdkStatus2, | ||
}; | ||
@@ -32,2 +145,3 @@ }; | ||
name: packageName, | ||
init, | ||
tag, | ||
@@ -34,0 +148,0 @@ }; |
{ | ||
"name": "@blotoutio/providers-attentive-sdk", | ||
"version": "0.44.0", | ||
"version": "0.44.1", | ||
"description": "Attentive Browser SDK for EdgeTag", | ||
@@ -5,0 +5,0 @@ "author": "Blotout", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12672
451
16
1