@blotoutio/edgetag-sdk-browser 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +1 -1
- package/index.min.js +1 -1
- package/index.min.js.gz +0 -0
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -94,9 +94,9 @@
|
|
|
94
94
|
headers: {
|
|
95
95
|
'Content-type': 'application/json; charset=utf-8',
|
|
96
96
|
Accept: 'application/json; charset=utf-8',
|
|
97
|
-
credentials: 'include',
|
|
98
97
|
},
|
|
99
98
|
body: JSON.stringify(payload),
|
|
99
|
+
credentials: 'include',
|
|
100
100
|
})
|
|
101
101
|
.then((response) => response.json().then((data) => ({ status: response.status, body: data })))
|
|
102
102
|
.then((data) => {
|
package/index.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="edgeTag",t="consent",n="providers",o="_workerStore",r=(e,t,n,o)=>{const r=c(e);r[t]||(r[t]={}),r[t][o]=n,a(e,r)},s=(e,t,n)=>{const o=c(e);if(o[t])return o[t][n]},a=(e,t,n=o)=>{"session"!==e?i(t,n):g(t,n)},c=(e,t=o)=>"session"===e?u(t):l(t),i=(e,t)=>{localStorage.setItem(t,JSON.stringify(e))},l=e=>JSON.parse(localStorage.getItem(e))||{},g=(e,t)=>{sessionStorage.setItem(t,JSON.stringify(e))},u=e=>JSON.parse(sessionStorage.getItem(e))||{},d=()=>{const e=navigator;let t=e.userAgent;return t+=e.brave?`${t} Brave`:"",t},f=(e,t)=>{let n;return t&&(n=new Blob([JSON.stringify(t)],{type:"application/json"})),navigator.sendBeacon(e,n)},h=async(e,t,n)=>await fetch(t,{method:e,headers:{"Content-type":"application/json; charset=utf-8",Accept:"application/json; charset=utf-8"
|
|
1
|
+
!function(e){"function"==typeof define&&define.amd?define(e):e()}((function(){"use strict";const e="edgeTag",t="consent",n="providers",o="_workerStore",r=(e,t,n,o)=>{const r=c(e);r[t]||(r[t]={}),r[t][o]=n,a(e,r)},s=(e,t,n)=>{const o=c(e);if(o[t])return o[t][n]},a=(e,t,n=o)=>{"session"!==e?i(t,n):g(t,n)},c=(e,t=o)=>"session"===e?u(t):l(t),i=(e,t)=>{localStorage.setItem(t,JSON.stringify(e))},l=e=>JSON.parse(localStorage.getItem(e))||{},g=(e,t)=>{sessionStorage.setItem(t,JSON.stringify(e))},u=e=>JSON.parse(sessionStorage.getItem(e))||{},d=()=>{const e=navigator;let t=e.userAgent;return t+=e.brave?`${t} Brave`:"",t},f=(e,t)=>{let n;return t&&(n=new Blob([JSON.stringify(t)],{type:"application/json"})),navigator.sendBeacon(e,n)},h=async(e,t,n)=>await fetch(t,{method:e,headers:{"Content-type":"application/json; charset=utf-8",Accept:"application/json; charset=utf-8"},body:JSON.stringify(n),credentials:"include"}).then((e=>e.json().then((t=>({status:e.status,body:t}))))).then((e=>e.status<200||e.status>=300?Promise.reject(new Error(JSON.stringify(e.body))):Promise.resolve(e.body))).catch((e=>Promise.reject(new Error(e))));async function p(e,t,n){if(!e)return Promise.reject(new Error("URL is empty"));const o=(e=>{const t={pageUrl:window.location.href,userAgent:d(),...e};let n={};const o=c("session");o&&(n={...n,...o});const r=c("local");return r&&(n={...n,...r}),t.storage=n,t})(t);return n&&"beacon"===n.method&&navigator.sendBeacon?Promise.resolve(f(e,o)):await h("POST",e,o)}let w="";const y=e=>{const t=m();return t?`${t}${e}`:(console.log("URL is not valid"),"")},m=()=>w,v=e=>{},S=n=>{const o={consentString:n};r("local",e,n,t),p(y("/consent"),o).catch(v)},b=(o,r,a)=>{let c={eventName:o};r&&(c.data=r),a&&(c.providers=a),(o=>{const r=s("local",e,t);if(!r)return!1;if(!0===r.all)return!0;if(!o)return Object.values(r).find((e=>e));const a=s("local",e,n)||[];for(const e of a){const t=o[e];if((t||!0===o.all&&null==t||!1===o.all&&!0===t)&&r[e])return!0}return!1})(a)?p(y("/tag"),c).catch(v):console.log("No consent")},O=e=>{return!!e&&(e.edgeURL?(null!=(t=e.edgeURL)&&(w=t),!0):(console.info("Please provide URL for EdgeTag"),!1));var t},j=(e,t,n,o)=>{let s;switch(t){case"cookie":s=(e=>{let t=`${e}=`,n=decodeURIComponent(document.cookie).split(";");for(let e=0;e<n.length;e++){let o=n[e];for(;" "==o.charAt(0);)o=o.substring(1);if(0==o.indexOf(t))return o.substring(t.length,o.length)}return""})(n);break;case"local":s=sessionStorage.getItem(n);break;case"session":s=localStorage.getItem(n)}s&&r(o,e,s,n)},k=(e,t)=>{switch(t.type){case"query":((e,t,n)=>{const o=new URLSearchParams(window.location.search);o&&o.get(t)&&r(n,e,o.get(t),t)})(e,t.key,t.persist);break;case"storage":j(e,t.location,t.key,t.persist)}},P=t=>{O(t)&&async function(e,t){return e?t&&"beacon"===t.method&&navigator.sendBeacon?Promise.resolve(f(e)):await h("GET",e):Promise.reject(new Error("URL is empty"))}(y("/init")).then((t=>{t?(t=>{const o=[];t.forEach((e=>{o.push(e.package),Object.entries(e.rules).forEach((([t,n])=>{switch(t){case"capture":return void k(e.package,n)}}))})),r("local",e,o,n)})(t.result):console.log("init failed")})).catch(v)};var E=new class{init(e){(e=>{P(e)})(e)}tag(e,t,n){((e,t,n)=>{b(e,t,n)})(e,t,n)}consent(e){(e=>{S(e)})(e)}};!function(){const e=e=>{const n=[].slice.call(e);if(Array.isArray(n))try{return t[n[0]](...n.slice(1))}catch(e){console.error(e)}},t=E;let n=[];window.edgetag&&(n=window.edgetag.stubs||[]),window.edgetag=function(){return e(arguments)},n.forEach(e)}()}));
|
package/index.min.js.gz
CHANGED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blotoutio/edgetag-sdk-browser",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "Browser package for edge sdk",
|
|
5
5
|
"author": "Blotout",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"start:web": "rollup --config --configDev --w"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@blotoutio/edgetag-sdk-core": "^0.1.
|
|
28
|
+
"@blotoutio/edgetag-sdk-core": "^0.1.9"
|
|
29
29
|
},
|
|
30
30
|
"publishConfig": {
|
|
31
31
|
"access": "public"
|