@inploi/sdk 1.7.4 → 1.7.5
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/cdn/index.js +1 -1
- package/package.json +2 -2
package/cdn/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// This is an inploi sdk script. Learn more at https://inploi.com
|
|
2
2
|
|
|
3
|
-
"use strict";(()=>{var k=Object.defineProperty,I=Object.defineProperties;var
|
|
3
|
+
"use strict";(()=>{var k=Object.defineProperty,I=Object.defineProperties;var b=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable;var m=(e,o,t)=>o in e?k(e,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[o]=t,l=(e,o)=>{for(var t in o||(o={}))O.call(o,t)&&m(e,t,o[t]);if(y)for(var t of y(o))C.call(o,t)&&m(e,t,o[t]);return e},w=(e,o)=>I(e,b(o));var u=(e,o,t)=>new Promise((r,i)=>{var s=n=>{try{p(t.next(n))}catch(c){i(c)}},a=n=>{try{p(t.throw(n))}catch(c){i(c)}},p=n=>n.done?r(n.value):Promise.resolve(n.value).then(s,a);p((t=t.apply(e,o)).next())});function v(e,o){if(!e)throw new Error(o)}var A={sandbox:"https://preview.api.inploi.com",production:"https://api.inploi.com"},P=1,h="/analytics/log",f="isdk_anon_id";var _=e=>{let o=new Date;return o.setTime(o.getTime()+1e3*36e3),`${f}=${e};expires=${o.toUTCString()};path=/`},M=new RegExp(`${f}=([^;]+)`),N=e=>{let o=e?e.url:location.href,{searchParams:t}=new URL(o),r=t.get("anonymous_id");if(r)return r;let i=e?e.headers.get("cookie"):document.cookie;if(i){let s=M.exec(i);if(s!=null&&s[1])return s[1]}return null},R=e=>typeof e!="object"||e===null||!("anonymous_id"in e&&typeof e.anonymous_id=="string")?null:e.anonymous_id,E=({apiClient:e,logger:o})=>({log:r=>u(void 0,null,function*(){v(r.request||typeof window!="undefined","Cannot log on the server without a request. Please pass a request to `log`.");let i="request"in r&&r.request?{href:r.request.url,referrer:r.request.referrer,title:""}:{href:location.href,referrer:document.referrer,title:document.title};try{let s={library:{name:"inploi-sdk",version:P},page:i},a={anonymous_id:N(r.request),event:r.event,sent_at:new Date().toISOString(),context:s,properties:r.properties,custom_properties:r.customProperties},p=yield e.fetch(h,{method:"POST",body:JSON.stringify(a)}),n=R(p);n&&(a.anonymous_id=n);let c=n!=null?n:a.anonymous_id;return typeof window!="undefined"&&c&&(document.cookie=_(c)),{success:!0,data:a}}catch(s){return o.error("Failed to send log to API. Inspect error response of `log` for more information."),{success:!1,error:s}}}),getHeaders:r=>{let i=new Headers;return r.anonymous_id&&i.append("Set-Cookie",_(r.anonymous_id)),i}});var F="Unauthenticated",q="This action is unauthorized.",x=e=>{let o={Accept:"application/json","Content-Type":"application/json","x-publishable-key":e.publishableKey};return{fetch:(i,...s)=>u(void 0,[i,...s],function*(t,r={}){let a=w(l({},r),{headers:l(l({},r.headers),o)}),n=yield(yield fetch(`${e.baseUrl}${t}`,a)).json();if(typeof n=="object"&&n!==null&&"message"in n){if(n.message===F)throw new Error("You are not authenticated.");if(n.message===q)throw new Error("You are not authorised to perform this action.");if("exception"in n)throw new Error(`API error: \u201C${n.message}\u201D`);if("errors"in n)throw new Error(`API error: \u201C${n.message}\u201D`)}return n})}};var g="%c[inploi SDK]",d="color: #65BC67; font-weight: bold;",L={warn:(...e)=>console.warn(g,d,...e),error:(...e)=>console.error(g,d,...e),info:(...e)=>console.info(g,d,...e),log:(...e)=>console.log(g,d,...e)},T={info:()=>{},error:()=>{},log:()=>{},warn:()=>{}};function S({publishableKey:e,env:o,logger:t=L}){let r=x({baseUrl:A[o],publishableKey:e}),i=t===!1?T:t,s=E({apiClient:r,logger:i});return{register:p=>p({logger:i,apiClient:r,analytics:s}),analytics:s}}typeof window.inploi!="object"&&(window.inploi={});window.process=window.process||{};window.process.env=window.process.env||{};window.process.env.NODE_ENV="production";window.inploi.initialiseSdk=S;})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inploi/sdk",
|
|
3
|
-
"version": "1.7.
|
|
3
|
+
"version": "1.7.5",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@inploi/core": "1.
|
|
19
|
+
"@inploi/core": "1.7.0"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@happy-dom/global-registrator": "^12.6.0",
|